/* =============================================================
   Commons World — hero3d.css
   The homepage hero as a contained photoreal NASA Earth (night →
   day on scroll; camera fixed). The WebGL <canvas> is CONFINED to
   the hero — a full-bleed stage behind the copy — not a page-wide
   layer; the rest of the site stays a normal stacked 2D page.
   When the engine boots the hero goes navy and the copy switches
   to light-on-dark. Progressive enhancement: if it never boots
   (no-JS, no-WebGL, reduced-motion, mobile) the original cream
   poster hero stays intact. Loaded on the front page only.
   ============================================================= */

/* The Earth canvas stage: a full-bleed layer confined to the hero, behind the
   copy. Lives in the hero markup ([data-cw-hero3d]); EarthHero appends its
   <canvas> here. Hidden until the engine boots (.cw-hero[data-hero3d-active]), so
   the static poster fallback is untouched. Background matches the engine clear
   colour so first paint is seamless. */
.cw-hero__stage {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1200ms ease;
  background: #142844; /* brand-navy void — matches the renderer clear colour */
}
.cw-hero3d__canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.cw-hero[data-hero3d-active] .cw-hero__stage {
  opacity: 1;
}

/* ---- Scroll runway + sticky stage (active only) ---- */
/* The runway is inert until the engine boots; then it becomes a 200vh scroll
   track and the hero sticks for its first 100vh, giving the night→day sunrise
   scrub its distance (plan §8). ScrollTrigger reads progress 0→1 across the
   runway and sweeps the sun. :has() scopes this to the enhanced state, so the
   reduced-motion / no-JS / mobile fallback keeps the hero a normal stacked
   section in flow. */
.cw-hero-runway:has(.cw-hero[data-hero3d-active]) {
  height: 200vh;
}
.cw-hero[data-hero3d-active] {
  position: sticky;
  top: 0;
  height: 100vh;
  min-height: 100vh;
}

/* Smooth the cream → navy / dark-text → light-text flip. */
.cw-hero {
  transition: background-color 900ms ease;
}
.cw-hero__title,
.cw-hero__sub,
.cw-eyebrow,
.cw-hero__principle-lead,
.cw-hero__principle-text,
.cw-link-arrow {
  transition: color 900ms ease;
}

/* ---- Active: transparent hero over the Earth stage, light copy ---- */
/* The hero background goes transparent so the .cw-hero__stage canvas shows
   through it; a hero-local scrim keeps the copy legible. */
.cw-hero[data-hero3d-active] {
  background: transparent;
}
/* Legibility scrim over the world, behind the hero copy (hero-local, so it never
   tints the rest of the page). .cw-hero is position:relative; overflow:hidden. */
.cw-hero[data-hero3d-active]::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  /* Darken the copy side (left) so the type stays legible, plus a soft vignette. */
  background: linear-gradient(
      96deg,
      #07111f 0%,
      rgba(7, 17, 31, 0.86) 22%,
      rgba(7, 17, 31, 0.28) 48%,
      transparent 64%
    ),
    radial-gradient(
      120% 120% at 68% 46%,
      transparent 44%,
      rgba(7, 17, 31, 0.5) 100%
    );
}
@media (max-width: 1023px) {
  .cw-hero[data-hero3d-active]::after {
    /* Copy stacks below the world on mobile — darken the lower band instead. */
    background: linear-gradient(
        180deg,
        rgba(7, 17, 31, 0.4) 0%,
        transparent 26%,
        transparent 50%,
        rgba(7, 17, 31, 0.88) 88%
      ),
      radial-gradient(
        120% 80% at 50% 38%,
        transparent 50%,
        rgba(7, 17, 31, 0.5) 100%
      );
  }
}
.cw-hero[data-hero3d-active] .cw-hero__inner {
  position: relative;
  z-index: 2;
}

.cw-hero[data-hero3d-active] .cw-eyebrow {
  color: var(--cw-gold-light);
}
.cw-hero[data-hero3d-active] .cw-hero__title {
  color: var(--cw-on-dark);
  text-shadow: 0 1px 2px rgba(7, 17, 31, 0.55), 0 2px 34px rgba(7, 17, 31, 0.72);
}
.cw-hero[data-hero3d-active] .cw-hero__sub {
  color: rgba(245, 240, 232, 0.86);
  text-shadow: 0 1px 16px rgba(7, 17, 31, 0.62);
}
.cw-hero[data-hero3d-active] .cw-hero__principle-lead {
  color: rgba(245, 240, 232, 0.66);
}
.cw-hero[data-hero3d-active] .cw-hero__principle-text {
  color: var(--cw-on-dark);
}
.cw-hero[data-hero3d-active] .cw-hero__principle-em {
  color: var(--cw-gold-light);
}
.cw-hero[data-hero3d-active] .cw-link-arrow {
  color: var(--cw-on-dark);
}

/* Retire the static poster (kept in flow so layout never shifts). */
.cw-hero[data-hero3d-active] .cw-hero__lens {
  opacity: 0;
  transition: opacity 1200ms ease;
}
.cw-hero[data-hero3d-active] .cw-hero__art::before {
  opacity: 0;
}

/* ---- Display typeface: Fraunces — homepage hero headline.
   @font-face declarations live in base.css (site-wide); only
   the hero-specific optical size, weight, and variation settings
   are set here. ---- */
.cw-hero--lens .cw-hero__title {
  font-family: var(--cw-font-heading);
  font-weight: 370;
  font-variation-settings: "opsz" 144;
  font-size: clamp(3.2rem, 5.6vw, 5.6rem);
  line-height: 1;
  letter-spacing: -0.018em;
  max-width: 14ch;
  text-wrap: balance;
}
.cw-hero--lens .cw-hero__title .cw-ht-em,
.cw-hero--lens .cw-hero__title em {
  font-style: italic;
  font-weight: 340;
}
.cw-hero__title .cw-ht-word {
  display: inline-block;
}
.cw-hero__title .cw-ht-ink {
  display: inline-block;
  will-change: transform, opacity, filter;
}

/* Reduced-motion: never show the Earth stage; keep the cream poster hero.
   Defensive — main.js also never boots or sets data-hero3d-active in this case. */
@media (prefers-reduced-motion: reduce) {
  .cw-hero__stage {
    display: none !important;
  }
  .cw-hero[data-hero3d-active] {
    background: linear-gradient(
      180deg,
      var(--cw-cream-light) 0%,
      var(--cw-cream) 100%
    ) !important;
  }
  .cw-hero[data-hero3d-active]::after {
    display: none !important;
  }
  .cw-hero[data-hero3d-active] .cw-hero__lens {
    opacity: 1 !important;
  }
  .cw-hero[data-hero3d-active] .cw-hero__art::before {
    opacity: 1 !important;
  }
}
