:root {
  --bg-deep: #050813;
  --bg-mid: #0b1024;
  --ink: #e8ecf7;
  --ink-soft: #9aa3bf;
  --accent: #f5e7c4;
}

/* ── Loading overlay ─────────────────────────────────────────────────────
   Sits on top of everything until the moon texture has loaded. Removed
   from the DOM after fade-out so it never interferes with later interaction. */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-deep);
  transition: opacity 0.6s ease;
}

.loading-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loading-pulse {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(245, 231, 196, 0.55) 0%,
    rgba(245, 231, 196, 0.12) 55%,
    rgba(245, 231, 196, 0) 75%
  );
  animation: loading-pulse 2.2s ease-in-out infinite;
}

@keyframes loading-pulse {
  0%, 100% { transform: scale(0.8); opacity: 0.4; }
  50%      { transform: scale(1.15); opacity: 1; }
}

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

/* Solid deep-blue on the html element so iOS Safari's rubber-band
   overscroll area shows the night-sky color instead of system white. */
html {
  background-color: var(--bg-deep);
}

html, body {
  background: radial-gradient(ellipse at top, var(--bg-mid) 0%, var(--bg-deep) 70%);
  background-attachment: fixed;
  background-color: var(--bg-deep);
  color: var(--ink);
  font-family: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  overflow-x: hidden;
}

/* Per-node ambient tint. A solid color overlay at the very back of the
   stack; JS swaps the background-color when the user reaches a new node,
   and the long transition gives a slow color drift between memories. */
.ambient-tint {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-color: transparent;
  transition: background-color 1.5s ease;
}

.stars {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 0;
  display: block;
  overflow: visible;
  will-change: transform;
}

.stars circle {
  fill: #ffffff;
  opacity: var(--star-base, 0.6);
  animation: twinkle var(--twinkle-dur, 5s) ease-in-out infinite;
  animation-delay: var(--twinkle-delay, 0s);
  filter: drop-shadow(0 0 var(--star-glow, 1px) rgba(255, 255, 255, 0.45));
}

.stars circle.bright {
  fill: #fff7e8;
  filter: drop-shadow(0 0 var(--star-glow, 3px) rgba(255, 244, 220, 0.6));
}

.stars line {
  stroke: rgba(255, 244, 220, 0.12);
  stroke-width: 0.6;
  stroke-linecap: round;
}

@keyframes twinkle {
  0%, 100% { opacity: var(--star-min, 0.25); }
  50%      { opacity: var(--star-max, 0.95); }
}

#moon {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  z-index: 1;
  pointer-events: none;
}

#moon canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.hero {
  position: relative;
  z-index: 2;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 3rem 1.5rem 3rem;
  text-align: center;
  pointer-events: none;
}

.timeline {
  position: relative;
  z-index: 2;
}

.timeline-node {
  height: var(--section-height, 200dvh);
  position: relative;
}

.node-content {
  position: absolute;
  left: 50%;
  top: calc(100dvh - 3rem);
  transform: translate(-50%, -100%);
  width: calc(100vw - 3rem);
  max-width: 32rem;
  text-align: center;
  background: rgba(5, 8, 19, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 1.5rem 2rem;
  border-radius: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.node-description {
  font-size: clamp(1.2rem, 2.5vw, 1.6rem);
  line-height: 1.5;
  color: var(--ink);
}

.node-collage {
  position: absolute;
  left: 50%;
  top: 60dvh;
  transform: translate(-50%, -50%);
  /* Desktop: width grows up to 60rem on wide screens. Height has a rem
     floor (~previous baked-in size) and scales up to ~75% of the dvh
     space available between the compact moon and the description card. */
  width: min(calc(100vw - 4rem), 60rem);
  height: max(20rem, 38dvh);
  pointer-events: none;
}

@media (max-width: 768px) {
  .node-collage {
    width: min(calc(100vw - 2rem), 22rem);
    /* Mobile keeps the proportional layout; height auto from aspect-ratio. */
    height: auto;
    aspect-ratio: 5 / 6;
    top: 60dvh;
  }
}

.collage-image {
  position: absolute;
  border-radius: 0.75rem;
  background: linear-gradient(135deg, #5a6678 0%, #3a4456 50%, #2d3748 100%);
  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.55),
    0 2px 6px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center;
  transition: box-shadow 0.3s ease;
  cursor: pointer;
  pointer-events: auto;

  /* Entrance starting state — invisible, slightly small, dropped down,
     and not yet rotated. Plays card-pop-in when its parent gets .in-view. */
  opacity: 0;
  transform: rotate(0deg) scale(0.65) translateY(40px);
}

.timeline-node.in-view .collage-image {
  animation: card-pop-in 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Stagger by source order so cards in a collage land one after another. */
.timeline-node.in-view .collage-image:nth-child(1) { animation-delay: 0.04s; }
.timeline-node.in-view .collage-image:nth-child(2) { animation-delay: 0.14s; }
.timeline-node.in-view .collage-image:nth-child(3) { animation-delay: 0.24s; }
.timeline-node.in-view .collage-image:nth-child(4) { animation-delay: 0.34s; }

@keyframes card-pop-in {
  0% {
    opacity: 0;
    transform: rotate(0deg) scale(0.65) translateY(40px);
  }
  55% {
    opacity: 1;
    /* Overshoot the final rotation and scale slightly past, plus a tiny
       upward jump so it feels like a real "land + bounce." */
    transform: rotate(calc(var(--rotation, 0deg) * 1.35)) scale(1.06) translateY(-5px);
  }
  100% {
    opacity: 1;
    transform: rotate(var(--rotation, 0deg)) scale(1) translateY(0);
  }
}

.collage-image.front {
  z-index: 100 !important;
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.65),
    0 4px 10px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* ── Image modal ───────────────────────────────────────────────────────── */

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 8, 19, 0.85);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 1.5rem;
}

.image-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.image-modal img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 0.75rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
  transform: scale(0.92);
  transition: transform 0.3s ease;
}

.image-modal.open img {
  transform: scale(1);
}

.image-modal-close {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 2; /* above the image, which has transform → stacking context */
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: rgba(20, 24, 40, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
  font-family: -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  padding: 0 0 2px 0;
  user-select: none;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.image-modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

.collage-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.collage-ph-label {
  color: rgba(255, 255, 255, 0.32);
  font-family: "Helvetica Neue", system-ui, sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  user-select: none;
}

.hero::before,
.hero::after {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  height: 25dvh;
  pointer-events: none;
  z-index: -1;
}

.hero::before {
  top: 0;
  background: linear-gradient(to bottom, rgba(5, 8, 19, 0.7), rgba(5, 8, 19, 0));
}

.hero::after {
  bottom: 0;
  background: linear-gradient(to top, rgba(5, 8, 19, 0.75), rgba(5, 8, 19, 0));
}

.eyebrow {
  position: fixed;
  top: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  white-space: nowrap;
  font-size: 0.95rem;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-family: "Helvetica Neue", system-ui, sans-serif;
  font-weight: 300;
  pointer-events: none;
  text-align: center;
  line-height: 2em;
}

.eyebrow .eyebrow-sep {
  color: var(--accent);
  margin: 0 0.5rem;
}

#days-counter {
  /* Tabular numerals so the day count doesn't shift width as it ticks up */
  font-variant-numeric: tabular-nums;
}

.hero-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.message {
  font-size: clamp(1.6rem, 3.5vw, 2.4rem);
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0.01em;
  max-width: 36rem;
  color: var(--ink);
  text-shadow: 0 2px 24px rgba(5, 8, 19, 0.6);
}

.phase-info {
  font-family: "Helvetica Neue", system-ui, sans-serif;
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.phase-info .dot {
  margin: 0 0.6rem;
  color: var(--accent);
}

/* Desktop / mobile variants — only one is visible at a time. Breakpoint
   matches config.mobileBreakpoint (768px) used by the JS. */
.phase-info.mobile  { display: none; }
.phase-info.desktop { display: block; }

@media (max-width: 767px) {
  .phase-info.mobile  { display: block; }
  .phase-info.desktop { display: none; }
}

/* ── Scroll hint ──────────────────────────────────────────────────────────
   Two icons layered in the same fixed-position container. Chevron is the
   default; heart appears on the last timeline node. JS toggles `.at-last`
   on the container, and CSS does the rest (icon crossfade + scale, plus
   a swap from the bounce keyframe to a heartbeat keyframe). */
.scroll-hint {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  z-index: 4;
  pointer-events: none;
  color: var(--ink-soft);
  width: 1.7rem;
  height: 1.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: scroll-hint-bounce 2.4s ease-in-out infinite;
}

.scroll-hint .hint-chevron,
.scroll-hint .hint-heart {
  position: absolute;
  display: block;
  filter: drop-shadow(0 2px 6px rgba(5, 8, 19, 0.6));
  transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.scroll-hint .hint-chevron {
  width: 1.6rem;
  height: 0.85rem;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  opacity: 1;
  transform: scale(1);
}

.scroll-hint .hint-heart {
  width: 1.4rem;
  height: 1.4rem;
  fill: #e15c7c; /* warm pink, slightly stronger than ink-soft */
  stroke: none;
  opacity: 0;
  transform: scale(0.55);
}

.scroll-hint.at-last {
  animation: scroll-hint-heartbeat 1.4s ease-in-out infinite;
}

.scroll-hint.at-last .hint-chevron {
  opacity: 0;
  transform: scale(0.6);
}

.scroll-hint.at-last .hint-heart {
  opacity: 1;
  transform: scale(1);
}

@keyframes scroll-hint-bounce {
  0%, 100% { transform: translate(-50%, 0); }
  50%      { transform: translate(-50%, 6px); }
}

@keyframes scroll-hint-heartbeat {
  0%, 100% { transform: translate(-50%, 0) scale(1); }
  18%      { transform: translate(-50%, 0) scale(1.18); }
  36%      { transform: translate(-50%, 0) scale(1); }
  54%      { transform: translate(-50%, 0) scale(1.10); }
  72%      { transform: translate(-50%, 0) scale(1); }
}
