/* ============================================================
   TOKENS
   ============================================================ */
:root{
  --midnight-1: #0a0e27;
  --midnight-2: #131a3d;
  --midnight-3: #1c2454;
  --moonlight: #fbefd6;
  --blush: #f3c6d4;
  --lavender: #cdb8e8;
  --lavender-soft: #e6dbf5;
  --paper: #fdf8ef;
  --ink: #3a2f45;

  --font-display: "Cormorant Garamond", "Times New Roman", serif;
  --font-hand: "Caveat", cursive;
  --font-body: "Jost", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.75rem;
  --space-4: 2.75rem;
  --space-5: 4.5rem;

  --ease-soft: cubic-bezier(.22,.61,.36,1);
  --dur-slow: 1.4s;
}

*{ box-sizing: border-box; }
html{ scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce){
  html{ scroll-behavior: auto; }
  *{ animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

body{
  margin: 0;
  background:
    radial-gradient(ellipse 80% 40% at 50% 0%, rgba(28,36,84,0.9), transparent),
    linear-gradient(180deg, var(--midnight-1) 0%, var(--midnight-2) 45%, var(--midnight-3) 100%);
  color: var(--moonlight);
  font-family: var(--font-body);
  font-weight: 300;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection{ background: var(--blush); color: var(--midnight-1); }

/* ============================================================
   AMBIENT CANVAS (stars / fireflies / hearts)
   ============================================================ */
#sky-canvas{
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ============================================================
   SCROLL THREAD
   ============================================================ */
.thread-track{
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 2px;
  background: rgba(251,239,214,0.08);
  z-index: 50;
}
.thread-fill{
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--blush), var(--lavender));
  transition: width 0.1s linear;
}

/* ============================================================
   MUSIC BUTTON
   ============================================================ */
.music-btn{
  position: fixed;
  top: max(1.1rem, env(safe-area-inset-top));
  right: 1.1rem;
  z-index: 60;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(251,239,214,0.25);
  background: rgba(19,26,61,0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--moonlight);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.3s var(--ease-soft), background 0.3s;
}
.music-btn:active{ transform: scale(0.92); }
.music-btn.playing .icon-note{ animation: note-bob 1.6s ease-in-out infinite; }
.music-ring{
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid rgba(243,198,212,0.5);
  opacity: 0;
}
.music-btn.playing .music-ring{
  animation: ring-pulse 2.4s ease-out infinite;
}
@keyframes ring-pulse{
  0%{ opacity: 0.6; transform: scale(0.9); }
  100%{ opacity: 0; transform: scale(1.4); }
}
@keyframes note-bob{
  0%,100%{ transform: translateY(0); }
  50%{ transform: translateY(-2px); }
}

/* ============================================================
   LAYOUT / SECTIONS
   ============================================================ */
main{ position: relative; z-index: 1; }

.section{
  position: relative;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-5) var(--space-2);
  text-align: center;
}

.section-eyebrow{
  font-family: var(--font-body);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-size: 0.68rem;
  color: var(--lavender);
  opacity: 0.75;
  margin: 0 0 var(--space-2);
}

.section-title{
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.7rem, 6vw, 2.6rem);
  margin: 0 0 var(--space-4);
  color: var(--paper);
  max-width: 20ch;
}

/* reveal-on-scroll base state */
.reveal{
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 1s var(--ease-soft), transform 1s var(--ease-soft);
}
.reveal.in-view{
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   HERO
   ============================================================ */
.hero{
  padding-top: var(--space-5);
  overflow: hidden;
}
.hero-moon{
  position: absolute;
  top: 8%;
  left: 50%;
  transform: translateX(-50%);
  width: 140px;
  height: 140px;
  z-index: 0;
}
.moon-glow{
  position: absolute;
  inset: -60px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(251,239,214,0.35), transparent 70%);
  animation: moon-breathe 6s ease-in-out infinite;
}
.moon-body{
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, #fffaf0, #f4dfb8 60%, #e9cf9e);
  box-shadow: 0 0 60px rgba(251,239,214,0.45);
}
@keyframes moon-breathe{
  0%,100%{ opacity: 0.8; transform: scale(1); }
  50%{ opacity: 1; transform: scale(1.08); }
}
.hero-cloud{
  position: absolute;
  width: 220px;
  height: 60px;
  border-radius: 50%;
  background: rgba(251,239,214,0.05);
  filter: blur(14px);
  z-index: 0;
}
.cloud-a{ top: 18%; left: -20%; animation: drift-right 40s linear infinite; }
.cloud-b{ top: 30%; right: -25%; width: 280px; animation: drift-left 55s linear infinite; }
@keyframes drift-right{
  0%{ transform: translateX(0); }
  100%{ transform: translateX(140vw); }
}
@keyframes drift-left{
  0%{ transform: translateX(0); }
  100%{ transform: translateX(-140vw); }
}
.hero-fog{
  position: absolute;
  bottom: 0; left: -10%;
  width: 120%;
  height: 40%;
  background: linear-gradient(to top, rgba(203,184,232,0.14), transparent);
  filter: blur(30px);
  pointer-events: none;
}
.hero-content{ position: relative; z-index: 2; }

.eyebrow{
  font-size: 0.7rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--blush);
  opacity: 0.8;
  margin: 0 0 var(--space-3);
  transition-delay: 0.1s;
}

.hero-title{
  font-family: var(--font-display);
  font-weight: 400;
  font-style: italic;
  font-size: clamp(2.6rem, 12vw, 5rem);
  line-height: 1.08;
  margin: 0 0 var(--space-3);
  color: var(--paper);
}
.hero-title span{ display: block; transition-delay: 0.25s; }
.hero-title span:nth-child(2){ transition-delay: 0.45s; }
.hero-title .dot{ color: var(--blush); }

.hero-sub{
  font-family: var(--font-body);
  font-weight: 300;
  font-size: clamp(0.95rem, 3vw, 1.15rem);
  color: var(--lavender-soft);
  max-width: 26ch;
  margin: 0 auto;
  letter-spacing: 0.01em;
  transition-delay: 0.65s;
}

.scroll-cue{
  position: absolute;
  bottom: max(2rem, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  opacity: 0.6;
}
.scroll-cue span{
  width: 1px;
  height: 34px;
  background: linear-gradient(to bottom, var(--moonlight), transparent);
  animation: cue-drop 2.2s ease-in-out infinite;
}
.scroll-cue p{
  margin: 0;
  font-size: 0.62rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--lavender-soft);
}
@keyframes cue-drop{
  0%{ transform: scaleY(0.3); transform-origin: top; opacity: 0.3; }
  50%{ transform: scaleY(1); transform-origin: top; opacity: 1; }
  100%{ transform: scaleY(0.3); transform-origin: bottom; opacity: 0.3; }
}

/* ============================================================
   LETTER SECTION
   ============================================================ */
.letter-section{ padding-top: var(--space-5); }

.envelope-wrap{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.envelope{
  position: relative;
  width: min(78vw, 300px);
  aspect-ratio: 3 / 2;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  perspective: 900px;
}
.envelope-back{
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: linear-gradient(160deg, #efd9c9, #e6c6b4);
  box-shadow: 0 18px 40px rgba(0,0,0,0.35), inset 0 0 0 1px rgba(255,255,255,0.25);
}
.envelope-paper-peek{
  position: absolute;
  left: 8%;
  right: 8%;
  top: 6%;
  height: 78%;
  background: var(--paper);
  border-radius: 6px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  transform: translateY(0);
  transition: transform 0.9s var(--ease-soft);
}
.envelope-flap{
  position: absolute;
  inset: 0 0 auto 0;
  height: 58%;
  background: linear-gradient(160deg, #e6c1ab, #dcb098);
  clip-path: polygon(0 0, 100% 0, 50% 78%);
  transform-origin: top center;
  border-radius: 10px 10px 0 0;
  transition: transform 0.9s var(--ease-soft);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.wax-seal{
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%,-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #e88ba3, #c85a78);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fbe2e8;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  transition: opacity 0.5s var(--ease-soft), transform 0.6s var(--ease-soft);
}

.envelope.open .envelope-flap{
  transform: rotateX(180deg);
}
.envelope.open .wax-seal{
  opacity: 0;
  transform: translate(-50%,-50%) scale(0.4);
}
.envelope.open .envelope-paper-peek{
  transform: translateY(-14%);
}

.envelope-hint{
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--lavender-soft);
  opacity: 0.7;
  animation: hint-breathe 2.6s ease-in-out infinite;
}
@keyframes hint-breathe{
  0%,100%{ opacity: 0.45; }
  50%{ opacity: 0.9; }
}

.letter-paper{
  margin-top: var(--space-4);
  width: min(90vw, 560px);
  background: var(--paper);
  color: var(--ink);
  border-radius: 14px;
  padding: var(--space-4) var(--space-3);
  box-shadow: 0 30px 70px rgba(0,0,0,0.45);
  transform-origin: top center;
  animation: unfold 1s var(--ease-soft) both;
}
.letter-paper[hidden]{ display: none; }
@keyframes unfold{
  0%{ opacity: 0; transform: scaleY(0.6) translateY(-10px); }
  100%{ opacity: 1; transform: scaleY(1) translateY(0); }
}
.letter-paper-inner{ text-align: left; }
.letter-line{
  font-family: var(--font-hand);
  font-size: clamp(1.15rem, 4.4vw, 1.5rem);
  line-height: 1.55;
  margin: 0 0 1.1rem;
  color: var(--ink);
}
.letter-signoff{
  font-family: var(--font-hand);
  font-size: clamp(1.2rem, 4.6vw, 1.55rem);
  color: var(--ink);
  margin: var(--space-2) 0 0;
}

/* ============================================================
   ILLUSTRATION SECTION
   ============================================================ */
.illustration-stage{
  width: min(92vw, 460px);
}
.couple-svg{ width: 100%; height: auto; overflow: visible; }
.figure{ animation: sway 5s ease-in-out infinite; transform-origin: bottom center; }
.figure-right{ animation-delay: 0.6s; }
@keyframes sway{
  0%,100%{ transform: rotate(-0.6deg); }
  50%{ transform: rotate(0.6deg); }
}
.hair{ animation: hair-drift 4s ease-in-out infinite; transform-origin: top center; }
@keyframes hair-drift{
  0%,100%{ transform: rotate(-0.8deg); }
  50%{ transform: rotate(0.8deg); }
}
.fireflies-svg circle{ animation: firefly-twinkle 2.4s ease-in-out infinite; }
.fireflies-svg circle:nth-child(2){ animation-delay: 0.8s; }
.fireflies-svg circle:nth-child(3){ animation-delay: 1.4s; }
@keyframes firefly-twinkle{
  0%,100%{ opacity: 0.2; }
  50%{ opacity: 1; }
}
.illustration-caption{
  margin-top: var(--space-3);
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.05rem, 3.6vw, 1.3rem);
  color: var(--lavender-soft);
}

/* ============================================================
   QUOTE SECTION
   ============================================================ */
.quote-section{ padding-top: var(--space-5); padding-bottom: var(--space-5); }
.quote-block{
  margin: 0;
  max-width: 30ch;
}
.type-line{
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.35rem, 6.4vw, 2.1rem);
  line-height: 1.5;
  margin: 0 0 0.35rem;
  color: var(--lavender-soft);
  white-space: pre-wrap;
}
.type-line-final{ color: var(--blush); }
.type-line .caret{
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--blush);
  margin-left: 2px;
  vertical-align: -0.1em;
  animation: caret-blink 0.9s steps(1) infinite;
}
@keyframes caret-blink{
  0%,49%{ opacity: 1; }
  50%,100%{ opacity: 0; }
}

/* ============================================================
   DREAMS SECTION
   ============================================================ */
.dreams-grid{
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
  width: min(94vw, 560px);
}
@media (min-width: 640px){
  .dreams-grid{ grid-template-columns: repeat(3, 1fr); }
}

.dream-card{
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: var(--space-3) 0.75rem;
  min-height: 132px;
  border-radius: 16px;
  border: 1px solid rgba(251,239,214,0.18);
  background: rgba(28,36,84,0.4);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--paper);
  cursor: pointer;
  transition: transform 0.4s var(--ease-soft), background 0.4s, box-shadow 0.4s;
}
.dream-card:active{ transform: scale(0.96); }
.dream-card.tapped,
.dream-card:hover{
  background: rgba(243,198,212,0.14);
  box-shadow: 0 14px 34px rgba(0,0,0,0.35);
  transform: translateY(-4px);
}
.dream-emoji{ font-size: 1.8rem; line-height: 1; }
.dream-label{
  font-size: 0.8rem;
  line-height: 1.3;
  letter-spacing: 0.01em;
  color: var(--lavender-soft);
  white-space: normal;
  overflow-wrap: break-word;
  max-width: 14ch;
}

/* ============================================================
   FINAL SCENE
   ============================================================ */
.final-section{ overflow: hidden; }
.final-fog{
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 30%, rgba(251,239,214,0.12), transparent 60%);
  pointer-events: none;
}
.final-content{ position: relative; z-index: 2; }
.final-line{
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.3rem, 5.6vw, 2rem);
  color: var(--lavender-soft);
  margin: 0 0 0.4rem;
}
.final-line-accent{
  color: var(--blush);
  margin-top: var(--space-2);
}
.made-with-love{
  margin-top: var(--space-4);
  font-family: var(--font-body);
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--lavender);
  opacity: 0.75;
}
.heart{
  display: inline-block;
  color: var(--blush);
  animation: heartbeat 1.8s ease-in-out infinite;
}
@keyframes heartbeat{
  0%,100%{ transform: scale(1); }
  25%{ transform: scale(1.18); }
  40%{ transform: scale(1); }
}

/* ============================================================
   FOCUS STATES (a11y)
   ============================================================ */
button:focus-visible,
.envelope:focus-visible{
  outline: 2px solid var(--blush);
  outline-offset: 3px;
}

/* ============================================================
   DESKTOP SCALE-UP
   ============================================================ */
@media (min-width: 900px){
  :root{ --space-5: 6rem; }
  .section{ padding-left: var(--space-5); padding-right: var(--space-5); }
  .letter-paper{ padding: var(--space-4) var(--space-5); }
}
