/* ── Palette: Lia's crimson line art on cream linen ───────────────── */
:root {
  color-scheme: light;
  --linen: #f3ede3;
  --linen-deep: #e7dfd1;
  --paper: #f7f2e9;
  --ink: #4a3a33;        /* warm brown for secondary text */
  --ink-soft: #8a7268;
  --red: #9d162c;        /* the crimson from the Figma file */
  --red-deep: #7a0f22;
  --serif: 'Crimson Pro', 'Crimson Text', 'EB Garamond', Georgia, serif;
  --hand: 'Reenie Beanie', 'Bradley Hand', 'Segoe Script', cursive;
  --ease: cubic-bezier(.22, .61, .36, 1);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='luminanceToAlpha'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { height: 100%; background: var(--linen); }
body {
  margin: 0; min-height: 100%;
  color: var(--ink); background: var(--linen);
  font: 400 17px/1.5 var(--serif);
  overflow-x: clip; -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }
[tabindex="-1"]:focus { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* letter-spaced serif caps, used for labels and small actions */
.gate-hint, .link-action, .pill, .field label, .excitement legend, .submit {
  font-family: var(--serif); font-weight: 600; text-transform: uppercase; letter-spacing: .24em;
}

/* ── Backdrop ─────────────────────────────────────────────────────── */
.backdrop { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.light {
  position: absolute; inset: 0;
  background:
    radial-gradient(70% 55% at 22% 6%, rgba(255,255,255,.75), rgba(255,255,255,0) 60%),
    radial-gradient(55% 45% at 86% 96%, rgba(140,105,75,.16), rgba(140,105,75,0) 62%),
    var(--linen);
}
.weave {
  position: absolute; inset: 0; opacity: .9;
  background-image:
    repeating-linear-gradient(0deg, rgba(120,95,70,.045) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, rgba(120,95,70,.045) 0 1px, transparent 1px 4px);
}
.grain { position: absolute; inset: 0; background-image: var(--grain); background-size: 180px 180px; opacity: .1; mix-blend-mode: multiply; }
.leaves { position: absolute; width: 48vmax; aspect-ratio: 1; opacity: .11; filter: blur(11px); }
.leaves svg { width: 100%; height: 100%; transform-origin: 0 0; animation: sway 12s ease-in-out infinite alternate; }
.leaves-tl { left: -10vmax; top: -8vmax; }
.leaves-br { right: -12vmax; bottom: -12vmax; transform: rotate(180deg); }
.leaves-br svg { animation-duration: 15s; animation-delay: -6s; }
@keyframes sway { from { transform: rotate(-1.4deg); } to { transform: rotate(1.4deg); } }
.fruit {
  position: absolute; width: var(--s); height: var(--s); overflow: visible;
  color: var(--red); opacity: .85; transform: rotate(var(--r, 0deg));
}
.art { position: absolute; width: var(--s); height: auto; transform: rotate(var(--r, 0deg)); }
.star { animation: twinkle var(--d, 4s) ease-in-out var(--delay, 0s) infinite alternate; }
@keyframes twinkle { from { opacity: .4; transform: scale(.88); } to { opacity: 1; transform: scale(1.06); } }
@media (max-width: 640px) { .fruit.wide, .art.wide, .fruit.bottom { display: none; } }

/* ── Controls ─────────────────────────────────────────────────────── */
.controls {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 0; pointer-events: none;
}
.controls > * { pointer-events: auto; }
.pill {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .55rem .95rem; border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(157,22,44,.35); background: rgba(247,242,233,.88); color: var(--red);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  font-size: .72rem; line-height: 1; letter-spacing: .18em;
  transition: background .2s, border-color .2s;
}
.pill:hover { background: var(--paper); border-color: var(--red); }
.pill svg { width: 1rem; height: 1rem; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.back { margin-right: auto; }
.sound { margin-left: auto; }
.sound .waves { opacity: .35; transition: opacity .2s; }
.sound.is-playing .waves { opacity: 1; }
.sound.is-playing .slash { display: none; }

/* ── Stage & scenes ───────────────────────────────────────────────── */
.stage {
  position: relative; z-index: 2;
  min-height: 100vh; min-height: 100svh;
  display: grid; place-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 4.5rem) 16px calc(env(safe-area-inset-bottom, 0px) + 2.5rem);
}
.stage[inert] { visibility: hidden; }
.scene {
  grid-area: 1 / 1; width: 100%; max-width: 60rem;
  display: flex; flex-direction: column; align-items: center; gap: 1.6rem;
  transition: opacity .55s var(--ease), transform .55s var(--ease);
}
.scene.is-leaving { opacity: 0; transform: translateY(-10px); }
.scene.is-entering { opacity: 0; transform: translateY(14px); }

.link-action {
  display: inline-flex; align-items: center; gap: .65rem; position: relative;
  background: none; border: 0; padding: .45rem 0; cursor: pointer; text-decoration: none;
  color: var(--red); font-size: .74rem; line-height: 1;
  transition: opacity .9s var(--ease) .3s, transform .9s var(--ease) .3s, color .2s;
}
.link-action::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: currentColor; opacity: .55; }
.link-action:hover { color: var(--red-deep); }
.arrow { width: 1.5rem; height: .95rem; stroke: currentColor; fill: none; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; transition: transform .3s var(--ease); }
.link-action:hover .arrow, .submit:hover .arrow { transform: translateX(4px); }

/* Scene 1: Lia's card, as exported */
.card-art { position: relative; width: min(88vw, 23rem, 58svh); isolation: isolate; transition: opacity 1.1s var(--ease), transform 1.1s var(--ease), filter 1.1s var(--ease); }
.intro-pending .card-art { opacity: 0; transform: translateY(34px); }
.intro-pending .next { opacity: 0; transform: translateY(6px); }
.card-img {
  display: block; width: 100%; height: auto; border-radius: 3px;
  box-shadow: 0 28px 44px -22px rgba(90,60,40,.5), 0 3px 6px rgba(90,60,40,.14), 0 0 0 1px rgba(90,60,40,.08);
}
.deco { position: absolute; height: auto; pointer-events: none; user-select: none; }
@media (max-width: 719px) { .deco.side { display: none; } }

/* Scene 2: YJ's framed illustration with the note beside it (below it on phones) */
.invite-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: clamp(1.4rem, 3vw, 2.6rem); width: 100%; }
.art-card {
  margin: 0; position: relative; flex: 1 1 22rem; width: 100%; max-width: 36rem;
  background: var(--paper); padding: .7rem;
  box-shadow: 0 22px 34px -18px rgba(90,60,40,.42), 0 2px 4px rgba(90,60,40,.12);
}
.illustration { display: block; width: 100%; height: auto; }
.tape {
  position: absolute; left: 50%; top: -.6rem; width: 26%; height: 1.4rem; transform: translateX(-50%);
  background:
    repeating-linear-gradient(0deg, rgba(157,22,44,.3) 0 5px, transparent 5px 10px),
    repeating-linear-gradient(90deg, rgba(157,22,44,.3) 0 5px, transparent 5px 10px),
    rgba(249,244,234,.92);
  box-shadow: 0 1px 2px rgba(90,60,40,.2);
}

/* the note */
.letter {
  position: relative; flex: 1 1 16rem; width: 100%; max-width: 22rem;
  background: var(--paper); color: var(--red); padding: 1.8rem 1.9rem 1.5rem;
  box-shadow: 0 18px 26px -14px rgba(90,60,40,.35), 0 2px 4px rgba(90,60,40,.1);
}
.letter p { position: relative; margin: 0 0 .7em; font: 400 clamp(1.5rem, 4.4vw, 1.8rem)/1.25 var(--hand); }
.letter p:last-child { margin-bottom: 0; }
.letter .sign { text-align: right; margin: .1em 0 0; padding-right: 2.4rem; }
.letter-sprig { right: -2.1rem; bottom: -2.6rem; width: 5.4rem; transform: rotate(10deg); }
.letter-flutes { left: -2.2rem; top: -2.6rem; width: 4.6rem; transform: rotate(-12deg); }
.hand-border { position: absolute; inset: 9px; width: calc(100% - 18px); height: calc(100% - 18px); overflow: visible; pointer-events: none; }
.hand-border rect { fill: none; stroke: var(--red); stroke-width: 1.5; vector-effect: non-scaling-stroke; }

.countdown { margin: -.4rem 0 0; display: flex; align-items: baseline; gap: .55rem; color: var(--red); }
.countdown .count { font: 400 clamp(2.4rem, 7vw, 3.4rem)/1 var(--hand); }
.countdown .count-label { font-family: var(--serif); font-weight: 600; font-size: .7rem; letter-spacing: .26em; text-transform: uppercase; }

/* Scene 3: details */
.details-layout { display: flex; flex-direction: column; align-items: center; gap: 1.5rem; width: 100%; }
.form-card {
  position: relative; width: min(100%, 30rem);
  background: var(--paper); color: var(--ink); padding: clamp(1.4rem, 3.5vw, 1.9rem) clamp(1.4rem, 3.5vw, 2rem) clamp(1.3rem, 3vw, 1.7rem);
  box-shadow: 0 22px 34px -18px rgba(90,60,40,.4), 0 2px 4px rgba(90,60,40,.1);
}
.form-cake { right: -1.8rem; bottom: -1.5rem; width: 6.2rem; transform: rotate(4deg); }
.form-sprig { right: -1.6rem; top: -1.9rem; width: 5rem; transform: rotate(12deg); }
.form-card h2 { margin: 0; font: 400 clamp(2.1rem, 6.5vw, 2.7rem)/1 var(--hand); color: var(--red); text-wrap: balance; }
.form-card .sub { margin: .3rem 0 1.1rem; color: var(--ink-soft); font: italic 400 1.02rem/1.35 var(--serif); }
.field { display: flex; flex-direction: column; gap: .32rem; margin-bottom: .85rem; }
.field label, .excitement legend { font-size: .78rem; line-height: 1; letter-spacing: .2em; color: var(--red); }
.field label .optional { text-transform: none; letter-spacing: 0; font-style: italic; font-weight: 400; font-size: .9rem; color: var(--ink-soft); margin-left: .3rem; }
.field input, .field textarea {
  width: 100%; color: var(--ink); background: rgba(255,255,255,.4); border: 1px solid rgba(74,58,51,.38); border-radius: 3px;
  padding: .5rem .7rem; font: 400 1.08rem/1.3 var(--serif); caret-color: var(--red);
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 2px rgba(157,22,44,.14); }
.field textarea { resize: vertical; min-height: 3.3rem; }
.excitement { border: 0; padding: 0; margin: 0 0 1.4rem; min-width: 0; }
.excitement legend { padding: 0; margin-bottom: .65rem; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { position: relative; display: inline-block; }
.chip input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.chip span {
  display: inline-block; padding: .4rem .85rem; border: 1px solid rgba(157,22,44,.45); border-radius: 999px; color: var(--red);
  font: 400 1rem/1.2 var(--serif); transition: background .2s, color .2s, border-color .2s;
}
.chip:hover span { border-color: var(--red); }
.chip input:checked + span { background: var(--red); color: var(--paper); border-color: var(--red); }
.chip input:focus-visible + span { outline: 2px solid var(--red); outline-offset: 2px; }
.honeypot { position: absolute; left: -9999px; top: 0; width: 1px; height: 1px; overflow: hidden; }
.submit {
  display: inline-flex; align-items: center; gap: .7rem; cursor: pointer; margin-top: .25rem;
  background: var(--red); color: var(--paper); border: 0; border-radius: 999px; padding: .8rem 1.4rem;
  font-size: .72rem; line-height: 1; letter-spacing: .22em;
  transition: transform .2s var(--ease), background .2s;
}
.submit:hover { transform: translateY(-1px); background: var(--red-deep); }
.submit:disabled { opacity: .6; cursor: default; transform: none; }
.status { min-height: 1.2em; margin: .6rem 0 0; font: italic 400 .98rem/1.35 var(--serif); color: var(--ink-soft); }
.status.is-error { color: var(--red-deep); }
.status:focus { outline: none; }
.preview-notice { margin: 0 0 .9rem; padding: .45rem .7rem; border: 1px dashed rgba(157,22,44,.45); font: italic 400 .98rem/1.35 var(--serif); color: var(--ink-soft); }
.thanks .thanks-copy { margin: 0 0 .5rem; font: 400 clamp(1.7rem, 5vw, 2.1rem)/1.25 var(--hand); color: var(--red); }
.thanks .thanks-copy:focus { outline: none; }
.thanks .preview-line { margin: 0 0 1rem; font: italic 400 .98rem/1.35 var(--serif); color: var(--ink-soft); }
.text-button { background: none; border: 0; padding: 0; color: var(--red); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font: 400 1.05rem/1.3 var(--serif); }
.calendar { position: relative; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .6rem 2rem; padding: .4rem .9rem; border-radius: 999px; background: rgba(243,237,227,.85); }
.cutlery { position: static; width: 2.6rem; opacity: .9; }
.cutlery.fork { transform: rotate(-24deg); }
.cutlery.spoon { transform: rotate(24deg); }
@media (max-width: 719px) { .cutlery { display: none; } }

/* ── The envelope gate ────────────────────────────────────────────── */
.gate { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; transition: opacity .8s var(--ease), visibility .8s; }
.gate-content { position: relative; display: flex; flex-direction: column; align-items: center; gap: 1.1rem; text-align: center; }
.ribbon-title { position: relative; width: min(88vw, 27rem); margin-bottom: .2rem; }
.ribbon { display: block; width: 100%; height: auto; }
.lettering { position: absolute; left: 40.6%; top: 50%; width: 34%; height: auto; transform: translate(-50%, -50%); }
.envelope-row { position: relative; display: flex; align-items: center; justify-content: center; gap: 1.2rem; width: 100%; }
.flute { position: static; width: clamp(4rem, 9vw, 6.5rem); }
.flute-left { transform: translateY(-1.4rem) rotate(-6deg); }
.flute-right { transform: translateY(-1.8rem) rotate(6deg); }
.berry-left, .berry-right { position: static; width: clamp(4.5rem, 10vw, 7rem); }
.berry-left { transform: translateY(-1rem) rotate(-8deg); }
.berry-right { transform: translateY(1.2rem) rotate(4deg); }
.envelope {
  position: relative; width: min(82vw, 23rem); aspect-ratio: 3 / 2;
  perspective: 900px; filter: drop-shadow(0 22px 26px rgba(90,60,40,.28)) drop-shadow(0 2px 3px rgba(90,60,40,.12));
}
.env-back, .env-front { position: absolute; inset: 0; width: 100%; height: 100%; }
.env-clip { position: absolute; inset: 0; clip-path: inset(-300% -60% 0 -60%); pointer-events: none; }
.env-card { position: absolute; left: 14%; top: 30%; width: 72%; height: auto; border-radius: 2px; box-shadow: 0 6px 14px -8px rgba(90,60,40,.4); transition: transform .95s cubic-bezier(.3,.7,.3,1) .5s; }
.flap { position: absolute; left: 0; top: 0; width: 100%; height: 56%; transform-origin: 50% 0; transform-style: preserve-3d; transition: transform .6s cubic-bezier(.4,0,.7,.3) .15s; }
.flap-face { position: absolute; inset: 0; width: 100%; height: 100%; backface-visibility: hidden; }
.seal {
  position: absolute; left: 50%; top: 50%; width: 6.8rem; height: 6.8rem; margin: -3.4rem 0 0 -3.4rem;
  border: 0; padding: 0; background: none; cursor: pointer; border-radius: 50%; color: var(--red);
  transform: translateY(8%);
  filter: drop-shadow(0 8px 10px rgba(90,60,40,.3));
  transition: transform .45s var(--ease), opacity .45s var(--ease), filter .3s;
}
.seal svg { width: 100%; height: 100%; overflow: visible; }
.seal-text { font: 600 11px var(--serif); letter-spacing: 3.5px; fill: var(--red); dominant-baseline: middle; }
.seal:hover { transform: translateY(8%) scale(1.05); filter: drop-shadow(0 12px 14px rgba(90,60,40,.32)); }
.gate-hint { margin: .2rem 0 0; font-size: .64rem; line-height: 1; letter-spacing: .3em; color: var(--ink-soft); }
.opener.is-opening .seal { transform: translateY(8%) scale(.3); opacity: 0; pointer-events: none; }
.opener.is-opening .flap { transform: rotateX(-104deg); }   /* lifts to edge-on and vanishes; never shows its back */
/* lift: the card rises out while the envelope holds still, then everything else falls away */
.opener.open-lift.is-opening .env-card { transform: translateY(-62%); }
.opener.open-lift.is-opening .env-back, .opener.open-lift.is-opening .env-front { transition: opacity .6s var(--ease) .75s, transform .7s var(--ease) .75s; opacity: 0; transform: translateY(6%); }
/* dissolve: the envelope softens away and the card fades in behind it */
.opener.open-dissolve.is-opening .envelope { transition: filter .9s var(--ease) .3s, opacity .9s var(--ease) .3s, transform .9s var(--ease) .3s; filter: blur(14px); opacity: 0; transform: scale(.94); }
.scene-invitation.intro-pending.dissolve-in .card-art { filter: blur(6px); transform: translateY(24px) scale(.96); }
.gate.is-gone { opacity: 0; visibility: hidden; pointer-events: none; }
.opener.open-dissolve.is-gone .envelope { opacity: 0; }
.gate.is-gone .ribbon-title, .gate.is-gone .gate-hint, .gate.is-gone .flute { opacity: 0; transition: opacity .4s; }

/* ── Photo version of the opened view (?inside=photo) ─────────────── */
.only-photo { display: none; }
:root[data-inside="photo"] .only-photo { display: block; }
:root[data-inside="photo"] .not-photo { display: none; }
.only-photoai { display: none; }
:root[data-inside="photoai"] .only-photoai { display: block; }
:root[data-inside="photoai"] .not-photo { display: none; }

/* ── Strawberry variant (?variant=strawberry) ─────────────────────── */
.only-strawberry { display: none; }
:root[data-variant="strawberry"] .only-strawberry { display: block; }
:root[data-variant="strawberry"] .not-strawberry { display: none; }
:root[data-variant="strawberry"] .letter { background-image: var(--berry-pattern); background-size: 92px 92px; background-position: 12px 8px; }
@media (max-width: 640px) { :root[data-variant="strawberry"] .only-strawberry.wide { display: none; } }
@media (max-width: 719px) { :root[data-variant="strawberry"] .only-strawberry.side { display: none; } }

/* ── Misc ─────────────────────────────────────────────────────────── */
.noscript-message { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 40; margin: 0; padding: .8rem 1rem; background: var(--paper); color: var(--ink); border: 1px solid var(--red); text-align: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
