/* ============================================================================
   IC hero scene — live DOM replacement for /video/hero-*.{webm,mp4}
   Plan: ##_plan/2026-09-29_InstitutionalCharts_HeroMotionRebuild_v1.md

   Colours are the application's own design tokens, resolved from
   00_src/frontend-v10/design-tokens.css + vpi-dashboard.css.

   Grid structure follows the application: one class per column applied to the
   header cell and the body cell alike (vpi-dashboard.js:1285), 2px slate rules
   on every cell (vpi-dashboard.css:1196-1197), and centre alignment only on the
   market, tier and energy columns (vpi-dashboard.css:825-831, :1488-1494).

   Motion contract (tripwire T4): only `transform` and `opacity` are ever
   animated. Anything that looks like a width change is scaleX on a child.
   ========================================================================= */

.heroScene {
  --hs-black: #0A0A0A;
  --hs-slate: #2C3E50;
  --hs-slate-a85: rgba(44, 62, 80, 0.85);
  --hs-gold: #C9A84C;
  --hs-salmon: #F08030;
  --hs-fairway: #6B8E6B;
  --hs-burgundy: #8B1A1A;
  --hs-cash: #D6CDB8;
  --hs-cash-a15: rgba(214, 205, 184, 0.15);
  --hs-cash-a40: rgba(214, 205, 184, 0.40);
  --hs-cash-a62: rgba(214, 205, 184, 0.62);
  --hs-tier-c: rgba(214, 205, 184, 0.40);
  --hs-track: rgba(214, 205, 184, 0.18);
  --hs-rule: 2px solid var(--hs-slate-a85);

  --hs-mono: 'IBM Plex Mono', 'JetBrains Mono', ui-monospace, monospace;
  --hs-ui: Montserrat, -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;

  /* Design canvas. The scene is authored at this size and scaled to fit its
     box; --hs-fit is a plain number written by hero.js on build and on resize.
     It cannot be done in CSS: calc() divides a length by a number, never by a
     length, so `calc(92vw / 1280)` is a length and scale() rejects it. */
  --hs-w: 1280px;
  --hs-h: 748px;
  --hs-fit: 1;

  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--hs-black);
  z-index: 0;
  contain: layout paint;
}

/* ── ambient light ───────────────────────────────────────────────────────── */
.hs-amb {
  position: absolute;
  inset: -10%;
  background:
    radial-gradient(90% 105% at 86% 46%,
      rgba(107, 142, 107, 0.50) 0%,
      rgba(107, 142, 107, 0.26) 30%,
      rgba(40, 62, 44, 0.34) 56%,
      rgba(12, 18, 13, 0.55) 76%,
      #0A0A0A 100%);
  will-change: transform, opacity;
}

.hs-vig {
  position: absolute;
  inset: 0;
  background: radial-gradient(78% 82% at 32% 40%, rgba(0, 0, 0, 0) 52%, rgba(0, 0, 0, 0.55) 100%);
  pointer-events: none;
}

/* ── monitor ─────────────────────────────────────────────────────────────── */
.hs-rig {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--hs-w);
  height: var(--hs-h);
  margin: calc(var(--hs-h) / -2) 0 0 calc(var(--hs-w) / -2);
  transform: scale(var(--hs-fit));
  transform-origin: 50% 50%;
}

.hs-bezel {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  padding: 13px;
  background: linear-gradient(160deg, #23262b 0%, #15171a 38%, #101215 100%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.045),
    0 42px 90px rgba(0, 0, 0, 0.72),
    0 8px 22px rgba(0, 0, 0, 0.5);
}

.hs-screen {
  position: absolute;
  inset: 13px;
  border-radius: 5px;
  overflow: hidden;
  background: var(--hs-black);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.9), inset 0 0 44px rgba(0, 0, 0, 0.6);
}

/* faint glass sheen across the panel */
.hs-glass {
  position: absolute;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  background: linear-gradient(112deg,
    rgba(255, 255, 255, 0.045) 0%,
    rgba(255, 255, 255, 0.012) 22%,
    rgba(255, 255, 255, 0) 46%);
}

/* ── beats ───────────────────────────────────────────────────────────────── */
.hs-beat {
  position: absolute;
  inset: 0;
  opacity: 0;
  will-change: transform, opacity;
}

/* ── Konsole beat ────────────────────────────────────────────────────────── */
.hs-kon { display: flex; flex-direction: column; padding: 16px 20px 0; }

.hs-kon__top { display: flex; align-items: baseline; gap: 12px; }
.hs-kon__title { font: 700 19px/1 var(--hs-ui); color: var(--hs-cash); letter-spacing: 0.2px; }
.hs-kon__scan { font: 400 11px/1 var(--hs-mono); color: var(--hs-cash-a40); }

.hs-kon__chips { display: flex; align-items: center; gap: 9px; margin-top: 11px; }
.hs-chip {
  font: 500 10.5px/1 var(--hs-mono);
  color: var(--hs-cash-a62);
  padding: 4px 8px;
  border: 1px solid var(--hs-cash-a15);
  border-radius: 3px;
  letter-spacing: 0.4px;
}
.hs-chip--on { color: var(--hs-gold); border-color: rgba(201, 168, 76, 0.5); }
.hs-chip--play { color: var(--hs-gold); padding: 4px 7px; }

.hs-kon__strip {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--hs-slate-a85);
  font: 600 9.5px/1 var(--hs-mono);
  letter-spacing: 1.1px;
  color: var(--hs-cash-a62);
}
.hs-kon__holiday { padding: 5px 12px 7px; font: 400 9.5px/1 var(--hs-mono); color: var(--hs-gold); text-align: center; }
.hs-kon__holiday span { color: var(--hs-cash-a40); }

/* ── grid ────────────────────────────────────────────────────────────────── */
.hs-grid { margin-top: 4px; border-top: var(--hs-rule); }
.hs-row {
  display: grid;
  grid-template-columns:
    34px 88px 56px 68px 188px 150px 62px 132px 116px 54px 112px 112px;
  align-items: stretch;
  height: 38px;
}
.hs-row--head { height: 30px; background: var(--hs-slate-a85); }

/* One cell rule for header and body alike — this is what keeps a header over
   its own column. Per-column modifiers only ever change alignment. */
.hs-cell {
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 0 11px;
  overflow: hidden;
  white-space: nowrap;
  border-right: var(--hs-rule);
  border-bottom: var(--hs-rule);
  font-variant-numeric: tabular-nums;
}
.hs-row > .hs-cell:last-child { border-right: none; }

.hs-row--head .hs-cell {
  font: 600 9.5px/1 var(--hs-mono);
  letter-spacing: 1px;
  color: var(--hs-cash-a62);
}
.hs-row--body {
  font: 400 11.5px/1 var(--hs-mono);
  color: var(--hs-cash-a62);
  will-change: transform, opacity;
  opacity: 0;
}

/* centred columns, matching vpi-dashboard.css:825-831 and :1488-1494 */
.hs-c-m, .hs-c-tier { justify-content: center; padding: 0 6px; }
.hs-c-e1h, .hs-c-e4h { justify-content: center; padding: 0 4px; }

.hs-tk { color: var(--hs-cash); font-weight: 500; letter-spacing: 0.3px; }
.hs-m { color: rgba(214, 205, 184, 0.3); font-size: 10px; }

.hs-tier { font-weight: 600; font-size: 11px; }
.hs-tier--a, .hs-tier--b { color: var(--hs-cash); }
.hs-tier--c { color: var(--hs-tier-c); }

/* bar cells: the fill is scaleX, never width */
.hs-bar { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; }
.hs-bar__track {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 13px;
  background: var(--hs-track);
  overflow: hidden;
}
.hs-bar__fill {
  position: absolute;
  inset: 0;
  transform: scaleX(0);
  transform-origin: left center;
  background: var(--hs-cash-a62);
  will-change: transform;
}
.hs-bar__fill--gold { background: var(--hs-gold); }
.hs-bar__fill--salmon { background: var(--hs-salmon); }
.hs-bar__tick {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 1px;
  background: var(--hs-salmon);
}
.hs-bar__val { flex: 0 0 auto; min-width: 40px; text-align: right; font-size: 10.5px; color: var(--hs-cash-a62); }
.hs-bar__val--hot { color: var(--hs-salmon); }

/* centre-zero (R) bar */
.hs-r { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; }
.hs-r__track { position: relative; flex: 1; min-width: 0; height: 13px; background: var(--hs-track); overflow: hidden; }
.hs-r__fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 50%;
  transform: scaleX(0);
  transform-origin: left center;
  background: var(--hs-cash-a40);
  will-change: transform;
}
.hs-r__zero { position: absolute; top: -2px; bottom: -2px; left: 50%; width: 1px; background: rgba(214, 205, 184, 0.45); }

/* 1W sparkline */
.hs-spark { display: flex; align-items: center; gap: 3px; width: 100%; }
.hs-spark i { display: block; width: 6px; height: 2px; background: var(--hs-cash-a40); }
.hs-spark i.up { background: var(--hs-fairway); }
.hs-spark i.dn { background: var(--hs-burgundy); }

/* LED strips */
.hs-led { display: flex; align-items: center; justify-content: center; gap: 2.5px; width: 100%; }
.hs-led i {
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 1px;
  background: rgba(214, 205, 184, 0.13);
}
.hs-led i.on-bull { background: var(--hs-fairway); box-shadow: 0 0 5px rgba(107, 142, 107, 0.8); }
.hs-led i.on-bear { background: var(--hs-burgundy); box-shadow: 0 0 5px rgba(139, 26, 26, 0.8); }
.hs-led i.on-mid { background: var(--hs-cash-a40); box-shadow: 0 0 4px rgba(214, 205, 184, 0.5); }
.hs-led i.on-tip { background: var(--hs-salmon); box-shadow: 0 0 6px rgba(240, 128, 48, 0.95); }

/* counter under the grid */
.hs-ghost {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 96px;
  text-align: center;
  font: 700 46px/1 var(--hs-ui);
  letter-spacing: -0.5px;
  color: var(--hs-cash);
  opacity: 0;
  will-change: transform, opacity;
}

/* ── chart beat ──────────────────────────────────────────────────────────── */
.hs-chart { padding: 14px 18px; }
.hs-chart__hd { font: 400 11px/1.65 var(--hs-mono); color: var(--hs-cash-a40); }
.hs-chart__hd b { color: var(--hs-cash); font-weight: 500; }
.hs-chart__svg { position: absolute; left: 18px; right: 18px; top: 74px; bottom: 16px; }
.hs-only-tall { display: none; }
.hs-chart__svg svg { width: 100%; height: 100%; display: block; overflow: visible; }

/* No will-change on SVG parts: ~90 promoted layers costs more than it saves. */
.hs-cndl, .hs-srline, .hs-rrbox { transform-box: fill-box; }

/* ── memo beat ───────────────────────────────────────────────────────────── */
.hs-memo { display: flex; align-items: center; justify-content: center; }
.hs-memo__dim { position: absolute; inset: 0; background: rgba(5, 5, 5, 0.66); }
.hs-memo__panel {
  position: relative;
  width: 760px;
  border: 1px solid rgba(44, 62, 80, 0.9);
  background: #070809;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.75);
  will-change: transform, opacity;
}
.hs-memo__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 13px;
  background: var(--hs-slate-a85);
  font: 600 10px/1 var(--hs-mono);
  letter-spacing: 1.4px;
  color: var(--hs-cash);
}
/* advisory-panel.js sets statusEl to 'done' on advisory-done */
.hs-memo__status { color: var(--hs-cash-a40); letter-spacing: 0.6px; text-transform: none; }
.hs-memo__body { padding: 15px 16px 20px; }
.hs-memo__ask { display: flex; align-items: center; gap: 11px; }
.hs-memo__lbl { font: 600 9.5px/1 var(--hs-mono); letter-spacing: 1.2px; color: var(--hs-cash-a40); }
.hs-memo__field {
  position: relative;
  flex: 1;
  padding: 9px 11px;
  border: 1px solid rgba(44, 62, 80, 0.9);
  background: #0A0B0C;
  font: 400 12.5px/1.2 var(--hs-mono);
  color: var(--hs-cash);
  overflow: hidden;
}
.hs-type { position: relative; display: inline-block; white-space: pre; }
.hs-type__mask {
  position: absolute;
  top: -4px;
  bottom: -4px;
  left: 0;
  right: -2px;
  background: #0A0B0C;
  transform: translateX(0);
  will-change: transform;
}
.hs-type__caret { position: absolute; top: 2px; bottom: 2px; left: 0; width: 1.5px; background: var(--hs-gold); }

.hs-memo__out {
  position: relative;
  margin-top: 13px;
  min-height: 250px;
  border: 1px solid rgba(44, 62, 80, 0.7);
  border-radius: 4px;
  padding: 12px;
  background: var(--hs-black);
  overflow: hidden;
}

/* Phase 1 — advisory-panel.js `.ic-adv__ans--stream`:
   pre-wrap, monospace, 12px. Raw markdown exactly as the chunks arrive. */
.hs-ans {
  position: absolute;
  inset: 12px;
  will-change: opacity;
}
.hs-ans--stream {
  white-space: pre-wrap;
  font-family: var(--hs-mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--hs-cash-a62);
}
.hs-raw { position: relative; display: block; width: fit-content; max-width: 100%; }
.hs-raw__mask {
  position: absolute;
  top: -1px;
  bottom: -1px;
  left: 0;
  right: -2px;
  background: var(--hs-black);
  transform: translateX(0);
  will-change: transform;
}

/* Phase 2 — the rendered answer, matching .ic-adv__ans in advisory-panel.js */
.hs-ans--done { line-height: 1.5; color: var(--hs-cash-a62); font-size: 12px; }
.hs-ans--done h3 { margin: 0 0 8px; color: var(--hs-gold); font: 600 13px/1.35 var(--hs-mono); }
.hs-ans--done p { margin: 6px 0; font-family: var(--hs-mono); }
.hs-ans--done table { border-collapse: collapse; width: 100%; margin: 8px 0; font: 400 11.5px/1.4 var(--hs-mono); }
.hs-ans--done th,
.hs-ans--done td { border: 1px solid var(--hs-slate); padding: 3px 8px; text-align: left; }
.hs-ans--done th { color: var(--hs-gold); background: var(--hs-slate); font-weight: 600; }
.hs-ans--done td { color: var(--hs-cash); }
.hs-ans--done ol { margin: 6px 0 0; padding-left: 18px; font-family: var(--hs-mono); }
.hs-ans--done li { margin: 3px 0; line-height: 1.55; }

/* ── small viewports: same DOM, fewer columns, taller canvas ─────────────── */
@media (max-width: 600px) {
  .heroScene {
    --hs-w: 452px;
    --hs-h: 700px;
  }
  .hs-amb {
    background: radial-gradient(86% 62% at 62% 30%,
      rgba(107, 142, 107, 0.48) 0%,
      rgba(107, 142, 107, 0.24) 32%,
      rgba(40, 62, 44, 0.34) 58%,
      #0A0A0A 100%);
  }
  .hs-row {
    grid-template-columns: 66px 38px 100px 78px 52px 52px;
    height: 42px;
  }
  .hs-row--head { height: 32px; }
  .hs-row--body { font-size: 12.5px; }
  .hs-c-m, .hs-c-ewma, .hs-c-avol, .hs-c-r, .hs-c-wk, .hs-c-pct { display: none; }
  .hs-cell { padding: 0 7px; }
  .hs-c-e1h, .hs-c-e4h { padding: 0 2px; }
  .hs-bar { gap: 5px; }
  .hs-bar__val { min-width: 32px; font-size: 9.5px; }
  .hs-led { gap: 1.5px; }
  .hs-led i { width: 3px; height: 3px; }
  .hs-kon__title { font-size: 21px; }
  .hs-ghost { font-size: 22px; bottom: 118px; }
  .hs-memo__panel { width: 410px; }
  .hs-memo__out { min-height: 330px; }
  .hs-chart__svg { top: 72px; }
  .hs-only-wide { display: none; }
  .hs-only-tall { display: block; }
}
