/* --- Intro overlay --- */
#intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 10001;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  will-change: transform;
}

/* Lock scroll while overlay is present */
body:has(#intro-overlay) { overflow: hidden; }

.intro-letters {
  display: flex;
  gap: 0.06em;
  font-family: var(--serif);
  font-size: clamp(64px, 12vw, 128px);
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--fg);
  font-style: italic;
}

.intro-letters span {
  display: inline-block;
  opacity: 0;
  transform: translateY(22px);
  animation: introLetterIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes introLetterIn {
  to { opacity: 1; transform: translateY(0); }
}

/* Panel wipe up on outro */
#intro-overlay.outro {
  animation: introWipeUp 0.7s cubic-bezier(0.76, 0, 0.24, 1) forwards;
}

@keyframes introWipeUp {
  to { transform: translateY(-100%); }
}

/* --- Hero h1 stagger (first visit only, synced with intro outro) ---
   The overlay wipes upward: hero (top of page) is uncovered last,
   around 1.5-1.8s. Animations start mid-flight for a dramatic reveal. */
html.intro-running .hero-col-text h1 {
  animation: none;
  opacity: 1;
  transform: none;
}

html.intro-running .hero-col-text h1 .hero-fn {
  opacity: 0;
  animation: fadeUp 0.8s 1.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

html.intro-running .hero-col-text h1 em {
  opacity: 0;
  animation: fadeUp 0.8s 1.65s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  #intro-overlay { display: none !important; }
  html.intro-running .hero-col-text h1 { animation: none; opacity: 1; transform: none; }
  html.intro-running .hero-col-text h1 .hero-fn { animation: none; opacity: 1; }
  html.intro-running .hero-col-text h1 em { animation: none; opacity: 1; }
}
