:root {
  --ink: #0e0d10;
  --ink-soft: #16141a;
  --gold: #c8a45c;
  --paper: #f3ece0;
  --paper-dim: rgba(243, 236, 224, 0.72);
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --scene-fade: 800ms;
}

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

html, body {
  height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  background: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ---------- Scenes ---------- */
.scene {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity var(--scene-fade) ease;
  pointer-events: none;
  overflow: hidden;
}
.scene.active { opacity: 1; pointer-events: auto; }

.backdrop {
  position: absolute;
  inset: -8%;
  background-size: cover;
  background-position: center;
  filter: blur(16px) brightness(0.42) saturate(1.1);
  transform: scale(1.05);
}

.photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 1000ms ease;
  will-change: transform, opacity;
}
.photo.shown { opacity: 1; }

/* Ken Burns drift only while the scene is active and not paused */
.scene.active .photo.shown {
  animation: drift 11s ease-out forwards;
}
.scene.paused .photo.shown { animation-play-state: paused; }

@keyframes drift {
  from { transform: scale(1.0) translate(0, 0); }
  to   { transform: scale(1.12) translate(-1.5%, -2%); }
}

.scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.78) 0%,
    rgba(0, 0, 0, 0.32) 26%,
    rgba(0, 0, 0, 0) 52%
  );
  pointer-events: none;
}

.caption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 0 8vw calc(env(safe-area-inset-bottom) + 9vh) 8vw;
  text-align: center;
}
/* photo-less years: center the text in the screen instead of bottom-anchoring */
.scene.text-only .caption {
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-bottom: 8vh;
}
.scene.text-only .line { margin-top: 1.4rem; }
.caption .milestone {
  font-family: var(--sans);
  font-weight: 500;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--gold);
  opacity: 0;
  transform: translateY(12px);
}
.caption .year {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(3.4rem, 18vw, 7rem);
  line-height: 0.96;
  letter-spacing: 0.01em;
  opacity: 0;
  transform: translateY(16px);
}
.caption .place {
  font-family: var(--sans);
  font-weight: 400;
  letter-spacing: 0.12em;
  font-size: 0.82rem;
  color: var(--paper-dim);
  margin-top: 0.5rem;
  opacity: 0;
  transform: translateY(16px);
}
.caption .line {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(1.15rem, 5.4vw, 1.7rem);
  line-height: 1.4;
  color: var(--paper);
  margin: 0.9rem auto 0;
  max-width: 30ch;
  opacity: 0;
  transform: translateY(16px);
}

/* staggered reveal when active */
.scene.active .caption .milestone { animation: rise 900ms ease 220ms forwards; }
.scene.active .caption .year      { animation: rise 1000ms ease 360ms forwards; }
.scene.active .caption .place     { animation: rise 1000ms ease 620ms forwards; }
.scene.active .caption .line      { animation: rise 1100ms ease 820ms forwards; }

@keyframes rise {
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Progress bar ---------- */
.progress {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 10px);
  left: 12px; right: 12px;
  display: flex;
  gap: 4px;
  z-index: 30;
  opacity: 0;
  transition: opacity 400ms ease;
}
.progress.visible { opacity: 1; }
.seg {
  flex: 1;
  height: 2.5px;
  border-radius: 2px;
  background: rgba(243, 236, 224, 0.25);
  overflow: hidden;
}
.seg .fill {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--paper);
  border-radius: 2px;
}
.seg.done .fill { width: 100% !important; }

/* ---------- Mute ---------- */
.mute {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 22px);
  right: 16px;
  z-index: 31;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(243, 236, 224, 0.3);
  background: rgba(14, 13, 16, 0.4);
  color: var(--paper);
  font-size: 1rem;
  backdrop-filter: blur(6px);
  cursor: pointer;
}
.mute.muted { color: rgba(243, 236, 224, 0.4); }

/* ---------- Overlays (opening + finale) ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8vw;
  background: radial-gradient(120% 120% at 50% 40%, #1a1720 0%, var(--ink) 70%);
  transition: opacity 900ms ease;
}
.overlay[hidden] { display: none; }
.overlay.fade-out { opacity: 0; pointer-events: none; }

.opening-eyebrow, .finale-family {
  font-family: var(--sans);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--gold);
  margin-bottom: 1.4rem;
}
.opening-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2.6rem, 12vw, 4.4rem);
  line-height: 1.04;
}
.opening-sub, .finale-line {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.1rem, 5vw, 1.5rem);
  color: var(--paper-dim);
  margin-top: 0.8rem;
}
.finale-line { margin-bottom: 1.4rem; }
.finale-wish {
  font-family: var(--serif);
  font-size: clamp(1.4rem, 6vw, 2rem);
  margin-top: 1rem;
}

.begin {
  margin-top: 2.4rem;
  font-family: var(--sans);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.8rem;
  color: var(--ink);
  background: var(--gold);
  border: none;
  border-radius: 999px;
  padding: 0.95rem 2.6rem;
  cursor: pointer;
  transition: transform 200ms ease, box-shadow 200ms ease;
  box-shadow: 0 10px 30px rgba(200, 164, 92, 0.25);
}
.begin:active { transform: scale(0.97); }

.opening-hint {
  margin-top: 1.4rem;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: rgba(243, 236, 224, 0.4);
}

/* ---------- Year strip (finale) ---------- */
.yearstrip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem 0.9rem;
  max-width: 32ch;
  margin-top: 2.2rem;
}
.yearstrip button {
  background: none;
  border: none;
  color: var(--paper-dim);
  font-family: var(--serif);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.1rem 0.2rem;
}
.yearstrip button:active { color: var(--gold); }

/* ---------- Grain + vignette ---------- */
.grain, .vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}
.grain {
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}
.vignette {
  z-index: 49;
  background: radial-gradient(120% 100% at 50% 50%, transparent 58%, rgba(0,0,0,0.5) 100%);
}

@media (prefers-reduced-motion: reduce) {
  .scene.active .photo.shown { animation: none; }
  .caption * { animation-duration: 1ms !important; }
}
