/* ═══════════════════════════════════════════════════════════
   GIRLFRIEND'S DAY — HAND-DRAWN TIMELINE
   Design Tokens & Color Palette
   ═══════════════════════════════════════════════════════════ */

:root {
  --paper: #FFF8F0;
  --paper-lines: rgba(176, 168, 160, 0.1);
  --ink: #3D2B1F;
  --ink-light: #6B5B4F;
  --rose: #E8A0BF;
  --rose-deep: #D4789F;
  --rose-soft: rgba(232, 160, 191, 0.18);
  --sage: #A8C5A0;
  --pencil: #B0A8A0;
  --tape: rgba(255, 220, 170, 0.55);

  --font-handwriting: 'Caveat', cursive;
  --font-notes: 'Patrick Hand', cursive;

  --ease-spring: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-soft: cubic-bezier(0.25, 0.1, 0.25, 1);
}


/* ─── Reset & Base ──────────────────────────────── */

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-notes);
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    /* Subtle warm glow at the top */
    radial-gradient(
      ellipse at 50% 0%,
      rgba(232, 160, 191, 0.06) 0%,
      transparent 60%
    ),
    /* Notebook ruled lines */
    repeating-linear-gradient(
      to bottom,
      transparent,
      transparent 31px,
      var(--paper-lines) 31px,
      var(--paper-lines) 32px
    );
  overflow-x: hidden;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}


/* ─── Paper Grain Texture Overlay ───────────────── */

.paper-grain {
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 1000;
  opacity: 0.45;
  mix-blend-mode: multiply;
}


/* ═══════════════════════════════════════════════════════════
   HERO SECTION
   ═══════════════════════════════════════════════════════════ */

.hero {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  position: relative;
}

.hero-content {
  max-width: 640px;
}

.hero-heart {
  font-size: clamp(2.5rem, 6vw, 4rem);
  color: var(--rose);
  margin-bottom: 1.5rem;
  opacity: 0.7;
  animation: pulse-heart 3s var(--ease-soft) infinite;
}

@keyframes pulse-heart {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.hero-title {
  font-family: var(--font-handwriting);
  font-size: clamp(3.2rem, 10vw, 6.5rem);
  font-weight: 700;
  line-height: 1.05;
  color: var(--ink);
  margin-bottom: 0.6rem;
  letter-spacing: -0.01em;
}

.hero-subtitle {
  font-family: var(--font-handwriting);
  font-size: clamp(1.5rem, 4vw, 2.4rem);
  color: var(--rose);
  font-weight: 500;
  margin-bottom: 0.4rem;
}

.hero-date {
  font-family: var(--font-notes);
  font-size: 1.05rem;
  color: var(--pencil);
  letter-spacing: 0.06em;
  margin-bottom: 4rem;
}

/* Scroll indicator */
.scroll-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  animation: bounce 2.5s var(--ease-soft) infinite;
}

.scroll-text {
  font-family: var(--font-handwriting);
  font-size: 1.15rem;
  color: var(--pencil);
  letter-spacing: 0.08em;
}

.scroll-arrow {
  font-family: var(--font-handwriting);
  font-size: 2.2rem;
  color: var(--pencil);
  line-height: 1;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(14px); }
}


/* ═══════════════════════════════════════════════════════════
   TIMELINE SECTION
   ═══════════════════════════════════════════════════════════ */

.timeline {
  position: relative;
  max-width: 1100px;
  margin: 0 auto;
  padding: 5rem 2rem 10rem;
}

/* Static background line (dashed pencil) */
.timeline-line {
  position: absolute;
  left: 50%;
  /* top/bottom set dynamically by JS to span first→last dot */
  top: 0;
  bottom: 0;
  width: 3px;
  transform: translateX(-50%);
  background: repeating-linear-gradient(
    to bottom,
    var(--pencil) 0px,
    var(--pencil) 10px,
    transparent 10px,
    transparent 18px
  );
  opacity: 0.25;
}

/* Animated progress line */
.timeline-progress {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 3px;
  transform: translateX(-50%) scaleY(0);
  z-index: 0;
  transform-origin: top;
  background: linear-gradient(
    to bottom,
    var(--rose),
    var(--rose-deep),
    var(--sage)
  );
  opacity: 0.6;
}


/* ─── Milestone Layout ──────────────────────────── */

.milestone {
  display: grid;
  grid-template-columns: 1fr 64px 1fr;
  align-items: start;
  margin-bottom: 7rem;
  position: relative;
}

.milestone:last-of-type {
  margin-bottom: 0;
}

/* Dot — always in center column */
.milestone-dot-wrapper {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  justify-content: center;
  padding-top: 2.2rem;
  z-index: 4;
}

.milestone-dot {
  width: 38px;
  height: 38px;
  border-radius: 52% 45% 55% 48% / 48% 54% 44% 52%;
  border: 3px solid var(--rose);
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-handwriting);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--rose-deep);
  box-shadow: 0 2px 10px rgba(232, 160, 191, 0.25);
  transition: transform 0.5s var(--ease-spring),
              box-shadow 0.5s var(--ease-spring);
}

.milestone:hover .milestone-dot {
  transform: scale(1.15);
  box-shadow: 0 4px 16px rgba(232, 160, 191, 0.35);
}

/* Card — alternating columns */
.milestone:nth-of-type(odd) .milestone-card {
  grid-column: 1;
  grid-row: 1;
  text-align: right;
}

.milestone:nth-of-type(odd) .milestone-card .doodle-wrapper {
  /* Right-align doodle for left-side cards */
  float: right;
  clear: both;
}

.milestone:nth-of-type(even) .milestone-card {
  grid-column: 3;
  grid-row: 1;
  text-align: left;
}

.milestone:nth-of-type(even) .milestone-card .doodle-wrapper {
  float: left;
  clear: both;
}


/* ─── Milestone Card ────────────────────────────── */

.milestone-card {
  padding: 2rem 2rem;
  background: rgba(255, 255, 255, 0.45);
  border: 2px solid rgba(176, 168, 160, 0.35);
  /* Hand-drawn border effect! */
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  transform: rotate(var(--card-rotate, 0deg));
  transition: transform 0.6s var(--ease-spring),
              box-shadow 0.6s var(--ease-spring);
  position: relative;
}

.milestone-card:hover {
  box-shadow: 0 8px 32px rgba(61, 43, 31, 0.06),
              inset 0 1px 2px rgba(255, 255, 255, 0.4);
  transform: rotate(0deg) scale(1.02);
}

.chapter-label {
  font-family: var(--font-notes);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--pencil);
  display: block;
  margin-bottom: 0.2rem;
}

.milestone-card h2 {
  font-family: var(--font-handwriting);
  font-size: clamp(2rem, 4.5vw, 3rem);
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.8rem;
  text-decoration: underline;
  text-decoration-style: wavy;
  text-decoration-color: var(--rose-soft);
  text-underline-offset: 6px;
  text-decoration-thickness: 2px;
}

.milestone-card p {
  font-family: var(--font-notes);
  font-size: clamp(1.1rem, 2.2vw, 1.4rem);
  color: var(--ink-light);
  line-height: 1.7;
  margin-bottom: 1.5rem;
}


/* ─── Doodle Images ─────────────────────────────── */

.doodle-wrapper {
  position: relative;
  display: inline-block;
  margin-top: 0.5rem;
}

/* Masking tape decoration */
.doodle-wrapper::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%) rotate(var(--tape-rotate, 2deg));
  width: 56px;
  height: 18px;
  background: var(--tape);
  border-radius: 2px;
  z-index: 2;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  /* Subtle tape texture */
  background-image: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 4px,
    rgba(255, 255, 255, 0.15) 4px,
    rgba(255, 255, 255, 0.15) 5px
  );
}

.doodle-img {
  max-width: 420px;
  width: 100%;
  height: auto;
  mix-blend-mode: multiply;
  filter: saturate(0.85) contrast(1.05);
  transform: rotate(var(--doodle-rotate, -1deg));
  transition: transform 0.5s var(--ease-spring),
              filter 0.5s var(--ease-spring);
  border-radius: 4px;
}

.doodle-img:hover {
  transform: rotate(0deg) scale(1.06);
  filter: saturate(1) contrast(1.08);
}

/* Last milestone — spans full grid width for visual impact */
#milestone-4 {
  grid-template-columns: 1fr;
  justify-items: center;
}

#milestone-4 .milestone-dot-wrapper {
  grid-column: 1;
  grid-row: 1;
  margin-bottom: 1rem;
}

#milestone-4 .milestone-card {
  grid-column: 1;
  grid-row: 2;
  text-align: center;
  max-width: 800px;
  width: 100%;
}

#milestone-4 .milestone-card .doodle-wrapper {
  float: none;
  display: block;
  width: 100%;
}

#milestone-4 .doodle-img {
  max-width: 100%;
  width: 100%;
  object-fit: contain;
}


/* ═══════════════════════════════════════════════════════════
   CLOSING SECTION
   ═══════════════════════════════════════════════════════════ */

.closing {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  position: relative;
  overflow: hidden;
}

.closing-content {
  max-width: 640px;
  position: relative;
  z-index: 2;
}

.closing-title {
  font-family: var(--font-handwriting);
  font-size: clamp(2.4rem, 7vw, 4.5rem);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.15;
  margin-bottom: 1.5rem;
}

.closing-signoff {
  font-family: var(--font-handwriting);
  font-size: clamp(1.5rem, 3.5vw, 2.2rem);
  color: var(--rose);
  font-weight: 500;
}


/* ─── Floating Hearts ───────────────────────────── */

.floating-hearts {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.floating-heart {
  position: absolute;
  bottom: -40px;
  opacity: 0;
  animation: float-up linear infinite;
  will-change: transform, opacity;
}

@keyframes float-up {
  0% {
    transform: translateY(0) rotate(0deg) scale(1);
    opacity: 0;
  }
  8% {
    opacity: 0.65;
  }
  80% {
    opacity: 0.45;
  }
  100% {
    transform: translateY(-100vh) rotate(40deg) scale(0.4);
    opacity: 0;
  }
}


/* ═══════════════════════════════════════════════════════════
   SCROLL-DRIVEN ANIMATIONS — Native CSS
   Supported: Chrome 115+, Edge 115+, Safari 26+
   ═══════════════════════════════════════════════════════════ */

@supports ((animation-timeline: view()) and (animation-range: 0% 100%)) {

  /* Milestone cards reveal as they enter the viewport */
  .milestone {
    opacity: 0;
    animation: milestone-reveal linear both;
    animation-timeline: view();
    animation-range: entry 5% cover 35%;
  }

  @keyframes milestone-reveal {
    from {
      opacity: 0;
      transform: translateY(60px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  /* Closing section fades in */
  .closing-content {
    opacity: 0;
    animation: closing-reveal linear both;
    animation-timeline: view();
    animation-range: entry 10% cover 40%;
  }

  @keyframes closing-reveal {
    from {
      opacity: 0;
      transform: translateY(40px) scale(0.96);
    }
    to {
      opacity: 1;
      transform: translateY(0) scale(1);
    }
  }
}


/* ─── Fallback: JS-driven reveal ────────────────── */
/* Applied when CSS scroll-driven animations are NOT supported */

@supports not ((animation-timeline: view()) and (animation-range: 0% 100%)) {
  .milestone {
    opacity: 0;
    transform: translateY(60px);
    transition: opacity 0.9s var(--ease-spring),
                transform 0.9s var(--ease-spring);
  }

  .milestone.is-visible {
    opacity: 1;
    transform: translateY(0);
  }

  .closing-content {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.9s var(--ease-spring),
                transform 0.9s var(--ease-spring);
  }

  .closing-content.is-visible {
    opacity: 1;
    transform: translateY(0);
  }
}


/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE (< 768px)
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {

  .timeline {
    padding: 3rem 1.2rem 6rem;
  }

  /* Switch to single column — card always on right of the dot */
  .milestone {
    grid-template-columns: 44px 1fr;
    margin-bottom: 4.5rem;
  }

  .milestone-dot-wrapper {
    grid-column: 1;
    padding-top: 0.2rem;
  }

  .milestone-dot {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }

  .milestone:nth-of-type(odd) .milestone-card,
  .milestone:nth-of-type(even) .milestone-card {
    grid-column: 2;
    grid-row: 1;
    text-align: left;
  }

  .milestone:nth-of-type(odd) .milestone-card .doodle-wrapper,
  .milestone:nth-of-type(even) .milestone-card .doodle-wrapper {
    float: none;
  }

  .milestone-card {
    padding: 1.5rem 1.6rem;
  }

  /* Timeline line moves to the left */
  .timeline-line,
  .timeline-progress {
    left: 22px;
  }

  .doodle-img {
    max-width: 180px;
  }
}

@media (max-width: 480px) {
  .hero-title {
    font-size: clamp(2.5rem, 12vw, 3.5rem);
  }

  .milestone-card {
    padding: 1.2rem 1.3rem;
  }

  .doodle-img {
    max-width: 140px;
  }
}


/* ═══════════════════════════════════════════════════════════
   REDUCED MOTION — Accessibility
   ═══════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  .milestone,
  .closing-content {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  .scroll-indicator {
    animation: none !important;
  }

  .hero-heart {
    animation: none !important;
  }

  .floating-heart {
    animation: none !important;
    display: none;
  }

  .timeline-progress {
    animation: none !important;
    transform: translateX(-50%) scaleY(1) !important;
  }

  .milestone-card,
  .milestone-dot,
  .doodle-img {
    transition: none !important;
  }
}
