/* 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 */

  /* Grade / quintile palette (v21 — canonical semantic tokens so every
     .grade-* and .q1..q5 style references named colours, not hex.
     Previously duplicated across quality/earnings/value/lowvol/price. */
  --grade-a-bg:     #cce9ec;   /* A grade badge fill */
  --grade-a-ink:    #0f4a51;   /* A grade badge text */
  --grade-bplus-bg: #cce0f5;   /* B+ grade badge fill (paired with --navy-alt) */

  /* Quintile band pastels (Q1 best → Q5 worst).  Q1 uses --green-tint /
     --q1-ink; Q5 uses --red-tint / --red-ink already defined above. */
  --q1-ink:         #155724;   /* dark green ink on --green-tint */
  --q2-bg:          #e8f4e0;   /* light green tint */
  --q2-ink:         #2d6a1e;
  --q3-bg:          #fff3cd;   /* amber tint */
  --q3-ink:         #856404;
  --q4-bg:          #fde2cc;   /* orange tint */
  --q4-ink:         #984c0c;
  --q5-ink:         #721c24;   /* dark red ink on --red-tint */

  /* Additional semantic accents used across dashboard/detail pages. */
  --green-ink-strong: #0f7a3a;  /* darker green for alpha-leader score ink */
  --grade-a-onteal:   #7FD9E4;  /* pale teal ink when badge sits on --teal-dark */
  --grade-bplus-onnavy: #7EB4F0; /* pale blue ink when badge sits on --navy-alt */

  /* Chart palette (v18) — pastel data series harmonised with chrome.
     These are the ONLY sanctioned non-chrome colours: every chart series,
     bar, area, gridline, axis label, and gain/loss bar draws from here.
     No hardcoded hex on any dataset anywhere on the site. */
  --chart-1:        #7fa8a2;   /* muted teal */
  --chart-2:        #c9a3a9;   /* muted rose */
  --chart-3:        #a3b6c9;   /* muted slate */
  --chart-4:        #c9bfa3;   /* muted khaki */
  --chart-5:        #a9c9a3;   /* muted sage */
  --chart-6:        #b6a3c9;   /* muted lilac */
  --chart-7:        #c9b0a3;   /* muted clay */
  --chart-8:        #8fb8c4;   /* muted azure */
  --chart-grid:     #e7e9e9;   /* gridlines */
  --chart-axis:     #9aa0a3;   /* axis + tick labels */
  --chart-pos:      #8fbf7f;   /* pastel gain */
  --chart-neg:      #cf8f97;   /* pastel loss */

  /* 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);
  /* v19b: brand token now points to the Option 3 factor-blocks dark green.
     Used by the header lockup, favicon set, and any brand-forward surface.
     Charts/links still use --teal; --brand is chrome-only. */
  --brand:          #2f4a3e;
  --brand-dark:     #24382e;   /* v24 §5: active-sort thead background */
}

/* -------------------------------------------------------------------
   v19b brand chrome — header lockup canonical rules.
   Applies to .nav-logo, .header-logo, .logo (the three header link
   classes across the site). All three render the same inline SVG that
   uses fill: var(--brand). No decorative borders, no drop-shadows.
   ------------------------------------------------------------------- */
.nav-logo,
.header-logo,
.logo {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--brand);
  line-height: 1;
}
.nav-logo svg,
.header-logo svg,
.logo svg {
  display: block;
  height: 32px;
  width: auto;
}
@media (max-width: 640px) {
  .nav-logo svg,
  .header-logo svg,
  .logo svg { height: 28px; }
}

/* -------------------------------------------------------------------
   v19b minimalist pass — coordinated overrides to neutralise
   decorative colour, tighten card chrome, and enforce three text sizes.

   Rules restated from the v19 brief:
     2-3  Borders → whitespace. Cards lose their 1px border and get room
          to breathe. Tables keep --line only for row separators.
     2-4  Three text sizes per page: --fs-h1 / --fs-body / --fs-label.
          --fs-h2/--fs-h3/--fs-table stay defined for legacy code, but the
          preferred hierarchy is weight + colour, not five type sizes.
     2-5  Colour = meaning only. Strip decorative tints from section
          icons, feature cards, and rainbow badges. Semantic colours
          (--pos, --neg, --warn, --brand, --teal for CTAs) remain.
   ------------------------------------------------------------------- */

/* 2-3: Cards lose their frame. Padding + whitespace does the grouping. */
.section-card,
.factor-card,
.info-card,
.metric-card {
  border: 0 !important;
  box-shadow: none !important;
}

/* 2-5: Neutralise the section-icon rainbow. All icon holders become a
   subtle paper chip so the number/glyph carries the meaning, not the tint. */
.section-icon {
  background: transparent !important;
  color: var(--ink-muted);
}
.section-icon svg [stroke]:not([stroke="none"]) { stroke: var(--ink-muted) !important; }
.section-icon svg [fill]:not([fill="none"]):not([fill="currentColor"]) { fill: var(--ink-muted) !important; }

/* 2-5: Grade badges (used in lowvol/quality) collapse to weight-only.
   No tint, no coloured pill; just a compact monospace label. */
.grade-Aplus, .grade-A, .grade-Bplus, .grade-B, .grade-Cplus, .grade-C, .grade-D {
  background: transparent !important;
  color: var(--ink) !important;
  font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 600;
  padding: 1px 5px !important;
  border: 0 !important;
  border-radius: 3px !important;
}

/* 2-5: Confluence / conflict / signal chips on the composite alpha overlay
   drop their fills. Keep the label + border-left accent so the meaning
   (confluence = positive, conflict = warning) still reads. */
.badge-confluence, .badge-conflict {
  background: transparent !important;
  border: 0 !important;
  padding-left: 6px !important;
  border-left: 2px solid var(--ink-muted) !important;
  border-radius: 0 !important;
}
.badge-confluence { border-left-color: var(--green) !important; color: var(--green-ink) !important; }
.badge-conflict   { border-left-color: var(--amber) !important; color: var(--amber-ink) !important; }

/* 2-4: Body copy consolidates to --fs-body. Page-local overrides that
   fought for 12.5/13/13.5/14/15 collapse here. Headings still use --fs-h1;
   labels/eyebrows use --fs-label. Anything else is legacy and gradually
   migrates through per-page edits. */
body { font-size: var(--fs-body); }
.eyebrow, .label, .kpi-label, .section-eyebrow, .alpha-leaders-col-label {
  font-size: var(--fs-label) !important;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

/* 2-1: "How this works" expander pattern — a details/summary tuned for
   the minimalist look. Pages migrate wall-of-text methodology paragraphs
   inside <details class="how-this-works">. */
details.how-this-works {
  margin: 12px 0;
  border: 0;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
details.how-this-works > summary {
  cursor: pointer;
  list-style: none;
  font-size: var(--fs-label);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding: 4px 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
details.how-this-works > summary::-webkit-details-marker { display: none; }
details.how-this-works > summary::before {
  content: "▸";
  transition: transform 120ms ease;
  display: inline-block;
  color: var(--ink-muted);
}
details.how-this-works[open] > summary::before { transform: rotate(90deg); }
details.how-this-works > *:not(summary) {
  margin-top: 10px;
  color: var(--ink-muted);
  font-size: var(--fs-body);
  line-height: 1.55;
}

/* 2-1: Info tooltip pattern — the small ⓘ that opens on hover/focus.
   Kept intentionally simple: a right-of-heading superscript that reveals
   the source text without expanding page height. */
.info-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--line);
  color: var(--ink-muted);
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  cursor: help;
  margin-left: 4px;
  vertical-align: middle;
  background: var(--surface);
}
.info-tip:hover, .info-tip:focus { border-color: var(--ink-muted); color: var(--ink); }
.info-tip[title]:hover::after {
  /* Native title tooltip is fine; no JS needed. */
}

/* 2-2: One-number surfaces — hero KPI treatment for the regime pill,
   the stock header alpha_z number, and the composite score in leader
   cards. Big serif number, no ornament. */
.one-number {
  font-family: var(--font-display, 'Source Serif 4', Georgia, serif);
  font-size: 36px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.one-number .one-number-suffix {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-muted);
  margin-left: 4px;
  vertical-align: middle;
}

/* End v19b minimalist overrides */

/* -------------------------------------------------------------------
   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: #fff;                        /* white text on brand green */
  background: var(--brand);           /* v24 §5: brand dark green header */
  padding: 10px 12px;                 /* v24 §5: taller header for 40px thead row */
  height: 40px;
  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(--brand-dark);      /* v24 §5: darker brand for active sort */
}
.eqt-table tbody td {
  padding: 9px 12px;                  /* v24 §5: 40px row height (9 + ~22 line + 9) */
  font-size: 13px;                    /* v24 §5: standard body row font */
  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;
}

/* v19c: hamburger menu icon uses brand green (matches EQT Lab wordmark). */
.nav-hamburger span,
.nav-hamburger::before,
.nav-hamburger::after {
  background: var(--brand) !important;
}
.nav-hamburger:hover span,
.nav-hamburger:hover::before,
.nav-hamburger:hover::after {
  background: #1d3327 !important;
}
