/* ================================================================
   CM Group BAMI Dashboard — Global Typography System
   Version: 2.0 — Investment Bank Grade
   
   Standards based on: Goldman Sachs, FactSet, Bloomberg, JPMorgan
   
   Rules:
   - ONE font family: Inter
   - THREE weights only: 400 (data), 500 (labels), 600 (headings)
   - ZERO font-weight:300 on headings
   - Tabular nums on all data
   ================================================================ */

/* ── Preload hint (put this in HTML <head> for critical pages) ──
   <link rel="preconnect" href="https://fonts.googleapis.com">
   <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
   <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
   ── */

/* ================================================================
   1. BASE RESET — Force Inter everywhere
   Uses html body (specificity 0,0,2) to override page body{} rules
   ================================================================ */

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-size: 14px;
}

html body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
               Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  color: #1a1a1a;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'liga' 1, 'calt' 1, 'kern' 1;
}

/* Form elements don't inherit font by default in browsers */
html body input,
html body select,
html body textarea,
html body button {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
               Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: inherit;
}

/* Strong/bold → 600, never 700+ */
html body b,
html body strong {
  font-weight: 600;
}

/* ================================================================
   2. HEADING SCALE — Bloomberg / Goldman Sachs standard
   
   Investment bank rule: headings are ALWAYS 600 (SemiBold).
   300 (Light) is never used for headings at any size.
   ================================================================ */

html body h1,
html body h2,
html body h3,
html body h4,
html body h5,
html body h6 {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
               Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: inherit; /* explicit: inherit from parent — allows dark-bg cards to keep white text */
}

html body h1 {
  letter-spacing: -0.02em;
  line-height: 1.1;
}

html body h2 {
  letter-spacing: -0.015em;
}

html body h3 {
  letter-spacing: -0.01em;
}

html body h4 {
  letter-spacing: 0;
}

/* ================================================================
   3. TYPE SCALE — CSS Variables
   
   Based on JPMorgan Salt Design System + IBM Carbon
   ================================================================ */

:root {
  /* Font family */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
               Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SF Mono', 'Roboto Mono', Consolas, monospace;

  /* Type scale — 9 stops, Goldman/Bloomberg standard */
  --text-micro: 11px;   /* Footnotes, compliance labels        */
  --text-xs:    12px;   /* Table column headers, captions      */
  --text-sm:    13px;   /* Dense table data, sidebar labels    */
  --text-base:  14px;   /* Standard body, table cells          */
  --text-md:    16px;   /* Card headings, subheadings          */
  --text-lg:    20px;   /* Section headings                    */
  --text-xl:    24px;   /* Page titles                         */
  --text-2xl:   32px;   /* KPI primary numbers                 */
  --text-3xl:   48px;   /* Hero display metrics                */

  /* Font weights — 4 only, no 300, no 800 */
  --weight-regular:  400;   /* Body text, data values          */
  --weight-medium:   500;   /* Labels, subheadings, nav        */
  --weight-semibold: 600;   /* Headings, KPI labels, CTAs      */
  --weight-bold:     700;   /* H1 primary heading only         */

  /* Line heights */
  --lh-tight:   1.1;    /* Large display headings              */
  --lh-heading: 1.2;    /* Section headings                    */
  --lh-snug:    1.35;   /* Card titles                         */
  --lh-table:   1.4;    /* Standard data rows                  */
  --lh-body:    1.5;    /* Body text                           */
  --lh-relaxed: 1.65;   /* Marketing prose                     */
  --lh-compact: 1.2;    /* Bloomberg-style dense tables        */

  /* Letter spacing — Goldman Sachs / MSCI standard */
  --ls-display:    -0.02em;  /* Large headings (28px+)         */
  --ls-heading:    -0.01em;  /* Section headings               */
  --ls-body:        0;       /* Body text — never adjust       */
  --ls-label:       0.01em;  /* Mixed-case UI labels           */
  --ls-caps:        0.07em;  /* Uppercase column headers       */
  --ls-badge:       0.05em;  /* Uppercase badges/pills         */

  /* Semantic text colors */
  --text-primary:   #1a1a1a;
  --text-secondary: #3c4043;
  --text-muted:     #5f6368;
  --text-disabled:  #9aa0a6;
  --text-positive:  #1a7340;   /* Goldman Sachs green */
  --text-negative:  #c41230;   /* Goldman Sachs red */
  --text-link:      #024d8f;
}

/* ================================================================
   4. DATA & NUMBERS — Bloomberg Terminal standard
   
   ALL numbers in financial data must use tabular figures.
   This prevents columns shifting when values update.
   ================================================================ */

/* Universal tabular nums for financial data */
html body table td,
html body table th,
html body .kpi-value,
html body .stat-val,
html body .stat-value,
html body .price-value,
html body .price,
html body .cost,
html body .number,
html body .percentage,
html body [data-numeric] {
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: 'tnum' 1, 'lnum' 1;
}

/* Table column headers — MSCI/GS standard */
html body table th {
  font-size: var(--text-xs);        /* 12px */
  font-weight: var(--weight-semibold);  /* 600 */
  letter-spacing: var(--ls-caps);   /* 0.07em */
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Table data cells */
html body table td {
  font-size: var(--text-base);      /* 14px */
  font-weight: var(--weight-regular); /* 400 */
  letter-spacing: var(--ls-label);  /* 0.01em */
}

/* Positive / negative values */
html body .value-positive,
html body .change-positive,
html body .pct-positive { color: var(--text-positive); }

html body .value-negative,
html body .change-negative,
html body .pct-negative { color: var(--text-negative); }

/* ================================================================
   5. SIDEBAR LABELS — consistent across all data pages
   ================================================================ */

html body .sb-label,
html body .section-label,
html body .data-label {
  font-size: var(--text-xs);        /* 12px */
  font-weight: var(--weight-semibold); /* 600 */
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);   /* 0.07em */
  color: var(--text-muted);
  line-height: var(--lh-heading);
}

/* ================================================================
   6. BUTTONS & INTERACTIVE — consistent font treatment
   ================================================================ */

html body .btn,
html body .tab-btn,
html body .view-btn,
html body .tb-btn,
html body .ctrl {
  font-family: var(--font-sans);
  font-size: var(--text-sm);        /* 13px */
  font-weight: var(--weight-medium); /* 500 */
  letter-spacing: var(--ls-label);
}

html body .btn.active,
html body .tab-btn.active,
html body .view-btn.active,
html body .ctrl.active {
  font-weight: var(--weight-semibold); /* 600 when active */
}

/* ================================================================
   7. NAVIGATION — product header
   ================================================================ */

html body .product-nav-item {
  font-size: var(--text-sm);        /* 13px */
  font-weight: var(--weight-medium); /* 500 */
  letter-spacing: var(--ls-label);
}

html body .product-nav-item.active {
  font-weight: var(--weight-semibold); /* 600 */
}

html body .product-switcher-name {
  font-size: var(--text-base);      /* 14px */
  font-weight: var(--weight-semibold); /* 600 */
}

/* ================================================================
   8. FOCUS — consistent brand blue ring (accessibility)
   ================================================================ */

html body *:focus-visible {
  outline: 2px solid #024d8f;
  outline-offset: 2px;
}

/* ================================================================
   9. MONOSPACE — for price ticks and data codes
   ================================================================ */

html body .mono,
html body .price-tick,
html body .data-code,
html body code,
html body pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

/* ================================================================
   10. BADGE / PILL labels
   ================================================================ */

html body .badge,
html body .soon-badge,
html body .nav-soon,
html body .pill {
  font-size: 10px;
  font-weight: var(--weight-semibold);
  letter-spacing: var(--ls-badge);
  text-transform: uppercase;
}
