/* eqt-theme.css — v17 single source of truth
 *
 * Rules of the road (from the v17 brief):
 *   1. Token values are FINAL. No substitutions from per-page sprawl even
 *      where a local variant looks marginally nicer. One source of truth.
 *   2. Display font: Source Serif 4 site-wide. Body font: Inter.
 *   3. Per-page :root blocks MUST be removed. All pages import this file
 *      via <link rel="stylesheet" href="./eqt-theme.css"> before their
 *      page-local <style>.
 *
 * Chart-data colours (series, per-bin heatmaps, etc.) remain the only
 * legitimate source of new hexes outside this file.
 */

/* -------------------------------------------------------------------
   Fonts — Source Serif 4 (display) + Inter (body)
   ------------------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,400;8..60,600;8..60,700&family=Inter:wght@400;500;600;700&display=swap');

/* -------------------------------------------------------------------
   Tokens
   Locked palette (exact hex values from the v17 brief).
   ------------------------------------------------------------------- */
:root {
  /* Ink + surfaces */
  --ink:            #2d3133;
  --ink-muted:      #6b7177;
  --paper:          #f7f6f2;
  --surface:        #ffffff;
  --line:           #e1e3e4;

  /* Accents */
  --teal:           #5f8a85;
  --teal-dark:      #3f6b66;
  --teal-light:     #e8efec;

  /* Semantic */
  --green:          #437a22;
  --red:            #a13544;
  --amber:          #c08a6e;
  --navy:           #2d3338;

  /* Semantic tints (backgrounds for badges, chips, callouts).
     Kept minimal: one fill + one dark-text variant per family so pages
     never reach for one-off hex shades. */
  --red-tint:       #f5e1de;
  --red-ink:        #7a1a25;   /* dark text on --red-tint */
  --green-tint:     #e6f4ec;
  --green-ink:      #1c5c2c;   /* dark text on --green-tint */
  --amber-tint:     #f5e7dc;
  --amber-ink:      #6b4e00;   /* dark text on --amber-tint */
  --navy-tint:      #e8ebea;   /* subtle surface tint */
  --navy-alt:       #2a3140;   /* headers/rare deep backgrounds */

  /* Typography */
  --font-display:   'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-body:      'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --fs-h1:          28px;
  --fs-h2:          20px;
  --fs-h3:          16px;
  --fs-body:        14px;
  --fs-table:       13px;
  --fs-label:       11px;

  /* Geometry */
  --radius:         10px;
  --gap:            16px;
  --pad-card:       20px;
  --maxw:           1380px;

  /* ---- Aliases for legacy per-page variable names ----
     Pages defined their own tokens with names like --bg, --card,
     --text, --text-muted, --border, --accent, --pos, --neg, --warn.
     Mapping them here means we can delete every page-local :root
     block without hunting for callsites. */
  --bg:             var(--paper);
  --bg-alt:         var(--paper);
  --card:           var(--surface);
  --panel:          var(--surface);
  --text:           var(--ink);
  --text-muted:     var(--ink-muted);
  --text-dim:       var(--ink-muted);
  --border:         var(--line);
  --divider:        var(--line);
  --accent:         var(--teal);
  --accent-dark:    var(--teal-dark);
  --accent-light:   var(--teal-light);
  --primary:        var(--teal);
  --primary-dark:   var(--teal-dark);
  --pos:            var(--green);
  --neg:            var(--red);
  --warn:           var(--amber);
  --brand:          var(--navy);
}

/* -------------------------------------------------------------------
   Base
   ------------------------------------------------------------------- */
html, body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.5;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6,
.eqt-display {
  font-family: var(--font-display);
  color: var(--ink);
  font-weight: 600;
  margin: 0 0 0.4em 0;
  line-height: 1.2;
}
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }

a { color: var(--teal-dark); text-decoration: none; }
a:hover { color: var(--teal); text-decoration: underline; }

/* Utility numerics — always tabular so tables line up. */
.eqt-num, [data-num] {
  font-variant-numeric: tabular-nums lining-nums;
}

/* -------------------------------------------------------------------
   Cards
   ------------------------------------------------------------------- */
.eqt-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad-card);
}
.eqt-card + .eqt-card { margin-top: var(--gap); }

/* -------------------------------------------------------------------
   Buttons
   ------------------------------------------------------------------- */
.eqt-btn {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  line-height: 1;
  transition: background 120ms ease, border-color 120ms ease;
}
.eqt-btn:hover { border-color: var(--teal); }
.eqt-btn.is-primary {
  background: var(--teal);
  color: var(--surface);
  border-color: var(--teal);
}
.eqt-btn.is-primary:hover { background: var(--teal-dark); border-color: var(--teal-dark); }
.eqt-btn.is-ghost { background: transparent; }

/* -------------------------------------------------------------------
   Badges
   ------------------------------------------------------------------- */
.eqt-badge {
  display: inline-block;
  font-size: var(--fs-label);
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--teal-light);
  color: var(--teal-dark);
  border: 1px solid var(--teal-light);
  white-space: nowrap;
}
.eqt-badge.is-pos { background: rgba(67,122,34,0.10); color: var(--green); border-color: rgba(67,122,34,0.20); }
.eqt-badge.is-neg { background: rgba(161,53,68,0.10); color: var(--red);   border-color: rgba(161,53,68,0.20); }
.eqt-badge.is-warn{ background: rgba(192,138,110,0.14); color: var(--amber); border-color: rgba(192,138,110,0.25); }
.eqt-badge.is-neutral { background: var(--paper); color: var(--ink-muted); border-color: var(--line); }

/* -------------------------------------------------------------------
   Regime chip tokens
   Same visual grammar used by the regime hero on the alpha page and
   the crowding chip in the regime secondary row.
   ------------------------------------------------------------------- */
.eqt-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: var(--fs-label);
  font-weight: 500;
  background: var(--paper);
  color: var(--ink-muted);
  border: 1px solid var(--line);
}
.eqt-chip .eqt-chip-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: 0.65;
}
.eqt-chip.is-teal  { color: var(--teal-dark); background: var(--teal-light); border-color: var(--teal-light); }
.eqt-chip.is-amber { color: var(--amber);     background: rgba(192,138,110,0.12); border-color: rgba(192,138,110,0.22); }
.eqt-chip.is-pos   { color: var(--green);     background: rgba(67,122,34,0.10); border-color: rgba(67,122,34,0.20); }
.eqt-chip.is-neg   { color: var(--red);       background: rgba(161,53,68,0.10); border-color: rgba(161,53,68,0.20); }

/* -------------------------------------------------------------------
   Canonical table — .eqt-table   (v17 Part A-1 finalisation)
   Every data table site-wide applies this class. Per-page overrides
   are limited to column-specific alignment (td:nth-child(N) text-align)
   and sortable-header cursor behaviour; typography, colour, hairlines,
   hover, sticky, badge treatment are all owned here.
   ------------------------------------------------------------------- */
.eqt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-table);         /* 13px body */
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  font-variant-numeric: tabular-nums lining-nums;   /* tables line up */
}
.eqt-table thead th {
  text-align: left;
  font-weight: 600;
  font-size: var(--fs-label);         /* 11-12px uppercase labels */
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--surface);              /* white text */
  background: var(--navy);            /* dark navy header */
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky;                   /* sticky on scroll */
  top: 0;
  z-index: 1;
}
.eqt-table thead th.is-sortable,
.eqt-table thead th[data-sort] { cursor: pointer; user-select: none; }
.eqt-table thead th.active-sort {
  background: var(--teal-dark);
}
.eqt-table tbody td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);   /* hairline row separators */
  vertical-align: middle;
}
.eqt-table tbody tr:last-child td { border-bottom: none; }
.eqt-table tbody tr:nth-child(even) td { background: var(--paper); }   /* zebra */
.eqt-table tbody tr:hover td { background: var(--teal-light); cursor: pointer; }  /* hover */

/* Numeric cells always right-align + tabular */
.eqt-table td.num,
.eqt-table th.num,
.eqt-table .eqt-num,
.eqt-table [data-num] {
  text-align: right;
  font-variant-numeric: tabular-nums lining-nums;
}
/* Explicit text-left helper for non-numeric columns that would otherwise
   inherit right-align via `td.num`. */
.eqt-table td.text-left,
.eqt-table th.text-left { text-align: left; }

/* Semantic value colouring — one --green, one --red, one --amber. */
.eqt-table .is-pos { color: var(--green); font-weight: 600; }
.eqt-table .is-neg { color: var(--red);   font-weight: 600; }
.eqt-table .is-warn{ color: var(--amber); font-weight: 600; }

/* Ticker treatment — mono-adjacent, brand-navy, bold. */
.eqt-table .ticker,
.eqt-table .eqt-ticker {
  font-weight: 700;
  color: var(--navy);
  letter-spacing: 0.02em;
}

/* Compact-mode tweak for dense tables. */
.eqt-table.is-compact thead th,
.eqt-table.is-compact tbody td { padding: 5px 10px; }

/* Badges inside cells — reuse .eqt-badge treatment cleanly. */
.eqt-table .eqt-badge { vertical-align: middle; }

/* -------------------------------------------------------------------
   Layout container
   ------------------------------------------------------------------- */
.eqt-container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
}

/* -------------------------------------------------------------------
   Small utilities used across pages
   ------------------------------------------------------------------- */
.eqt-muted { color: var(--ink-muted); }
.eqt-mono  { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; }
.eqt-hr    { border: 0; border-top: 1px solid var(--line); margin: var(--gap) 0; }

/* Two-line description clamp used by stock.html (v17 Part 4). */
.eqt-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Focus visibility — WCAG AA. */
:where(a, button, .eqt-btn, [tabindex]):focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}
