/* ============ tokens ============ */
:root {
  --paper: #ecdcc4;
  --paper-hi: #f4ead9;
  --ink: #2a1c15;
  --ink-soft: #5b4637;
  --ink-faint: rgba(42, 28, 21, .55);
  --red: #9e1b1b;
  --red-hi: #c0262a;
  --red-deep: #6f1010;
  --kraft: #b48a5a;
  --f-script: 'Great Vibes', cursive;
  --f-hand: 'Comforter', cursive;
  --f-write: 'Bad Script', cursive;
  --f-caps: 'Amatic SC', cursive;
  --f-serif: 'Cormorant Garamond', 'Times New Roman', serif;
  --f-mono: 'PT Mono', ui-monospace, monospace;
  --tx: 0; --ty: 0;           /* device tilt -1..1 */
  --gutter: clamp(18px, 5.5vw, 28px);
  --film: contrast(1.06) saturate(.82) sepia(.16) brightness(1.02) blur(0px);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body {
  font-family: var(--f-serif);
  overflow-x: clip;
  min-height: 100svh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
body.is-locked { overflow: hidden; height: 100svh; }
img { display: block; max-width: 100%; -webkit-user-drag: none; user-select: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
[hidden] { display: none !important; }
figure { margin-inline: 0; }

/* ============ paper, grain, light ============ */
.paper {
  position: fixed; inset: 0; z-index: -3; pointer-events: none;
  background: var(--paper) url(../img/e/paper.jpg) center / cover no-repeat;
}
.paper::after {
  content: ''; position: absolute; inset: 0;
  background: url(../img/e/paper_crumpled.jpg) center / cover no-repeat;
  mix-blend-mode: multiply; opacity: .42;
}
.grain {
  position: fixed; inset: -50%; z-index: 60; pointer-events: none;
  background-image: var(--noise);
  background-size: 180px 180px;
  opacity: .14; mix-blend-mode: multiply;
  animation: grain 1s steps(6) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); } 17% { transform: translate(-6%, 4%); }
  33% { transform: translate(5%, -7%); } 50% { transform: translate(-3%, 9%); }
  67% { transform: translate(8%, 2%); } 83% { transform: translate(-9%, -4%); }
  100% { transform: translate(0, 0); }
}
.vignette {
  position: fixed; inset: 0; z-index: 59; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(80, 40, 20, .22) 100%);
}

/* ============ story layout ============ */
.story { position: relative; width: 100%; max-width: 500px; margin: 0 auto; }
.thread { position: absolute; left: 0; top: 0; width: 100%; pointer-events: none; z-index: 0; overflow: visible; }
.thread path { fill: none; stroke: var(--red); stroke-width: 1.6; stroke-linecap: round; opacity: .75; }
.thread .knot { fill: var(--red); opacity: .8; }

.page {
  position: relative; z-index: 1;
  min-height: 100svh;
  padding: calc(env(safe-area-inset-top) + 64px) var(--gutter) calc(env(safe-area-inset-bottom) + 56px);
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
}
.page--center { justify-content: center; }
.pno {
  position: absolute; top: calc(env(safe-area-inset-top) + 22px); left: var(--gutter); right: var(--gutter);
  display: flex; justify-content: space-between;
  font: 11px/1 var(--f-mono); letter-spacing: .18em; text-transform: uppercase; color: var(--ink-faint);
}

/* ============ typography ============ */
.t-script { font-family: var(--f-script); font-weight: 400; color: var(--red); line-height: 1; }
.t-hand { font-family: var(--f-hand); color: var(--red); line-height: 1; }
.t-write { font-family: var(--f-write); color: var(--ink); line-height: 1.25; }
.t-caps { font-family: var(--f-caps); font-weight: 700; line-height: .95; letter-spacing: .02em; }
.t-serif { font-family: var(--f-serif); font-weight: 400; line-height: 1.18; }
.t-it { font-style: italic; font-weight: 300; }
.t-small {
  font-family: var(--f-serif); font-weight: 500; text-transform: uppercase;
  letter-spacing: .16em; font-size: 12.5px; line-height: 1.9; color: var(--ink-soft);
}
.t-mono { font-family: var(--f-mono); font-size: 12px; letter-spacing: .08em; color: var(--ink-soft); }
.red { color: var(--red); }
.s-xxl { font-size: clamp(84px, 27vw, 124px); }
.s-xl { font-size: clamp(60px, 18vw, 88px); }
.s-l { font-size: clamp(40px, 12vw, 58px); }
.s-m { font-size: clamp(28px, 8.4vw, 38px); }
.s-s { font-size: clamp(21px, 6vw, 26px); }

/* handwriting svg */
.write { display: block; margin: 0 auto; max-width: 100%; }
.write:not(.hw-ready) { visibility: hidden; }
.hw-svg { display: block; max-width: 100%; height: auto; overflow: visible; margin: 0 auto; }
.hw-g { fill: currentColor; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }

/* word reveal */
.words .w { display: inline-block; opacity: 0; transform: translateY(.45em); filter: blur(6px); }
.words.is-in .w { animation: wordIn .9s cubic-bezier(.2, .7, .1, 1) forwards; animation-delay: calc(var(--i) * 70ms + var(--d, 0ms)); }
@keyframes wordIn { to { opacity: 1; transform: none; filter: blur(0); } }

/* generic reveal */
[data-reveal] { opacity: 0; }
[data-reveal].is-in { opacity: 1; }
[data-reveal="fade"].is-in { animation: fadeUp 1.1s cubic-bezier(.2, .7, .1, 1) both; animation-delay: var(--d, 0ms); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(26px); filter: blur(5px); } to { opacity: 1; transform: none; filter: none; } }
[data-reveal="pop"].is-in { animation: pop .8s cubic-bezier(.3, 1.6, .5, 1) both; animation-delay: var(--d, 0ms); }
@keyframes pop { from { opacity: 0; transform: scale(.3) rotate(-14deg); } to { opacity: 1; transform: none; } }
[data-reveal="stamp"].is-in { animation: stamp .55s cubic-bezier(.2, .9, .3, 1.3) both; animation-delay: var(--d, 0ms); }
@keyframes stamp { 0% { opacity: 0; transform: scale(2.6) rotate(12deg); filter: blur(3px); } 70% { opacity: 1; transform: scale(.94) rotate(-3deg); filter: none; } 100% { opacity: 1; transform: none; } }

[data-reveal="nav"].is-in { animation: fadeUp 1s cubic-bezier(.2, .7, .1, 1) both; animation-delay: var(--d, 0ms); }
[data-reveal="fadein"].is-in { animation: fadeIn 1.2s ease both; animation-delay: var(--d, 0ms); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.fl[data-reveal="pop"].is-in { animation: none; }
.fl[data-reveal="pop"].is-in > img { animation: pop .9s cubic-bezier(.3, 1.6, .5, 1) both; animation-delay: var(--d, 0ms); }
.wiggle.is-in { animation: stamp .55s cubic-bezier(.2, .9, .3, 1.3) both, wig 1.8s 1.2s ease-in-out infinite; }
@keyframes wig { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-4deg) scale(1.04); } 40% { transform: rotate(3deg); } 60% { transform: rotate(-2deg); } }

/* ============ floating items, parallax + tilt ============ */
.fl {
  position: absolute; z-index: 2; pointer-events: none;
  transform: translate3d(calc(var(--tx) * var(--z, 1) * 9px), calc(var(--py, 0px) + var(--ty) * var(--z, 1) * 9px), 0) rotate(var(--r, 0deg));
  will-change: transform;
}
.fl img { width: 100%; }
.sticker img { filter: drop-shadow(0 6px 8px rgba(60, 25, 10, .18)); }

/* ============ polaroid ============ */
.pol {
  --r: 0deg;
  position: relative; display: inline-block;
  transform: translate3d(calc(var(--tx) * var(--z, 1.5) * 7px), calc(var(--py, 0px) + var(--ty) * var(--z, 1.5) * 7px), 0) rotate(var(--r));
  will-change: transform;
}
.pol__in {
  position: relative; background: #fbf7ef; padding: 10px 10px 46px;
  box-shadow: 0 1px 1px rgba(0,0,0,.08), 0 10px 22px -6px rgba(60, 30, 15, .35), 0 24px 40px -18px rgba(60, 30, 15, .35);
  background-image: linear-gradient(transparent, rgba(150, 120, 80, .06));
}
.pol__ph { position: relative; overflow: hidden; background: #1c1410; aspect-ratio: 4 / 5; }
.pol__ph img, .gif img { width: 100%; height: 100%; object-fit: cover; filter: var(--film); }
.pol__ph::after, .gif::after { /* vignette */
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(140% 100% at 50% 50%, transparent 55%, rgba(30, 10, 0, .38) 100%);
  mix-blend-mode: multiply;
}
.pol__ph::before, .gif::before { /* warm light leak */
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(120% 80% at 100% 0%, rgba(255, 120, 50, .3), transparent 45%);
  mix-blend-mode: screen;
}
.pol--bw .pol__ph img { filter: grayscale(1) contrast(1.14) brightness(1.03) blur(0px); }
.pol__cap {
  position: absolute; left: 0; right: 0; bottom: 7px;
  font-family: var(--f-hand); color: var(--ink); font-size: 30px; line-height: 1;
}
.pol__cap .write { height: 32px; }
.pol__cap .hw-svg { height: 32px; width: auto; }
.pol__in--2 { padding-bottom: 72px; }
.pol__cap--2 .write, .pol__cap--2 .hw-svg { height: 60px; }
.pol__cap--2 { bottom: 6px; }
.pol.is-drop .pol__in { animation: polDrop 1.15s cubic-bezier(.18, .7, .2, 1) both; animation-delay: var(--d, 0ms); }
@keyframes polDrop {
  0% { opacity: 0; transform: translate3d(0, -90px, 0) rotate(-16deg) scale(1.3); box-shadow: 0 60px 80px -20px rgba(60,30,15,.0); filter: blur(3px); }
  45% { opacity: 1; filter: none; }
  78% { transform: translate3d(0, 5px, 0) rotate(1.5deg) scale(.985); }
  100% { opacity: 1; transform: none; }
}
.pol:not(.is-drop) .pol__in { opacity: 0; }
.pol.is-drop .pol__ph img { animation: develop 3.2s ease-out both; animation-delay: calc(var(--d, 0ms) + 350ms); }
.pol--bw.is-drop .pol__ph img { animation-name: developBw; }
/* same functions in the same order on both ends, so the browser interpolates instead of snapping */
@keyframes develop { 0% { filter: contrast(.35) saturate(0) sepia(.4) brightness(2.6) blur(2px); } 100% { filter: contrast(1.06) saturate(.82) sepia(.16) brightness(1.02) blur(0px); } }
@keyframes developBw { 0% { filter: grayscale(1) contrast(.3) brightness(2.6) blur(2px); } 100% { filter: grayscale(1) contrast(1.14) brightness(1.03) blur(0px); } }

/* tape */
.tape {
  position: absolute; z-index: 3; width: 92px; height: 30px; left: 50%; top: -15px;
  transform: translateX(-50%) rotate(var(--tr, -4deg));
  background: url(../img/e/tape_beige.png) center / 100% 100% no-repeat; opacity: .92;
}
.tape--red { background-image: url(../img/e/tape_red.png); opacity: .85; }
.tape--l { left: 8px; transform: rotate(-38deg); top: -6px; }
.tape--r { left: auto; right: -14px; transform: rotate(40deg); top: 2px; }
.is-drop .tape { animation: tapeOn .5s cubic-bezier(.3, 1.4, .5, 1) both; animation-delay: calc(var(--d, 0ms) + 720ms); }
.pol:not(.is-drop) .tape { opacity: 0; }
@keyframes tapeOn { from { opacity: 0; scale: 1.5; } to { opacity: .92; scale: 1; } }

/* gif (stop-motion flipbook) */
.gif { position: relative; overflow: hidden; background: #1c1410; aspect-ratio: 4 / 5; }
.gif img { position: absolute; inset: 0; opacity: 0; }
.gif img.on { opacity: 1; }
.gif__tag {
  position: absolute; z-index: 2; left: 8px; top: 8px;
  font: 700 10px/1 var(--f-mono); letter-spacing: .14em; color: #fff;
  background: var(--red); padding: 4px 6px 3px; border-radius: 2px;
}
.gif__rec { position: absolute; z-index: 2; right: 9px; top: 9px; font: 10px/1 var(--f-mono); color: #fff; letter-spacing: .1em; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.gif__rec::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #ff3b30; margin-right: 5px; vertical-align: -1px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ============ doodles ============ */
.doodle { position: absolute; pointer-events: none; overflow: visible; z-index: 3; }
.doodle path, .doodle circle, .doodle line, .doodle ellipse { fill: none; stroke: var(--red); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.doodle.ink path { stroke: var(--ink); }
.doodle .fillr { fill: var(--red); stroke: none; }
/* hand-drawn wobble rendered once, then a cheap stop-motion jitter on the compositor */
.boil { filter: url(#boil0); will-change: transform; animation: boilJ .45s steps(1, end) infinite; }
@keyframes boilJ { 0% { translate: 0 0; rotate: 0deg; } 33% { translate: .6px -.5px; rotate: .5deg; } 66% { translate: -.5px .4px; rotate: -.4deg; } }
@media (prefers-reduced-motion: reduce) { .boil { animation: none; } }

/* ============ buttons ============ */
.nav { margin-top: auto; padding-top: 40px; display: flex; gap: 18px; justify-content: center; align-items: center; flex-wrap: wrap; position: relative; z-index: 5; }
.arrow {
  position: relative; width: 84px; height: 84px; display: grid; place-items: center;
  animation: bob 2.4s ease-in-out infinite;
}
.arrow svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.arrow svg path { fill: none; stroke: var(--red); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.arrow span { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 6px; white-space: nowrap; font: 11px var(--f-mono); letter-spacing: .2em; text-transform: uppercase; color: var(--ink-faint); }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(7px); } }
.arrow:active { scale: .92; }

.choice {
  position: relative; padding: 16px 30px 18px; min-width: 112px;
  font-family: var(--f-write); font-size: 25px; color: var(--ink); line-height: 1.1;
  transition: transform .2s;
}
.choice svg { position: absolute; inset: -8px -10px; width: calc(100% + 20px); height: calc(100% + 16px); overflow: visible; pointer-events: none; }
.choice svg path { fill: none; stroke: var(--red); stroke-width: 2.4; stroke-linecap: round; }
.choice:active { transform: scale(.95) rotate(-1deg); }
.choice.is-picked { color: var(--red); }
.choice.is-picked svg path { stroke-width: 3.6; }
.choice[disabled], .arrow[disabled] { pointer-events: none; }
.page.is-done .nav .choice:not(.is-picked), .page.is-done .nav .arrow { opacity: .35; animation: none; }

.runaway { position: relative; transition: transform .35s cubic-bezier(.3, 1.5, .5, 1); z-index: 6; white-space: nowrap; background: radial-gradient(closest-side, rgba(244, 234, 217, .95) 70%, rgba(244, 234, 217, 0)); }

/* ============ intro envelope ============ */
.intro {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 34px;
  background: var(--paper) url(../img/e/paper.jpg) center / cover no-repeat; perspective: 1200px;
}
.intro::before { content: ''; position: absolute; inset: 0; background: url(../img/e/paper_crumpled.jpg) center / cover; mix-blend-mode: multiply; opacity: .42; pointer-events: none; }
.intro.is-gone { pointer-events: none; }
.intro__hint { font: 13px var(--f-mono); letter-spacing: .14em; color: var(--ink-soft); }
.intro__tap { font: 11px var(--f-mono); letter-spacing: .22em; text-transform: uppercase; color: var(--ink-faint); animation: blink 2s ease-in-out infinite; }
.env { position: relative; width: min(78vw, 330px); aspect-ratio: 1.42; }
.env__back { position: absolute; inset: 0; background: linear-gradient(160deg, #8e1717, #6b0f0f); border-radius: 4px; box-shadow: 0 30px 50px -18px rgba(70, 15, 10, .55), 0 10px 18px -8px rgba(70,15,10,.4); }
.env__letter {
  position: absolute; left: 7%; right: 7%; top: 8%; height: 86%;
  background: #fbf6ec url(../img/e/paper.jpg) center / cover; border-radius: 2px;
  display: grid; place-items: center; padding: 10px; box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.env__letter .t-script { font-size: 44px; }
.env__front { position: absolute; inset: 0; z-index: 3; filter: drop-shadow(0 -1px 2px rgba(60, 8, 8, .3)); }
.env__front::before, .env__front::after { content: ''; position: absolute; inset: 0; }
.env__front::before { background: linear-gradient(100deg, #9a1b1b, #a52020); clip-path: polygon(0 0, 53% 54%, 0 100%); border-radius: 4px; }
.env__front::after { background: linear-gradient(260deg, #941a1a, #a52020); clip-path: polygon(100% 0, 47% 54%, 100% 100%); border-radius: 4px; }
.env__bottom { position: absolute; inset: 0; z-index: 3; background: linear-gradient(175deg, #b22525, #8a1717); clip-path: polygon(0 100%, 50% 44%, 100% 100%); filter: drop-shadow(0 -2px 3px rgba(60, 8, 8, .35)); border-radius: 4px; }
.env__flap {
  position: absolute; left: 0; right: 0; top: 0; height: 60%; z-index: 4;
  transform-origin: 50% 0;
  background: linear-gradient(180deg, #a61f1f, #841414);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  filter: drop-shadow(0 3px 3px rgba(40, 5, 5, .3));
}
.env__seal {
  position: absolute; z-index: 6; left: 50%; top: 60%; width: 32%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 6px 8px rgba(40, 5, 5, .45));
  animation: sealPulse 2.2s ease-in-out infinite;
}
.env__seal img { width: 100%; height: 100%; }
@keyframes sealPulse { 0%, 100% { transform: translate(-50%, -50%) scale(1); } 50% { transform: translate(-50%, -50%) scale(1.06); } }

/* ============ page specifics ============ */
.p1-title { margin-top: 6px; }
.p1-photo { margin: 78px 0 34px; width: 66%; }
.heart-wrap { position: relative; display: inline-block; }
.heart-wrap .doodle { top: -18%; left: -20%; width: 140%; height: 97%; } /* ~square box → classic heart proportions; cusp sits above the photo */
.underline { position: relative; display: inline-block; }
.underline .doodle { left: -6%; bottom: -14px; width: 112%; height: 24px; }

.p2-q { margin-top: 12vh; }

.contract {
  position: relative; margin: 30px auto 0; width: 100%; max-width: 360px; padding: 34px 26px 40px;
  background: url(../img/e/torn_paper_strip.png) center / 100% 100% no-repeat;
}

.grid-smiles { position: relative; width: calc(100% + 10px); margin-top: 30px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.grid-smiles .pol { width: 100%; }
.grid-smiles .pol:nth-child(even) { margin-top: 64px; margin-bottom: -40px; }
.grid-smiles .pol:nth-child(4n+1) { --r: -4deg; }
.grid-smiles .pol:nth-child(4n+2) { --r: 3.5deg; }
.grid-smiles .pol:nth-child(4n+3) { --r: 2deg; }
.grid-smiles .pol:nth-child(4n) { --r: -2.5deg; }
.grid-smiles .pol__in { padding: 7px 7px 34px; }
.grid-smiles .pol__cap { font-size: 24px; bottom: 5px; }
.grid-smiles .pol__cap .hw-svg { height: 25px; }

.lines > * { margin: 0 0 18px; }
.zipper { position: relative; width: 74%; margin: 26px auto 10px; }
.zipper .doodle { width: 100%; height: 100%; inset: 0; }

.vibes { position: relative; width: 100%; margin-top: 36px; columns: 2; column-gap: 14px; }
.vibes > * { break-inside: avoid; margin-bottom: 18px; }
.vibes .pol { width: 100%; }
.vibes .pol__in { padding: 6px 6px 22px; }
.vibes .tall .pol__ph, .vibes .tall.gif { aspect-ratio: 3 / 4.4; }

.note {
  position: relative; margin: 34px 0 0; width: 104%; max-width: 420px; padding: 44px 30px 46px;
  background: url(../img/e/torn_paper_strip.png) center / 100% 100% no-repeat;
  font-family: var(--f-mono); font-size: 14px; line-height: 1.7; color: var(--ink); text-align: left;
  filter: drop-shadow(0 8px 12px rgba(70, 35, 15, .18));
}
.type .ch { opacity: 0; }
.type .ch.on { opacity: 1; }
.type .caret { display: inline-block; width: .55em; height: 1.1em; background: var(--red); vertical-align: -.2em; animation: blink 1s steps(2) infinite; }

/* hands page */
.p7 { padding: 0; min-height: 0; height: 280svh; display: block; }
.p7__stick { position: sticky; top: 0; height: 100svh; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 var(--gutter); }
.hand { position: absolute; top: 50%; width: 92%; max-width: 470px; pointer-events: none; }
.hand--l { right: 50%; transform: translate3d(calc(var(--hp, 0) * 1px), -50%, 0); }
.hand--r { left: 50%; transform: translate3d(calc(var(--hp, 0) * -1px), -50%, 0); }
.p7 .p7-t { position: absolute; left: var(--gutter); right: var(--gutter); }
.p7-t1 { top: 11%; } .p7-t2 { top: 26%; } .p7-t3 { bottom: 19%; }
.spark { position: absolute; left: 50%; top: 50%; width: 120px; height: 120px; margin: -60px 0 0 -60px; pointer-events: none; opacity: 0; }
.spark.on { animation: spark 1.4s ease-out forwards; }
@keyframes spark { 0% { opacity: 0; transform: scale(.2); } 25% { opacity: 1; } 100% { opacity: 0; transform: scale(2.4); } }
.p7 .nav { position: absolute; bottom: calc(env(safe-area-inset-bottom) + 40px); left: 0; right: 0; opacity: 0; transition: opacity .6s; pointer-events: none; }
.p7.is-met .nav { opacity: 1; pointer-events: auto; }

/* film strip */
.film {
  position: relative; width: calc(100% + var(--gutter) * 2); margin: 26px calc(var(--gutter) * -1) 6px; overflow: hidden;
  background: #17110d; padding: 22px 0; transform: rotate(-3deg);
  box-shadow: 0 14px 26px -12px rgba(30, 10, 0, .5);
}
.film::before, .film::after {
  content: ''; position: absolute; left: 0; right: 0; height: 12px;
  background: repeating-linear-gradient(90deg, transparent 0 9px, #efe3cf 9px 19px, transparent 19px 28px);
  -webkit-mask: linear-gradient(#000 0 0); opacity: .9;
}
.film::before { top: 5px; } .film::after { bottom: 5px; }
.film__track { display: flex; gap: 10px; width: max-content; animation: filmRun 26s linear infinite; }
.film__f { width: 132px; aspect-ratio: 4 / 5; background: #2a201a; overflow: hidden; position: relative; flex: none; }
.film__f img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 18%; filter: var(--film); }
.film__f--ph { display: grid; place-items: center; color: #d9c9ae; font: 11px/1.3 var(--f-mono); letter-spacing: .1em; text-align: center; padding: 10px; }
@keyframes filmRun { to { transform: translateX(-50%); } }

.rows { width: 100%; margin-top: 18px; text-align: left; }
.row { position: relative; padding: 16px 0; border-bottom: 1px dashed rgba(90, 60, 40, .3); }
.row p { margin: 0; }
.row__n { display: block; font: 11px var(--f-mono); color: var(--red); letter-spacing: .12em; margin-bottom: 6px; }
.row--ph { display: grid; grid-template-columns: 1fr 44%; gap: 16px; align-items: center; }
.row--l { grid-template-columns: 44% 1fr; }
.row--l > div { order: 2; }
.row .pol { width: 100%; }
.row .pol__in { padding: 6px 6px 18px; }
.credits { width: 100%; text-align: left; margin-top: 24px; }
.credits li { list-style: none; position: relative; padding: 12px 0 12px 34px; border-bottom: 1px dashed rgba(90, 60, 40, .3); }
.credits li::before { content: attr(data-n); position: absolute; left: 0; top: 15px; font: 11px var(--f-mono); color: var(--red); letter-spacing: .1em; }
.credits ul { padding: 0; margin: 0; }

.icons { display: flex; justify-content: center; gap: 22px; margin: 26px 0 4px; }
.icons svg { width: 74px; height: 74px; overflow: visible; }
.icons path, .icons circle { fill: none; stroke: var(--red); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

/* finale */
.ticket {
  position: relative; margin: 30px auto 0; width: 100%; max-width: 360px; display: flex;
  filter: drop-shadow(0 16px 20px rgba(80, 20, 10, .3));
}
.ticket__main, .ticket__stub { background: #f8efe0; position: relative; }
.ticket__main { flex: 1; padding: 22px 18px 20px 22px; text-align: left; border-radius: 10px 0 0 10px; border-left: 6px solid var(--red); }
.ticket p { white-space: nowrap; }
.ticket__stub { width: 56px; padding: 20px 8px; border-radius: 0 10px 10px 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; border-left: 2px dashed rgba(110, 60, 40, .45); }
.ticket__stub b { font: 700 13px var(--f-mono); writing-mode: vertical-rl; transform: rotate(180deg); letter-spacing: .3em; color: var(--red); }
.ticket h3 { margin: 0 0 6px; font: 700 34px/1 var(--f-caps); letter-spacing: .04em; color: var(--red); }
.ticket p { margin: 2px 0; font: 12.5px/1.6 var(--f-mono); color: var(--ink); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 55; overflow: hidden; }
.confetti i { position: absolute; top: -40px; width: 18px; height: 16px; background: var(--red); clip-path: path('M9 15 C2 10 0 7 0 4.5 C0 2 2 0 4.5 0 C6.5 0 8 1.2 9 3 C10 1.2 11.5 0 13.5 0 C16 0 18 2 18 4.5 C18 7 16 10 9 15 Z'); }

/* tap ink hearts */
.ink { position: fixed; z-index: 58; width: 26px; height: 24px; margin: -12px 0 0 -13px; pointer-events: none; color: var(--red); animation: ink 1.1s ease-out forwards; }
@keyframes ink { 0% { opacity: .9; transform: scale(.3) rotate(var(--ir)); } 30% { opacity: .9; transform: scale(1.1) rotate(var(--ir)); } 100% { opacity: 0; transform: translateY(-40px) scale(.8) rotate(var(--ir)); } }

@media (min-width: 700px) {
  .story { box-shadow: 0 0 0 1px rgba(120, 80, 50, .08); }
}
@media (prefers-reduced-motion: reduce) {
  .grain, .arrow, .film__track, .env__seal { animation: none !important; }
}

/* page 8: the dance — two overlapping polaroids */
.dance { position: relative; width: 100%; display: grid; grid-template-columns: 1fr 1fr; margin-top: 30px; padding: 0 4px; }
.dance .pol { width: 112%; }
.dance .pol:first-child { justify-self: start; z-index: 1; }
.dance .pol:nth-child(2) { justify-self: end; margin-top: 56px; z-index: 2; }
.dance .pol__in { padding: 7px 7px 34px; }
.dance .pol__cap { font-size: 24px; bottom: 5px; }
.dance .pol__cap .write, .dance .pol__cap .hw-svg { height: 25px; }

/* page 9: the invitation as a postcard */
.invite { position: relative; width: 100%; max-width: 360px; margin: 38px auto 0; perspective: 1100px; }
.invite__in {
  position: relative; padding: 100px 26px 46px; text-align: center; border-radius: 4px;
  background: #fbf4e6 url(../img/e/paper.jpg) center / cover;
  transform: rotate(-1.6deg); transform-origin: 50% 100%;
  box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 14px 26px -10px rgba(80, 30, 10, .4), 0 34px 50px -24px rgba(80, 30, 10, .35);
}
.invite__in::before { /* double red frame */
  content: ''; position: absolute; inset: 11px; border: 1.5px solid var(--red);
  outline: 1px solid rgba(158, 27, 27, .45); outline-offset: 4px; pointer-events: none; border-radius: 2px;
}
.invite__in::after { /* soft paper sheen */
  content: ''; position: absolute; inset: 0; pointer-events: none; border-radius: 4px;
  background: linear-gradient(115deg, rgba(255,255,255,.35), transparent 40%, transparent 70%, rgba(120,70,30,.08));
}
[data-reveal="invite"] { opacity: 1; }
[data-reveal="invite"] .invite__in { opacity: 0; }
[data-reveal="invite"].is-in .invite__in { animation: inviteIn 1.3s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes inviteIn {
  0% { opacity: 0; transform: translateY(70px) rotateX(62deg) rotate(5deg) scale(.9); }
  60% { opacity: 1; }
  100% { opacity: 1; transform: rotate(-1.6deg); }
}
.invite__stamp { position: absolute; z-index: 2; right: 20px; top: 20px; width: 56px; transform: rotate(7deg); filter: drop-shadow(0 2px 2px rgba(60, 25, 10, .25)); }
.invite__postmark { position: absolute; z-index: 3; right: 40px; top: 30px; width: 104px; transform: rotate(-14deg); opacity: .6; overflow: visible; }
.invite__postmark circle, .invite__postmark path { fill: none; stroke: #6b2a1e; stroke-width: 2; }
.invite__postmark text { fill: #6b2a1e; font: 700 12px var(--f-mono); letter-spacing: .08em; }
.invite__kicker {
  display: flex; align-items: center; justify-content: center; gap: 10px; margin: 6px 0 0;
  font: 600 13px var(--f-serif); letter-spacing: .34em; text-transform: uppercase; color: var(--red);
}
.invite__kicker span { width: 28px; height: 1px; background: var(--red); opacity: .6; }
.invite__sub { margin: 6px 0 18px; font: italic 300 19px var(--f-serif); color: var(--ink-soft); }
.invite__text { color: var(--red); font-size: clamp(25px, 7.4vw, 31px); }
.invite__icons { margin: 18px 0 2px; gap: 18px; }
.invite__icons svg { width: 58px; height: 58px; }
.invite__labels { display: flex; justify-content: center; gap: 18px; font: 11px var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); }
.invite__labels span { width: 58px; }
.invite__to { display: flex; align-items: flex-end; gap: 10px; margin: 16px 8px 0; border-bottom: 1px dashed rgba(90, 60, 40, .45); padding-bottom: 2px; text-align: left; }
.invite__to:first-of-type { margin-top: 22px; }
.invite__to span { font: 11px var(--f-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-faint); padding-bottom: 6px; min-width: 40px; }
.invite__to b { font-family: var(--f-hand); font-weight: 400; font-size: 30px; color: var(--ink); line-height: 1; margin: 0; }
.invite__to b .hw-svg { height: 32px; width: auto; margin: 0; }
.invite__seal { position: absolute; z-index: 3; left: 50%; bottom: -30px; width: 66px; transform: translateX(-50%) rotate(-8deg); filter: drop-shadow(0 6px 8px rgba(60, 10, 5, .4)); }

/* ============ intro v2: trace the heart → seal cracks → pull the letter ============ */
.intro__hint { text-align: center; }
.intro__sound { display: block; margin-top: 8px; font: 12px var(--f-mono); letter-spacing: .12em; color: var(--red); }
.env__seal { pointer-events: none; }
.seal__half { position: absolute; inset: 0; background: url(../img/e/wax_seal.png) center / contain no-repeat; }
.seal__half--l { clip-path: polygon(0 0, 52% 0, 46% 22%, 55% 40%, 45% 58%, 54% 78%, 48% 100%, 0 100%); }
.seal__half--r { clip-path: polygon(52% 0, 100% 0, 100% 100%, 48% 100%, 54% 78%, 45% 58%, 55% 40%, 46% 22%); }
.env__trace {
  position: absolute; z-index: 7; left: 50%; top: 58%; width: 80%;
  transform: translate(-50%, -54%); overflow: visible; touch-action: none; cursor: crosshair;
}
.trace__hit { fill: transparent; }
.trace__guide { fill: none; stroke: rgba(255, 243, 222, .92); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 1 9; animation: march 1.2s linear infinite; }
@keyframes march { to { stroke-dashoffset: -20; } }
.trace__ink { fill: none; stroke: #fff4df; stroke-width: 6.5; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 5px rgba(255, 214, 160, .95)); }
.trace__start { fill: #fff4df; transform-box: fill-box; transform-origin: center; animation: startPulse 1.3s ease-in-out infinite; }
@keyframes startPulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.6); opacity: .55; } }
.trace__finger circle { fill: rgba(255, 244, 223, .28); stroke: rgba(255, 244, 223, .9); stroke-width: 2; }
.trace__finger { opacity: 0; pointer-events: none; }
.env__trace.is-done .trace__guide, .env__trace.is-done .trace__start { opacity: 0; transition: opacity .3s; }
.env__letter { touch-action: none; cursor: grab; transition: box-shadow .2s; }
.env__letter.is-drag { cursor: grabbing; box-shadow: 0 10px 24px rgba(60, 20, 10, .3); }
.letter__pull {
  position: absolute; left: 0; right: 0; top: 8px; text-align: center;
  font: 10px var(--f-mono); letter-spacing: .18em; text-transform: uppercase; color: var(--red);
  opacity: 0; transition: opacity .4s;
}
.env__letter.is-peek .letter__pull { opacity: 1; animation: bob 1.6s ease-in-out infinite; }
.intro__tap { transition: opacity .4s; }

/* sound toggle: a tiny spinning record */
.sound {
  position: fixed; z-index: 62; left: 14px; bottom: calc(env(safe-area-inset-bottom) + 14px);
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(248, 239, 224, .9); border: 1px solid rgba(158, 27, 27, .35);
  box-shadow: 0 6px 14px -6px rgba(70, 30, 10, .45); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.sound__disc {
  width: 30px; height: 30px; border-radius: 50%;
  background: radial-gradient(circle, var(--paper-hi) 0 9%, var(--red) 10% 30%, #1d1512 31% 100%);
  box-shadow: inset 0 0 0 4px #2a201b, inset 0 0 0 5px #3a2e28, inset 0 0 0 9px #1d1512, inset 0 0 0 10px #33282263;
}
.sound.is-on .sound__disc { animation: spin 2.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sound__bars { position: absolute; right: 6px; bottom: 7px; display: flex; gap: 1.5px; align-items: flex-end; height: 10px; }
.sound__bars i { width: 2px; height: 3px; background: var(--red); border-radius: 1px; }
.sound.is-on .sound__bars i { animation: eq .8s ease-in-out infinite; }
.sound.is-on .sound__bars i:nth-child(2) { animation-delay: .2s; }
.sound.is-on .sound__bars i:nth-child(3) { animation-delay: .4s; }
@keyframes eq { 0%, 100% { height: 3px; } 50% { height: 10px; } }
.sound:not(.is-on)::after { content: ''; position: absolute; width: 34px; height: 2px; background: var(--red); transform: rotate(-45deg); border-radius: 2px; }

/* ============ "Распишись": drawing card ============ */
.sign { width: 100%; max-width: 360px; margin: 26px auto 0; }
.sign__card {
  position: relative; width: 100%; aspect-ratio: 3 / 2; border-radius: 4px; overflow: hidden;
  background: #fbf5ea url(../img/e/paper.jpg) center / cover;
  box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 12px 24px -10px rgba(80, 30, 10, .4);
  transform: rotate(-1deg);
}
.sign__card::before { content: ''; position: absolute; inset: 9px; border: 1px dashed rgba(158, 27, 27, .35); border-radius: 2px; pointer-events: none; }
.sign__canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; z-index: 2; }
.sign__line { position: absolute; left: 22px; right: 22px; bottom: 26%; border-bottom: 1.5px solid rgba(90, 60, 40, .45); pointer-events: none; z-index: 1; }
.sign__line b { position: absolute; left: 0; bottom: 2px; font: 600 20px var(--f-serif); color: rgba(158, 27, 27, .6); }
.sign__line span { position: absolute; right: 0; top: 6px; font: 10px var(--f-mono); letter-spacing: .2em; text-transform: uppercase; color: var(--ink-faint); }
.sign__empty { position: absolute; left: 0; right: 0; top: 30%; margin: 0; text-align: center; font: italic 300 18px var(--f-serif); color: rgba(90, 60, 40, .45); pointer-events: none; transition: opacity .3s; z-index: 1; }
.sign__tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.sign__colors { display: flex; gap: 9px; }
.sw {
  width: 28px; height: 28px; border-radius: 50%; position: relative;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.35), transparent 45%), var(--c);
  box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .2s;
}
.sw.is-on { transform: scale(1.12); box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px var(--c); }
.sign__hist { display: flex; gap: 6px; align-items: center; }
.tool { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; border: 1px solid rgba(90, 60, 40, .3); background: rgba(251, 245, 234, .7); }
.tool svg { width: 20px; height: 20px; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tool--txt { width: auto; padding: 0 12px; border-radius: 19px; font: 11px var(--f-mono); letter-spacing: .1em; color: var(--ink); }
.tool:disabled { opacity: .35; }
.tool:active:not(:disabled) { transform: scale(.92); }

/* signature on the ticket */
.ticket__sign { display: flex; align-items: flex-end; gap: 8px; margin-top: 8px; padding-top: 6px; border-top: 1px dashed rgba(110, 60, 40, .35); }
.ticket__sign span { font: 12.5px var(--f-mono); color: var(--ink); padding-bottom: 6px; }
.ticket__sign img { max-height: 62px; max-width: 160px; object-fit: contain; filter: contrast(1.6) saturate(1.15); }
/* 8-colour palette: full-width row, history tools below */
.sign__tools { flex-direction: column; align-items: stretch; gap: 12px; }
.sign__colors { justify-content: space-between; gap: 0; }
.sw { width: 30px; height: 30px; }
.sign__hist { justify-content: center; }
.sign__label { margin: 10px 0 0; text-align: center; font: 11px var(--f-mono); letter-spacing: .24em; text-transform: uppercase; color: var(--ink-faint); }
.sign__empty { top: 42%; }
