/* ==========================================================================
   Motion. Everything here is decorative and switched off for visitors who
   prefer reduced motion. Content is always visible without JavaScript.
   ========================================================================== */

@keyframes meridian-fall {
  0% { transform: translateY(-110%); opacity: 0; }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translateY(260%); opacity: 0; }
}
@keyframes cue {
  0% { top: -40%; }
  100% { top: 110%; }
}
@keyframes book-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-16px); }
}
@keyframes book-shadow {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(0.88); opacity: 0.6; }
}
@keyframes halo-breathe {
  0%, 100% { opacity: 0.85; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
}
@keyframes marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
@keyframes spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}
@keyframes twinkle {
  0%, 100% { opacity: 1; transform: scale(1) rotate(0deg); }
  50% { opacity: 0.55; transform: scale(0.82) rotate(45deg); }
}
@keyframes drift {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-14px) rotate(-1.5deg); }
}
@keyframes nebula-drift-a {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(6vw, 4vh, 0) scale(1.08); }
}
@keyframes nebula-drift-b {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1.05); }
  50% { transform: translate3d(-5vw, -6vh, 0) scale(0.96); }
}
@keyframes gold-shimmer {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}
@keyframes rise-in {
  from { opacity: 0; transform: translateY(26px); filter: blur(6px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}
@keyframes title-in {
  from { opacity: 0; letter-spacing: 0.32em; filter: blur(14px); }
  to { opacity: 1; letter-spacing: 0.02em; filter: blur(0); }
}
@keyframes rule-in {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}
@keyframes book-arrive {
  from { opacity: 0; transform: translateY(40px) scale(0.94); }
  to { opacity: 1; transform: none; }
}

/* Ambient drift of the background nebulae */
.cosmos__nebula--a { animation: nebula-drift-a 46s var(--ease-in-out) infinite; }
.cosmos__nebula--b { animation: nebula-drift-b 58s var(--ease-in-out) infinite; }
.cosmos__nebula--c { animation: nebula-drift-a 64s var(--ease-in-out) infinite reverse; }

/* Slow golden shimmer on the main title */
.hero__title {
  background-image: linear-gradient(100deg, #a98250 0%, #d9b77e 18%, #fff1d6 30%, #f2d5a8 42%, #d9b77e 60%, #fff1d6 78%, #a98250 100%);
  background-size: 200% 100%;
  animation: gold-shimmer 14s linear infinite;
}

/* ---------- Hero entrance (only when JS is running) ---------- */
.js .hero [data-hero] { opacity: 0; }
.js.is-loaded .hero [data-hero] { animation: rise-in 1.3s var(--ease-out) forwards; animation-delay: var(--d, 0ms); }
.js .hero__title { opacity: 0; }
.js.is-loaded .hero__title { animation: title-in 2.2s var(--ease-out) 0.15s forwards, gold-shimmer 14s linear infinite; }
.js .hero__rule { transform: scaleX(0); }
.js.is-loaded .hero__rule { animation: rule-in 1.6s var(--ease-out) 0.7s forwards; }
.js .hero__book { opacity: 0; }
.js.is-loaded .hero__book { animation: book-arrive 1.8s var(--ease-out) 0.35s forwards; }

/* ---------- Scroll reveals ---------- */
.js [data-reveal] {
  opacity: 0;
  transform: translateY(34px);
  transition: opacity 1.1s var(--ease-out), transform 1.1s var(--ease-out), filter 1.1s var(--ease-out);
  transition-delay: var(--d, 0ms);
}
.js [data-reveal="fade"] { transform: none; }
.js [data-reveal="scale"] { transform: scale(0.94); }
.js [data-reveal="left"] { transform: translateX(-40px); }
.js [data-reveal="right"] { transform: translateX(40px); }
.js [data-reveal="blur"] { transform: translateY(16px); filter: blur(10px); }
.js [data-reveal].is-visible { opacity: 1; transform: none; filter: none; }

/* Parallax layers (offset set by animations.js) */
[data-parallax] { transform: translate3d(0, var(--py, 0px), 0); will-change: transform; }

/* Word-by-word heading reveals */
.split-word { display: inline-block; overflow: hidden; vertical-align: top; padding: 0 0.08em 0.1em 0; margin: 0 -0.08em -0.1em 0; }
.split-word__inner { display: inline-block; }
.split-word__inner.is-gold { background: var(--gold-text); -webkit-background-clip: text; background-clip: text; color: transparent; }
.has-split-gold { background: none !important; }
.js [data-split] .split-word__inner {
  transform: translateY(105%);
  opacity: 0;
  transition: transform 1.2s var(--ease-out), opacity 1.2s var(--ease-out);
  transition-delay: calc(var(--wi) * 55ms + var(--d, 0ms));
}
.js [data-split].is-visible .split-word__inner { transform: none; opacity: 1; }

/* Staggered children */
.js [data-stagger] > * {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 1s var(--ease-out), transform 1s var(--ease-out);
}
.js [data-stagger].is-visible > * { opacity: 1; transform: none; }
.js [data-stagger].is-visible > *:nth-child(1) { transition-delay: 0ms; }
.js [data-stagger].is-visible > *:nth-child(2) { transition-delay: 90ms; }
.js [data-stagger].is-visible > *:nth-child(3) { transition-delay: 180ms; }
.js [data-stagger].is-visible > *:nth-child(4) { transition-delay: 270ms; }
.js [data-stagger].is-visible > *:nth-child(5) { transition-delay: 360ms; }
.js [data-stagger].is-visible > *:nth-child(6) { transition-delay: 450ms; }
.js [data-stagger].is-visible > *:nth-child(7) { transition-delay: 540ms; }
.js [data-stagger].is-visible > *:nth-child(8) { transition-delay: 630ms; }

/* Image arrival */
.js [data-reveal="image"] { opacity: 0; transform: scale(1.06); clip-path: inset(8% 8% 8% 8%); transition: opacity 1.4s var(--ease-out), transform 1.6s var(--ease-out), clip-path 1.6s var(--ease-out); }
.js [data-reveal="image"].is-visible { opacity: 1; transform: none; clip-path: inset(0 0 0 0); }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    transition-delay: 0ms !important;
  }
  .js [data-reveal],
  .js [data-split] .split-word__inner,
  .js [data-stagger] > *,
  .js .hero [data-hero],
  .js .hero__title,
  .js .hero__book { opacity: 1 !important; transform: none !important; filter: none !important; clip-path: none !important; }
  .js .hero__rule { transform: none !important; }
  .marquee__track { animation: none !important; flex-wrap: wrap; width: auto; justify-content: center; }
  .marquee__group[aria-hidden="true"] { display: none; }
  .book3d__float, .book3d__shadow, .book3d__halo { animation: none !important; }
}
