:root {
  --bg: #fff6da;
  --bg-2: #fdedb8;
  --ink: #1b2a6b;
  --muted: #5b6a99;
  --blue: #2e5bff;
  --sun: #ffc72c;
  --paper: #ffffff;
  --line: rgba(27, 42, 107, .14);
  --shadow: rgba(27, 42, 107, .18);
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "Geist", system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, monospace;
  --pad: 20px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; overflow-x: clip; }
main, #intro, .glow, .grain-wrap { overflow: clip; }
html.lenis, html.lenis body { height: auto; }
body {
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 300;
  line-height: 1.5;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}
body.locked { overflow: hidden; height: 100svh; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
em { font-style: italic; }
.mono { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Film grain + slow sun and sky glow behind everything. */
.grain-wrap { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.grain {
  position: absolute; inset: -50%; opacity: .05;
  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");
  animation: grain 1.2s steps(6) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); } 20% { transform: translate(-3%, 2%); } 40% { transform: translate(2%, -4%); }
  60% { transform: translate(-4%, -2%); } 80% { transform: translate(3%, 3%); } 100% { transform: translate(0, 0); }
}
.glow { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.glow i {
  position: absolute; width: 70vmax; height: 70vmax; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 199, 44, .45), transparent 62%);
  animation: drift 26s ease-in-out infinite alternate;
}
.glow i:nth-child(1) { left: -30vmax; top: -20vmax; }
.glow i:nth-child(2) { right: -35vmax; top: 30vh; background: radial-gradient(circle, rgba(46, 91, 255, .16), transparent 60%); animation-duration: 32s; }
.glow i:nth-child(3) { left: -10vmax; bottom: -40vmax; animation-duration: 38s; }
@keyframes drift { to { transform: translate(12vmax, 8vmax) scale(1.15); } }

/* ---------- Intro ---------- */
#intro { position: fixed; inset: 0; z-index: 40; overflow: hidden; }
.intro-half { position: absolute; left: 0; right: 0; height: 50.5%; background: var(--bg); }
.intro-top { top: 0; }
.intro-bottom { bottom: 0; }
.intro-col { position: absolute; top: 0; width: 26vw; max-width: 160px; display: flex; flex-direction: column; gap: 12px; }
.intro-col-l { left: -4vw; }
.intro-col-r { right: -4vw; }
.intro-col img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 6px; opacity: .5; box-shadow: 0 8px 20px var(--shadow); }
.intro-words { position: absolute; inset: 0; font-family: var(--serif); font-size: clamp(44px, 12.5vw, 130px); line-height: 1; }
.intro-line {
  position: absolute; inset: 0; display: flex; flex-wrap: wrap; align-content: center; justify-content: center;
  gap: 0 .26em; padding: 0 12vw; text-align: center;
}
.intro-line span { text-shadow: 0 0 18px var(--bg), 0 0 6px var(--bg); display: inline-block; opacity: 0; transform: translateY(40%); filter: blur(8px); }
.intro-line span.it { font-style: italic; color: var(--blue); }
.intro-skip { position: absolute; right: var(--pad); bottom: calc(var(--pad) + env(safe-area-inset-bottom)); font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); padding: 10px; }

/* ---------- Top bar ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) var(--pad) 12px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  background: linear-gradient(var(--bg), rgba(255, 246, 218, 0));
  opacity: 0; transition: opacity .5s;
}
.topbar.on { opacity: 1; }
.topbar-date { color: var(--ink); min-width: 9.5em; }
.topbar-track { flex: 1; height: 1px; background: var(--line); position: relative; }
.topbar-fill { position: absolute; inset: 0; background: var(--blue); transform-origin: left; transform: scaleX(0); }

/* ---------- Hero ---------- */
#hero {
  position: relative; min-height: 100svh; padding: 0 var(--pad);
  display: flex; flex-direction: column; justify-content: center; gap: 22px;
  touch-action: pan-y; overflow: hidden;
}
.trail { position: absolute; inset: 0; pointer-events: none; }
.trail img {
  position: absolute; width: 92px; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 4px;
  border: 3px solid var(--paper); box-shadow: 0 10px 24px var(--shadow);
}
.hero-kicker { position: relative; color: var(--blue); }
.hero-title { position: relative; font-family: var(--serif); font-weight: 400; font-size: clamp(64px, 20vw, 200px); line-height: .88; letter-spacing: -.02em; }
.hero-title .line { display: block; overflow: hidden; padding-bottom: .06em; }
.hero-title .line > * { display: inline-block; }
.hero-top { font-size: 1.9em; line-height: .85; }
.hero-name { color: var(--blue); background: linear-gradient(transparent 64%, var(--sun) 64%, var(--sun) 90%, transparent 90%); padding: 0 .06em; }
.hero-intro { position: relative; white-space: pre-line; color: var(--ink); font-size: clamp(14px, 4vw, 18px); }
.hero-hint { position: absolute; left: var(--pad); bottom: calc(28px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 10px; }
.hero-hint .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--blue); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.8); opacity: .4; } }

/* ---------- Photo wall behind the hero: tilted columns drifting in opposite directions ---------- */
.mosaic { position: absolute; inset: -20% -30%; display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; transform: rotate(-9deg); pointer-events: none; }
.mosaic-col { display: flex; flex-direction: column; gap: 10px; animation: drift-up 70s linear infinite; }
.mosaic-col:nth-child(even) { animation-name: drift-down; animation-duration: 85s; }
.mosaic-col img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 6px; border: 3px solid var(--paper); }
@keyframes drift-up { from { transform: translateY(0); } to { transform: translateY(-50%); } }
@keyframes drift-down { from { transform: translateY(-50%); } to { transform: translateY(0); } }
#hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(var(--bg) 0%, rgba(255, 246, 218, 0) 18%, rgba(255, 246, 218, 0) 82%, var(--bg) 100%),
    linear-gradient(100deg, rgba(255, 246, 218, .94) 0%, rgba(255, 246, 218, .86) 55%, rgba(255, 246, 218, .55) 100%);
}
.hero-kicker, .hero-title, .hero-intro, .hero-hint { z-index: 1; }
#hero .trail { z-index: 2; }

/* ---------- Count: each number gets a picture of what it counts ---------- */
#count { position: relative; min-height: 100svh; display: flex; align-items: center; padding: 12vh var(--pad); overflow: hidden; }
.count-inner { width: 100%; display: grid; gap: 34px; }
.count-row { display: grid; gap: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.count-num { display: grid; gap: 2px; align-content: start; }
.count-row b { font-family: var(--serif); font-weight: 400; font-size: clamp(72px, 24vw, 180px); line-height: .9; font-variant-numeric: tabular-nums; }
.count-row:nth-child(3) b { font-style: italic; color: var(--blue); }
.count-row span { color: var(--muted); font-size: 15px; }
.count-vis { position: relative; }
.print { position: absolute; background: var(--paper); padding: 6px 6px 22px; box-shadow: 0 12px 26px var(--shadow); border-radius: 3px; }
.print img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; }
.print figcaption { position: absolute; left: 7px; right: 7px; bottom: 5px; font-family: var(--mono); font-size: 9px; letter-spacing: .08em; color: var(--muted); }
.vis-span { display: flex; align-items: center; gap: 14px; }
.vis-span .print { position: relative; width: min(34vw, 170px); }
.vis-span .print:first-child { transform: rotate(-5deg); }
.vis-span .print:last-child { transform: rotate(4deg); }
.vis-span .arrow { flex: 1; max-width: 120px; height: 2px; background: repeating-linear-gradient(90deg, var(--blue) 0 8px, transparent 8px 14px); position: relative; }
.vis-span .arrow::after { content: ""; position: absolute; right: -2px; top: -5px; border: 6px solid transparent; border-left-color: var(--blue); border-right: 0; }
.vis-days { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 5px; }
.vis-days img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; border: 2px solid var(--paper); box-shadow: 0 3px 8px var(--shadow); opacity: 0; transform: scale(.4); transition: opacity .3s, transform .3s cubic-bezier(.3, 1.6, .5, 1); }
.vis-days img.on { opacity: 1; transform: none; }
.vis-days img.bday { border-color: var(--sun); }
.vis-fan { min-height: 240px; }
.vis-fan .print { width: min(30vw, 160px); left: calc(50% - min(15vw, 80px)); bottom: 0; transform-origin: 50% 130%; }

@media (min-width: 900px) {
  .count-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); align-items: center; gap: 5vw; }
  .vis-fan { min-height: 270px; }
}

/* ---------- Year interlude ---------- */
.year { position: relative; height: 220svh; }
.year-stage { position: sticky; top: 0; height: 100svh; display: grid; place-items: center; overflow: hidden; }
.year-bg { position: absolute; inset: 0; }
.year-bg img { position: absolute; width: 34vw; max-width: 220px; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 6px; opacity: .6; box-shadow: 0 10px 24px var(--shadow); }
.year-num::before { content: ""; position: absolute; z-index: -1; width: .9em; height: .9em; border-radius: 50%; background: var(--sun); right: -.08em; top: .02em; }
.year-num { position: relative; z-index: 0; font-family: var(--serif); font-size: clamp(120px, 42vw, 420px); line-height: 1; letter-spacing: -.04em; }
.year-num em { color: var(--blue); }
.year-sub { position: absolute; bottom: calc(40px + env(safe-area-inset-bottom)); left: 0; right: 0; text-align: center; }

/* ---------- Day chapter ---------- */
.day { position: relative; padding: 18vh var(--pad) 10vh; min-height: 100svh; }
.day-head { display: grid; gap: 6px; margin-bottom: 28px; }
.day-meta { display: flex; justify-content: space-between; gap: 12px; }
.day-date { font-family: var(--serif); font-weight: 400; font-size: clamp(56px, 17vw, 140px); line-height: .9; letter-spacing: -.02em; }
.day-date em { color: var(--blue); }
.day-title { font-family: var(--serif); font-style: italic; font-size: 28px; line-height: 1.1; }
.day-title.long { font-size: 22px; line-height: 1.2; }
.day-caption { color: var(--muted); max-width: 34ch; }
.day.bday .day-title span { background: var(--sun); padding: 0 .2em; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.day.bday .bday-tag { display: inline-flex; }
.bday-tag { display: none; width: max-content; padding: 6px 10px; background: var(--sun); border-radius: 99px; color: var(--ink); }

/* Story deck: a stack of prints; fling the top one away and it slides under the pile. */
.deck { position: relative; width: min(78vw, 400px); aspect-ratio: 4 / 5; margin: 0 auto; touch-action: pan-y; }
.card {
  position: absolute; inset: 0; padding: 10px 10px 42px; background: var(--paper); border-radius: 4px;
  box-shadow: 0 16px 34px var(--shadow); will-change: transform; user-select: none; -webkit-user-select: none;
  cursor: grab;
}
.card img { width: 100%; height: 100%; object-fit: cover; background: #f4e7bd; pointer-events: none; -webkit-user-drag: none; opacity: 0; transition: opacity .5s; }
.card img.ok { opacity: 1; }
.card figcaption { position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; justify-content: space-between; font-family: var(--mono); font-size: 10px; letter-spacing: .1em; color: var(--muted); }
.deck-ui { display: flex; align-items: center; justify-content: space-between; width: min(78vw, 400px); margin: 22px auto 0; }
.deck-count { font-family: var(--mono); font-size: 12px; letter-spacing: .1em; }
.deck-btn { display: flex; align-items: center; gap: 10px; font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); padding: 8px 0; }
.deck-btn svg { width: 34px; height: 34px; }
.deck-btn circle.track { stroke: var(--line); }
.deck-btn circle.ring { stroke: var(--blue); stroke-dasharray: 100; stroke-dashoffset: 100; transform: rotate(-90deg); transform-origin: center; }
.deck-single .deck-ui { justify-content: center; }
.deck-single .deck-btn { display: none; }

/* ---------- Finale ---------- */
#finale { position: relative; height: 260svh; }
.finale-pin { position: sticky; top: 0; height: 100svh; }
.petals { width: 100%; height: 100%; display: block; }
.finale-hint { position: absolute; left: 0; right: 0; bottom: calc(30px + env(safe-area-inset-bottom)); text-align: center; }

/* ---------- Letter ---------- */
#letter { min-height: 100svh; display: grid; place-items: center; padding: 10vh var(--pad); }
.letter-card { width: min(100%, 460px); background: var(--paper); color: var(--ink); border-top: 10px solid var(--sun); padding: 32px 26px 28px; border-radius: 4px; display: grid; gap: 18px; transform: rotate(-1.2deg); box-shadow: 0 26px 50px var(--shadow); }
.letter-card .mono { color: var(--muted); }
.letter-message { font-family: var(--serif); font-size: 28px; line-height: 1.15; }
.letter-from { font-family: var(--serif); font-style: italic; font-size: 22px; color: var(--blue); text-align: right; }
.replay { justify-self: start; font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); padding: 10px 0 0; border-top: 1px solid var(--line); width: 100%; text-align: left; }

@media (min-width: 900px) {
  :root { --pad: 6vw; }
  .day { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 6vw; }
  .day-head { margin: 0; }
  .deck, .deck-ui { width: min(34vw, 440px); }
}

@media (prefers-reduced-motion: reduce) {
  .grain, .glow i, .hero-hint .dot, .mosaic-col { animation: none; }
}

/* Gentle "beautify" pass on every photo: a touch brighter and warmer, never blurred. */
.card img, .print img, .vis-days img, .mosaic-col img, .intro-col img, .trail img, .year-bg img {
  filter: brightness(1.1) saturate(1.1) contrast(1.03);
}

/* ---------- Background music: tap-to-open gate (browsers only play sound after a tap) + toggle ---------- */
.intro-gate {
  position: absolute; inset: 0; z-index: 2; display: grid; place-content: center; gap: 14px; text-align: center;
  background: var(--bg); cursor: pointer;
}
.intro-gate[hidden] { display: none; }
.gate-title { font-family: var(--serif); font-style: italic; font-size: clamp(44px, 13vw, 110px); line-height: 1; color: var(--blue); }
.gate-sub { animation: pulse 1.8s ease-in-out infinite; }
.sound {
  position: fixed; right: var(--pad); bottom: calc(var(--pad) + env(safe-area-inset-bottom)); z-index: 35;
  width: 42px; height: 42px; border-radius: 50%; background: var(--paper); box-shadow: 0 8px 20px var(--shadow);
  display: grid; place-items: center;
}
.sound[hidden] { display: none; }
.sound .bars { display: flex; align-items: flex-end; gap: 3px; height: 16px; }
.sound .bars i { width: 3px; height: 100%; background: var(--blue); border-radius: 2px; animation: eq .9s ease-in-out infinite; }
.sound .bars i:nth-child(2) { animation-delay: -.3s; }
.sound .bars i:nth-child(3) { animation-delay: -.6s; }
.sound.off .bars i { animation: none; height: 4px; }
@keyframes eq { 0%, 100% { height: 30%; } 50% { height: 100%; } }
