/* ============================================================================
   Viska document stylesheet — institutional_dense register
   ----------------------------------------------------------------------------
   EVERY visual decision is a token in the :root block below. Nothing downstream
   carries a raw value. To restyle, edit tokens here — index.html carries content
   and semantic classes only and contains no inline style.

   Anchored to src/index.css @theme and brand/viska.brand.json. Values are quoted
   from those sources, never invented.

   LAYOUT LAW FOR THIS DOCUMENT — read before changing anything:
     1. CONTENT USES THE FULL MEASURE. There is no document-wide prose cap. Long
        text is set in COLUMNS across the page, never in one narrow ribbon with
        dead space beside it. --col-min is what controls readability, by setting
        how narrow a column may get before the grid drops one.
     2. NO <h1>. The masthead is a compact band, not a title page.
     3. Vertical space is expensive. --section-y and --pad-box are deliberately
        tight; raise them only with a reason.

   Quick knobs, most-wanted first:
     --w-page      page measure
     --col-min     column floor — LOWER packs more columns in, raising density
     --density     scales table + box padding + section rhythm together
     --fs-base     root size; the whole scale is relative
     --radius      0 = institutional square. 4px softens everything at once.
     --sign-pos / --sign-neg    the P&L sign colours, everywhere
     --accent      gold; the eyebrow / rule / kpi accent
   ========================================================================== */

:root {
  /* ── Brand ink ─────────────────────────────────────────────────────────── */
  --navy: #253f59;
  --navy-deep: #1a2d3f;
  --navy-soft: #314a66;
  --navy-tint: #e8ecf1;
  --gold: #a59377;
  --gold-bright: #c5b08d;
  --gold-dim: #8b7635;
  --teal: #155e75;
  --slate: #475467;

  --accent: var(--gold);
  --accent-on-dark: var(--gold-bright);

  /* ── Canvas ────────────────────────────────────────────────────────────── */
  --bg: #ffffff;
  --bg-alt: #f7f5f1; /* brand.json light_alt — "warm-off-white" */
  --bg-sunk: #f3f4f6;
  --surface: #f9fafb; /* palette.surface — the quiet zebra tint */
  --border: #e5e7eb;
  --border-strong: #d1d5db;

  /* ── Text ──────────────────────────────────────────────────────────────── */
  --text: #111827;
  --text-2: #4a5168;
  --text-3: #6b7280;
  /* Dark-section alphas are MANDATED by brand.json dark_section_rules: heading
     1.0, body >= 0.82, eyebrow/numerals gold_bright 1.0, meta >= 0.60, rule 0.18. */
  --text-inv: #ffffff;
  --text-inv-2: rgba(255, 255, 255, 0.86);
  --text-inv-3: rgba(255, 255, 255, 0.64);
  --border-inv: rgba(255, 255, 255, 0.18);

  /* ── Signal axis 1 — SIGN. Money made or lost. ─────────────────────────── */
  --sign-pos: #15803d;
  --sign-neg: #b91c1c;
  --sign-nil: #6b7280;

  /* ── Signal axis 2 — DIRECTION. Which way capital moved. ────────────────
       Deliberately NOT the sign colours: deploying capital is not a loss. */
  --dir-out: #253f59; /* bought — cash out */
  --dir-in: #8b7635; /* sold   — cash in  */

  /* ── Series — categorical identity only. Live hero palette
       (src/artifacts/tradingMaster/palette.ts), green/red excluded by design. */
  --series-1: #253f59;
  --series-2: #8b7635;
  --series-3: #0e7490;
  --series-4: #5925dc;

  /* ── Type ──────────────────────────────────────────────────────────────── */
  --sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --fs-base: 15px;
  --fs-masthead: 20px;
  --fs-h2: 17px;
  --fs-h3: 14.5px;
  --fs-h4: 10.5px;
  --fs-body: 13.5px;
  --fs-small: 12.5px;
  --fs-micro: 10.5px;
  --fs-stat: 21px;
  --fs-table: 12.5px;

  --lh-tight: 1.25;
  --lh-body: 1.5;

  --track-eyebrow: 0.18em;
  --track-label: 0.08em;

  --weight-display: 800;
  --weight-strong: 700;
  --weight-med: 600;

  /* ── Geometry ──────────────────────────────────────────────────────────── */
  --radius: 0;
  --rail: 3px;
  --hair: 1px solid var(--border);
  --hair-strong: 1px solid var(--border-strong);

  --w-page: 1320px;
  --pad-x: 26px;
  --col-min: 275px; /* floor for SHORT items — key entries, chips, tiles */
  --col-prose: 520px; /* floor for LONG-FORM callouts. Too small and a 300-word
                         block becomes a tall thin ribbon with white beside it. */

  --density: 1;
  --pad-cell: calc(6px * var(--density)) calc(10px * var(--density));
  --pad-box: calc(13px * var(--density)) calc(15px * var(--density));
  --section-y: calc(26px * var(--density));
  --gap: calc(14px * var(--density));
  --gap-sm: calc(9px * var(--density));
}

/* ============================================================================
   Base
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: var(--fs-base);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.wrap {
  max-width: var(--w-page);
  margin: 0 auto;
  padding: 0 var(--pad-x);
}

h2,
h3,
h4 {
  margin: 0;
  line-height: var(--lh-tight);
}

/* No h1 in this document. The masthead is a band, not a title page. */

h2 {
  font-size: var(--fs-h2);
  font-weight: var(--weight-display);
  letter-spacing: -0.01em;
  color: var(--navy);
}

h3 {
  font-size: var(--fs-h3);
  font-weight: var(--weight-display);
  color: var(--navy);
  letter-spacing: -0.005em;
}

h4 {
  font-family: var(--mono);
  font-size: var(--fs-h4);
  font-weight: var(--weight-strong);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--navy);
  margin-bottom: 5px;
}

p {
  margin: 0 0 8px;
}
p:last-child {
  margin-bottom: 0;
}

strong,
b {
  font-weight: var(--weight-med);
  color: var(--text);
}

a {
  color: var(--teal);
}

code,
.mono {
  font-family: var(--mono);
  font-size: 0.9em;
}

code {
  background: var(--bg-sunk);
  border: var(--hair);
  border-radius: var(--radius);
  padding: 0 3px;
}

.num,
.stat__value,
.theme__pl,
table,
.mast__meta {
  font-variant-numeric: tabular-nums;
}

.eyebrow {
  font-family: var(--mono);
  font-size: var(--fs-micro);
  font-weight: var(--weight-strong);
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
  color: var(--accent);
  margin: 0;
}

/* ============================================================================
   Column grids — how this document uses its width.
   `.cols` auto-fits as many readable columns as --col-min allows.
   `.cols--2` / `.cols--3` pin a count where the content demands it.
   ========================================================================== */

/* Row grids, and they STRETCH. A short block in a row does not leave a hole
   under it — its card grows to the row height, so the space reads as part of
   the card instead of as a gap in the page.
   (CSS multicol was tried here and is wrong for this content: balancing long
   blocks across narrow columns produced 300px ribbons in one column with three
   empty columns beside them — worse than what it replaced.) */
.flow,
.cols {
  display: grid;
  gap: var(--gap);
  align-items: stretch;
}

/* Long-form callouts: size columns for PROSE, not for chips. --col-prose is
   what stops four 300px ribbons from ever happening again. */
.flow {
  grid-template-columns: repeat(auto-fit, minmax(min(var(--col-prose), 100%), 1fr));
}

/* Short items (key entries, stat-like blocks) pack tighter. */
.cols {
  grid-template-columns: repeat(auto-fit, minmax(min(var(--col-min), 100%), 1fr));
}

.cols--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cols--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* Kill an orphan: a block alone in the last row with empty cells beside it
   spans the row instead of leaving a hole. */
.span-all {
  grid-column: 1 / -1;
}

/* Wide-left / narrow-right: a table or chart beside its caveats. */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1.62fr) minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
}

.stack {
  display: grid;
  gap: var(--gap-sm);
  align-content: start;
}

/* ============================================================================
   Masthead — compact band. Title, scope and provenance on one deck.
   ========================================================================== */

.mast {
  background-color: var(--navy-deep);
  background-image: radial-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 20px 20px;
  color: var(--text-inv);
  padding: 18px 0 16px;
}

.mast .wrap {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 2fr);
  gap: 12px var(--gap);
  align-items: end;
}

.mast .eyebrow {
  color: var(--accent-on-dark);
}

.mast__title {
  font-size: var(--fs-masthead);
  font-weight: var(--weight-display);
  letter-spacing: -0.015em;
  line-height: 1.2;
  margin: 4px 0 3px;
  color: var(--text-inv);
}

.mast__lede {
  color: var(--text-inv-2);
  font-size: var(--fs-small);
  margin: 0;
}

/* Left-aligned: right-aligning a wrapping mono block leaves orphaned tails
   ("346 daily marks" alone on a line) that read as a layout fault. */
.mast__meta {
  font-family: var(--mono);
  font-size: var(--fs-micro);
  line-height: 1.7;
  color: var(--text-inv-3);
  margin: 0;
}

.mast__meta b {
  color: var(--accent-on-dark);
  font-weight: var(--weight-strong);
}

.mast__meta code {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-inv);
  color: var(--text-inv-2);
}

/* ============================================================================
   Section chrome — eyebrow + title + note ride on ONE line, not three blocks.
   ========================================================================== */

.section {
  padding: var(--section-y) 0;
  border-top: var(--hair);
}

.section--alt {
  background: var(--bg-alt);
}

.section__head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-bottom: var(--gap-sm);
}

.section__head .eyebrow {
  color: var(--text-3);
}

.section__note {
  color: var(--text-2);
  font-size: var(--fs-small);
  margin: 0;
  flex: 1 1 340px;
}

/* ============================================================================
   Callout — a stated caveat, correction, or limit. Variant sets the rail only;
   the <h4> always states which.
   ========================================================================== */

.callout {
  border: var(--hair);
  border-left: var(--rail) solid var(--sign-nil);
  border-radius: var(--radius);
  background: var(--bg);
  padding: var(--pad-box);
  font-size: var(--fs-small);
  color: var(--text-2);
}

.callout--warn {
  border-left-color: var(--sign-neg);
}
.callout--good {
  border-left-color: var(--sign-pos);
}
.callout--note {
  border-left-color: var(--accent);
}

.callout ul {
  margin: 6px 0 0;
  padding-left: 15px;
}
.callout li {
  margin: 5px 0;
}

/* ============================================================================
   Key — every mark in this document is defined here (rule 08).
   ========================================================================== */

.key {
  border: var(--hair);
  border-top: 2px solid var(--navy);
  border-radius: var(--radius);
  background: var(--bg);
  padding: var(--pad-box);
}

.key__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(215px, 100%), 1fr));
  gap: 8px 20px;
  margin-top: 8px;
}

.key__item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: var(--fs-small);
  color: var(--text-2);
}

.key__item b {
  color: var(--text);
  font-weight: var(--weight-med);
}

.swatch {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  display: inline-block;
  border-radius: var(--radius);
  transform: translateY(1px);
}

.swatch--rail {
  width: var(--rail);
  height: 13px;
  transform: translateY(2px);
}

.swatch--pos {
  background: var(--sign-pos);
}
.swatch--neg {
  background: var(--sign-neg);
}
.swatch--nil {
  background: var(--sign-nil);
}
.swatch--out {
  background: var(--dir-out);
}
.swatch--in {
  background: var(--dir-in);
}

/* ============================================================================
   Stat tiles — hairline grid, no per-cell borders (live metric-strip idiom).
   ========================================================================== */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(130px, 100%), 1fr));
  gap: 1px;
  background: var(--border);
  border: var(--hair);
}

.stat {
  border-top: 2px solid var(--accent);
  background: var(--bg);
  padding: 9px 12px;
  min-width: 0; /* without this a long unbreakable numeral paints over its neighbour */
}

.stat__label {
  font-family: var(--mono);
  font-size: var(--fs-micro);
  font-weight: var(--weight-strong);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--text-3);
}

.stat__value {
  font-family: var(--mono);
  font-size: clamp(16px, 1.55vw, var(--fs-stat));
  font-weight: var(--weight-strong);
  color: var(--navy);
  letter-spacing: -0.02em;
  margin-top: 2px;
  line-height: 1.15;
}

.stat__sub {
  font-size: var(--fs-micro);
  color: var(--text-3);
  margin-top: 2px;
}

/* ============================================================================
   Tables
   ========================================================================== */

.table-wrap {
  overflow-x: auto;
  border: var(--hair);
  border-radius: var(--radius);
  background: var(--bg);
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: var(--fs-table);
  line-height: 1.4;
}

th,
td {
  padding: var(--pad-cell);
  text-align: left;
  border-bottom: var(--hair);
  white-space: nowrap;
}

thead th {
  background: var(--bg-sunk);
  font-family: var(--mono);
  font-size: var(--fs-micro);
  font-weight: var(--weight-strong);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-2);
  border-bottom: var(--hair-strong);
  vertical-align: bottom;
}

/* Quiet zebra at palette.surface (bible ch.11) — zebra only, never plus hover. */
tbody tr:nth-child(even) td,
tbody tr:nth-child(even) th {
  background: var(--surface);
}

tbody tr:last-child td {
  border-bottom: 0;
}

td.num,
th.num {
  text-align: right;
  font-family: var(--mono);
}

tr.total td,
tbody tr.total:nth-child(even) td {
  font-weight: var(--weight-med);
  background: var(--navy-tint);
  border-top: var(--hair-strong);
}

.wrapcell {
  white-space: normal;
  min-width: 18ch;
}

.pos {
  color: var(--sign-pos);
}
.neg {
  color: var(--sign-neg);
}
.nil,
.dim {
  color: var(--text-3);
  font-weight: 400;
}

.ticker {
  font-family: var(--mono);
  font-weight: var(--weight-med);
  color: var(--text);
}

/* ============================================================================
   Charts
   ========================================================================== */

.chart {
  border: var(--hair);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 12px 14px;
  overflow-x: auto;
}

.chart__svg {
  display: block;
  width: 100%;
  height: auto;
  min-width: 600px;
  overflow: visible;
}

.chart__svg text {
  fill: var(--text-3);
  font-family: var(--mono);
  font-size: 10px;
}

.chart__svg .label-direct {
  fill: var(--text);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: var(--weight-med);
}

.chart__svg .label-note {
  font-size: 9px;
}

.chart__svg .label-value {
  fill: var(--text);
  font-size: 10px;
  font-weight: var(--weight-med);
}

.gridline {
  stroke: var(--border);
  stroke-width: 1;
}

.zeroline {
  stroke: var(--border-strong);
  stroke-width: 1;
}

.plot {
  fill: none;
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.plot--1 {
  stroke: var(--series-1);
}
.plot--2 {
  stroke: var(--series-2);
}
.plot--3 {
  stroke: var(--series-3);
}
.plot--4 {
  stroke: var(--series-4);
}

/* SHAPE carries fill direction, not colour — so a marker can never be read as
   the sign axis. Both shapes are legended under the chart. */
.marker {
  fill: var(--navy-deep);
  stroke: var(--bg);
  stroke-width: 2;
}

.bar--out {
  fill: var(--dir-out);
}
.bar--in {
  fill: var(--dir-in);
}

.chart__legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 18px;
  margin-top: 9px;
  padding-top: 8px;
  border-top: var(--hair);
  font-family: var(--mono);
  font-size: var(--fs-micro);
  color: var(--text-2);
}

.chart__legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart__legend .glyph {
  width: 9px;
  height: 9px;
  display: inline-block;
  background: var(--navy-deep);
}

.chart__legend .glyph--buy {
  transform: rotate(45deg) scale(0.85);
}
.chart__legend .glyph--sell {
  border-radius: 50%;
}
.chart__legend .glyph--out {
  background: var(--dir-out);
}
.chart__legend .glyph--in {
  background: var(--dir-in);
}

/* ============================================================================
   Theme cards — head across the full width, then DATA and READING side by side.
   The prose sits beside the table instead of under it; that is what keeps the
   right half of the page in use and the card short.
   ========================================================================== */

.themes {
  display: grid;
  gap: var(--gap);
}

.theme {
  border: var(--hair);
  border-left: var(--rail) solid var(--sign-nil);
  border-radius: var(--radius);
  background: var(--bg);
  padding: var(--pad-box);
}

.theme--gain {
  border-left-color: var(--sign-pos);
}
.theme--loss {
  border-left-color: var(--sign-neg);
}
.theme--open {
  border-left-color: var(--sign-nil);
}

.theme__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 18px;
  flex-wrap: wrap;
  padding-bottom: 8px;
  margin-bottom: 10px;
  border-bottom: var(--hair);
}

.theme__meta {
  font-size: var(--fs-small);
  color: var(--text-3);
  margin: 3px 0 0;
  font-variant-numeric: tabular-nums;
}

.theme__side {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex: 0 0 auto;
}

.badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: var(--weight-strong);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--navy);
  background: var(--navy-tint);
  border-radius: var(--radius);
  padding: 2px 6px;
}

.theme__pl {
  font-family: var(--mono);
  font-size: 17px;
  font-weight: var(--weight-strong);
  line-height: 1.2;
}

.theme__note {
  font-size: var(--fs-micro);
  color: var(--text-3);
}

/* The data column takes the width its TABLE needs, capped at 62%; the reading
   takes the rest. A fixed fr ratio was worse on both counts — it clipped four
   of the theme tables into horizontal scroll AND left more column imbalance,
   because a 2-row table and a 6-row table do not want the same share. */
.theme__body {
  display: grid;
  grid-template-columns: fit-content(62%) minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
}

/* A card with no table sets its reading across the width instead of down it. */
.theme__body--prose {
  grid-template-columns: repeat(auto-fit, minmax(min(var(--col-min), 100%), 1fr));
  align-items: stretch;
}

.theme__data,
.theme__read {
  display: grid;
  gap: var(--gap-sm);
  align-content: start;
}

.read {
  margin: 0;
  font-size: var(--fs-small);
}

/* ============================================================================
   Findings — the dark band, in columns.
   ========================================================================== */

.band {
  background-color: var(--navy);
  color: var(--text-inv);
  border-top: 0;
}

.band .eyebrow {
  color: var(--accent-on-dark);
}
.band h2 {
  color: var(--text-inv);
}
.band .section__note {
  color: var(--text-inv-2);
}
.band .section__head .eyebrow {
  color: var(--accent-on-dark);
}

.findings {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: finding;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  gap: var(--gap) calc(var(--gap) * 1.6);
  align-items: start;
}

.findings li {
  counter-increment: finding;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 10px;
  color: var(--text-inv-2);
  font-size: var(--fs-small);
  padding-top: 9px;
  border-top: 1px solid var(--border-inv);
}

.findings li::before {
  content: counter(finding, decimal-leading-zero);
  font-family: var(--mono);
  font-size: var(--fs-micro);
  font-weight: var(--weight-strong);
  letter-spacing: 0.06em;
  color: var(--accent-on-dark);
}

.findings strong,
.findings b {
  color: var(--text-inv);
  font-weight: var(--weight-med);
}

/* On navy the sign colours BOTH fail contrast and the register ships no light
   green/red — inventing a pair would be a token fabrication. brand.json mandates
   gold_bright for numerals on dark; the explicit + / − carries the sign. Stated
   in the document key. */
.band .pos,
.band .neg {
  color: var(--accent-on-dark);
  font-weight: var(--weight-med);
}

.band code {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-inv);
  color: var(--text-inv-2);
}

/* ============================================================================
   Footer
   ========================================================================== */

.foot {
  background: var(--navy-deep);
  color: var(--text-inv-3);
  padding: 12px 0;
  font-family: var(--mono);
  font-size: var(--fs-micro);
}

.foot .wrap {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 18px;
}

.foot b {
  color: var(--accent-on-dark);
  font-weight: var(--weight-strong);
}

.foot code {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-inv);
  color: var(--text-inv-2);
}

/* ============================================================================
   Responsive — the page body NEVER scrolls sideways. Wide content pans inside
   its own rail (.table-wrap, .chart); everything else reflows.
   ========================================================================== */

@media (max-width: 1080px) {
  .theme__body,
  .split {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  :root {
    --pad-x: 18px;
    --col-min: 240px;
    --density: 0.9;
  }

  .mast .wrap {
    grid-template-columns: minmax(0, 1fr);
  }

  .mast__meta {
    text-align: left;
  }

  .cols--2,
  .cols--3 {
    grid-template-columns: minmax(0, 1fr);
  }

  .theme__head {
    flex-direction: column;
  }

  .theme__side {
    gap: 10px;
  }
}

/* AGENTS.md: PDF exports are print material — backgrounds always #ffffff. The
   dark bands invert on paper; accents keep their brand colour. */
@media print {
  .mast,
  .band,
  .foot {
    background: #ffffff;
    background-image: none;
    color: var(--text);
  }

  .mast__title,
  .band h2 {
    color: var(--navy);
  }

  .mast__lede,
  .band .section__note,
  .findings li {
    color: var(--text-2);
  }

  .mast .eyebrow,
  .band .eyebrow,
  .band .section__head .eyebrow,
  .findings li::before,
  .foot b,
  .mast__meta b {
    color: var(--gold-dim);
  }

  .mast__meta,
  .foot {
    color: var(--text-3);
  }

  .findings li,
  .foot,
  .mast {
    border-color: var(--border);
  }

  .band .pos,
  .band .neg,
  .findings strong,
  .findings b {
    color: var(--text);
  }

  .theme,
  .chart,
  .table-wrap,
  .callout,
  .key {
    break-inside: avoid;
  }
}
