/* ──────────────────────────────────────────────────────────
   Yeng & Neil — Two Years
   A cinematic scroll-story.
   ────────────────────────────────────────────────────────── */

:root {
  /* Color journey — interpolated by JS as the page scrolls */
  --bg: #0A0815;
  --ink: #F5E9DA;
  --ink-soft: rgba(245, 233, 218, 0.72);
  --ink-faint: rgba(245, 233, 218, 0.42);

  --accent-coral: #E9806A;
  --accent-rose: #D26B7E;
  --accent-gold: #D4A574;
  --accent-cream: #F4E4D6;

  /* Fonts */
  --f-display: 'Fraunces', 'Times New Roman', serif;
  --f-hand:    'Caveat', cursive;
  --f-letter:  'Homemade Apple', cursive;
  --f-body:    'Inter', system-ui, sans-serif;

  /* Sizes */
  --hero-title: clamp(4rem, 16vw, 14rem);
  --chapter-quote: clamp(2.4rem, 6vw, 6rem);
  --end-title: clamp(3.5rem, 12vw, 11rem);
}

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

html { scroll-behavior: auto; }
html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-body);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  transition: background-color 0.8s ease;
}

/* Lenis smooth-scroll */
html.lenis { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }
.lenis.lenis-stopped { overflow: hidden; }
.lenis.lenis-scrolling iframe { pointer-events: none; }

img, video { display: block; max-width: 100%; height: auto; }

/* ──────────────── Background canvas (sakura petals) ──────────────── */
#petals {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  opacity: 0.65;
}

/* ──────────────── Cursor ──────────────── */
@media (hover: hover) and (pointer: fine) {
  body { cursor: none; }
  a, button { cursor: none; }
  #cursor {
    position: fixed;
    top: 0; left: 0;
    width: 40px; height: 40px;
    border: 1.5px solid var(--accent-coral);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 9999;
    mix-blend-mode: difference;
    transition: width .25s ease, height .25s ease, opacity .25s ease;
  }
  #cursor-dot {
    position: fixed;
    top: 0; left: 0;
    width: 6px; height: 6px;
    background: var(--accent-coral);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 10000;
  }
}

/* ──────────────── HERO ──────────────── */
.hero {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow: hidden;
  z-index: 2;
}

.hero-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
  opacity: 0.55;
  filter: saturate(1.1) contrast(0.95);
}

.hero-vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  background:
    radial-gradient(ellipse at center, transparent 0%, rgba(10,8,21,0.55) 60%, rgba(10,8,21,0.95) 100%),
    linear-gradient(to bottom, rgba(10,8,21,0.4) 0%, transparent 30%, transparent 70%, rgba(10,8,21,0.85) 100%);
  pointer-events: none;
}

.hero-inner {
  position: relative;
  z-index: 3;
  text-align: center;
  padding: 8vh 6vw;
  max-width: 100vw;
}

.hero-overline {
  font-family: var(--f-hand);
  font-size: clamp(1.2rem, 1.8vw, 1.8rem);
  color: var(--accent-cream);
  letter-spacing: 0.08em;
  margin-bottom: 2.2rem;
  opacity: 0;
  animation: fade-up 1.6s ease 0.4s forwards;
}
.hero-overline span { color: var(--accent-coral); margin: 0 0.6em; }

.hero-title {
  font-family: var(--f-display);
  font-weight: 300;
  font-style: italic;
  font-size: var(--hero-title);
  line-height: 0.92;
  letter-spacing: -0.04em;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(-1rem, -2vw, -0.5rem);
}
.hero-title .word {
  display: block;
  opacity: 0;
  transform: translateY(60px) scale(0.96);
  animation: word-rise 1.6s cubic-bezier(.2,.7,.2,1) forwards;
}
.hero-title .word:nth-child(1) { animation-delay: 0.9s; }
.hero-title .word:nth-child(2) {
  animation-delay: 1.4s;
  color: var(--accent-cream);
  font-style: italic;
  margin-top: -0.18em;
}

.hero-sub {
  font-family: var(--f-display);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.5rem, 2.4vw, 2.4rem);
  color: var(--ink-soft);
  margin-top: 2.5rem;
  letter-spacing: 0.02em;
  opacity: 0;
  animation: fade-up 1.6s ease 2.0s forwards;
}

.hero-date {
  font-family: var(--f-hand);
  font-size: clamp(1.4rem, 1.8vw, 1.8rem);
  color: var(--accent-coral);
  margin-top: 0.4rem;
  letter-spacing: 0.04em;
  opacity: 0;
  animation: fade-up 1.6s ease 2.3s forwards;
}

.hero-doodles {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.hero-doodles .d {
  position: absolute;
  color: var(--accent-coral);
  opacity: 0;
  animation: doodle-in 2s ease forwards;
}
.hero-doodles .d1 { top: 18%;  left: 12%; width: 38px;  color: var(--accent-rose); animation-delay: 2.5s; transform: rotate(-12deg); }
.hero-doodles .d2 { top: 28%;  right: 14%; width: 28px;  color: var(--accent-cream); animation-delay: 2.8s; }
.hero-doodles .d3 { bottom: 22%; left: 18%; width: 50px;  color: var(--accent-gold);  animation-delay: 3.0s; }
.hero-doodles .d4 { top: 14%;  right: 22%; width: 34px;  color: var(--accent-coral); animation-delay: 3.2s; transform: rotate(15deg); }
.hero-doodles .d5 { bottom: 30%; right: 12%; width: 80px;  color: var(--accent-rose);  animation-delay: 3.4s; }

.scroll-cue {
  position: absolute;
  bottom: 3vh;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--f-hand);
  font-size: 1.1rem;
  color: var(--ink-faint);
  letter-spacing: 0.2em;
  text-transform: lowercase;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  opacity: 0;
  animation: fade-up 1.6s ease 3.5s forwards, bob 2.4s ease-in-out 5s infinite;
}
.scroll-cue svg { width: 12px; height: 24px; opacity: 0.6; }

@keyframes word-rise {
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes doodle-in {
  to { opacity: 0.85; }
}
@keyframes bob {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%      { transform: translateX(-50%) translateY(8px); }
}

/* ──────────────── CHAPTERS ──────────────── */
#chapters { position: relative; z-index: 2; }

.chapter {
  position: relative;
  min-height: 100vh;
  display: grid;
  align-items: center;
  padding: 12vh 6vw;
  overflow: hidden;
}

/* Three layouts: left / right / overlay */
.chapter[data-layout="left"]    { grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr); gap: 6vw; }
.chapter[data-layout="right"]   { grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr); gap: 6vw; }
.chapter[data-layout="overlay"] { grid-template-columns: 1fr; }

.chapter[data-layout="left"]  .chapter-quote { grid-column: 1; order: 1; }
.chapter[data-layout="left"]  .chapter-media { grid-column: 2; order: 2; }
.chapter[data-layout="right"] .chapter-media { grid-column: 1; order: 1; }
.chapter[data-layout="right"] .chapter-quote { grid-column: 2; order: 2; }

.chapter-number {
  font-family: var(--f-hand);
  font-size: 1.4rem;
  color: var(--accent-coral);
  letter-spacing: 0.4em;
  margin-bottom: 0.8rem;
  opacity: 0.7;
}

.chapter-title-small {
  font-family: var(--f-hand);
  font-size: 1.2rem;
  color: var(--ink-faint);
  letter-spacing: 0.3em;
  text-transform: lowercase;
  margin-bottom: 2rem;
}

.chapter-quote {
  position: relative;
}

.quote-text {
  font-family: var(--f-display);
  font-weight: 300;
  font-style: italic;
  font-size: var(--chapter-quote);
  line-height: 1.08;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.quote-text-hand {
  font-family: var(--f-hand);
  font-weight: 600;
  font-size: calc(var(--chapter-quote) * 1.15);
  line-height: 1.05;
  color: var(--accent-cream);
  letter-spacing: 0.005em;
}

.quote-decoration {
  position: relative;
  display: inline-block;
  margin-top: 1.5rem;
}

.brush-underline {
  display: block;
  width: clamp(140px, 18vw, 240px);
  height: 14px;
  color: var(--accent-coral);
  margin-top: 0.6rem;
}

/* Chapter media (image OR video) */
.chapter-media {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  max-height: 78vh;
  overflow: hidden;
  border-radius: 4px;
  box-shadow:
    0 30px 80px -30px rgba(0,0,0,0.7),
    0 4px 24px -4px rgba(0,0,0,0.45);
  transform-origin: center;
}
.chapter-media::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.35), transparent 40%);
  pointer-events: none;
}
.chapter-media video,
.chapter-media img {
  width: 100%; height: 100%;
  object-fit: cover;
  transform-origin: center;
  will-change: transform;
}

/* Overlay layout — image full-bleed, quote centered */
.chapter[data-layout="overlay"] {
  padding: 0;
}
.chapter[data-layout="overlay"] .chapter-media {
  position: absolute; inset: 0;
  aspect-ratio: auto;
  max-height: none;
  border-radius: 0;
  width: 100%; height: 100%;
  z-index: 1;
}
.chapter[data-layout="overlay"] .chapter-media::after {
  background:
    radial-gradient(ellipse at center, transparent 0%, rgba(0,0,0,0.5) 70%, rgba(0,0,0,0.85) 100%);
}
.chapter[data-layout="overlay"] .chapter-quote {
  position: relative;
  z-index: 3;
  text-align: center;
  margin: 0 auto;
  padding: 0 6vw;
  max-width: 1100px;
  min-height: 100vh;
  display: grid;
  align-content: center;
  justify-items: center;
}

/* Doodle accents inside each chapter */
.chapter-doodles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.chapter-doodles .d {
  position: absolute;
  opacity: 0;
  transform: rotate(var(--rot, 0deg));
  color: var(--accent-coral);
}
.chapter.in-view .chapter-doodles .d {
  opacity: 0.75;
  transition: opacity 1.6s ease;
}

/* Chapter quote enter animation */
.chapter-quote .quote-text,
.chapter-quote .quote-text-hand,
.chapter-quote .chapter-number,
.chapter-quote .chapter-title-small,
.chapter-quote .brush-underline {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 1.2s ease, transform 1.2s cubic-bezier(.2,.7,.2,1);
}
.chapter.in-view .chapter-quote .quote-text,
.chapter.in-view .chapter-quote .quote-text-hand,
.chapter.in-view .chapter-quote .chapter-number,
.chapter.in-view .chapter-quote .chapter-title-small,
.chapter.in-view .chapter-quote .brush-underline {
  opacity: 1;
  transform: translateY(0);
}
.chapter.in-view .chapter-quote .chapter-title-small { transition-delay: 0.15s; }
.chapter.in-view .chapter-quote .quote-text,
.chapter.in-view .chapter-quote .quote-text-hand { transition-delay: 0.30s; }
.chapter.in-view .chapter-quote .brush-underline { transition-delay: 0.55s; }

/* ──────────────── MONTAGE ──────────────── */
.montage {
  position: relative;
  z-index: 2;
  padding: 18vh 6vw;
  overflow: hidden;
}
.montage-quote {
  text-align: center;
  margin-bottom: 6vh;
  position: relative;
  z-index: 2;
}
.montage-quote .quote-overline {
  font-family: var(--f-hand);
  font-size: 1.4rem;
  color: var(--accent-coral);
  letter-spacing: 0.3em;
  text-transform: lowercase;
  margin-bottom: 0.8rem;
  opacity: 0.85;
}
.montage-quote .quote-text {
  font-family: var(--f-display);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1.15;
}

.montage-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  max-width: 1400px;
  margin: 0 auto;
}
.montage-grid .cell {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 4px;
  background: rgba(255,255,255,0.04);
  box-shadow: 0 8px 30px -10px rgba(0,0,0,0.5);
  opacity: 0;
  transform: translateY(30px) scale(0.92);
  transition: opacity 0.8s ease, transform 0.8s cubic-bezier(.2,.7,.2,1);
}
.montage.in-view .cell { opacity: 1; transform: translateY(0) scale(1); }
.montage-grid .cell:nth-child(1)  { transition-delay: 0.05s; }
.montage-grid .cell:nth-child(2)  { transition-delay: 0.10s; }
.montage-grid .cell:nth-child(3)  { transition-delay: 0.15s; }
.montage-grid .cell:nth-child(4)  { transition-delay: 0.20s; }
.montage-grid .cell:nth-child(5)  { transition-delay: 0.25s; }
.montage-grid .cell:nth-child(6)  { transition-delay: 0.30s; }
.montage-grid .cell:nth-child(7)  { transition-delay: 0.35s; }
.montage-grid .cell:nth-child(8)  { transition-delay: 0.40s; }
.montage-grid .cell:nth-child(9)  { transition-delay: 0.45s; }
.montage-grid .cell:nth-child(10) { transition-delay: 0.50s; }
.montage-grid .cell:nth-child(n+11) { transition-delay: 0.55s; }

.montage-grid .cell img,
.montage-grid .cell video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}

@media (max-width: 760px) {
  .montage-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
}

/* ──────────────── END CARD ──────────────── */
.end-card {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 16vh 6vw;
  background: var(--accent-cream);
  color: #2A1A24;
  overflow: hidden;
}

.end-mosaic {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  grid-auto-rows: 120px;
  gap: 4px;
  opacity: 0.18;
  filter: saturate(1.05) blur(0.6px);
  pointer-events: none;
}
.end-mosaic img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.end-card::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, rgba(246,235,220,0.5) 0%, rgba(246,235,220,0.92) 70%);
  pointer-events: none;
}

.end-inner {
  position: relative;
  z-index: 2;
  max-width: 900px;
}

.end-overline {
  font-family: var(--f-hand);
  font-size: 1.4rem;
  color: #C9614A;
  letter-spacing: 0.5em;
  margin-bottom: 2rem;
}

.end-title {
  font-family: var(--f-display);
  font-style: italic;
  font-weight: 300;
  font-size: var(--end-title);
  line-height: 0.95;
  letter-spacing: -0.04em;
  color: #2A1A24;
}
.end-title .amp { color: var(--accent-coral); font-weight: 400; font-style: italic; }

.end-anniv {
  font-family: var(--f-hand);
  font-size: clamp(1.5rem, 2.2vw, 2.2rem);
  color: #6A4030;
  margin-top: 1rem;
  letter-spacing: 0.15em;
}

.end-dedication { margin-top: 5rem; }
.quote-handwritten {
  font-family: var(--f-letter);
  font-size: clamp(1.6rem, 3vw, 3rem);
  line-height: 1.25;
  color: #4A2B30;
}
.end-dedication .brush-underline { color: var(--accent-coral); margin: 1.2rem auto 0; }

.end-dedication-sub {
  font-family: var(--f-hand);
  font-size: clamp(1.2rem, 1.6vw, 1.6rem);
  color: #6A4030;
  margin-top: 2.2rem;
  letter-spacing: 0.05em;
}

.end-doodles { position: absolute; inset: 0; pointer-events: none; }
.end-doodles .d { position: absolute; color: var(--accent-coral); opacity: 0.4; }
.end-doodles .d1 { top: 12%; left: 8%; width: 36px; transform: rotate(-15deg); }
.end-doodles .d2 { top: 18%; right: 12%; width: 32px; transform: rotate(20deg); }
.end-doodles .d3 { bottom: 16%; left: 14%; width: 60px; transform: rotate(-8deg); }

/* ──────────────── RESPONSIVE ──────────────── */
@media (max-width: 900px) {
  .chapter[data-layout="left"],
  .chapter[data-layout="right"] {
    grid-template-columns: 1fr;
    gap: 4vh;
  }
  .chapter[data-layout="left"]  .chapter-quote { grid-column: 1; order: 2; }
  .chapter[data-layout="left"]  .chapter-media { grid-column: 1; order: 1; }
  .chapter[data-layout="right"] .chapter-media { grid-column: 1; order: 1; }
  .chapter[data-layout="right"] .chapter-quote { grid-column: 1; order: 2; }
  .chapter-media { aspect-ratio: 4 / 5; max-height: 60vh; }
  .hero-doodles .d4, .hero-doodles .d5 { display: none; }
}

@media (max-width: 540px) {
  .hero-title { font-size: clamp(3.4rem, 18vw, 6rem); }
  .end-title { font-size: clamp(3rem, 16vw, 6rem); }
  .quote-text, .quote-text-hand { font-size: clamp(1.8rem, 7vw, 3rem); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  body { cursor: auto; }
  #cursor, #cursor-dot, #petals { display: none; }
}
