:root {
  --bg: #0c0809;
  --plum: #2a1418;
  --blush: #f4c6c6;
  --rose: #e8a0a8;
  --gold: #e9c46a;
  --cream: #fbf1e6;
  --dim: 0.2;              /* updated on scroll by script.js */
  --script: "Pinyon Script", cursive;
  --serif: "Bodoni Moda", Didot, Georgia, serif;
  --body: "Cormorant Garamond", Georgia, serif;
  --mono: "Courier Prime", "Courier New", monospace;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--cream);
  font-family: var(--body);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
body.locked { overflow: hidden; height: 100vh; }

.script { font-family: var(--script); }

/* ---------------- Collage ---------------- */
#collage {
  position: fixed;
  inset: -10vh -6vw;
  display: flex;
  gap: 2.2vw;
  justify-content: center;
  z-index: 0;
  transform: rotate(-4deg) scale(1.08);
}

.col {
  flex: 1 1 0;
  min-width: 0;
  overflow: visible;
}

.track {
  display: flex;
  flex-direction: column;
  gap: 2.2vw;
  animation: drift-up var(--speed, 60s) linear infinite;
}
.col.down .track { animation-name: drift-down; }

/* track contains the photo list twice, so -50% loops seamlessly */
@keyframes drift-up   { from { transform: translateY(0); }    to { transform: translateY(-50%); } }
@keyframes drift-down { from { transform: translateY(-50%); } to { transform: translateY(0); } }

.polaroid {
  background: #efe6d8;
  padding: 7px 7px 26px;
  border-radius: 3px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
  transform: rotate(var(--tilt, 0deg));
  position: relative;
}
.polaroid img {
  aspect-ratio: 3 / 4;
  object-fit: cover;
  filter: saturate(0.85) sepia(0.15) contrast(1.05) brightness(1.05);
  display: block;
  width: 100%;
  height: auto;
  border-radius: 1px;
  background: #e9dfd3;
}
/* little washi tape on some photos */
.polaroid.tape::before {
  content: "";
  position: absolute;
  top: -10px; left: 50%;
  width: 46%; height: 20px;
  transform: translateX(-50%) rotate(var(--tape, -3deg));
  background: rgba(244, 198, 198, 0.75);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.polaroid.tape.gold::before { background: rgba(233, 196, 106, 0.7); }

/* ---------------- Dim layer ---------------- */
#dim {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, rgba(12, 7, 8, 0) 0%, rgba(4, 2, 3, calc(var(--dim) + 0.15)) 100%),
    rgba(12, 7, 8, var(--dim));
}

/* ---------------- Sparkles ---------------- */
#sparkles { position: fixed; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; }
.sparkle {
  position: absolute;
  bottom: -30px;
  color: var(--gold);
  opacity: 0;
  animation: float-up linear infinite;
  text-shadow: 0 0 10px rgba(233, 196, 106, 0.8);
}
@keyframes float-up {
  0%   { transform: translateY(0) translateX(0) scale(0.6); opacity: 0; }
  10%  { opacity: 0.9; }
  90%  { opacity: 0.6; }
  100% { transform: translateY(-110vh) translateX(var(--sway, 20px)) scale(1); opacity: 0; }
}

/* ---------------- Film look ---------------- */
#grain {
  position: fixed;
  inset: 0;
  z-index: 45;
  pointer-events: none;
  opacity: 0.13;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 1.4 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 0.9s steps(6) infinite;
}
@keyframes grain {
  0%   { background-position: 0 0; }
  20%  { background-position: -40px 30px; }
  40%  { background-position: 30px -50px; }
  60%  { background-position: -20px 60px; }
  80%  { background-position: 50px 10px; }
  100% { background-position: -10px -30px; }
}

/* warm light leaks drifting across the frame */
#leak {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(40vmax 30vmax at 0% 15%, rgba(255, 110, 50, 0.12), transparent 70%),
    radial-gradient(35vmax 40vmax at 100% 90%, rgba(200, 60, 80, 0.1), transparent 70%);
  animation: leak 14s ease-in-out infinite alternate;
}
@keyframes leak {
  0%   { opacity: 0.35; transform: translateX(0); }
  50%  { opacity: 0.85; }
  100% { opacity: 0.45; transform: translateX(4vw); }
}
@keyframes flicker { 0% { filter: brightness(1); } 100% { filter: brightness(0.92); } }

/* faint film scratches */
#scratches { position: fixed; inset: 0; z-index: 44; pointer-events: none; }
#scratches i {
  position: absolute;
  top: 0; bottom: 0;
  width: 1px;
  background: linear-gradient(transparent, rgba(255, 245, 230, 0.35) 30%, rgba(255, 245, 230, 0.15) 70%, transparent);
  opacity: 0;
  animation: scratch 7s steps(1) infinite;
}
#scratches i:nth-child(2) { animation-duration: 11s; animation-delay: -4s; }
@keyframes scratch {
  0%   { left: 18%; opacity: 0.6; }
  4%   { left: 19%; opacity: 0; }
  40%  { left: 71%; opacity: 0.45; }
  43%  { opacity: 0; }
  70%  { left: 44%; opacity: 0.35; }
  72%  { opacity: 0; }
}

/* ---------------- Gate ---------------- */
#gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at center, rgba(28, 16, 18, 0.15), rgba(4, 2, 3, 0.5));
  cursor: pointer;
  transition: opacity 1.2s ease, visibility 1.2s;
  -webkit-tap-highlight-color: transparent;
}
#gate.open { opacity: 0; visibility: hidden; }
.gate-inner { text-align: center; }
.gate-penguin {
  display: inline-block;
  animation: bob 2.4s ease-in-out infinite;
  filter: drop-shadow(0 8px 20px rgba(232, 160, 168, 0.5));
}
.gate-penguin img { width: 150px; height: auto; display: block; border-radius: 12px; }
.gate-text {
  margin-top: 18px;
  font-family: var(--script);
  font-size: 38px;
  color: var(--blush);
}
.gate-hint {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: rgba(251, 241, 230, 0.95);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes bob   { 0%,100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-10px) rotate(4deg); } }
@keyframes pulse { 0%,100% { opacity: 0.65; } 50% { opacity: 1; } }

/* ---------------- Story ---------------- */
main { position: relative; z-index: 3; }

section {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12vh 7vw;
}

/* Hero */
.hero { flex-direction: column; text-align: center; }

.hero-kicker {
  font-size: clamp(44px, 8vw, 100px);
  color: var(--blush);
  text-shadow: 0 0 30px rgba(244, 198, 198, 0.35);
  line-height: 1;
}
.hero-name {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(80px, 20vw, 240px);
  line-height: 1;
  letter-spacing: 0.01em;
  margin-top: 0.05em;
  background: linear-gradient(180deg, #f7eee2 25%, #d9b48a 130%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 24px rgba(0, 0, 0, 0.7));
}
.hero-name .ch {
  display: inline-block;
  opacity: 0;
  transform: translateY(40px) rotate(6deg);
  background: inherit;
  -webkit-background-clip: text;
  background-clip: text;
}
.started .hero-name .ch {
  animation: letter-in 1.1s cubic-bezier(.2,.8,.2,1) forwards;
  animation-delay: calc(1.1s + var(--i) * 0.14s);
}
@keyframes letter-in { to { opacity: 1; transform: none; } }

.hero-sub {
  margin-top: 26px;
  font-size: clamp(19px, 2.6vw, 26px);
  font-style: italic;
  font-weight: 300;
  color: rgba(251, 241, 230, 0.85);
  max-width: 32ch;
}

[data-hero] { opacity: 0; transform: translateY(18px); }
.started [data-hero] { animation: rise 1.3s cubic-bezier(.2,.8,.2,1) forwards; }
.started [data-hero="1"] { animation-delay: 0.3s; }
.started [data-hero="3"] { animation-delay: 2.4s; }
.started [data-hero="4"] { animation-delay: 3.4s; }
@keyframes rise { to { opacity: 1; transform: none; } }

.scroll-hint {
  font-family: var(--mono);
  position: absolute;
  bottom: 6vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: rgba(251, 241, 230, 0.6);
}
.scroll-hint .arrow { font-size: 20px; animation: nudge 1.8s ease-in-out infinite; }
@keyframes nudge { 0%,100% { transform: translateY(0); } 50% { transform: translateY(8px); } }

/* Message sections */
.msg {
  gap: 6vw;
}
.msg.flip { flex-direction: row-reverse; }

.msg-text { max-width: 560px; }
.msg.center .msg-text { text-align: center; max-width: 720px; }

.msg-kicker {
  font-family: var(--mono);
  font-size: clamp(12px, 1.3vw, 14px);
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--rose);
  margin-bottom: 18px;
}
.msg-body {
  font-size: clamp(23px, 3.1vw, 36px);
  line-height: 1.42;
  font-weight: 300;
  font-style: italic;
  color: var(--cream);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8), 0 2px 24px rgba(0, 0, 0, 0.9);
}
.msg-body em { color: var(--blush); font-style: normal; }

.feature {
  flex: 0 0 auto;
  width: min(340px, 38vw);
  padding: 10px 10px 46px;
  background: #efe6d8;
  border-radius: 3px;
  box-shadow: 0 30px 60px rgba(0,0,0,0.55);
  transform: rotate(var(--tilt, -3deg));
  position: relative;
}
.feature.wide { width: min(520px, 46vw); }
.feature img { display: block; width: 100%; height: auto; filter: saturate(0.75) sepia(0.15) contrast(1.08); }
.feature figcaption {
  position: absolute;
  left: 0; right: 0; bottom: 10px;
  text-align: center;
  font-family: var(--script);
  font-size: 22px;
  color: #6b3a40;
}

/* Reveal on scroll */
.reveal .msg-kicker,
.reveal .msg-body,
.reveal .feature,
.reveal .finale-kicker,
.reveal .finale-title,
.reveal .finale-sign {
  opacity: 0;
  transform: translateY(40px);
  filter: blur(6px);
  transition: opacity 1.2s ease, transform 1.2s cubic-bezier(.2,.8,.2,1), filter 1.2s ease;
}
.reveal .feature { transform: translateY(50px) rotate(calc(var(--tilt, -3deg) * 3)) scale(0.92); }
.reveal.in .msg-kicker,
.reveal.in .msg-body,
.reveal.in .finale-kicker,
.reveal.in .finale-title,
.reveal.in .finale-sign { opacity: 1; transform: none; filter: blur(0); }
.reveal.in .feature { opacity: 1; transform: rotate(var(--tilt, -3deg)); filter: blur(0); }
.reveal.in .msg-body     { transition-delay: 0.25s; }
.reveal.in .feature      { transition-delay: 0.1s; }
.reveal.in .finale-title { transition-delay: 0.4s; }
.reveal.in .finale-sign  { transition-delay: 1.2s; }

/* Finale */
.finale { flex-direction: column; text-align: center; min-height: 110vh; }
.finale-kicker { font-size: clamp(36px, 6vw, 64px); color: var(--blush); }
.finale-title {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(48px, 10vw, 120px);
  line-height: 1.05;
  margin: 10px 0 28px;
  background: linear-gradient(180deg, #fff6ea 30%, var(--rose) 130%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.finale-sign { font-family: var(--mono); letter-spacing: 0.2em; font-size: clamp(13px, 1.6vw, 16px); color: rgba(251,241,230,0.8); }

.heart-burst {
  position: fixed;
  z-index: 4;
  pointer-events: none;
  font-size: 22px;
  animation: burst 2.6s cubic-bezier(.15,.7,.3,1) forwards;
}
@keyframes burst {
  0%   { transform: translate(0, 0) scale(0.3); opacity: 1; }
  70%  { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1.1) rotate(var(--rot)); opacity: 0; }
}

/* Music button */
.music-btn {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(244, 198, 198, 0.45);
  background: rgba(42, 20, 24, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--blush);
  font-size: 22px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.2s ease, opacity 0.3s ease;
}
.music-btn:hover { transform: scale(1.08); }
.music-btn.hidden { display: none; }
.music-btn.playing .note { animation: spin-note 3s linear infinite; display: inline-block; }
.music-btn:not(.playing) { opacity: 0.6; }
.music-btn:not(.playing)::after {
  content: "";
  position: absolute;
  width: 26px; height: 2px;
  background: var(--blush);
  transform: rotate(-45deg);
}
@keyframes spin-note { 0%,100% { transform: rotate(-12deg); } 50% { transform: rotate(12deg) translateY(-2px); } }

/* ---------------- Mobile ---------------- */
@media (max-width: 760px) {
  #collage { gap: 3.5vw; inset: -10vh -14vw; }
  .track { gap: 3.5vw; }
  .polaroid { padding: 5px 5px 18px; }

  .msg, .msg.flip { flex-direction: column; text-align: center; gap: 40px; }
  .msg-text { text-align: center; }
  .feature { width: min(260px, 68vw); }
}

@media (prefers-reduced-motion: reduce) {
  .track { animation-duration: 400s !important; }
  .sparkle, .heart-burst, #scratches { display: none; }
  #grain, #leak { animation: none; }
}

/* ---------------- Readability: dark soft panels behind text ---------------- */
.hero, .finale { position: relative; }
.finale::before {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: min(900px, 110vw);
  height: min(520px, 62vh);
  transform: translate(-50%, -50%);
  background: radial-gradient(ellipse at center, rgba(8, 4, 5, 0.6) 0%, rgba(8, 4, 5, 0.35) 40%, transparent 70%);
  pointer-events: none;
  z-index: -1;
}

.msg-text {
  background: rgba(10, 6, 7, 0.62);
  backdrop-filter: blur(10px) saturate(0.8);
  -webkit-backdrop-filter: blur(10px) saturate(0.8);
  padding: clamp(24px, 4vw, 44px) clamp(24px, 4vw, 48px);
  border-radius: 4px;
  border: 1px solid rgba(244, 198, 198, 0.12);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}
.reveal .msg-text { opacity: 0; transition: opacity 1s ease; }
.reveal.in .msg-text { opacity: 1; }

/* ---------------- Phone polish ---------------- */
@media (max-width: 760px) {
  #scratches { display: none; }           /* looked like a stray line on small screens */
  section { padding: 10vh 6vw; }
  .msg, .msg.flip { gap: 26px; }
  .feature { width: min(230px, 60vw); padding: 8px 8px 38px; }
  .feature figcaption { font-size: 19px; bottom: 8px; }
  .msg-text { padding: 26px 22px; }
  .msg-body { font-size: 21px; line-height: 1.45; }
  .finale-kicker { font-size: 34px; }
  .finale-title { font-size: 58px; }
  .hero-sub { font-size: 18px; padding: 0 8px; }
  .music-btn { right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); }
}

/* keep hero text crisp over brighter photos */
.hero-kicker, .hero-sub, .finale-kicker, .finale-sign { text-shadow: 0 2px 4px rgba(0,0,0,.9), 0 0 24px rgba(0,0,0,.8); }
.hero-name, .finale-title { filter: drop-shadow(0 2px 3px rgba(0,0,0,.9)) drop-shadow(0 4px 24px rgba(0,0,0,.7)); }
.gate-text, .gate-hint { text-shadow: 0 2px 4px rgba(0,0,0,.9), 0 0 20px rgba(0,0,0,.8); }

/* card behind Happy Birthday Babe */
.hero-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(10, 6, 7, 0.62);
  backdrop-filter: blur(10px) saturate(0.8);
  -webkit-backdrop-filter: blur(10px) saturate(0.8);
  padding: clamp(30px, 5vw, 56px) clamp(28px, 6vw, 80px) clamp(34px, 5vw, 60px);
  border-radius: 4px;
  border: 1px solid rgba(244, 198, 198, 0.14);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  max-width: 92vw;
  opacity: 0;
  transform: translateY(20px) scale(0.97);
}
.started .hero-card { animation: rise 1.2s cubic-bezier(.2,.8,.2,1) forwards; }

/* keep slanted letters from being clipped, and size the hero to short screens too */
.hero-name .ch { padding: 0.08em 0.1em; margin: -0.08em -0.1em; }
.hero-name { font-size: clamp(64px, min(20vw, 24vh), 240px); }
.hero-kicker { font-size: clamp(38px, min(8vw, 10vh), 100px); }
.hero-sub { margin-top: clamp(12px, 2.5vh, 26px); }

/* solid cream letters (more reliable than gradient text, esp. Safari) */
.hero-name { background: none; -webkit-background-clip: border-box; background-clip: border-box; color: #f6ead8; }
.hero-name .ch { background: none; -webkit-background-clip: border-box; background-clip: border-box; color: inherit; }

.hero-sub { max-width: 36ch; line-height: 1.5; }

/* Landscape photos ("wide") get a wider frame on phones too */
@media (max-width: 760px) {
  .feature.wide { width: min(360px, 86vw); }
}
