/* =========================================================
   Little Surprise for Aigerim — v3 Premium Edition
   Palette sampled frame-by-frame from assets/aigerim-edit.mp4
   ========================================================= */
:root {
  --void:      #0b080b;   /* deepest black of the fade-outs      */
  --night:     #130f15;   /* plum-black of the dark scenes        */
  --plum:      #1e131d;   /* shadow tone of the red finale        */
  --ivory:     #f1e8e2;   /* white captions                       */
  --mist:      #a99da1;   /* secondary text                       */
  --scarlet:   #e83a26;   /* the red italic typography            */
  --scarlet-hi:#f85042;   /* its brightest highlight              */
  --rose-deep: #9e1b1b;   /* shadow side of the rose              */
  --glow:      #f1605e;   /* pink-red light of the final frame    */
  --wine:      #7e2429;   /* dark red haze around the glow        */

  --serif-display: "Playfair Display", "Didot", "Bodoni 72", Georgia, serif;
  --serif-text:    "Cormorant Garamond", "Garamond", Georgia, serif;

  --ease-cine: cubic-bezier(.22, .61, .21, 1);   /* long, settling */
  --ease-soft: cubic-bezier(.45, 0, .2, 1);      /* in-out, filmic */
  --ease-out:  cubic-bezier(.16, 1, .3, 1);

  --gutter: max(16px, env(safe-area-inset-left), env(safe-area-inset-right));

  /* pointer parallax (desktop only, written by script.js) */
  --px: 0;
  --py: 0;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--void);
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  color: var(--ivory);
  font-family: var(--serif-text);
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

[tabindex="-1"]:focus { outline: none; }

/* ---------------------------------------------------------
   Atmosphere — everything here sits BEHIND the stage,
   so nothing is ever drawn over the film.
   --------------------------------------------------------- */
.atmos, .embers, .grain, .vignette, .flash {
  position: fixed; inset: 0; pointer-events: none;
}

.atmos {
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% 0%, #1a1219 0%, transparent 60%),
    var(--void);
}

.atmos__glow {
  position: absolute;
  border-radius: 50%;
  will-change: transform, opacity;
  transition: opacity 2.4s var(--ease-soft);
}

/* light rising behind the horizon — the "sun" of the first & last frames */
.atmos__glow--a {
  left: 50%; bottom: -38vmax;
  width: 120vmax; height: 90vmax;
  margin-left: -60vmax;
  background: radial-gradient(closest-side,
      rgba(248, 80, 66, .55) 0%,
      rgba(232, 58, 38, .28) 28%,
      rgba(126, 36, 41, .16) 52%,
      transparent 72%);
  opacity: .32;
  translate: calc(var(--px) * 10px) calc(var(--py) * 6px);
  animation: breathe 14s var(--ease-soft) infinite alternate;
}

/* drifting red haze, like the clouds of the finale */
.atmos__glow--b {
  right: -30vmax; top: -34vmax;
  width: 80vmax; height: 80vmax;
  background: radial-gradient(closest-side,
      rgba(126, 36, 41, .45), rgba(126, 36, 41, .12) 55%, transparent 75%);
  opacity: .35;
  translate: calc(var(--px) * -26px) calc(var(--py) * -16px);
  animation: drift 22s var(--ease-soft) infinite alternate;
}

/* the little planet */
.atmos__horizon {
  position: absolute;
  left: 50%; bottom: 0;
  width: 190vmax; height: 190vmax;
  margin-left: -95vmax;
  border-radius: 50%;
  transform: translateY(calc(100% - 13vh));
  translate: calc(var(--px) * 6px) 0;
  background: radial-gradient(closest-side, #0a0709 92%, #140d11 99%, transparent 100%);
  box-shadow:
    0 -1px 0 rgba(241, 96, 94, .22),
    0 -18px 60px -10px rgba(232, 58, 38, .22);
  opacity: .9;
  transition:
    transform 3.2s var(--ease-cine),
    box-shadow 2.8s var(--ease-soft),
    opacity 1.8s var(--ease-soft);
}

@keyframes breathe {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(0, -2.5vh, 0) scale(1.06); }
}
@keyframes drift {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(-8vmax, 6vmax, 0); }
}

/* scene-driven light */
body[data-scene="film"] .atmos__glow--a   { opacity: .16; }
body[data-scene="film"] .atmos__glow--b   { opacity: .22; }
body[data-scene="film"] .atmos__horizon   { transform: translateY(calc(100% + 2vh)); opacity: 0; }

/* the last frame of the edit fades to black — its red light spills into the page */
body[data-scene="film"].is-afterglow .atmos__glow--a { opacity: .62; }
body[data-scene="film"].is-afterglow .atmos__horizon { transform: translateY(calc(100% - 5vh)); opacity: .9; }

body[data-scene="finale"] .atmos__glow--a { opacity: 1; }
body[data-scene="finale"] .atmos__glow--b { opacity: .7; }
body[data-scene="finale"] .atmos__horizon {
  transform: translateY(calc(100% - 17vh));
  box-shadow:
    0 -1px 0 rgba(255, 190, 180, .55),
    0 -10px 40px -4px rgba(248, 80, 66, .65),
    0 -60px 160px -20px rgba(232, 58, 38, .55);
}

/* while the film plays, the background stops moving (saves battery, keeps eyes on the film) */
body.is-playing .atmos__glow { animation-play-state: paused; }

.embers {
  z-index: 1;
  width: 100%; height: 100%;
  opacity: .9;
  transition: opacity 1.6s var(--ease-soft);
}
body[data-scene="film"] .embers { opacity: .35; }
body.is-playing .embers { opacity: 0; }

.grain {
  z-index: 2;
  opacity: .07;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
}

.vignette {
  z-index: 2;
  background: radial-gradient(130% 100% at 50% 45%, transparent 45%, rgba(0, 0, 0, .72) 100%);
}

/* brief white-rose bloom between scenes — like the edit's light cuts */
.flash {
  z-index: 7;
  opacity: 0;
  background: radial-gradient(70% 60% at 50% 55%, rgba(255, 236, 232, .5), rgba(241, 96, 94, .22) 45%, transparent 75%);
}
.flash.is-on { animation: flash 1.6s var(--ease-soft) both; }
@keyframes flash {
  0% { opacity: 0; } 20% { opacity: 1; } 100% { opacity: 0; }
}

/* ---------------------------------------------------------
   Scenes — opacity + transform only (no full-screen blur:
   cheap on iPhone, and never filters the video layer)
   --------------------------------------------------------- */
.stage { position: relative; z-index: 3; height: 100%; }

.scene {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding:
    max(24px, env(safe-area-inset-top))
    var(--gutter)
    max(24px, env(safe-area-inset-bottom));
  overflow-x: hidden;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: scale(1.02);
  transition:
    opacity 1.1s var(--ease-soft),
    transform 1.6s var(--ease-cine),
    visibility 0s linear 1.6s;
}
.scene.is-active {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition:
    opacity 1.4s var(--ease-soft) .2s,
    transform 2s var(--ease-cine) .2s,
    visibility 0s;
}
/* leaving: letters exit first, then the scene dims */
.scene.is-leaving {
  transform: scale(.985);
  transition:
    opacity 1s var(--ease-soft) .35s,
    transform 1.6s var(--ease-soft),
    visibility 0s linear 1.6s;
}
/* the film always fits the screen by construction; its decorative light must not create scroll */
.scene--film { overflow: hidden; }
/* the film arrives faster, so the first frames are not lost */
.scene--film.is-active {
  transition:
    opacity .9s var(--ease-soft) .1s,
    transform 1.6s var(--ease-cine) .1s,
    visibility 0s;
}

/* ---------------------------------------------------------
   Rose — grows from the stem, then the bud opens
   --------------------------------------------------------- */
.rose { display: block; color: var(--scarlet); overflow: visible; }
.rose__lines {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.rose__lines path { stroke-dasharray: 1; stroke-dashoffset: 0; }
.rose__bloom { fill: currentColor; opacity: .14; }

.rose-wrap {
  position: relative;
  width: clamp(58px, 15vw, 84px); height: clamp(58px, 15vw, 84px);
  margin: 0 auto clamp(18px, 4vh, 34px);
  cursor: pointer;
  -webkit-user-select: none; user-select: none;
}
.rose-wrap::before {    /* soft halo that breathes behind the bud */
  content: ""; position: absolute;
  left: 50%; top: 30%; width: 180%; height: 140%;
  transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, rgba(232, 58, 38, .32), rgba(158, 27, 27, .08) 60%, transparent);
  opacity: 0;
  pointer-events: none;
  transition: opacity .8s var(--ease-soft), transform .8s var(--ease-cine);
}
.rose--intro {
  width: 100%; height: 100%;
  filter: drop-shadow(0 0 6px rgba(232, 58, 38, .5));
  transform-origin: 50% 94%;
  transition: transform .9s var(--ease-out);
}
.rose--finale {
  width: 42px; height: 42px;
  margin: 0 auto 24px;
  filter: drop-shadow(0 0 8px rgba(248, 80, 66, .7));
  transform-origin: 50% 94%;
}

/* draw order: stem → leaves → outer petals → folds → back → heart */
.rose .r-stem   { --d: 0s;    --t: 1.1s; }
.rose .r-leaf-r { --d: .55s;  --t: 1s; }
.rose .r-leaf-l { --d: .75s;  --t: 1s; }
.rose .r-out-l  { --d: .95s;  --t: 1.2s; }
.rose .r-out-r  { --d: .95s;  --t: 1.2s; }
.rose .r-fold-l { --d: 1.35s; --t: 1s; }
.rose .r-fold-r { --d: 1.35s; --t: 1s; }
.rose .r-back   { --d: 1.55s; --t: 1.1s; }
.rose .r-heart  { --d: 1.8s;  --t: 1.6s; }
.rose--intro  { --start: .2s; }
.rose--finale { --start: .7s; }

.is-active .rose__lines path {
  stroke-dashoffset: 1;
  animation: draw var(--t, 1.2s) var(--ease-soft) forwards;
  animation-delay: calc(var(--start, 0s) + var(--d, 0s));
}
.is-active .rose__bloom {
  opacity: 0;
  animation: bloom 2.2s var(--ease-soft) forwards;
  animation-delay: calc(var(--start, 0s) + 2.6s);
}
.scene--intro.is-active .rose-wrap::before {
  animation: halo-in 2.4s var(--ease-soft) 2.6s forwards, halo-breathe 6s var(--ease-soft) 5s infinite alternate;
}
/* once it has bloomed, the rose sways — barely */
.scene--intro.is-active .rose--intro,
.scene--finale.is-active .rose--finale {
  animation: sway 9s var(--ease-soft) 3.4s infinite alternate;
}
@keyframes draw   { to { stroke-dashoffset: 0; } }
@keyframes bloom  { to { opacity: .16; } }
@keyframes halo-in { to { opacity: .8; } }
@keyframes halo-breathe { from { opacity: .8; } to { opacity: .45; } }
@keyframes sway   { from { rotate: -1.6deg; } to { rotate: 1.6deg; } }

/* touch / hover: the rose breathes in */
.rose-wrap.is-touched .rose--intro { transform: scale(1.08); }
.rose-wrap.is-touched::before { transform: translate(-50%, -50%) scale(1.25); }
@media (hover: hover) {
  .rose-wrap:hover .rose--intro { transform: scale(1.06); }
}

/* ---------------------------------------------------------
   Split text — enter & exit
   --------------------------------------------------------- */
.w  { display: inline-block; white-space: nowrap; }
.ch, .wd { display: inline-block; opacity: 0; }

.is-active .ch {
  animation: charIn 1.5s var(--ease-cine) forwards;
  animation-delay: calc(var(--base, 0s) + var(--i) * var(--step, 55ms));
}
.is-active .wd {
  animation: wordIn 1.9s var(--ease-cine) forwards;
  animation-delay: calc(var(--base, 0s) + var(--i) * var(--step, 240ms));
}
@keyframes charIn {
  from { opacity: 0; transform: translate3d(0, .32em, 0); filter: blur(10px); }
  to   { opacity: 1; transform: none;                     filter: blur(0); }
}
@keyframes wordIn {
  from { opacity: 0; transform: translate3d(0, .45em, 0); filter: blur(9px); }
  60%  { filter: blur(0); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}

.fade { opacity: 0; }
.is-active .fade {
  animation: fadeUp 1.6s var(--ease-cine) forwards;
  animation-delay: var(--base, 0s);
}
@keyframes fadeUp {
  from { opacity: 0; transform: translate3d(0, 14px, 0); }
  to   { opacity: 1; transform: none; }
}

/* exit: letters lift away like dust in light */
.is-leaving .ch, .is-leaving .wd {
  animation: textOut .9s var(--ease-soft) forwards;
  animation-delay: calc(var(--i) * 14ms);
}
.is-leaving .fade, .is-leaving .rose, .is-leaving .finale__divider {
  animation: fadeOut .7s var(--ease-soft) forwards;
}
@keyframes textOut {
  from { opacity: 1; transform: none; filter: blur(0); }
  to   { opacity: 0; transform: translate3d(0, -.3em, 0); filter: blur(8px); }
}
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

/* intro waits for the fonts so letters never jump */
body.is-loading .scene--intro .ch,
body.is-loading .scene--intro .fade,
body.is-loading .scene--intro .rose__lines path,
body.is-loading .scene--intro .rose__bloom,
body.is-loading .scene--intro .rose-wrap::before { animation-play-state: paused; }

/* ---------------------------------------------------------
   Scene 1 — opening
   --------------------------------------------------------- */
.intro {
  width: 100%;
  max-width: 900px;
  margin: auto;
  padding-bottom: 3vh;   /* optical centre sits a little above the true centre */
  text-align: center;
  translate: calc(var(--px) * 5px) calc(var(--py) * 4px);
}

.title {
  margin: 0;
  font-family: var(--serif-display);
  font-style: italic;
  font-weight: 400;
  line-height: 1.02;
  letter-spacing: -.012em;
  font-feature-settings: "kern", "liga";
}
.title__line { display: block; }
.title__line--a {
  font-size: clamp(2.5rem, 10.6vw, 6.4rem);
  color: var(--ivory);
  text-shadow: 0 0 40px rgba(241, 232, 226, .08);
  --base: .9s;
}
.title__line--b {
  margin-top: .06em;
  font-size: clamp(2.7rem, 11.6vw, 7rem);
  font-weight: 500;
  color: var(--scarlet);
  text-shadow:
    0 0 18px rgba(232, 58, 38, .45),
    0 0 60px rgba(232, 58, 38, .25);
  --base: 1.75s;
  --step: 62ms;
}

.subtitle {
  margin: clamp(18px, 3.4vh, 30px) 0 0;
  font-size: clamp(1.12rem, 4.4vw, 1.5rem);
  font-style: italic;
  color: var(--mist);
  letter-spacing: .015em;
}

.cta {
  position: relative;
  margin-top: clamp(30px, 6vh, 52px);
  padding: 1.15em 2.5em;
  min-height: 52px;
  border: 1px solid rgba(232, 58, 38, .6);
  border-radius: 999px;
  background: rgba(30, 10, 12, .35);
  color: var(--ivory);
  font: 500 .8rem/1 var(--serif-text);
  font-size: clamp(.8rem, 3.2vw, .9rem);
  letter-spacing: .3em;
  text-transform: uppercase;
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
  -webkit-appearance: none; appearance: none;
  touch-action: manipulation;
  box-shadow: 0 0 0 0 rgba(232, 58, 38, 0), inset 0 0 18px rgba(232, 58, 38, .08);
  transition:
    box-shadow .7s var(--ease-soft),
    border-color .7s var(--ease-soft),
    transform .35s var(--ease-cine),
    color .5s var(--ease-soft);
}
.cta__label { position: relative; z-index: 1; padding-left: .3em; /* balances trailing tracking */ }
.cta__fill {
  position: absolute; inset: -1px;
  z-index: 0;
  border-radius: inherit;
  background:
    radial-gradient(120% 160% at 50% 120%, var(--scarlet-hi) 0%, var(--scarlet) 35%, var(--rose-deep) 80%);
  transform: scaleX(0);
  transform-origin: 50% 50%;
  opacity: 0;
  transition: transform .8s var(--ease-cine), opacity .6s var(--ease-soft);
}
/* a thin glint that crosses the button once, when it has appeared */
.cta::before {
  content: "";
  position: absolute; top: 0; bottom: 0; left: -40%;
  width: 30%;
  z-index: 1;
  background: linear-gradient(100deg, transparent, rgba(255, 220, 210, .22), transparent);
  transform: translateX(0) skewX(-18deg);
  opacity: 0;
  pointer-events: none;
}
.is-active .cta::before { animation: glint 1.6s var(--ease-soft) 5s 1 both; }
@keyframes glint {
  0%   { opacity: 0; transform: translateX(0) skewX(-18deg); }
  15%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(560%) skewX(-18deg); }
}
/* slow halo inviting a tap */
.cta::after {
  content: "";
  position: absolute; inset: -1px;
  border-radius: inherit;
  border: 1px solid rgba(248, 80, 66, .5);
  opacity: 0;
  pointer-events: none;
}
.is-active .cta::after { animation: halo 3.8s var(--ease-soft) 6.4s infinite; }
@keyframes halo {
  0%   { opacity: .7; transform: scale(1); }
  70%  { opacity: 0;  transform: scale(1.22, 1.5); }
  100% { opacity: 0;  transform: scale(1.22, 1.5); }
}

@media (hover: hover) {
  .cta:hover {
    border-color: rgba(248, 80, 66, .95);
    box-shadow: 0 0 34px -4px rgba(232, 58, 38, .65), inset 0 0 18px rgba(255, 200, 190, .12);
  }
  .cta:hover .cta__fill { transform: scaleX(1); opacity: 1; }
}
.cta:focus-visible {
  outline: none;
  border-color: var(--scarlet-hi);
  box-shadow: 0 0 0 3px rgba(11, 8, 11, 1), 0 0 0 4px rgba(248, 80, 66, .9), 0 0 30px rgba(232, 58, 38, .5);
}
.cta:active { transform: scale(.965); }
.cta:active .cta__fill,
.cta.is-pressed .cta__fill { transform: scaleX(1); opacity: 1; }
.cta.is-pressed { box-shadow: 0 0 60px 4px rgba(248, 80, 66, .7); }

.hint {
  margin: 18px 0 0;
  font-size: 1rem;
  font-style: italic;
  color: rgba(169, 157, 161, .82);
  letter-spacing: .04em;
}

.scene--intro .subtitle { --base: 3.0s; }
.scene--intro .cta-wrap { --base: 3.6s; }
.scene--intro .hint     { --base: 4.3s; }

/* ---------------------------------------------------------
   Scene 2 — the film
   --------------------------------------------------------- */
.film {
  width: 100%;
  max-width: 1180px;
  margin: auto;
  display: flex; flex-direction: column; align-items: center;
}

.film__kicker {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin: 0 0 clamp(18px, 3.2vh, 30px);
  font-family: var(--serif-display);
  font-size: clamp(1.05rem, 3.8vw, 1.4rem);
  color: var(--scarlet);
  text-shadow: 0 0 16px rgba(232, 58, 38, .45);
  --base: .5s;
}
.film__kicker em { font-style: italic; }
.film__rule {
  display: block; width: clamp(28px, 8vw, 70px); height: 1px;
  background: linear-gradient(90deg, transparent, rgba(232, 58, 38, .7));
}
.film__rule:last-child { transform: scaleX(-1); }

.frame {
  --amb: 232, 58, 38;
  --amb-a: .2;
  position: relative;
  /* width bounded by the screen width AND by its height, keeping 1204:512 exactly */
  width: min(100%, calc((100svh - 200px) * 1204 / 512));
  aspect-ratio: 1204 / 512;
  /* hairline + glow drawn with shadows, so the video box keeps its exact ratio */
  box-shadow:
    0 0 0 1px rgba(232, 58, 38, .4),
    0 0 0 2px rgba(0, 0, 0, .7),
    0 0 50px -6px rgba(232, 58, 38, .35),
    0 40px 120px -30px rgba(158, 27, 27, .55);
  transition: box-shadow 2s var(--ease-soft), opacity .9s var(--ease-soft) .5s;
}
@supports not (height: 100svh) {
  .frame { width: min(100%, calc((100vh - 200px) * 1204 / 512)); }
}

/* the film's own light, sampled live, spills softly around the screen */
.frame__ambient {
  position: absolute; inset: -22% -9%;
  z-index: -1;
  background-color: rgb(var(--amb));
  opacity: var(--amb-a);
  -webkit-mask-image: radial-gradient(closest-side, #000 35%, transparent 100%);
          mask-image: radial-gradient(closest-side, #000 35%, transparent 100%);
  transition: background-color 1.1s linear, opacity 1.1s linear;
  pointer-events: none;
}

.frame__screen {
  position: absolute; inset: 0;
  overflow: hidden;
  background: #000;
}

.frame video {
  display: block;
  width: 100%; height: 100%;
  object-fit: contain;
  background: #000;
  outline: none;
}

/* projector shutter */
.frame__bar {
  position: absolute; left: 0; right: 0; height: 50.5%;
  background: #000;
  pointer-events: none;
  transition: transform 1.05s var(--ease-cine);
}
.frame__bar--top    { top: 0;    transform-origin: top; }
.frame__bar--bottom { bottom: 0; transform-origin: bottom; }
.scene--film.is-active .frame:not(.is-closing) .frame__bar--top    { transform: translateY(-101%); transition-delay: .3s; }
.scene--film.is-active .frame:not(.is-closing) .frame__bar--bottom { transform: translateY(101%);  transition-delay: .3s; }
.frame.is-closing .frame__bar { transition-duration: .85s; transition-timing-function: var(--ease-soft); }

.frame__slit {
  position: absolute; left: 0; right: 0; top: 50%; height: 1px;
  margin-top: -.5px;
  background: linear-gradient(90deg, transparent, rgba(255, 200, 190, .95) 30%, #fff 50%, rgba(255, 200, 190, .95) 70%, transparent);
  box-shadow: 0 0 12px 2px rgba(248, 80, 66, .8), 0 0 40px 6px rgba(232, 58, 38, .5);
  opacity: 0;
  transform: scaleX(.2);
  pointer-events: none;
}
.scene--film.is-active .frame:not(.is-closing) .frame__slit { animation: slitOpen 1.2s var(--ease-soft) .15s both; }
.frame.is-closing .frame__slit { animation: slitClose 1.3s var(--ease-soft) .55s both; }
@keyframes slitOpen  { 0% { opacity: 0; transform: scaleX(.2); } 30% { opacity: 1; transform: scaleX(1); } 100% { opacity: 0; transform: scaleX(1); } }
@keyframes slitClose { 0% { opacity: 0; transform: scaleX(1); } 35% { opacity: 1; } 100% { opacity: 0; transform: scaleX(1.25); } }

.frame.is-closing { opacity: 0; transition: box-shadow 2s var(--ease-soft), opacity .8s var(--ease-soft) 1.1s; }
.frame.is-closing ~ .film__note { opacity: 0; transition: opacity .6s; }

.frame__corner {
  position: absolute; width: 16px; height: 16px;
  border: 0 solid var(--scarlet);
  opacity: .85;
  pointer-events: none;
  transition: transform 1.4s var(--ease-cine) .5s;
}
.frame__corner--tl { top: -9px;    left: -9px;  border-top-width: 1px;    border-left-width: 1px; }
.frame__corner--tr { top: -9px;    right: -9px; border-top-width: 1px;    border-right-width: 1px; }
.frame__corner--bl { bottom: -9px; left: -9px;  border-bottom-width: 1px; border-left-width: 1px; }
.frame__corner--br { bottom: -9px; right: -9px; border-bottom-width: 1px; border-right-width: 1px; }
/* corners settle into place as the shutter opens */
.frame__corner--tl { transform: translate(-6px, -6px); }
.frame__corner--tr { transform: translate(6px, -6px); }
.frame__corner--bl { transform: translate(-6px, 6px); }
.frame__corner--br { transform: translate(6px, 6px); }
.scene--film.is-active .frame__corner { transform: none; }

/* progress hairline under the frame — never on the picture */
.frame__progress {
  position: absolute; left: 14px; right: 14px; top: calc(100% + 7px);
  height: 1px;
  background: rgba(232, 58, 38, .14);
  overflow: hidden;
  pointer-events: none;
}
.frame__progress-fill {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(232, 58, 38, .4), var(--scarlet-hi));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .3s linear;
}
.frame.is-buffering .frame__progress::after {   /* gentle shimmer while loading */
  content: ""; position: absolute; top: 0; bottom: 0; width: 30%;
  background: linear-gradient(90deg, transparent, rgba(255, 190, 180, .8), transparent);
  animation: shimmer 1.4s var(--ease-soft) .6s infinite backwards;   /* silent on fast connections */
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(440%); } }

.frame__play {
  position: absolute; left: 50%; top: 50%;
  width: 74px; height: 74px; margin: -37px 0 0 -37px;
  border-radius: 50%;
  border: 1px solid rgba(248, 80, 66, .8);
  background: rgba(11, 8, 11, .55);
  color: var(--ivory);
  cursor: pointer;
  display: grid; place-items: center;
  box-shadow: 0 0 40px rgba(232, 58, 38, .5);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  transition: transform .4s var(--ease-cine), background .4s;
}
.frame__play svg { width: 28px; height: 28px; fill: currentColor; margin-left: 4px; }
.frame__play:hover { transform: scale(1.06); background: rgba(158, 27, 27, .55); }
.frame__play:active { transform: scale(.95); }
.frame__play:focus-visible { outline: 1px solid var(--ivory); outline-offset: 4px; }

.frame__msg {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px;
  padding: 16px;
  background: radial-gradient(closest-side, rgba(30, 10, 12, .92), rgba(11, 8, 11, .96));
  text-align: center;
}
.frame__msg p {
  margin: 0;
  font-family: var(--serif-display);
  font-style: italic;
  font-size: clamp(1.05rem, 3.6vw, 1.5rem);
  color: var(--ivory);
}
.frame__msg-actions { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }

.link-btn {
  display: inline-flex; align-items: center;
  min-height: 44px;
  padding: 8px 6px;
  border: 0; background: none;
  color: rgba(241, 232, 226, .78);
  font: italic 1.05rem var(--serif-text);
  letter-spacing: .06em;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(232, 58, 38, .6);
  text-underline-offset: 6px;
  transition: color .4s, text-decoration-color .4s;
}
.link-btn:hover, .link-btn:focus-visible { color: var(--ivory); text-decoration-color: var(--scarlet-hi); outline: none; }
.link-btn:focus-visible { outline: 1px solid rgba(248, 80, 66, .8); outline-offset: 2px; }

.film__note {
  display: none;
  margin: 26px 0 0;
  font-size: 1rem;
  font-style: italic;
  color: rgba(169, 157, 161, .85);
  text-align: center;
  --base: 1.6s;
}
@media (hover: none) and (orientation: portrait) {
  .film__note { display: block; }
}

.film__status {
  min-height: 1.4em;
  margin: 10px 0 0;
  font-size: .98rem;
  font-style: italic;
  color: rgba(169, 157, 161, .85);
  text-align: center;
  opacity: 0;
  transition: opacity .8s var(--ease-soft);
}
.film__status.is-shown { opacity: 1; }

/* ---------------------------------------------------------
   Scene 3 — finale
   --------------------------------------------------------- */
.finale {
  width: 100%; max-width: 980px;
  margin: auto;
  padding-bottom: 8vh;
  text-align: center;
  translate: calc(var(--px) * 4px) calc(var(--py) * 3px);
}

.finale__line {
  margin: 0;
  font-family: var(--serif-display);
  font-style: italic;
  font-size: clamp(1.45rem, 6vw, 2.9rem);
  line-height: 1.25;
  color: var(--ivory);
  text-shadow: 0 0 30px rgba(0, 0, 0, .6);
  text-wrap: balance;
  --base: 2.1s;
  --step: 250ms;
}

.finale__divider {
  display: block;
  width: clamp(60px, 18vw, 120px); height: 1px;
  margin: clamp(18px, 3.2vh, 28px) auto 0;
  background: linear-gradient(90deg, transparent, var(--scarlet), transparent);
  box-shadow: 0 0 10px rgba(232, 58, 38, .6);
  transform: scaleX(0);
  opacity: 0;
}
.is-active .finale__divider { animation: divider 1.6s var(--ease-cine) 4.1s forwards; }
@keyframes divider { to { transform: scaleX(1); opacity: .9; } }

.finale__wish {
  position: relative;
  isolation: isolate;
  margin: clamp(14px, 2.6vh, 24px) 0 0;
  font-family: var(--serif-display);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(2.3rem, 10vw, 5.6rem);
  line-height: 1.06;
  color: var(--scarlet-hi);
  text-shadow:
    0 0 14px rgba(248, 80, 66, .6),
    0 0 46px rgba(232, 58, 38, .5),
    0 0 110px rgba(232, 58, 38, .35);
}
.finale__wish-line { display: block; }
.finale__wish-line--a { --base: 4.7s; --step: 58ms; }
.finale__wish-line--b { --base: 6.0s; --step: 105ms; }   /* her name arrives after a breath */

.finale__wish::before {          /* breathing red light behind the wish */
  content: ""; position: absolute; z-index: -1;
  left: 50%; top: 50%; width: 120%; height: 160%;
  transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, rgba(232, 58, 38, .3), rgba(158, 27, 27, .1) 60%, transparent);
  opacity: 0;
  pointer-events: none;
}
.is-active .finale__wish::before {
  animation: glowIn 3.2s var(--ease-soft) 6.2s forwards, glowPulse 5s var(--ease-soft) 9.4s infinite alternate;
}
@keyframes glowIn    { to { opacity: .85; } }
@keyframes glowPulse { from { opacity: .85; transform: translate(-50%, -50%) scale(1); } to { opacity: 1; transform: translate(-50%, -50%) scale(1.12); } }

.replay {
  margin-top: clamp(34px, 7vh, 60px);
  padding: 10px 14px;
  min-height: 44px;
  border: 0;
  background: none;
  color: rgba(241, 232, 226, .66);
  font: italic 1.05rem var(--serif-text);
  letter-spacing: .06em;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(232, 58, 38, .5);
  text-underline-offset: 6px;
  touch-action: manipulation;
  transition: color .4s, text-decoration-color .4s;
  --base: 8.6s;
}
.replay:hover, .replay:focus-visible { color: var(--ivory); text-decoration-color: var(--scarlet-hi); }
.replay:focus-visible { outline: 1px solid rgba(248, 80, 66, .8); outline-offset: 2px; }

/* ---------------------------------------------------------
   Responsive
   --------------------------------------------------------- */
@media (max-width: 600px) {
  .frame__corner { width: 11px; height: 11px; }
  .frame__corner--tl, .frame__corner--tr { top: -6px; }
  .frame__corner--bl, .frame__corner--br { bottom: -6px; }
  .frame__corner--tl, .frame__corner--bl { left: -6px; }
  .frame__corner--tr, .frame__corner--br { right: -6px; }
  .frame__play { width: 62px; height: 62px; margin: -31px 0 0 -31px; }
  .frame__progress { left: 10px; right: 10px; top: calc(100% + 6px); }
}

/* phones held sideways: give the film the whole height */
@media (orientation: landscape) and (max-height: 500px) {
  .film__kicker, .film__note { display: none; }
  .scene--film {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  .frame { width: min(100%, calc((100svh - 48px) * 1204 / 512)); }
  .film__status { position: absolute; bottom: 4px; left: 0; right: 0; margin: 0; }
  .rose-wrap { width: 36px; height: 36px; margin-bottom: 10px; }
  .title__line--a { font-size: clamp(2rem, 7.5vh + 2vw, 3.6rem); }
  .title__line--b { font-size: clamp(2.2rem, 8vh + 2vw, 4rem); }
  .cta { margin-top: 20px; }
  .hint { display: none; }
  .intro { padding-bottom: 0; }
  .rose--finale { width: 30px; height: 30px; margin-bottom: 10px; }
  .finale { padding-bottom: 4vh; }
  .finale__line { font-size: clamp(1.2rem, 7vh, 1.9rem); }
  .finale__divider { margin-top: 10px; }
  .finale__wish { font-size: clamp(1.9rem, 11vh, 3.4rem); margin-top: 8px; }
  .replay { margin-top: 12px; }
}

/* ---------------------------------------------------------
   Reduced motion: keep the soft fades, drop the movement
   --------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .atmos__glow, .is-active .cta::after, .is-active .cta::before,
  .scene--intro.is-active .rose--intro, .scene--finale.is-active .rose--finale,
  .scene--intro.is-active .rose-wrap::before { animation: none !important; }
  .scene--intro.is-active .rose-wrap::before { opacity: .7; }
  .is-active .finale__wish::before { animation: glowIn 2s ease 2.4s forwards !important; }
  .scene, .scene.is-active, .scene.is-leaving { transform: none !important; }
  .is-active .ch, .is-active .wd, .is-active .fade, .is-active .finale__divider {
    animation: plainFade 1.2s ease forwards !important;
    animation-delay: var(--base, 0s) !important;
  }
  .is-active .finale__divider { transform: none; --base: 1.6s; }
  .finale__line { --base: .6s; }
  .finale__wish-line--a, .finale__wish-line--b { --base: 1.6s; }
  .replay { --base: 2.6s; }
  .is-leaving .ch, .is-leaving .wd, .is-leaving .fade, .is-leaving .rose {
    animation: fadeOut .6s ease forwards !important;
  }
  .is-active .rose__lines path { animation: none !important; stroke-dashoffset: 0 !important; }
  .is-active .rose__bloom { animation: none !important; opacity: .16; }
  .frame__bar, .frame__slit { display: none; }
  .frame__corner { transform: none !important; }
  .frame__ambient { transition-duration: 3s; }
  .frame.is-buffering .frame__progress::after { animation: none; opacity: .6; width: 100%; }
  .flash.is-on { animation: none; }
  .embers { display: none; }
  .intro, .finale, .atmos__glow, .atmos__horizon { translate: none !important; }
  @keyframes plainFade { from { opacity: 0; } to { opacity: 1; } }
}
