/* ==========================================================================
   AE4Play — effects: preloader, cursor, grain, overlays, konami, motion prefs
   ========================================================================== */

/* =========================== PRELOADER =========================== */
.preloader { display: none; }
.js .preloader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  pointer-events: all;
}
.js .preloader.is-gone { display: none; }
.preloader__shutter {
  position: absolute;
  left: 0;
  right: 0;
  height: 50.5%;
  background: var(--ink);
  will-change: transform;
}
.preloader__shutter--top { top: 0; border-bottom: 1px solid rgba(198, 255, 61, .0); }
.preloader__shutter--bottom { bottom: 0; }
.preloader__shutter--top::after,
.preloader__shutter--bottom::after {
  /* hazard edge revealed when the shutter opens */
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 10px;
  background: repeating-linear-gradient(-45deg, var(--acid) 0 12px, var(--ink) 12px 24px);
  opacity: 0;
}
.preloader.is-open .preloader__shutter::after { opacity: 1; }
.preloader__shutter--top::after { bottom: 0; }
.preloader__shutter--bottom::after { top: 0; }
.preloader__slit {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  margin-top: -1px;
  background: var(--acid);
  box-shadow: 0 0 24px var(--acid), 0 0 60px var(--hot);
  transform: scaleX(0);
  opacity: 0;
}
.preloader__inner {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 1.1rem;
  font-family: var(--font-mono);
  text-align: center;
}
.preloader__coin {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(1.4rem, 5vw, 3rem);
  letter-spacing: .04em;
  color: var(--paper);
  text-shadow: 3px 0 0 var(--hot), -3px 0 0 var(--volt);
  animation: blink 1s steps(2, jump-none) infinite;
}
.preloader__count {
  font-size: clamp(3rem, 14vw, 9rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.06em;
  color: var(--acid);
  font-variant-numeric: tabular-nums;
}
.preloader__count small { font-size: .3em; letter-spacing: 0; color: var(--paper-dim); margin-left: .2em; }
.preloader__bar {
  width: min(320px, 70vw);
  height: 14px;
  padding: 2px;
  border: 2px solid var(--paper-dim);
}
.preloader__bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: repeating-linear-gradient(90deg, var(--acid) 0 8px, transparent 8px 10px);
}
.preloader__credit { font-size: .75rem; color: var(--paper-dim); letter-spacing: .1em; }

.preloader.is-glitch .preloader__inner { animation: glitch .45s steps(6) both; }
@keyframes glitch {
  0%   { transform: translate(0); clip-path: inset(0 0 0 0); filter: none; }
  20%  { transform: translate(-8px, 2px); clip-path: inset(10% 0 55% 0); filter: hue-rotate(90deg); }
  40%  { transform: translate(10px, -3px); clip-path: inset(60% 0 8% 0); }
  60%  { transform: translate(-4px, 0); clip-path: inset(30% 0 30% 0); filter: hue-rotate(-90deg) saturate(3); }
  80%  { transform: translate(6px, 1px); clip-path: inset(45% 0 45% 0); }
  100% { transform: translate(0); clip-path: inset(50% 0 50% 0); opacity: 0; }
}

/* Lock scroll while the preloader is up */
.is-loading body { overflow: hidden; }

/* =========================== CURSOR =========================== */
.has-cursor,
.has-cursor a,
.has-cursor button,
.has-cursor [data-tilt] { cursor: none; }
.has-cursor input,
.has-cursor textarea { cursor: text; }

.cursor,
.cursor-ring {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 120;
  pointer-events: none;
  border-radius: 50%;
  will-change: transform;
  opacity: 0;
  transition: opacity .3s ease;
}
.has-cursor.cursor-visible .cursor,
.has-cursor.cursor-visible .cursor-ring { opacity: 1; }
.cursor {
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  background: var(--acid);
  mix-blend-mode: difference;
}
.cursor-ring {
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  display: grid;
  place-items: center;
  mix-blend-mode: difference;
}
.cursor-ring__shape {
  position: absolute;
  inset: 0;
  border: 1.5px solid var(--paper);
  border-radius: 50%;
  transition: transform .45s var(--ease-out), background-color .3s ease, border-color .3s ease;
}
.cursor-ring__label {
  position: relative;
  font-family: var(--font-mono);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--ink);
  opacity: 0;
  transform: scale(.6);
  transition: opacity .25s ease, transform .35s var(--ease-out);
}
.cursor-ring.is-hover .cursor-ring__shape { transform: scale(1.9); background: var(--paper); border-color: var(--paper); }
.cursor-ring.has-label .cursor-ring__label { opacity: 1; transform: scale(1); }
.cursor-ring.is-down .cursor-ring__shape { transform: scale(.75); }
.cursor-ring.is-hover.is-down .cursor-ring__shape { transform: scale(1.6); }
.cursor-ring.is-text .cursor-ring__shape { transform: scale(.4); }

/* =========================== GRAIN + SCANLINES =========================== */
.grain {
  position: fixed;
  inset: -50%;
  z-index: 90;
  pointer-events: none;
  opacity: .05;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 1.2 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain 1s steps(6) infinite;
}
@keyframes grain {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-6%, 4%); }
  40%  { transform: translate(5%, -7%); }
  60%  { transform: translate(-3%, 9%); }
  80%  { transform: translate(8%, 2%); }
  100% { transform: translate(-2%, -4%); }
}
.scanlines {
  position: fixed;
  inset: 0;
  z-index: 89;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, .14) 0 1px, transparent 1px 4px);
  opacity: .35;
}

/* =========================== CONFETTI + TOAST =========================== */
.confetti {
  position: fixed;
  inset: 0;
  z-index: 110;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  z-index: 115;
  padding: .85rem 1.3rem;
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: .85rem;
  box-shadow: 0 20px 50px -10px rgba(0, 0, 0, .6), 4px 4px 0 var(--hot);
  transform: translate(-50%, 160%);
  transition: transform .5s var(--ease-out);
  max-width: calc(100vw - 2rem);
  text-align: center;
}
.toast.is-on { transform: translate(-50%, 0); }
.toast:empty { visibility: hidden; }

/* =========================== KONAMI MODE =========================== */
html.is-konami {
  --acid: #FF2E88;
  --hot: #C6FF3D;
  --volt: #FFB13D;
  --sun: #3DF5FF;
}
html.is-konami .hero__canvas { filter: hue-rotate(140deg) saturate(1.4); }
html.is-konami .btn-start { background: #8a0d44; }
html.is-konami .btn-start:hover .btn-start__inner { background: #ff6aa9; }
html.is-konami .wordmark { animation: rainbow 2.4s linear infinite; }
@keyframes rainbow { to { filter: hue-rotate(360deg); } }
html.konami-flash body { animation: flash .6s steps(3) 1; }
@keyframes flash {
  0% { filter: invert(1); }
  50% { filter: invert(0) hue-rotate(90deg); }
  100% { filter: none; }
}

/* =========================== MOTION PREFERENCES =========================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .grain { animation: none; }
  .hero__fallback { animation: none; }
  .hero__floor { animation: none; }
  .hud__blink, .preloader__coin, .cabinet__start, .badge::before { animation: none !important; opacity: 1 !important; }
}
