:root {
  --bg: #F1ECE3;
  --paper: #FBF8F2;
  --ink: #1A1816;
  --ink-2: #3C3833;
  --wet: #2E3F86;
  --muted: #8F877B;
  --line: #D9D1C3;
  --rule: #DCE3EA;
  --accent: #EC4A26;

  --sans: "Inter Tight", system-ui, -apple-system, sans-serif;
  --mono: "Courier Prime", ui-monospace, monospace;
  --hand: "Reenie Beanie", cursive;

  --ease: cubic-bezier(.16, 1, .3, 1);
  --ease-io: cubic-bezier(.76, 0, .24, 1);
}

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

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.mono {
  font-family: var(--mono);
  font-size: .74rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.display {
  font-weight: 500;
  font-size: clamp(2.3rem, 10vw, 3.8rem);
  line-height: 1;
  letter-spacing: -.045em;
}
.display.small { font-size: clamp(1.8rem, 8vw, 2.8rem); }
.display.huge  { font-size: clamp(3.2rem, 15vw, 5.5rem); line-height: .92; }
.display.accent { color: var(--accent); }
.lead {
  font-size: clamp(1.2rem, 5vw, 1.5rem);
  line-height: 1.35;
  letter-spacing: -.015em;
  color: var(--ink-2);
}
.lead.strong { color: var(--ink); font-weight: 500; }
.tag { margin-bottom: .4rem; }
.aside { color: var(--muted); }

.gate {
  position: relative;
  min-height: 100svh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: max(28px, env(safe-area-inset-top)) 24px calc(120px + env(safe-area-inset-bottom));
  text-align: center;
}
.gate-mid { display: flex; flex-direction: column; align-items: center; gap: 1.1rem; will-change: transform, opacity; }
.gate-name {
  font-weight: 600;
  font-size: clamp(3.8rem, 20vw, 8.5rem);
  letter-spacing: -.06em;
  line-height: .9;
  overflow: hidden;
  padding: 0 .04em .08em;
}
.gate-line { display: inline-block; animation: up 1.4s var(--ease) .2s both; }
.gate-note {
  font-size: clamp(1.8rem, 7vw, 2.6rem); line-height: 1.1; white-space: nowrap;
  rotate: -3deg;
  animation: fade 1.4s var(--ease) 1.1s both;
}
@keyframes up   { from { transform: translateY(105%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.scroll-cue {
  position: absolute; left: 50%; bottom: max(28px, env(safe-area-inset-bottom)); translate: -50% 0;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  transition: opacity .6s var(--ease);
}
.scroll-cue > * { animation: fade 1.4s var(--ease) 1.6s both; }
.scroll-line { position: relative; display: block; width: 1px; height: 56px; background: var(--line); overflow: hidden; }
.scroll-line b {
  position: absolute; left: 0; top: 0; width: 1px; height: 18px; background: var(--ink);
  animation: drip 1.9s var(--ease) infinite;
}
@keyframes drip {
  from { transform: translateY(-18px); }
  to   { transform: translateY(56px); }
}
body.ready .scroll-cue { opacity: 0; }

.scene { position: relative; height: calc(var(--len) * 1svh); }
.stage {
  position: sticky; top: 0;
  height: 100svh;
  max-width: 560px; margin: 0 auto;
  padding: 76px 24px 40px;
  display: flex; flex-direction: column; justify-content: center;
  gap: 1.1rem;
  overflow: hidden;
}

[data-at]:not(.flag) {
  opacity: 0;
  transform: translateY(1.1rem);
  transition: opacity .9s var(--ease), transform .9s var(--ease), filter .9s var(--ease);
}
[data-at].on:not(.flag) { opacity: 1; transform: none; }

.display[data-at] { clip-path: inset(-10% -5% 100% -5%); transform: translateY(40%); transition: clip-path 1.1s var(--ease), transform 1.1s var(--ease), opacity .6s; }
.display[data-at].on { clip-path: inset(-10% -5% -15% -5%); }

.strike { position: relative; white-space: nowrap; transition: color .8s var(--ease) .3s; }
.strike::after {
  content: ""; position: absolute; left: -.06em; right: -.06em; top: 50%; height: .06em;
  background: var(--accent); border-radius: 1em;
  transform: scaleX(0) rotate(-4deg); transform-origin: left;
  transition: transform .7s var(--ease);
}
.strike.on { color: var(--muted); }
.strike.on::after { transform: scaleX(1) rotate(-4deg); }
.hint { margin-top: 1.5rem; }
.arrow { display: inline-block; animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(4px); } }

body::after {
  content: ""; position: fixed; inset: 0; z-index: 100; pointer-events: none;
  background-image: 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='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .3 0 0 0 0 .25 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: .45; mix-blend-mode: multiply;
}

.hand {
  font-family: var(--hand);
  font-size: 1.75rem; line-height: 1.05;
  color: var(--ink);
  letter-spacing: .01em;
}
.hand.hint { margin-top: 1.4rem; rotate: -2deg; }


.tape {
  position: absolute; top: -13px; left: 50%; z-index: 2;
  width: 96px; height: 26px;
  translate: -50% 0; rotate: -4deg;
  background: rgba(236, 226, 196, .72);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
  -webkit-mask-image: linear-gradient(90deg, transparent 0 2px, #000 2px calc(100% - 2px), transparent 0);
}

.letter { position: relative; z-index: 3; margin-top: -24svh; padding: 0 10px; }
.paper {
  position: relative;
  max-width: 560px; margin: 0 auto;
  padding: 30px 22px 44px 50px;
  background: var(--paper);
  box-shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 18px 40px -18px rgba(60, 40, 20, .25);
  rotate: -.4deg;
}
.paper::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 36px; width: 1px;
  background: var(--accent); opacity: .35;
}
.fold {
  position: absolute; left: 0; right: 0; height: 18px; translate: 0 -50%;
  background: linear-gradient(180deg, transparent, rgba(80, 60, 30, .05) 48%, rgba(255, 255, 255, .7) 52%, transparent);
  pointer-events: none;
}
.paper-hello { font-size: 2.6rem; color: var(--ink); margin-bottom: .8rem; }
.paper-body {
  font-family: var(--hand);
  font-size: 1.6rem; line-height: 36px; color: var(--ink);
  background-image: linear-gradient(transparent 28px, var(--rule) 28px, var(--rule) 29px, transparent 29px);
  background-size: 100% 36px;
}
.paper-body p + p { margin-top: 36px; text-indent: 1.2em; }
.paper-body p:first-child { text-indent: 1.2em; }
.scratch {
  text-decoration: none; position: relative; color: var(--muted);
}
.scratch::after {
  content: ""; position: absolute; left: -2px; right: -2px; top: 48%; height: 2px;
  background: var(--ink); border-radius: 2px; rotate: -3deg;
}
.paper-sign { margin-top: 2.6rem; display: flex; justify-content: center; }
.paper-sign .hand { font-size: 2.4rem; color: var(--ink); text-align: center; }
.sign-name { position: relative; display: inline-block; }
.paper-sign svg {
  position: absolute; left: 0; top: 100%;
  width: 100%; height: 12px; margin-top: -2px;
  overflow: visible; pointer-events: none;
}
.paper-sign path {
  fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 100; stroke-dashoffset: 100;
  transition: stroke-dashoffset 1.4s var(--ease) .8s;
}
.paper-sign.inked path { stroke-dashoffset: 0; }
.paper-ps { margin-top: 2rem; font-size: 1.6rem; rotate: -1.5deg; }

[data-ink] {
  opacity: 0; filter: blur(3px); transform: translateY(8px);
  transition: opacity 1.2s var(--ease), filter 1.2s var(--ease), transform 1.2s var(--ease);
}
.paper-body [data-ink] { color: var(--wet); transition: opacity 1.2s var(--ease), filter 1.2s var(--ease), transform 1.2s var(--ease), color 2.6s ease .6s; }
[data-ink].inked { opacity: 1; filter: none; transform: none; }
.paper-body [data-ink].inked { color: var(--ink); }

.music {
  max-width: 560px; margin: 0 auto;
  padding: 72px 24px 0;
  display: flex; flex-direction: column; justify-content: center; gap: 1rem;
}
.music-note { font-size: 2.2rem; rotate: -2deg; }
.taped { position: relative; padding: 18px; background: var(--paper); box-shadow: 0 14px 30px -16px rgba(60, 40, 20, .3); }

.lyrics {
  --size: min(34vw, 140px);
  margin: 1.4rem 0 calc(var(--size) * .55);
  padding: 26px 22px 22px;
  rotate: .8deg;
}
.lyrics .tape { left: 50%; }
.album {
  position: absolute; z-index: 3;
  right: 4px; bottom: calc(var(--size) * -.28 - 22px);
  width: var(--size); height: var(--size);
  rotate: 6deg;
}
.sleeve {
  position: absolute; inset: 0; z-index: 1;
  background: #ddd; overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .1), 0 16px 30px -12px rgba(60, 40, 20, .5);
}
.sleeve img { width: 100%; height: 100%; object-fit: cover; display: block; }
.record {
  position: absolute; top: 4%; left: 4%;
  width: 92%; aspect-ratio: 1; border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .12), transparent 40%),
    repeating-radial-gradient(circle, #1d1b19 0 2px, #2a2724 2px 3px);
  transition: translate 1.6s var(--ease) .6s;
}
.record i { position: absolute; inset: 34%; border-radius: 50%; background: var(--accent); }
.record i::after { content: ""; position: absolute; inset: 42%; border-radius: 50%; background: var(--bg); }
.io.on .record { translate: 40% 0; animation: spin 4s linear 1.6s infinite; }
@keyframes spin { to { rotate: 360deg; } }

.track-row {
  position: relative;
  min-height: calc(var(--size) * .72);
  margin-top: 1.4rem;
  display: flex; align-items: flex-end;
}
.track { display: flex; flex-direction: column; gap: 4px; padding-right: calc(var(--size) + 18px); }
.track-title { font-weight: 500; font-size: 1.2rem; letter-spacing: -.03em; line-height: 1.05; white-space: nowrap; }

.lyric-lines { display: flex; flex-direction: column; gap: .35rem; }
.lyric {
  font-family: var(--hand); font-size: 1.65rem; line-height: 1.1; color: var(--ink);
  clip-path: inset(-20% 100% -20% 0);
  transition: clip-path 1.3s cubic-bezier(.45, 0, .2, 1) var(--d, 0s);
}
.lyrics.on .lyric { clip-path: inset(-20% -5% -20% 0); }

.io .rv { opacity: 0; transform: translateY(1.2rem); transition: opacity 1s var(--ease) var(--d, 0s), transform 1s var(--ease) var(--d, 0s); }
.io.on .rv { opacity: 1; transform: none; }
.io.on .lyrics.rv { transform: none; }

.photos {
  max-width: 560px; margin: 0 auto;
  padding: 56px 24px 0;
  display: flex; flex-direction: column; align-items: center; gap: 64px;
}
.photo {
  position: relative;
  width: min(80vw, 340px);
  padding: 12px 12px 0;
  background: #FFFDF9;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .05), 0 22px 40px -18px rgba(60, 40, 20, .4);
  opacity: 0;
  transform: translateY(40px) rotate(calc(var(--r) + 4deg));
  transition: transform 1.3s var(--ease), opacity 1s var(--ease);
}
.photo.on { opacity: 1; transform: rotate(var(--r)); }
.photo-img { position: relative; background: #ECE6DA; }
.photo-img img { display: block; width: 100%; height: auto; }
.photo figcaption {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 12px 6px 14px; text-align: center;
}
.cap { font-size: 1.7rem; line-height: 1.05; }
.cap:empty { display: none; }
.cap-date { font-size: .62rem; letter-spacing: .12em; color: var(--muted); opacity: .8; }

.love {
  min-height: 80svh;
  display: grid; place-items: center;
  padding: 12vh 24px 20vh;
}
.love-line {
  font-weight: 500;
  font-size: clamp(2.6rem, 12vw, 4rem);
  letter-spacing: -.045em;
  line-height: 1;
  white-space: nowrap;
}
.love .caret {
  display: inline-block; width: 2px; height: .85em; margin-left: 4px;
  background: var(--ink); vertical-align: -.08em;
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

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