/* ════════════════════════════════════════════════════════════════════════
   An Episode Made For You — for Maman 🌷
   Aesthetic: warm cinema night. Deep plum, champagne gold, dusty rose, cream.
   Mobile-first. Soft, glowy, literary.
   ════════════════════════════════════════════════════════════════════════ */

:root {
  --ink:        #160f1d;   /* deep plum-black */
  --ink-2:      #211627;
  --ink-3:      #2c1f33;
  --cream:      #f7ede1;
  --cream-dim:  #d8c9bd;
  --rose:       #e7a39c;
  --rose-deep:  #c87b76;
  --gold:       #ecc88a;
  --gold-soft:  #f0d6a6;
  --line:       rgba(247,237,225,.14);

  --font-display: "Fraunces", Georgia, serif;
  --font-body:    "Instrument Sans", system-ui, sans-serif;

  --ease: cubic-bezier(.22,.61,.36,1);
  --shadow-soft: 0 24px 60px -24px rgba(0,0,0,.7);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  color: var(--cream);
  background: var(--ink);
  /* layered atmosphere: warm spotlights + vignette */
  background-image:
    radial-gradient(120% 80% at 50% -10%, rgba(236,200,138,.16), transparent 55%),
    radial-gradient(90% 60% at 85% 20%, rgba(231,163,156,.12), transparent 50%),
    radial-gradient(100% 70% at 10% 90%, rgba(200,123,118,.10), transparent 55%),
    linear-gradient(180deg, var(--ink-2), var(--ink) 60%);
  background-attachment: fixed;
  min-height: 100svh;
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Film grain overlay */
.grain {
  position: fixed; inset: 0; z-index: 60; pointer-events: none;
  opacity: .05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Particle canvas (petals + tap hearts) */
#petals {
  position: fixed; inset: 0; z-index: 40; pointer-events: none;
  width: 100%; height: 100%;
}

/* ───────────────────────── screens ───────────────────────── */
.screen { display: block; }
.screen[hidden] { display: none !important; }

#app { position: relative; z-index: 10; }

.eyebrow {
  font-size: .72rem; letter-spacing: .32em; text-transform: uppercase;
  color: var(--gold); font-weight: 600;
}

/* ───────────────────────── SCREEN 1 · TITLE ───────────────────────── */
.screen--title {
  min-height: 100svh;
  display: grid; place-items: center;
  padding: calc(4.2rem + env(safe-area-inset-top)) 1.4rem calc(2.5rem + env(safe-area-inset-bottom));
}
.title-wrap { text-align: center; max-width: 30rem; width: 100%; }

.poster {
  position: relative; margin: 1.4rem auto 1.8rem; width: 100%;
  border-radius: 18px; overflow: hidden;
  box-shadow: var(--shadow-soft), 0 0 0 1px var(--line);
  aspect-ratio: 16/10;
}
.poster img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  filter: saturate(1.05) contrast(1.03);
}
.poster::after { /* cinematic gradient over photo */
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(22,15,29,.05) 40%, rgba(22,15,29,.78));
}
.poster__badge {
  position: absolute; top: .8rem; left: .8rem; z-index: 2;
  font-size: .64rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink); background: var(--gold);
  padding: .34rem .6rem; border-radius: 100px; font-weight: 600;
}

.title { line-height: .96; margin-bottom: .8rem; }
.title__pre {
  display: block; font-family: var(--font-display); font-weight: 400;
  font-style: italic; font-size: clamp(1.4rem, 7vw, 2rem); color: var(--rose);
  font-optical-sizing: auto;
}
.title__big {
  display: block; font-family: var(--font-display); font-weight: 500;
  font-size: clamp(2.7rem, 14vw, 4.6rem); line-height: .95; letter-spacing: -.015em;
  color: var(--cream); text-shadow: 0 0 40px rgba(236,200,138,.18);
}

.starring { font-size: 1.05rem; color: var(--cream-dim); margin-bottom: 2rem; }
.starring__name {
  font-family: var(--font-display); font-style: italic; font-weight: 500;
  font-size: 1.5rem; color: var(--gold);
  border-bottom: 1px solid rgba(236,200,138,.4); padding-bottom: 1px;
}

/* Play button */
.play {
  display: inline-flex; align-items: center; gap: .7rem;
  font-family: var(--font-body); font-weight: 600; font-size: 1.05rem;
  color: var(--ink); background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  border: none; padding: .95rem 2.2rem; border-radius: 100px; cursor: pointer;
  box-shadow: 0 0 0 0 rgba(236,200,138,.5), 0 14px 30px -10px rgba(236,200,138,.5);
  animation: pulse 2.8s var(--ease) infinite; transition: transform .25s var(--ease);
}
.play:active { transform: scale(.96); }
.play__tri {
  width: 0; height: 0; border-style: solid;
  border-width: 7px 0 7px 12px; border-color: transparent transparent transparent var(--ink);
}
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(236,200,138,.45), 0 14px 30px -10px rgba(236,200,138,.5); }
  50%     { box-shadow: 0 0 0 14px rgba(236,200,138,0), 0 14px 30px -10px rgba(236,200,138,.5); }
}

.hint { margin-top: 1.6rem; font-size: .85rem; color: var(--cream-dim); font-style: italic;
  font-family: var(--font-display); }

/* ───────────────────────── SCREEN 2 · EPISODES ───────────────────────── */
.screen--episodes {
  min-height: 100svh; max-width: 34rem; margin: 0 auto;
  padding: calc(3.2rem + env(safe-area-inset-top)) 1.3rem calc(3rem + env(safe-area-inset-bottom));
}
.ep-head { text-align: center; margin-bottom: 2rem; }
.ep-title {
  font-family: var(--font-display); font-weight: 500; font-size: clamp(2.4rem, 11vw, 3.2rem);
  margin: .3rem 0 .7rem; line-height: 1;
}
.ep-sub { color: var(--cream-dim); font-size: .92rem; }

.ep-list { list-style: none; display: flex; flex-direction: column; gap: 1rem; }

.ep-card {
  position: relative; display: flex; gap: 1rem; align-items: stretch;
  background: linear-gradient(150deg, var(--ink-3), var(--ink-2));
  border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
  padding: .7rem; cursor: pointer; text-align: left; width: 100%;
  color: inherit; font-family: inherit;
  transition: transform .3s var(--ease), border-color .3s, box-shadow .3s;
  -webkit-tap-highlight-color: transparent;
}
.ep-card:active { transform: scale(.98); }
@media (hover:hover) {
  .ep-card:hover { transform: translateY(-3px); border-color: rgba(236,200,138,.4);
    box-shadow: var(--shadow-soft); }
}
.ep-card__thumb {
  position: relative; flex: 0 0 92px; height: 92px; border-radius: 11px; overflow: hidden;
  background: var(--ink);
}
.ep-card__thumb .t-bg {
  position: absolute; inset: 0; background-size: cover; background-position: center;
  filter: blur(9px) brightness(.6); transform: scale(1.25);
}
.ep-card__thumb img { position: relative; width: 100%; height: 100%; object-fit: contain; display: block; }
.ep-card__body { flex: 1; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.ep-card__no { font-size: .68rem; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); }
.ep-card__name {
  font-family: var(--font-display); font-weight: 500; font-size: 1.18rem; line-height: 1.15;
  margin: .15rem 0 .25rem; color: var(--cream);
}
.ep-card__desc { font-size: .8rem; color: var(--cream-dim); }
.ep-card__play {
  align-self: center; flex: 0 0 auto; margin-right: .4rem;
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid rgba(236,200,138,.4); color: var(--gold);
}
.ep-card__play::before {
  content: ""; width: 0; height: 0; margin-left: 3px;
  border-style: solid; border-width: 6px 0 6px 10px;
  border-color: transparent transparent transparent currentColor;
}

/* watched state */
.ep-card.is-watched { opacity: .82; }
.ep-card.is-watched .ep-card__play { background: rgba(236,200,138,.16); }
.ep-card.is-watched .ep-card__no::after { content: " · watched ✓"; color: var(--rose); }

/* locked finale */
.ep-card.is-locked { cursor: not-allowed; }
.ep-card.is-locked .ep-card__thumb { filter: grayscale(.6) brightness(.5); }
.ep-card.is-locked .ep-card__play { border-color: var(--line); color: var(--cream-dim); }
.ep-card.is-locked .ep-card__play::before {
  border: none; width: 13px; height: 11px; margin: 0; border-radius: 2px 2px 0 0;
  background: currentColor;
  box-shadow: 0 -6px 0 -2px transparent, inset 0 0 0 2px var(--ink-3);
}
.ep-card.is-locked .ep-card__play { position: relative; }
.ep-card.is-locked .ep-card__play::after {
  content: ""; position: absolute; top: 8px; width: 8px; height: 8px;
  border: 2px solid currentColor; border-bottom: none; border-radius: 8px 8px 0 0;
}
.ep-card.is-finale .ep-card__name { color: var(--gold); }
.ep-card.is-finale:not(.is-locked) {
  border-color: rgba(236,200,138,.5);
  background: linear-gradient(150deg, #3a2433, #271a2e);
  box-shadow: 0 0 30px -8px rgba(236,200,138,.35);
}

.ep-foot { text-align: center; margin-top: 2.2rem; font-family: var(--font-display);
  font-style: italic; color: var(--cream-dim); font-size: .95rem; }

/* ───────────────────────── SCENE PLAYER ───────────────────────── */
.player, .finale {
  position: fixed; inset: 0; z-index: 70; background: var(--ink);
  background-image: radial-gradient(120% 80% at 50% 0%, rgba(236,200,138,.10), transparent 60%);
  display: none; flex-direction: column;
}
.player.is-open, .finale.is-open { display: flex; }

.player__close {
  position: absolute; top: calc(.8rem + env(safe-area-inset-top)); right: .9rem; z-index: 5;
  width: 42px; height: 42px; border-radius: 50%; cursor: pointer;
  background: rgba(22,15,29,.6); backdrop-filter: blur(8px);
  border: 1px solid var(--line); color: var(--cream); font-size: 1.05rem;
  -webkit-tap-highlight-color: transparent;
}
.player__close:active { transform: scale(.92); }

.player__progress {
  position: absolute; top: 0; left: 0; right: 0; height: 3px; z-index: 5;
  background: rgba(247,237,225,.1);
}
#player-bar { display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--rose), var(--gold)); transition: width .2s linear; }

.player__scroll {
  flex: 1; overflow-y: auto; scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* a "shot" = full-bleed photo + subtitle */
.shot {
  min-height: 100svh; position: relative; display: flex; flex-direction: column;
  justify-content: flex-end; padding: 1.4rem 1.3rem calc(3.5rem + env(safe-area-inset-bottom));
  scroll-snap-align: start;
}
.player__scroll { scroll-snap-type: y proximity; }
.shot__img {
  position: absolute; inset: 0; z-index: -1; overflow: hidden; background: var(--ink);
}
/* blurred fill behind, so the full photo is always shown — never crops Maman out */
.shot__bg {
  position: absolute; inset: 0; background-size: cover; background-position: center;
  filter: blur(34px) brightness(.42) saturate(1.15); transform: scale(1.25);
}
.shot__img img {
  position: relative; width: 100%; height: 100%; object-fit: contain; display: block;
  transform: scale(1.05); transition: transform 6s ease-out;
  filter: saturate(1.04) contrast(1.02);
}
.shot.is-seen .shot__img img { transform: scale(1); }
.shot__img::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(22,15,29,.55) 0%, transparent 28%, transparent 45%, rgba(22,15,29,.85) 100%);
}

.shot__intro {
  position: absolute; top: calc(1.25rem + env(safe-area-inset-top)); left: 0; right: 0;
  text-align: center;
  font-size: .7rem; letter-spacing: .24em; text-transform: uppercase; color: var(--gold);
  text-shadow: 0 2px 10px rgba(0,0,0,.8);
  opacity: 0; transform: translateY(-6px); transition: .6s var(--ease);
}
.shot.is-seen .shot__intro { opacity: 1; transform: none; }

/* subtitle (kdrama style) */
.sub {
  max-width: 30rem; margin: 0 auto; width: 100%; text-align: center;
  font-size: clamp(1.05rem, 4.6vw, 1.35rem); line-height: 1.45;
  color: var(--cream); font-weight: 400;
  text-shadow: 0 2px 14px rgba(0,0,0,.85);
}
.sub .em { color: var(--gold); font-family: var(--font-display); font-style: italic; }
.sub__caret {
  display: inline-block; width: .55ch; color: var(--gold);
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.sub.done .sub__caret { display: none; }

.player__next {
  position: absolute; bottom: calc(1rem + env(safe-area-inset-bottom)); left: 0; right: 0;
  display: flex; justify-content: center; z-index: 5; pointer-events: none; opacity: 0;
  transition: opacity .5s;
}
.player__next.show { opacity: 1; pointer-events: auto; }
.btn-soft {
  font-family: var(--font-body); font-weight: 500; color: var(--ink);
  background: var(--cream); border: none; border-radius: 100px;
  padding: .7rem 1.4rem; font-size: .9rem; cursor: pointer;
  box-shadow: var(--shadow-soft);
}
.btn-soft:active { transform: scale(.96); }

/* scroll cue */
.scroll-cue {
  position: absolute; bottom: calc(1.2rem + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%); font-size: .75rem; color: var(--cream-dim);
  letter-spacing: .18em; text-transform: uppercase; animation: bob 1.8s ease-in-out infinite;
  text-shadow: 0 2px 10px rgba(0,0,0,.8);
}
@keyframes bob { 0%,100%{transform:translate(-50%,0)} 50%{transform:translate(-50%,8px)} }

/* ───────────────────────── FINALE · LETTER ───────────────────────── */
.finale { justify-content: flex-start; align-items: center; padding: 1.4rem; overflow-y: auto;
  -webkit-overflow-scrolling: touch; }

.envelope { display: grid; place-items: center; gap: 1.2rem; perspective: 900px; margin: auto; }
.envelope__body {
  position: relative; width: min(86vw, 22rem); aspect-ratio: 7/5;
  background: linear-gradient(160deg, #efe2d0, #e3d0bb);
  border-radius: 10px; box-shadow: var(--shadow-soft);
  display: grid; place-items: center;
}
.envelope__body::before { /* paper fold lines */
  content: ""; position: absolute; inset: 0; border-radius: 10px;
  background:
    linear-gradient(135deg, transparent 49.6%, rgba(0,0,0,.07) 50%, transparent 50.4%),
    linear-gradient(-135deg, transparent 49.6%, rgba(0,0,0,.07) 50%, transparent 50.4%);
}
.envelope__flap {
  position: absolute; top: 0; left: 0; right: 0; height: 52%;
  background: linear-gradient(160deg, #e8d8c3, #d9c3a9);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top; transition: transform .8s var(--ease);
  box-shadow: 0 6px 12px -8px rgba(0,0,0,.4);
}
.seal {
  position: relative; z-index: 3; width: 70px; height: 70px; border-radius: 50%;
  border: none; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, var(--rose), var(--rose-deep) 75%);
  box-shadow: 0 8px 20px -6px rgba(176,86,80,.7), inset 0 2px 6px rgba(255,255,255,.4);
  display: grid; place-items: center; transition: transform .3s var(--ease);
  animation: pulse-rose 2.6s var(--ease) infinite;
}
.seal:active { transform: scale(.9); }
.seal__mark {
  font-family: var(--font-display); font-weight: 600; font-size: 1.8rem; color: #fff3ea;
  font-style: italic; text-shadow: 0 1px 2px rgba(0,0,0,.3);
}
@keyframes pulse-rose {
  0%,100% { box-shadow: 0 8px 20px -6px rgba(176,86,80,.7), inset 0 2px 6px rgba(255,255,255,.4), 0 0 0 0 rgba(231,163,156,.5); }
  50%     { box-shadow: 0 8px 20px -6px rgba(176,86,80,.7), inset 0 2px 6px rgba(255,255,255,.4), 0 0 0 16px rgba(231,163,156,0); }
}
.envelope__hint { font-family: var(--font-display); font-style: italic; color: var(--cream-dim); font-size: .95rem; }

.envelope.is-opening .envelope__flap { transform: rotateX(180deg); }
.envelope.is-opening .seal { transform: scale(0); opacity: 0; }
.envelope.is-opening .envelope__hint { opacity: 0; }

/* the letter itself */
.letter {
  max-width: 32rem; width: 100%; color: var(--cream); margin: auto;
  padding: calc(3.6rem + env(safe-area-inset-top)) .4rem calc(3rem + env(safe-area-inset-bottom));
  animation: rise .9s var(--ease) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(26px); } }
.letter__date { font-size: .8rem; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); }
.letter__hi {
  font-family: var(--font-display); font-weight: 500; font-style: italic;
  font-size: clamp(1.8rem, 8vw, 2.4rem); margin: .4rem 0 1.1rem; color: var(--cream);
}
.letter p { margin-bottom: 1rem; font-size: 1.04rem; line-height: 1.72; color: var(--cream-dim); }
.letter p:first-of-type { color: var(--cream); }
.letter__sign { font-family: var(--font-display); font-style: italic; color: var(--cream) !important;
  font-size: 1.15rem; margin-top: 1.6rem; }
.letter__name { color: var(--gold); font-weight: 500; }

/* ───────────────────────── OST toggle ───────────────────────── */
.ost {
  position: fixed; top: calc(.9rem + env(safe-area-inset-top)); left: .9rem; z-index: 80;
  display: inline-flex; align-items: center; gap: .5rem;
  background: rgba(22,15,29,.55); backdrop-filter: blur(8px);
  border: 1px solid var(--line); color: var(--cream-dim);
  border-radius: 100px; padding: .5rem .85rem .5rem .7rem; cursor: pointer;
  font-family: var(--font-body); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase;
  -webkit-tap-highlight-color: transparent; transition: color .3s, border-color .3s;
}
.ost[aria-pressed="true"] { color: var(--gold); border-color: rgba(236,200,138,.4); }
.ost__icon { display: inline-flex; align-items: flex-end; gap: 2px; height: 13px; }
.ost__icon i {
  width: 2.5px; height: 4px; background: currentColor; border-radius: 2px;
}
.ost[aria-pressed="true"] .ost__icon i { animation: eq .9s ease-in-out infinite; }
.ost__icon i:nth-child(2){ animation-delay:.15s } .ost__icon i:nth-child(3){ animation-delay:.3s } .ost__icon i:nth-child(4){ animation-delay:.45s }
@keyframes eq { 0%,100%{height:4px} 50%{height:13px} }

/* ───────────────────────── reveal-on-load ───────────────────────── */
.reveal { opacity: 0; transform: translateY(16px); animation: reveal .9s var(--ease) forwards; animation-delay: var(--d, 0s); }
@keyframes reveal { to { opacity: 1; transform: none; } }

/* ───────────────────────── reduced motion ───────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
  .shot__img img { transform: none; }
}

/* larger screens: keep it phone-shaped & centered, framed like a device */
@media (min-width: 760px) {
  body::before {
    content: ""; position: fixed; inset: 0; z-index: 0;
    background-image: radial-gradient(60% 50% at 50% 40%, rgba(236,200,138,.06), transparent 70%);
  }
  .player__scroll, .finale { max-width: 30rem; margin: 0 auto; }
}
