/**
 * tokens.css — Design Token Definitions
 * ======================================
 * This file is the single source of truth for all visual design values.
 * Every colour, font, spacing unit, and border-radius is defined here as
 * a CSS custom property (variable). All other CSS files and inline styles
 * reference these tokens — nothing is ever hard-coded.
 *
 * THEMING
 * -------
 * Colour tokens are defined under [data-theme="dark"] and [data-theme="light"].
 * The active theme is set via a data-theme attribute on the <html> element.
 * A small JS helper (theme-toggle.js) swaps the attribute and persists the
 * user's choice in localStorage.
 *
 * WHY?
 * - Changing a colour or spacing value in one place updates it everywhere.
 * - Keeps the codebase consistent and easy to maintain.
 * - Makes it simple to re-brand or theme the app later.
 */

/* ===========================
   DARK THEME (default)
   =========================== */
[data-theme="dark"] {
  --color-bg:             #0d0829;
  --color-surface:        #0f113b;
  --color-surface-2:      #16254c;
  --color-border:         rgba(255,255,255,0.07);
  --color-text-primary:   #f7fafc;
  --color-text-secondary: #8790a4;
  --color-accent:         #00a5ac;
  --color-accent-2:       #1549f4;

  /* Shadows are more visible against dark backgrounds */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);

  /* Font families */
  --font-display: 'Poppins', sans-serif;
  --font-mono:    'IBM Plex Mono', monospace;

  /* Numeric rendering */
  --numeric-tabular:      tabular-nums;
  --numeric-proportional: proportional-nums;

  /* Semantic data typography */
  --font-data-value:    'IBM Plex Mono', monospace;
  --font-axis-label:    'IBM Plex Mono', monospace;
  --font-kpi-number:    'IBM Plex Mono', monospace;
  --font-code:          'IBM Plex Mono', monospace;
  --font-inline-number: 'Poppins', sans-serif;

  /* Data font weights */
  --weight-data-value:    500;
  --weight-axis-label:    400;
  --weight-kpi-number:    400;
  --weight-code:          400;
  --weight-inline-number: 400;

  /* Chart typography scale */
  --font-size-chart-title:   18px;
  --font-size-data-label:    14px;
  --font-size-tooltip-value: 14px;
  --font-size-legend-label:  12px;
  --font-size-axis-label:    12px;

  --font-weight-chart-title:   600;
  --font-weight-data-label:    500;
  --font-weight-tooltip-value: 500;
  --font-weight-legend-label:  400;
  --font-weight-axis-label:    400;
  --font-weight-kpi-number:    400;
}

/* ===========================
   LIGHT THEME
   =========================== */
[data-theme="light"] {
  --color-bg:             #f7fafc;
  --color-surface:        #ffffff;
  --color-surface-2:      #e0e5ea;
  --color-border:         #E0E5EA;
  --color-text-primary:   #16254c;
  --color-text-secondary: #5a6581;
  --color-accent:         #1549f4;
  --color-accent-2:       #00a5ac;

  /* Lighter, subtler shadows for the light theme */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.1);

  /* Font families */
  --font-display: 'Poppins', sans-serif;
  --font-mono:    'IBM Plex Mono', monospace;

  /* Numeric rendering */
  --numeric-tabular:      tabular-nums;
  --numeric-proportional: proportional-nums;

  /* Semantic data typography */
  --font-data-value:    'IBM Plex Mono', monospace;
  --font-axis-label:    'IBM Plex Mono', monospace;
  --font-kpi-number:    'IBM Plex Mono', monospace;
  --font-code:          'IBM Plex Mono', monospace;
  --font-inline-number: 'Poppins', sans-serif;

  /* Data font weights */
  --weight-data-value:    500;
  --weight-axis-label:    400;
  --weight-kpi-number:    400;
  --weight-code:          400;
  --weight-inline-number: 400;

  /* Chart typography scale */
  --font-size-chart-title:   18px;
  --font-size-data-label:    14px;
  --font-size-tooltip-value: 14px;
  --font-size-legend-label:  12px;
  --font-size-axis-label:    12px;

  --font-weight-chart-title:   600;
  --font-weight-data-label:    500;
  --font-weight-tooltip-value: 500;
  --font-weight-legend-label:  400;
  --font-weight-axis-label:    400;
  --font-weight-kpi-number:    400;
}

/* ===========================
   THEME-INDEPENDENT TOKENS
   These values are the same in both themes.
   =========================== */
:root {
  /* ---- Categorical palette — use in series order ---- */
  --cat-1: #00a5ac;   /* Teal/600    — primary series  */
  --cat-2: #1549f4;   /* Blue/600    — second series   */
  --cat-3: #14b58f;   /* Green/500   — third series    */
  --cat-4: #f9b326;   /* Yellow/400  — fourth series   */
  --cat-5: #685bf9;   /* Purple/500  — fifth series    */
  --cat-6: #fe9000;   /* Orange/600  — sixth series    */

  /* ---- Sequential palette — Teal low to high ---- */
  --seq-1: #053e47;   /* Teal/950 */
  --seq-2: #125d67;   /* Teal/900 */
  --seq-3: #10707a;   /* Teal/800 */
  --seq-4: #088d96;   /* Teal/700 */
  --seq-5: #00a5ac;   /* Teal/600 */
  --seq-6: #00dedd;   /* Teal/500 */
  --seq-7: #18f8f4;   /* Teal/400 */

  /* ---- Diverging palette — Red negative / Green positive ---- */
  --div-neg-strong: #af0b05;   /* Red/800   */
  --div-neg-mid:    #fc0e06;   /* Red/600   */
  --div-neg-soft:   #ff9995;   /* Red/300   */
  --div-neutral:    #b3bac7;   /* Grey/400  */
  --div-pos-soft:   #71e4c1;   /* Green/300 */
  --div-pos-mid:    #089375;   /* Green/600 */
  --div-pos-strong: #085d4d;   /* Green/800 */

  /* ---- Semantic colours — fixed meaning, never repurpose ---- */
  --semantic-positive: #42d2ab;   /* Green/400  */
  --semantic-negative: #e90800;   /* Red/700    */
  --semantic-yellow:   #fac748;   /* Yellow/300 */
  --semantic-neutral:  #cacfd9;   /* Grey/300   */
  --semantic-info:     #1549f4;   /* Blue/600   */

  /* Trend badge colours — from Springpod Figma */
  --color-trend-up-bg:    #CDFFFA;
  --color-trend-up-text:  #10707A;
  --color-trend-down-bg:  #FFDEDD;
  --color-trend-down-text:#9B1C1C;

  /* ===========================
     TYPOGRAPHY
     =========================== */

  /* Poppins loaded from Google Fonts in each HTML file */
  --font-family: 'Poppins', sans-serif;

  /* Font sizes — a simple modular scale */
  --font-size-xs: 0.75rem;   /* 12px */
  --font-size-sm: 0.875rem;  /* 14px */
  --font-size-base: 1rem;    /* 16px */
  --font-size-lg: 1.125rem;  /* 18px */
  --font-size-xl: 1.25rem;   /* 20px */
  --font-size-2xl: 1.5rem;   /* 24px */
  --font-size-3xl: 2rem;     /* 32px */

  /* Font weights */
  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* ===========================
     BORDER RADIUS SCALE
     =========================== */

  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px; /* Fully rounded (pills, avatars) */

  /* ===========================
     SPACING SCALE
     =========================== */

  --space-1: 2px;
  --space-2: 4px;
  --space-3: 8px;
  --space-4: 12px;
  --space-5: 16px;
  --space-6: 20px;
  --space-7: 24px;
  --space-8: 32px;
  --space-9: 48px;
  --space-10: 64px;

  /* ===========================
     TRANSITIONS
     =========================== */

  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
}

/* ===========================
   SMOOTH THEME TRANSITION
   Animates colour changes when toggling themes so the
   switch feels polished rather than jarring.
   =========================== */
html[data-theme] body,
html[data-theme] .sidebar,
html[data-theme] .kpi-card,
html[data-theme] .chart-card,
html[data-theme] .embed__chart-wrap,
html[data-theme] .home__link {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}
