/* =====================================================================
 * design/hero.css — scoped stylesheet for the P2 hero scene, now
 * repurposed as the SITE-WIDE background layer.
 *
 * WHY THIS FILE EXISTS
 *   Originally .hero-bg was an absolutely-positioned layer scoped to
 *   the .hero grid track on index.html. It has since been promoted to a
 *   fixed, full-viewport backdrop that lives at BODY level on every page
 *   (index, vetlock, docsforge, telemetry-sdk-patterns), so the same
 *   dependency-graph poster + animated canvas sit behind every route.
 *   The panels / cards / hero copy stay opaque and the graph reads
 *   through the gaps between them.
 *
 *     • .hero-bg      — a fixed-position background layer that stacks a
 *                       static poster SVG under an animated canvas, both
 *                       filling the viewport.
 *     • .hero-poster  — the always-present static SVG (the LCP element
 *                       per ADR 0003; ships whether or not JS runs).
 *     • .hero-canvas  — the enhancement layer that fades in once
 *                       hero.js has committed to running the scene, and
 *                       fades back out if the runtime watchdog trips.
 *
 * TOKEN DISCIPLINE
 *   Every value on the right of a colon resolves through var(--*). No
 *   hardcoded colors, spacing, radii, or durations. The
 *   scripts/no-hardcoded-colors.mjs gate will reject this file if it
 *   drifts. Add new values to tokens.css first.
 *
 * STATE MODEL
 *   Baseline (no JS, no state attribute): poster visible, canvas hidden.
 *   Once hero.js has passed every F.1–F.3 check AND painted its first
 *   frame, it flips the hero into the "running" state via either
 *     • data-hero-state="running" on .hero-bg
 *     • .is-canvas-ready class on .hero-bg
 *   In "running" the canvas fades up and the poster fades to zero
 *   opacity while remaining in the layout — LCP-captured paint stays
 *   stable, and a mid-run degradation can restore the poster instantly.
 * ===================================================================== */


/* =====================================================================
 * 1) HERO COPY / CONSOLE STACKING
 * ---------------------------------------------------------------------
 * .hero-bg is now body-level and fixed to the viewport (see §2). It sits
 * at z-index: -1 so ordinary flow content stacks above it by default —
 * no positioning gymnastics required on cards, main, footer, etc.
 * The .hero-copy / .hero > .console rules from the pre-move geometry
 * remain harmless: they still promote those children into their own
 * stacking layer above whatever body content sits behind.
 * ===================================================================== */
.hero > .hero-copy,
.hero > .console {
  position: relative;
  z-index: 1;
}


/* =====================================================================
 * 2) HERO BACKGROUND LAYER — fixed, full viewport.
 * ---------------------------------------------------------------------
 * .hero-bg wraps the poster SVG and the canvas. It's a fixed layer
 * pinned to the viewport so the same graph shows behind every page as
 * the user scrolls, and the LCP paint stays anchored regardless of
 * where the section is placed in the document.
 * pointer-events: none lets clicks pass through to whatever content
 * sits above. hero.js listens on document/window for pointermove so
 * the scene still reacts to the cursor. overflow: hidden clips
 * sweep-ring overshoot at edges.
 * ===================================================================== */
.hero-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}


/* =====================================================================
 * 3) POSTER + CANVAS — shared positioning, opacity-driven cross-fade.
 * ---------------------------------------------------------------------
 * Both children fill .hero-bg identically and cross-fade via opacity.
 * Kept in the layout at all times (no display:none, no visibility:hidden)
 * so LCP paint stays stable and the watchdog can restore the poster
 * instantly by flipping the state attribute back to "poster".
 * ===================================================================== */
.hero-poster,
.hero-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /* --dur-slow feels intentional, not jarring. Reduced-motion collapses
     it to ~0ms via tokens.css, so a11y users get an instant swap. */
  transition: opacity var(--dur-slow) var(--ease-standard);
}

/* Baseline: poster visible, canvas invisible. This is the state the
   page renders in with JS off, or before hero.js has run. */
.hero-poster { opacity: 1; }
.hero-canvas { opacity: 0; }


/* =====================================================================
 * 4) STATE: RUNNING — canvas fades in, poster fades out.
 * ---------------------------------------------------------------------
 * Expressed via BOTH a data attribute (data-hero-state="running") and a
 * class (.is-canvas-ready) so whichever the runtime uses lights up the
 * same rules. Selectors match either .hero-bg or the .hero section so
 * hero.js can flip the flag on whichever element is convenient.
 * ===================================================================== */
.hero-bg[data-hero-state="running"] .hero-canvas,
.hero[data-hero-state="running"] .hero-canvas,
.hero-bg.is-canvas-ready .hero-canvas {
  opacity: 1;
}

.hero-bg[data-hero-state="running"] .hero-poster,
.hero[data-hero-state="running"] .hero-poster,
.hero-bg.is-canvas-ready .hero-poster {
  opacity: 0;
}

/* Explicit "poster" state is a no-op relative to the baseline, but
   naming it makes hero.js legible: setState('poster') vs setState('running'). */
.hero-bg[data-hero-state="poster"] .hero-canvas,
.hero[data-hero-state="poster"] .hero-canvas {
  opacity: 0;
}


/* =====================================================================
 * 5) REDUCED-MOTION — no cross-fade, just instant state.
 * ---------------------------------------------------------------------
 * tokens.css already collapses --dur-* to ~0ms under
 * prefers-reduced-motion. This block is defensive — it kills the
 * transition outright so no user agent that ignores the token override
 * can animate the fade against the user's preference.
 * ===================================================================== */
@media (prefers-reduced-motion: reduce) {
  .hero-poster,
  .hero-canvas {
    transition: none;
  }
}


/* =====================================================================
 * 6) SITE-WIDE SCRIM
 * ---------------------------------------------------------------------
 * With .hero-bg now covering the full viewport across every page, the
 * old left-to-right scrim (which faded the LEFT 38% down to --color-bg
 * to protect the hero copy column) no longer maps to anything
 * meaningful. Replace it with two composited layers:
 *
 *   • ::before — a subtle page-wide veil in --color-bg at ~35% opacity.
 *     Establishes a floor of legibility for text that sits above the
 *     graph without hiding the texture entirely; the graph still reads
 *     through in the gaps between cards / sections / footer.
 *
 *   • ::after — a radial dim centered near the top-left (30% 20%) that
 *     fades from --color-bg 82% at center to transparent at ~45% radius.
 *     Dims the poster around the top-of-page zone where the nav + hero
 *     copy live, so the H1/lede/CTAs stay high-contrast without needing
 *     a solid backdrop on the hero copy column.
 *
 * Stacking: .hero-bg lives at z-index: -1 relative to body. Its ::before
 * / ::after both use position: absolute; inset: 0 so they compose over
 * the poster + canvas siblings but stay contained in the fixed layer.
 * ===================================================================== */
.hero-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: color-mix(in srgb, var(--color-bg) 35%, transparent);
  z-index: 0;
}

.hero-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(
      ellipse 60% 40% at 30% 20%,
      color-mix(in srgb, var(--color-bg) 82%, transparent) 0%,
      color-mix(in srgb, var(--color-bg) 40%, transparent) 60%,
      transparent 100%
    );
  z-index: 1;
}

@media (max-width: 900px) {
  /* Mobile: text sits in a narrower single column and hugs the top of
     the viewport, so dim more aggressively and center the radial higher
     (30% 15%). Wider veil radius (50%) so the whole H1/lede band stays
     legible without hiding the graph entirely lower down. */
  .hero-bg::after {
    background:
      radial-gradient(
        ellipse 70% 45% at 30% 15%,
        color-mix(in srgb, var(--color-bg) 85%, transparent) 0%,
        color-mix(in srgb, var(--color-bg) 60%, transparent) 50%,
        transparent 100%
      );
  }
}


/* =====================================================================
 * 7) .sr-only — screen-reader-only text primitive.
 * ---------------------------------------------------------------------
 * primitives.css ships .visually-hidden with the same effect, but the
 * hero spec §G.2 explicitly names .sr-only for the accessibility
 * clarifier inside .hero-copy. We ship both names so either can be used
 * without renaming. Standard clip-based pattern; keeps the element in
 * the a11y tree while removing it from visual layout.
 * ===================================================================== */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
