/* Hero: a total solar eclipse that emerges slowly from darkness (hero.js draws
   it in WebGL; the CSS eclipse below is the fallback and the layout anchor).
   The copy fades in with CSS only, so it appears even if the script fails. */
:root {
  /* Gentle onset, long tail: the light, the copy and the nav must never pop in. */
  --hero-ease: cubic-bezier(0.4, 0, 0.5, 1);
}
.hero {
  --ecl-r: clamp(120px, 35vmin, 400px);   /* moon radius: the ring frames the copy */
  --ecl-y: 50%;                            /* eclipse centre, from the top of the hero */
  position: relative;
  isolation: isolate;
  height: 100vh;
  height: 100svh;
  min-height: 340px;
  overflow: hidden;
  overflow: clip;
  background: var(--bg);
}
@media (max-aspect-ratio: 4/5) {
  .hero { --ecl-r: clamp(120px, 42vmin, 300px); --ecl-y: 48%; }
}

.hero-sky { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.hero-canvas { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; opacity: 0; }
.hero.has-gl .hero-canvas { opacity: 1; }
.hero.has-gl .hero-eclipse { visibility: hidden; }

/* ---------- CSS eclipse (fallback when WebGL is unavailable) ---------- */
.hero-eclipse {
  position: absolute; left: 50%; top: var(--ecl-y);
  width: calc(var(--ecl-r) * 2); height: calc(var(--ecl-r) * 2);
  translate: -50% -50%;
  border-radius: 50%;
  opacity: var(--hero-light, 1);
  animation: hero-dawn 7.85s var(--hero-ease) 0.15s backwards;
}
/* Corona, rim and moon in one layer: the moon limb sits at 1 / 3.4 of the radius. */
.hero-eclipse::before {
  content: ""; position: absolute; inset: calc(var(--ecl-r) * -2.4);
  rotate: -14deg;
  background:
    radial-gradient(circle closest-side,
      #040405 0, #040405 29.3%,
      #ffefc4 29.44%, rgba(240, 199, 94, 0.62) 29.62%,
      rgba(220, 166, 45, 0.32) 30.3%, rgba(220, 166, 45, 0.15) 33%,
      rgba(190, 135, 35, 0.07) 39%, rgba(168, 118, 26, 0.025) 50%, transparent 70%),
    radial-gradient(ellipse 46% 15% at 50% 50%, rgba(220, 166, 45, 0.13), rgba(168, 118, 26, 0.04) 55%, transparent 100%);
}
/* Diamond-ring glint on the upper right of the rim (38 degrees), with a fine sparkle. */
.hero-eclipse::after {
  content: ""; position: absolute;
  left: calc(50% + var(--ecl-r) * 0.788); top: calc(50% - var(--ecl-r) * 0.616);
  width: calc(var(--ecl-r) * 0.44); height: calc(var(--ecl-r) * 0.44);
  translate: -50% -50%;
  background:
    radial-gradient(circle closest-side, #fff 0, #fff3d6 5%, rgba(240, 199, 94, 0.4) 13%, rgba(220, 166, 45, 0.08) 34%, transparent 60%),
    linear-gradient(90deg, transparent, var(--pop), transparent) center / 100% 1px no-repeat,
    linear-gradient(transparent, var(--pop), transparent) center / 1px 100% no-repeat;
}
/* The light never reaches the foot of the hero: the next section starts dark. */
.hero-sky::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 16%;
  background: linear-gradient(to top, var(--bg), transparent);
}
@keyframes hero-dawn { from { opacity: 0; } }

/* ---------- Copy ---------- */
.hero-copy {
  position: absolute; left: 50%; top: var(--ecl-y);
  translate: -50% -50%;
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  opacity: var(--hero-copy, 1);
}
.hero-eyebrow, .hero-line, .hero-cta {
  animation: hero-rise 3.6s var(--hero-ease) backwards;
}
.hero-eyebrow {
  margin: 0 0 calc(var(--ecl-r) * 0.075);
  padding-left: var(--tracking-wide);       /* balances the trailing letter-space */
  animation-delay: 2.4s;
}
.hero-title {
  margin: 0;
  font-size: calc(var(--ecl-r) * 0.215);
  font-weight: 300;
  line-height: 1.08;
  letter-spacing: -0.012em;
}
.hero-line { display: block; white-space: nowrap; animation-delay: 3s; }
.hero-line-gold {
  font-weight: 600;
  padding-bottom: 0.12em; margin-bottom: -0.12em;   /* room for descenders under the clipped gradient */
  background: var(--gold-gradient); -webkit-background-clip: text; background-clip: text; color: transparent;
  animation-delay: 3.8s;
}
.hero-cta {
  margin-top: calc(var(--ecl-r) * 0.13);
  min-height: 42px; padding: 0 20px 0 24px; gap: 8px;
  font-size: 14px;
  animation-delay: 5s;
}
.hero-cta svg { animation: hero-nudge 3.6s ease-in-out 10s infinite; }

@keyframes hero-rise { from { opacity: 0; translate: 0 12px; filter: blur(5px); } }
@keyframes hero-nudge { 0%, 55%, 100% { translate: 0 0; } 78% { translate: 0 3px; } }

/* ---------- Nav (home page only) ----------
   The page opens from pure darkness, so the nav arrives with the first light
   instead of being lit from the first frame. Only its opacity is animated: it
   can be clicked and tabbed to throughout. */
body:has(.hero) .nav { animation: hero-dawn 3.6s var(--hero-ease) 0.4s backwards; }

/* Keyboard focus never lands on something still invisible: a focused control
   shows at once. The animation keeps running underneath (taking it away would
   start it again on blur), which is why these need !important to outrank it. */
.hero-cta:focus-visible { opacity: 1 !important; translate: none !important; filter: none !important; }
body:has(.hero) .nav:has(:focus-visible) { opacity: 1 !important; }

/* hero.js sets .is-waiting whenever the hero cannot be seen (tab in the
   background, page opened at an anchor further down, scrolled past): the reveal
   holds, in step with the shader's clock, so it is never missed. */
.hero.is-waiting .hero-eclipse,
.hero.is-waiting .hero-eyebrow,
.hero.is-waiting .hero-line,
.hero.is-waiting .hero-cta,
.hero.is-waiting .hero-cta svg { animation-play-state: paused; }

/* Reduced motion: the final state at once, nothing moving. (base.css shortens
   durations but keeps delays, so the animations are removed here.) */
@media (prefers-reduced-motion: reduce) {
  .hero-eclipse, .hero-eyebrow, .hero-line, .hero-cta, .hero-cta svg { animation: none; }
  body:has(.hero) .nav { animation: none; }   /* its own rule: a browser without :has drops only this one */
}
