/* ==========================================================================
   Memmy World — stage effects
   --------------------------------------------------------------------------
   The layers that make the room react to the pointer (lantern, wash, hint and
   cue). They sit between the film and the copy: the film stays behind, the copy
   stays on top, and the light travels across the empty space of the frame.
   ========================================================================== */

/* The lantern: a disc of the mascot's own pattern, lifted off the film wherever
   the pointer is. --mx / --my / --lantern / --fade are written by lantern.js. */
.act__lantern {
  position: absolute;
  inset: -10%;
  z-index: 1;
  pointer-events: none;
  background-image: var(--pattern, none);
  background-size: 210px 210px;
  background-repeat: repeat;
  opacity: calc(var(--fade, 0) * 0.5);
  mix-blend-mode: screen;
  -webkit-mask-image: radial-gradient(
    circle var(--lantern, 0px) at var(--mx, 50%) var(--my, 50%),
    #000 0%,
    rgba(0, 0, 0, 0.72) 46%,
    transparent 76%
  );
  mask-image: radial-gradient(
    circle var(--lantern, 0px) at var(--mx, 50%) var(--my, 50%),
    #000 0%,
    rgba(0, 0, 0, 0.72) 46%,
    transparent 76%
  );
  transition: opacity 0.3s linear;
  will-change: opacity, mask-image;
}

/* A soft pool of the character's colour so the whole frame leans towards them,
   not just the medallion. */
.act__wash {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(58% 46% at 22% 48%, var(--accent-soft), transparent 68%),
    radial-gradient(46% 40% at 78% 62%, var(--accent-soft), transparent 72%);
  opacity: calc(var(--vis, 0) * 0.9);
  transition: opacity 0.4s linear;
}

/* A slice of the deep tone under whichever column holds the words. The film
   gets bright exactly where the family sits, so without this the headline and
   the blurb wash out on the brightest frames. */
.act__wash::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to left,
    var(--deep-90) 0%,
    var(--deep-70) 30%,
    var(--deep-45) 52%,
    var(--deep-20) 68%,
    transparent 82%
  );
}

/* On flipped acts the copy is on the inline-start side, so the scrim follows. */
.act[data-side='end'] .act__wash::before {
  background: linear-gradient(
    to right,
    var(--deep-90) 0%,
    var(--deep-70) 30%,
    var(--deep-45) 52%,
    var(--deep-20) 68%,
    transparent 82%
  );
}

/* ------------------------------ stage hint ------------------------------ */
/* "Move the pointer" — the only instruction the effect needs. */
.act__stage-hint {
  position: absolute;
  z-index: 4;
  bottom: clamp(14px, 3vh, 30px);
  inset-inline-end: var(--shell);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--ink-faint);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: calc(var(--vis, 0) * 0.9);
  transition: opacity 0.3s linear;
}

.act__stage-hint i {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--accent-line);
  background: rgba(9, 6, 14, 0.5);
  color: var(--accent);
  font-style: normal;
  font-size: 0.62rem;
  animation: hint-glow 3.2s ease-in-out infinite;
}

@keyframes hint-glow {
  50% {
    box-shadow: 0 0 16px -2px var(--accent-glow);
    transform: scale(1.1);
  }
}

/* ==========================================================================
   Stage chrome — second pass
   --------------------------------------------------------------------------
   The lantern has to be unmistakable when the pointer crosses the character
   (that is the memmy-prototype feel the page is built around), and the two
   footer lines of an act must never share a baseline: the cue sits at the
   content's inline-start edge, the hint at the inline-end one, with the copy
   column between them.
   ========================================================================== */

/* ------------------------------- lantern -------------------------------- */
/* Two lights in one layer: the mascot's own pattern, and the pool of accent
   colour it floats in. Both are masked by the pointer disc. */
.act__lantern {
  inset: -14%;
  background-image:
    var(--pattern, none),
    radial-gradient(circle at center, var(--accent-glow), transparent 68%);
  background-size: 210px 210px, 100% 100%;
  background-repeat: repeat, no-repeat;
  background-position: 0 0, center;
  opacity: calc(var(--fade, 0) * 0.9);
  filter: saturate(1.15) brightness(1.1);
}

/* A crisp rim on the disc so the light reads as a lens travelling over the
   frame rather than a vague brightening. */
.stage::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: calc(var(--fade, 0) * 0.85);
  background: radial-gradient(
    circle calc(var(--lantern, 0px) * 0.72) at var(--mx, 50%) var(--my, 50%),
    transparent 62%,
    var(--accent-soft) 88%,
    transparent 100%
  );
  transition: opacity 0.3s linear;
}

/* ------------------------------ the hint -------------------------------- */
.act__stage-hint {
  bottom: clamp(10px, 2vh, 22px);
  max-width: 46%;
  text-align: end;
}

@media (max-width: 860px) {
  .act__stage-hint {
    display: none;
  }
}
/* -------------------------------- veil ---------------------------------- */
/* The room darkens everywhere except under the pointer, which is what makes the
   lantern read as a real light rather than a faint brightening: the disc is a
   hole in this veil. Above the pattern layer, below the copy, so the words keep
   their contrast while the film dims. --lantern / --mx / --my / --fade all come
   from lantern.js. */
.act__veil {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: calc(var(--fade, 0) * 0.9);
  background: radial-gradient(
    120% 90% at 50% 45%,
    rgba(6, 4, 10, 0.55) 0%,
    rgba(6, 4, 10, 0.78) 70%,
    rgba(6, 4, 10, 0.88) 100%
  );
  -webkit-mask-image: radial-gradient(
    circle var(--lantern, 0px) at var(--mx, 50%) var(--my, 50%),
    transparent 0%,
    rgba(0, 0, 0, 0.28) 46%,
    rgba(0, 0, 0, 0.72) 74%,
    #000 100%
  );
  mask-image: radial-gradient(
    circle var(--lantern, 0px) at var(--mx, 50%) var(--my, 50%),
    transparent 0%,
    rgba(0, 0, 0, 0.28) 46%,
    rgba(0, 0, 0, 0.72) 74%,
    #000 100%
  );
  transition: opacity 0.3s linear;
  will-change: opacity, mask-image;
}

/* The pattern sits on the lit part only, so tone it down now that the veil does
   the heavy lifting. */
.act__lantern {
  opacity: calc(var(--fade, 0) * 0.55);
}

@media (prefers-reduced-motion: reduce) {
  .act__veil {
    display: none;
  }
}
/* ==========================================================================
   The chapter cut
   --------------------------------------------------------------------------
   Clicking a chip on the rail does not scroll through the film — it cuts to the
   chapter (js/world/scroll-engine.js). Across the whole film a smooth scroll is
   thousands of pixels, the playhead cannot keep up, and every frame in between
   is a seek that Chromium paints black: the page went genuinely blank.

   So the jump happens behind a shutter. `html.is-cutting` is put on by the
   engine, which holds it down until the destination frame has been presented,
   then lifts it.
   ========================================================================== */

/* The copy drops away; the film does NOT. Blanking both made the transition
   read as an empty screen for the ~0.4s the seek takes, even though the
   destination frame was already painted underneath. Dimming the film keeps a
   real picture on screen the whole way and still softens the jump between the
   two frames. The topbar and the rail stay fully lit throughout. */
#main {
  transition: opacity 0.18s var(--ease-soft);
}

.film__video {
  transition: opacity 0.18s var(--ease-soft);
}

html.is-cutting #main {
  opacity: 0;
  transition-duration: 0.09s;
}

html.is-cutting .film__video {
  opacity: 0.45;
  transition-duration: 0.09s;
}

/* No motion to soften for these readers: the cut is instant in both directions
   (the engine skips the shutter wait too), which is exactly what they asked for. */
@media (prefers-reduced-motion: reduce) {
  #main,
  .film__video {
    transition: none;
  }

  html.is-cutting .film__video {
    opacity: 1;
  }
}
