@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Playfair+Display:ital,wght@0,400;0,600;1,400&family=Outfit:wght@300;400;500&family=Lora:ital,wght@0,400;1,400&display=swap');

/* ---------- design tokens ---------- */
:root {
  --cream: #FAF6F0;
  --cream-deep: #F3EBE0;
  --rose: #D4A5A5;
  --rose-soft: #EAD5D3;
  --gold: #B8892E;
  --gold-soft: #E4C97F;
  --brown: #3E2723;
  --brown-soft: #6D4C41;
  --ink: #2B1A16;
  --paper: #FFFDF8;
  --shadow: 0 18px 50px -18px rgba(62, 39, 35, 0.28);
  --z-petals: 10;
  --z-progress: 30;
  --z-player: 40;
  --z-modal: 50;
  --z-intro: 60;
  --font-script: 'Playfair Display', serif;
  --font-serif: 'Inter', sans-serif;
  --font-hand: 'Outfit', sans-serif;
  --font-letter: 'Lora', serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  line-height: 1.7;
  color: var(--ink);
  background: var(--cream);
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }

/* ---------- shared type ---------- */
.script { font-family: var(--font-script); font-weight: 400; }
.hand   { font-family: var(--font-hand); }

.chapter {
  max-width: 68rem;
  margin: 0 auto;
  padding: 6rem 1.5rem;
  position: relative;
}

.chapter-label {
  display: block;
  text-align: center;
  font-size: 0.85rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.75rem;
}

.chapter-title {
  font-family: var(--font-script);
  font-size: clamp(2.6rem, 6vw, 4.2rem);
  text-align: center;
  color: var(--brown);
  margin-bottom: 1rem;
  line-height: 1.2;
}

.chapter-intro {
  max-width: 38rem;
  margin: 0 auto 3rem;
  text-align: center;
  color: var(--brown-soft);
  font-size: 1.25rem;
}

.divider {
  width: 120px;
  margin: 0 auto 2.5rem;
  display: block;
  color: var(--gold);
}

/* ---------- scroll reveal ---------- */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.9s ease, transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal.visible { opacity: 1; transform: translateY(0); }

/* ---------- progress bar ---------- */
#progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--rose), var(--gold));
  z-index: var(--z-progress);
}

/* ---------- intro overlay ---------- */
#intro {
  position: fixed;
  inset: 0;
  z-index: var(--z-intro);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(212,165,165,0.35), transparent 55%),
    radial-gradient(ellipse at 75% 80%, rgba(228,201,127,0.3), transparent 55%),
    var(--cream);
  transition: opacity 1.2s ease, visibility 1.2s;
}
#intro.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

#intro .intro-hint {
  letter-spacing: 0.3em;
  text-transform: uppercase;
  font-size: 0.8rem;
  color: var(--brown-soft);
  margin-bottom: 1.5rem;
}
#intro .intro-name {
  font-family: var(--font-script);
  font-size: clamp(3.4rem, 10vw, 6.5rem);
  color: var(--brown);
  line-height: 1.15;
  margin-bottom: 2.5rem;
}

.passcode-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

#passcode-input {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  padding: 0.9rem 1.8rem;
  border-radius: 999px;
  border: 1px solid var(--gold-soft);
  background: rgba(255, 253, 248, 0.9);
  color: var(--brown);
  text-align: center;
  width: 280px;
  outline: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
#passcode-input::placeholder { color: var(--brown-soft); opacity: 0.7; }
#passcode-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(184, 137, 46, 0.2);
}

#passcode-error {
  color: #D32F2F;
  font-size: 0.95rem;
  font-weight: 500;
  display: none;
  margin-top: 0.5rem;
}

.begin-btn {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  letter-spacing: 0.12em;
  padding: 1rem 2.6rem;
  min-height: 44px;
  border: 1px solid var(--gold);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.85);
  color: var(--brown);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
  box-shadow: 0 6px 24px -8px rgba(184, 137, 46, 0.4);
}
.begin-btn:hover { background: var(--paper); box-shadow: 0 10px 30px -8px rgba(184, 137, 46, 0.55); }
.begin-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.begin-btn svg { width: 1.1rem; height: 1.1rem; }

/* ---------- hero ---------- */
#hero {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  overflow: hidden;
}
#hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 50%, rgba(255,253,248,0) 0%, rgba(255,253,248,0.7) 100%);
  pointer-events: none;
  z-index: 1;
}
#hero-floating-images {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.floating-img {
  position: absolute;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.6);
  border-radius: 6px;
  object-fit: cover;
  transition: opacity 2.5s ease, transform 6s cubic-bezier(0.1, 0.7, 1.0, 0.1);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.hero-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translateY(-4rem);
}
.hero-greeting {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 6vw, 3.8rem);
  color: var(--brown);
  margin-bottom: 0.5rem;
}
#hero .hero-greeting {
  font-family: var(--font-script);
  font-size: clamp(3rem, 9vw, 6rem);
  color: var(--brown);
  line-height: 1.15;
}
#hero .hero-name {
  font-family: var(--font-script);
  font-size: clamp(5rem, 20vw, 15rem);
  color: var(--gold);
  line-height: 1.1;
  margin: 0.5rem 0 1.5rem;
}
#hero .hero-date {
  font-size: 1.2rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--brown-soft);
  font-size: 0.95rem;
}
.scroll-cue {
  margin-top: 4rem;
  color: var(--gold);
  animation: bob 2.4s ease-in-out infinite;
}
.scroll-cue svg { width: 1.8rem; height: 1.8rem; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(10px); } }

/* ---------- photo frames ---------- */
.photo-frame {
  background: var(--paper);
  padding: 0.9rem 0.9rem 1rem;
  border-radius: 4px;
  box-shadow: var(--shadow);
  display: inline-block;
}
.photo-frame .photo {
  position: relative;
  overflow: hidden;
  border-radius: 2px;
  background:
    radial-gradient(circle at 35% 30%, rgba(255,255,255,0.55), transparent 60%),
    linear-gradient(140deg, var(--rose-soft), var(--cream-deep) 55%, var(--gold-soft));
}
.photo-frame .photo::after {
  /* soft flower watermark while the real photo is missing */
  content: "";
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b8892e' stroke-width='1' opacity='0.5'%3E%3Cpath d='M12 7.5a4.5 4.5 0 1 1 4.5 4.5M12 7.5A4.5 4.5 0 1 0 7.5 12M12 7.5V9m-4.5 3a4.5 4.5 0 1 0 4.5 4.5M7.5 12H9m7.5 0a4.5 4.5 0 1 1-4.5 4.5m4.5-4.5H15m-3 4.5V15'/%3E%3C/svg%3E") center / 26% no-repeat;
  opacity: 0.6;
  pointer-events: none;
}
.photo-frame .photo.loaded::after { display: none; }
.photo-frame .photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.8s ease;
}
.photo-frame .photo.loaded img { opacity: 1; }
.photo-frame figcaption {
  font-family: var(--font-hand);
  font-size: 1.25rem;
  color: var(--brown-soft);
  text-align: center;
  padding-top: 0.7rem;
}

/* opening chapter layout */
.opening-grid {
  display: grid;
  gap: 3rem;
  align-items: center;
  grid-template-columns: 1fr;
}
.opening-grid .photo-frame { justify-self: center; width: min(24rem, 100%); transform: rotate(-1.5deg); }
.opening-grid .photo { aspect-ratio: 4 / 5; }
.opening-text { font-size: 1.35rem; text-align: center; max-width: 34rem; margin: 0 auto; color: var(--brown); }
@media (min-width: 820px) {
  .opening-grid { grid-template-columns: 1fr 1.1fr; }
  .opening-text { text-align: left; }
}

/* ---------- timeline ---------- */
.timeline {
  position: relative;
  max-width: 70rem;
  margin: 0 auto;
  padding: 1rem 0;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0; bottom: 0;
  width: 2px;
  transform: translateX(-50%);
  background: linear-gradient(var(--rose-soft), var(--gold-soft), var(--rose-soft));
}
.timeline-item {
  position: relative;
  width: 50%;
  padding: 1.5rem 3rem 1.5rem 0;
}
.timeline-item:nth-child(even) { margin-left: 50%; padding: 1.5rem 0 1.5rem 3rem; }
.timeline-item::before {
  content: "";
  position: absolute;
  top: 2.4rem;
  right: -7px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--gold);
  border: 3px solid var(--cream);
  box-shadow: 0 0 0 2px var(--gold-soft);
}
.timeline-item:nth-child(even)::before { right: auto; left: -7px; }
.timeline-item .photo-frame { width: 100%; }
.timeline-item .photo { aspect-ratio: 4 / 3; }
.timeline-item:nth-child(odd) .photo-frame { transform: rotate(-1.2deg); }
.timeline-item:nth-child(even) .photo-frame { transform: rotate(1.2deg); }
.timeline-year {
  font-family: var(--font-hand);
  font-size: 1.5rem;
  color: var(--gold);
  margin-bottom: 0.4rem;
  display: block;
}
@media (max-width: 700px) {
  .timeline::before { left: 12px; }
  .timeline-item,
  .timeline-item:nth-child(even) { width: 100%; margin-left: 0; padding: 1.2rem 0 1.2rem 2.6rem; }
  .timeline-item::before,
  .timeline-item:nth-child(even)::before { left: 5px; right: auto; }
}

/* ---------- things cards ---------- */
.things-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.thing-card {
  background: var(--paper);
  border: 1px solid rgba(184, 137, 46, 0.22);
  border-radius: 14px;
  padding: 1.8rem 1.6rem;
  box-shadow: 0 10px 30px -18px rgba(62, 39, 35, 0.35);
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}
.thing-card:hover { border-color: var(--gold); box-shadow: 0 16px 38px -18px rgba(184, 137, 46, 0.45); }
.thing-card h3 {
  font-family: var(--font-hand);
  font-size: 1.6rem;
  color: var(--brown);
  margin-bottom: 0.5rem;
}
.thing-card p { color: var(--brown-soft); font-size: 1.1rem; }

/* ---------- reasons / flames ---------- */
#reasons-section { background: linear-gradient(180deg, var(--cream) 0%, var(--cream-deep) 50%, var(--cream) 100%); }
.flame-btn {
  display: none;
  align-items: center;
  gap: 0.7rem;
  margin: 0 auto 2.5rem;
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--brown);
  background: var(--paper);
  border: 1px solid var(--gold-soft);
  border-radius: 999px;
  padding: 0.85rem 1.8rem;
  min-height: 44px;
  cursor: pointer;
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}
.flame-btn:hover { border-color: var(--gold); box-shadow: 0 8px 26px -10px rgba(184, 137, 46, 0.5); }
.flame-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.flame-btn svg { width: 1.3rem; height: 1.3rem; color: var(--gold); }
.reasons-list { max-width: 34rem; margin: 0 auto; list-style: none; }
.reasons-list li {
  display: flex;
  gap: 0.9rem;
  align-items: baseline;
  padding: 0.7rem 0;
  font-size: 1.25rem;
  color: var(--brown);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.reasons-list li.lit { opacity: 1; transform: translateY(0); }
.reasons-list li .num {
  font-family: var(--font-hand);
  color: var(--gold);
  font-size: 1.3rem;
  min-width: 1.6rem;
  text-align: right;
}

/* ---------- cake ---------- */
.cake-wrap { text-align: center; }
.cake-svg { width: min(24rem, 88vw); height: auto; margin: 0 auto; display: block; }
.candle-flame { cursor: pointer; transform-origin: center bottom; animation: flicker 1.6s ease-in-out infinite alternate; }
.candle-flame:hover { filter: brightness(1.15); }
.candle-flame.out { animation: none; opacity: 0; transition: opacity 0.4s ease; pointer-events: none; }
@keyframes flicker {
  0%   { transform: scaleY(1) skewX(0deg); }
  40%  { transform: scaleY(0.92) skewX(2deg); }
  100% { transform: scaleY(1.06) skewX(-2deg); }
}
.cake-message {
  max-width: 30rem;
  margin: 2rem auto 0;
  font-size: 1.35rem;
  font-style: italic;
  color: var(--brown);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.9s ease, transform 0.9s ease;
}
.cake-message.visible { opacity: 1; transform: translateY(0); }

.wish-video {
  width: 100%;
  max-width: 42rem;
  object-fit: cover;
  display: block;
  margin: 0 auto;
  opacity: 0.85;
  filter: contrast(1.05);
  -webkit-mask-image: radial-gradient(ellipse at center, black 50%, transparent 95%);
  mask-image: radial-gradient(ellipse at center, black 50%, transparent 95%);
}

/* ---------- gallery ---------- */
.gallery-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  max-width: 68rem;
  margin: 0 auto;
}
.gallery-item:first-child {
  grid-column: 1 / -1;
  max-width: 40rem;
  margin: 0 auto;
  aspect-ratio: 3 / 3;
}
@media (min-width: 600px) {
  .gallery-item:first-child {
    aspect-ratio: 4 / 3;
  }
}
.gallery-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
  aspect-ratio: 4 / 3;
  background: var(--paper);
  padding: 0.6rem;
}
.gallery-item .photo {
  width: 100%;
  height: 100%;
  border-radius: 4px;
  overflow: hidden;
}
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s ease;
}
.gallery-item:hover img {
  transform: scale(1.05);
}

@media (max-width: 600px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.8rem;
    padding: 0 1rem;
  }
  .gallery-item {
    padding: 0.4rem;
    border-radius: 6px;
  }
}

/* ---------- letter ---------- */
.letter-paper {
  max-width: 40rem;
  margin: 0 auto;
  background: var(--paper);
  border: 1px solid rgba(184, 137, 46, 0.25);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: clamp(1.8rem, 5vw, 3.2rem);
  position: relative;
}
.letter-paper::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 5px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(90deg, var(--rose), var(--gold-soft), var(--rose));
}
#letter-text {
  font-family: var(--font-letter);
  font-weight: 300;
  font-size: 1.3rem;
  line-height: 1.8;
  color: var(--brown);
  white-space: pre-wrap;
  min-height: 12rem;
}
.caret {
  display: inline-block;
  width: 2px;
  background: var(--gold);
  animation: blink 0.9s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---------- finale ---------- */
#finale {
  text-align: center;
  padding-bottom: 8rem;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(228, 201, 127, 0.25), transparent 60%),
    var(--cream);
}
#finale .photo-frame { max-width: 45rem; margin: 0 auto; }
#finale .photo { aspect-ratio: 3 / 2; }
.finale-text { max-width: 32rem; margin: 1.8rem auto 2.5rem; font-size: 1.3rem; color: var(--brown-soft); }
.confetti-btn {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  letter-spacing: 0.08em;
  padding: 1rem 2.4rem;
  min-height: 44px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  color: var(--paper);
  background: linear-gradient(135deg, var(--rose) 0%, var(--gold) 100%);
  box-shadow: 0 12px 30px -10px rgba(184, 137, 46, 0.6);
  transition: box-shadow 0.25s ease, filter 0.25s ease;
}
.confetti-btn:hover { filter: brightness(1.06); box-shadow: 0 16px 36px -10px rgba(184, 137, 46, 0.7); }
.confetti-btn:focus-visible { outline: 3px solid var(--brown); outline-offset: 3px; }

/* ---------- floating controls ---------- */
#floating-controls {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: var(--z-player);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
#player, #auto-scroll-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--gold-soft);
  background: var(--paper);
  box-shadow: 0 10px 26px -8px rgba(62, 39, 35, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.25s ease, background-color 0.25s ease;
  color: var(--brown);
}
#player:hover, #auto-scroll-btn:hover { box-shadow: 0 14px 32px -8px rgba(184, 137, 46, 0.55); }
#player:focus-visible, #auto-scroll-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
#player .vinyl { width: 34px; height: 34px; }
#player.playing .vinyl { animation: spin 3.5s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#auto-scroll-btn svg { width: 24px; height: 24px; }
#auto-scroll-btn.active {
  background: var(--gold);
  color: var(--paper);
  border-color: var(--gold);
}

/* ---------- easter egg heart ---------- */
#secret-heart {
  position: fixed;
  left: 0.9rem;
  bottom: 0.9rem;
  z-index: var(--z-player);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.35;
  transition: opacity 0.3s ease;
}
#secret-heart:hover, #secret-heart:focus-visible { opacity: 1; outline: none; }
#secret-heart svg { width: 1.2rem; height: 1.2rem; color: var(--rose); }

/* ---------- modal ---------- */
#modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(43, 26, 22, 0.55);
  backdrop-filter: blur(4px);
}
#modal.open { display: flex; }
.modal-card {
  background: var(--paper);
  border-radius: 16px;
  max-width: 26rem;
  padding: 2.4rem 2rem;
  text-align: center;
  box-shadow: var(--shadow);
}
.modal-card p { font-family: var(--font-hand); font-size: 1.5rem; color: var(--brown); margin-bottom: 1.5rem; }
.modal-card button {
  font-family: var(--font-serif);
  font-size: 1rem;
  padding: 0.7rem 1.8rem;
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid var(--gold);
  background: var(--cream);
  color: var(--brown);
  cursor: pointer;
}
.modal-card button:hover { background: var(--cream-deep); }
.modal-card button:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

/* ---------- petals & confetti canvases ---------- */
#petals, #confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
}
#petals { z-index: var(--z-petals); }
#confetti { z-index: var(--z-modal); }

/* ---------- footer ---------- */
footer {
  text-align: center;
  padding: 2.5rem 1.5rem 6rem;
  color: var(--brown-soft);
  font-size: 1rem;
}
footer .script { font-size: 1.9rem; color: var(--gold); display: block; margin-bottom: 0.3rem; }

/* ---------- heart cursor ---------- */
body {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 24 24'%3E%3Cpath d='M12 21s-7.5-4.8-10-9.3C.4 8.6 2.4 5 6 5c2.2 0 3.6 1.2 6 3.7C14.4 6.2 15.8 5 18 5c3.6 0 5.6 3.6 4 6.7C19.5 16.2 12 21 12 21z' fill='%23D4A5A5' stroke='%23FFFDF8' stroke-width='1.6'/%3E%3C/svg%3E") 11 10, auto;
}
a, button, [role="button"], .flip-card, .candle-flame, .thing-card {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24'%3E%3Cpath d='M12 21s-7.5-4.8-10-9.3C.4 8.6 2.4 5 6 5c2.2 0 3.6 1.2 6 3.7C14.4 6.2 15.8 5 18 5c3.6 0 5.6 3.6 4 6.7C19.5 16.2 12 21 12 21z' fill='%23B8892E' stroke='%23FFFDF8' stroke-width='1.6'/%3E%3C/svg%3E") 13 12, pointer !important;
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .scroll-cue, .candle-flame, #player.playing .vinyl, .caret { animation: none; }
  .flip-inner { transition: none; }
}
