/* =====================================================================
   OPENING GATE
   ===================================================================== */
.intro-gate {
  position: fixed; inset: 0;
  z-index: var(--z-gate);
  background: var(--black);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(20px, 6vh, 40px);
  padding: 24px;
  transition: opacity 0.9s var(--ease-soft);
}
.intro-gate.is-leaving { opacity: 0; }
.intro-rose-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
}
.intro-lines {
  position: relative;
  text-align: center;
  display: flex; flex-direction: column; gap: clamp(10px, 2.4vh, 18px);
}
.intro-line {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(22px, 6.4vw, 40px);
  color: var(--ink);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 1.1s var(--ease), transform 1.1s var(--ease);
}
.intro-line.is-visible { opacity: 1; transform: translateY(0); }
.intro-line--crown {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--rose-bright);
  font-style: italic;
}
.crown-icon { width: clamp(28px, 7vw, 42px); height: auto; color: var(--gold); }

.enter-btn {
  position: relative;
  font-family: var(--accent-serif);
  font-style: italic;
  font-size: clamp(13px, 3.4vw, 16px);
  letter-spacing: 0.14em;
  text-transform: lowercase;
  color: var(--ink);
  padding: 14px 30px;
  border: 1px solid var(--faint);
  border-radius: 999px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 1s var(--ease), transform 1s var(--ease), border-color 0.4s, box-shadow 0.4s;
}
.enter-btn.is-visible {
  opacity: 1; transform: translateY(0);
  animation: enter-glow 2.6s ease-in-out infinite;
}
@keyframes enter-glow {
  0%, 100% { box-shadow: 0 0 0 rgba(184,28,58,0); border-color: var(--faint); }
  50% { box-shadow: 0 0 26px rgba(184,28,58,0.35); border-color: rgba(184,28,58,0.6); }
}

.curtain {
  position: fixed; top: 0; bottom: 0; width: 51%;
  z-index: var(--z-curtain);
  background: var(--black);
  transition: transform 1s var(--ease-soft);
}
.curtain--left { left: 0; }
.curtain--right { right: 0; }
.curtain--left.is-open { transform: translateX(-102%); }
.curtain--right.is-open { transform: translateX(102%); }

/* =====================================================================
   STORY SHELL
   ===================================================================== */
.story { position: relative; z-index: var(--z-content); }

.scene {
  position: relative;
  min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: max(48px, env(safe-area-inset-top)) 22px max(36px, env(safe-area-inset-bottom));
  gap: clamp(10px, 2vh, 18px);
  opacity: calc(0.1 + 0.9 * var(--enter, 0));
  transform:
    scale(calc(0.97 + 0.03 * var(--enter, 0)))
    translateY(calc((1 - var(--enter, 0)) * 18px));
  will-change: transform, opacity;
}

@media (min-width: 900px) {
  .scene { padding-left: 48px; padding-right: 48px; gap: clamp(18px, 3.4vh, 32px); }
}

/* =====================================================================
   02 — ROSE
   ===================================================================== */
.scene-rose { background: radial-gradient(120% 80% at 50% 40%, var(--burgundy), var(--black) 72%); }
.rose-canvas {
  width: min(78vw, 360px);
  height: min(78vw, 360px);
  animation: rose-breathe 5.5s ease-in-out infinite;
  cursor: pointer;
  transition: filter 0.4s var(--ease);
}
.rose-canvas.is-touched { filter: drop-shadow(0 0 28px rgba(217,44,76,0.55)); }
.rose-canvas--small { width: min(46vw, 200px); height: min(46vw, 200px); animation-duration: 6.5s; }
@keyframes rose-breathe {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.035) rotate(0.4deg); }
}
.scene-text { display: flex; flex-direction: column; gap: 6px; transition: opacity 0.6s var(--ease); }
.scene-text.is-faded { opacity: 0.35; }
.scene-text p, .scene-text-after {
  font-family: var(--serif);
  font-size: clamp(16px, 4.4vw, 22px);
  color: var(--ink);
}
.scene-text-after {
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
  color: var(--rose-bright);
  font-style: italic;
}
.scene-text-after.is-visible { opacity: 1; transform: translateY(0); }

.scroll-cue {
  position: absolute; bottom: clamp(18px, 5vh, 34px); left: 50%;
  transform: translateX(-50%);
  width: 1px; height: 30px;
  background: linear-gradient(180deg, transparent, var(--faint) 55%, transparent);
  opacity: 0.55;
  transition: opacity 0.8s var(--ease);
}
.scroll-cue.is-hidden { opacity: 0; }
.scroll-cue::after {
  content: "";
  position: absolute; left: 50%; top: 0;
  width: 5px; height: 5px; margin-left: -2.5px;
  border-radius: 999px; background: var(--gold);
  animation: scroll-cue-drop 1.9s ease-in-out infinite;
}
@keyframes scroll-cue-drop {
  0% { transform: translateY(-2px); opacity: 0; }
  20% { opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translateY(30px); opacity: 0; }
}

/* =====================================================================
   03 — DANCE (scroll-pinned choreography)
   ===================================================================== */
.scene-dance { height: 190vh; min-height: 190vh; padding: 0; display: block; opacity: 1; transform: none; }
.scene-sticky {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(180deg, var(--black), var(--burgundy) 55%, var(--deep-red));
  overflow: hidden;
}
.scene-dance.is-slow .scene-sticky { transition: filter 0.6s var(--ease); filter: saturate(0.7) brightness(0.92); }
.dance-canvas { width: min(80vw, 420px); height: min(58vh, 480px); }
.dance-text {
  position: absolute; bottom: clamp(28px, 8vh, 64px); left: 0; right: 0;
  padding: 0 24px; display: flex; flex-direction: column; gap: 8px; text-align: center;
}
.dance-line {
  font-family: var(--accent-serif); font-style: italic;
  font-size: clamp(15px, 4.4vw, 21px);
  color: var(--muted);
}

/* =====================================================================
   04 — MUSIC
   ===================================================================== */
.scene-music { background: radial-gradient(120% 80% at 50% 60%, var(--deep-red), var(--black) 75%); }
.scene-text-before { font-family: var(--serif); font-size: clamp(15px, 4vw, 19px); color: var(--muted); }
.music-player {
  position: relative;
  width: min(90vw, 360px);
  padding: clamp(20px, 4vw, 30px);
  border-radius: 18px;
  background: linear-gradient(165deg, rgba(38,18,20,0.94), rgba(20,10,12,0.94));
  border: 1px solid rgba(201,161,90,0.16);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 24px 60px rgba(0,0,0,0.45);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  transition: transform 0.4s var(--ease), box-shadow 0.4s var(--ease);
}
html.is-music-live .music-player,
.is-music-live .music-player {
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.06),
    0 24px 60px rgba(0,0,0,0.45),
    0 0 calc(14px + var(--music-level) * 46px) rgba(184,28,58,calc(0.15 + var(--music-level) * 0.35));
}
.song-title { font-family: var(--serif); font-size: clamp(19px, 5vw, 24px); }
.song-artist { font-family: var(--accent-serif); font-style: italic; color: var(--muted); font-size: 14px; margin-bottom: 6px; }
.waveform-canvas { width: 100%; height: 56px; }
.player-controls { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.player-play {
  width: 52px; height: 52px; border-radius: 999px;
  background: var(--rose); color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 22px rgba(184,28,58,0.35);
  transition: transform 0.2s var(--ease);
}
.player-play:active { transform: scale(0.94); }
.player-play svg { width: 20px; height: 20px; }
.player-play .icon-pause { display: none; }
.player-play[aria-pressed="true"] .icon-play { display: none; }
.player-play[aria-pressed="true"] .icon-pause { display: block; }
.player-time { display: flex; align-items: center; gap: 8px; width: 100%; font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.progress-track { flex: 1; height: 2px; background: rgba(243,236,230,0.14); border-radius: 2px; overflow: hidden; }
.progress-fill { display: block; height: 100%; width: 0%; background: var(--rose-bright); }
.player-volume { display: flex; align-items: center; gap: 8px; width: 100%; color: var(--faint); }
.player-volume svg { width: 15px; height: 15px; flex: none; }
.player-volume input[type="range"] { flex: 1; accent-color: var(--rose); }
.player-note { font-size: 11px; color: var(--faint); }
.player-note code { color: var(--muted); }

/* =====================================================================
   05 — DEVOTION — a quiet direct poem, nothing to find or unlock.
   ===================================================================== */
.scene-devotion { background: radial-gradient(110% 90% at 50% 46%, var(--burgundy), var(--black) 78%); gap: clamp(16px, 3vh, 28px); }
.scene-devotion .rose-canvas--small { width: min(30vw, 130px); height: min(30vw, 130px); animation-duration: 7s; opacity: 0.9; }
.section-kicker {
  font-family: var(--accent-serif);
  font-style: italic;
  font-size: clamp(13px, 3.6vw, 15px);
  letter-spacing: 0.03em;
  color: var(--faint);
}
.devotion-lines {
  display: flex; flex-direction: column; gap: clamp(10px, 2vh, 16px);
  max-width: 440px;
}
.devotion-line {
  font-family: var(--serif);
  font-size: clamp(16px, 4.6vw, 22px);
  line-height: 1.4;
  color: var(--ink);
}
.devotion-line:last-child { font-style: italic; color: var(--rose-bright); text-shadow: 0 0 22px rgba(217,44,76,0.35); }

/* =====================================================================
   06 — LETTER — the whole letter, written out and organized in one
   page: opening line, body, a divider, then the crush confession.
   ===================================================================== */
.scene-letter { background: radial-gradient(120% 90% at 50% 50%, var(--burgundy), var(--black) 78%); }

.letter-paper {
  max-width: 480px;
  width: 100%;
  display: flex; flex-direction: column; gap: 14px;
  padding: clamp(24px, 5vw, 40px) clamp(20px, 5vw, 36px);
  border-left: 1px solid rgba(201,161,90,0.35);
  background: linear-gradient(100deg, rgba(243,236,230,0.035), transparent 60%);
  box-shadow: -1px 0 24px rgba(201,161,90,0.06);
}
.letter-line {
  font-family: var(--serif);
  font-size: clamp(15px, 4vw, 19px);
  line-height: 1.5;
  color: var(--ink);
}
.letter-line:first-child { font-style: italic; color: var(--rose-bright); font-size: clamp(19px, 5vw, 24px); }

.letter-divider {
  align-self: center;
  width: 56px; height: 1px;
  margin: 4px 0 2px;
  background: rgba(201,161,90,0.35);
}

.crush-line { font-family: var(--serif); font-size: clamp(16px, 4.4vw, 21px); line-height: 1.5; color: var(--ink); }
.crush-line:last-child { text-align: center; font-size: clamp(20px, 5.4vw, 26px); }

/* =====================================================================
   07 — FINALE
   ===================================================================== */
.scene-finale {
  height: 140vh; min-height: 140vh; padding: 0; display: block;
  opacity: 1; transform: none;
}
.scene-sticky--finale {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(10px, 2vh, 18px);
  padding: max(48px, env(safe-area-inset-top)) 22px max(36px, env(safe-area-inset-bottom));
  text-align: center;
  background: radial-gradient(130% 100% at 50% 40%, var(--deep-red), var(--black) 80%);
  overflow: hidden;
}
.crown-mark { width: clamp(30px, 7vw, 40px); height: auto; color: var(--gold); opacity: 0.85; }
.finale-princess {
  font-family: var(--serif); font-size: clamp(19px, 5.6vw, 28px);
  color: var(--ink);
}
.secret-reveal { display: flex; flex-direction: column; gap: 6px; min-height: 1px; }
.secret-line {
  font-family: var(--accent-serif); font-style: italic; color: var(--rose-bright);
  font-size: clamp(14px, 4vw, 18px);
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
}
.secret-line.is-visible { opacity: 1; transform: translateY(0); }
.finale-goodnight {
  display: flex; flex-direction: column; gap: 6px;
  opacity: 0; transition: opacity 1.4s var(--ease);
}
.finale-goodnight.is-visible { opacity: 1; }
.finale-goodnight p:first-child { font-family: var(--serif); font-size: clamp(18px, 5vw, 24px); }
.finale-blackout {
  position: fixed; inset: 0; z-index: 2;
  background: var(--black);
  opacity: var(--fade, 0);
  pointer-events: none;
  transition: opacity 0.3s linear;
}


/* =====================================================================
   Small phones — tighten spacing, avoid overflow.
   ===================================================================== */
@media (max-width: 360px) {
  .music-player { padding: 16px; }
}
