/* =========================================================
   Hero Instrument module — the shared hero family.
   Self-contained on purpose (spec §1): rails work must not
   shift this file. Depends only on :root tokens in styles.css.

   Contract: CSS authors the FINISHED state. hero-instrument.js
   rewinds to the initial state and plays the boot; without JS,
   with a failed CDN, under prefers-reduced-motion, or below
   920px, the finished frame is what renders.
   ========================================================= */

.hero-family {
  /* motion tokens — single source for every vignette (plan: "Motion tokens") */
  --hi-ease-enter: cubic-bezier(0.22, 1, 0.36, 1);
  --hi-ease-resp: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --hi-dur-resp: 150ms;
  --hi-dur-arrive: 500ms;
  --hi-beat: 1100ms;
  --hi-pulse: 2400ms;

  background:
    radial-gradient(56% 48% at 82% 10%, rgba(13, 61, 107, 0.05), transparent 70%),
    radial-gradient(40% 42% at 8% 88%, rgba(13, 61, 107, 0.04), transparent 70%),
    var(--paper-2);
  border-bottom: 1px solid var(--line);
  padding-block: clamp(46px, 5vw, 74px) clamp(40px, 4.2vw, 62px);
}

.hf-grid {
  display: grid;
  grid-template-columns: 1fr 1fr; /* 50/50 locked (spec §1) */
  gap: clamp(32px, 4vw, 64px);
  align-items: center;
}

/* Copy column — page copy is verbatim; only its ground changed from dark
   to paper, so the on-dark treatments get their light-ground equivalents. */
.hf-copy .eyebrow { color: var(--blue); }
.hf-copy h1 { color: var(--ink); max-width: 15ch; }
.hf-copy h1 .hl { color: var(--blue); }
.hf-copy .lead { color: var(--ink-2); max-width: 54ch; }
.hf-ctas { margin-top: 28px; }

/* ---------- The instrument panel ---------- */
.hi-panel {
  position: relative;
  border-radius: var(--r-lg);
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 34px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 34px),
    linear-gradient(160deg, var(--navy-800), var(--navy-700));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 1px 2px rgba(11, 33, 54, 0.05),
    0 18px 38px -22px rgba(11, 33, 54, 0.4);
  padding: 18px 22px 20px;
  min-height: clamp(300px, 30vw, 400px);
  display: flex;
  flex-direction: column;
  will-change: transform;
}

/* Chrome strip — dots + mono address + status chip (top-right per plan) */
.hi-chrome {
  display: flex;
  align-items: center;
  gap: 7px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.hi-chrome i {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
}
.hi-url {
  margin-left: 6px;
  font-family: var(--f-mono);
  font-size: 0.625rem;
  letter-spacing: 0.08em;
  color: var(--label-on-dark);
}
.hi-status {
  margin-left: auto;
  position: relative;
  font-family: var(--f-mono);
  font-size: 0.625rem;
  letter-spacing: 0.1em;
  white-space: nowrap;
}
/* two stacked states crossfade — never tween a color through mud (craft bar #8) */
.hi-status span { display: flex; align-items: center; gap: 6px; }
.hi-status .hi-st-off { color: var(--muted-2); opacity: 0; position: absolute; inset: 0; }
.hi-status .hi-st-on { color: var(--accent-lite); opacity: 1; }
.hi-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-lite);
  animation: hi-pulse var(--hi-pulse) var(--hi-ease-resp) infinite;
  animation-play-state: paused; /* gateIdle() runs it in view (spec §6: idles gated) */
}
.hi-status .hi-st-off .hi-dot { background: var(--muted-2); animation: none; }
.anim-live .hi-dot { animation-play-state: running; }

@keyframes hi-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.7; }
}

/* Stage — the vignette lives here */
.hi-stage { flex: 1; display: flex; align-items: center; }
.hi-stage svg { width: 100%; height: auto; display: block; }

/* SVG vocabulary shared by all vignettes: one stroke width (craft bar #10),
   dim = the "before" layer, lit = the "after" layer. Final state: lit shows. */
.hi-stage text {
  font-family: var(--f-mono);
  letter-spacing: 0.08em;
  fill: var(--label-on-dark);
}
.hi-stage .dim { opacity: 0; }
.hi-stage .lit { opacity: 1; }

/* Foot — plain-language readout, the focal element (spec §2 focal-readout rule) */
.hi-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}
.hi-readout { display: flex; flex-direction: column; gap: 4px; }
.hi-ro-main {
  font-family: var(--f-display);
  font-weight: 600;
  font-size: clamp(1.05rem, 1.4vw, 1.375rem);
  letter-spacing: -0.01em;
  color: var(--ink-on-dark);
}
.hi-ro-sub {
  font-family: var(--f-mono);
  font-size: 0.625rem;
  letter-spacing: 0.1em;
  color: var(--label-on-dark);
  text-transform: uppercase;
}

/* ---------- Responsive: single column, panel after copy, idle-only ---------- */
@media (max-width: 920px) {
  .hf-grid { grid-template-columns: 1fr; }
  .hi-panel { min-height: 260px; }
}

/* ============================================================
   v2 — full-bleed hero scenes (index hero DNA).
   Everything above serves the 4 pages still on retired v1.
   Default state = FINISHED art: the value proposition reads on
   first paint; animations only replay the ignition. Reduced
   motion / no-JS / CDN failure all land on the finished frame.
   ============================================================ */
.hero-scene .scene-art { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: .95; }

/* draw-in (once, fast — story complete ~1.5s) */
.hero-scene .tr-flat, .hero-scene .tr-pulse { stroke-dasharray: 100 100; stroke-dashoffset: 0; }
.hero-scene .tr-flat { animation: scene-draw .35s ease-out .25s backwards; }
.hero-scene .tr-pulse { animation: scene-draw .9s cubic-bezier(0.25, 0.46, 0.45, 0.94) .55s backwards; }
.hero-scene .tr-ghost { animation: scene-fade .6s ease-out .15s backwards; }
.hero-scene .live { animation: scene-live .45s cubic-bezier(0.22, 1, 0.36, 1) 1.3s backwards; }
@keyframes scene-draw { from { stroke-dashoffset: 100; } }
@keyframes scene-fade { from { opacity: 0; } }
@keyframes scene-live { from { opacity: 0; transform: translateY(6px); } }

/* quiet perpetual life — viewport-gated via .in-view (hero-instrument.js) */
.hero-scene .live-ring {
  transform-origin: 1002px 400px;
  animation: scene-ring 2.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) 1.9s infinite;
  animation-play-state: paused;
}
.hero-scene .tr-shimmer {
  stroke-dasharray: 0.8 4;
  stroke-dashoffset: 0;
  opacity: 0;
  animation: scene-fade-in .5s linear 1.6s forwards, scene-shimmer 3.2s linear 1.6s infinite;
  animation-play-state: paused, paused;
}
.hero-scene.in-view .live-ring { animation-play-state: running; }
.hero-scene.in-view .tr-shimmer { animation-play-state: running, running; }
@keyframes scene-ring { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.35); opacity: .25; } }
@keyframes scene-fade-in { to { opacity: 1; } }
@keyframes scene-shimmer { to { stroke-dashoffset: -4.8; } }

@media (prefers-reduced-motion: reduce) {
  .hero-scene .tr-flat, .hero-scene .tr-pulse, .hero-scene .tr-ghost,
  .hero-scene .live, .hero-scene .live-ring, .hero-scene .tr-shimmer { animation: none; }
  .hero-scene .tr-shimmer { opacity: 0; }
}

.hero-scene .live-label { font-family: "JetBrains Mono", ui-monospace, monospace; }

/* concept polish: the glow BLOOMS as the screen comes alive, then breathes */
.hero-scene .glow-bloom { animation: scene-fade .9s ease-out 1.05s backwards; }
.hero-scene.in-view .glow-bloom { animation: scene-fade .9s ease-out 1.05s backwards, scene-breathe 6s ease-in-out 2.2s infinite; }
@keyframes scene-breathe { 0%, 100% { opacity: 1; } 50% { opacity: .78; } }
@media (prefers-reduced-motion: reduce) { .hero-scene .glow-bloom { animation: none; } }
