/* ════════════════════════════════════════════════════════════════════
 * CarbonReport Pro — Design Tokens
 * Single source of truth for color, type, spacing, radii, shadows.
 *
 * Every public page MUST import this file as the first stylesheet:
 *     <link rel="stylesheet" href="/assets/tokens.css"/>
 *
 * Do NOT add new hard-coded hex colors, px font sizes, or px spacing
 * to page-level CSS. If you need a new value, add it here first.
 * Tests/tokens.test.js enforces this — a hardcoded #0c1244 in
 * dashboard.html (not tokens.css) will fail CI.
 * ════════════════════════════════════════════════════════════════════ */

:root {
  /* ── Brand (canonical) ────────────────────────────────────────────── */
  /* Navy is the single primary. All page-level code MUST reference    */
  /* --brand-navy (or the step variants) — never a raw hex.            */
  --brand-navy-950: #060A28;  /* deep surfaces, cover-page backgrounds */
  --brand-navy-900: #0A0F3A;  /* hero backgrounds                     */
  --brand-navy-800: #0C1244;  /* primary navy (nav, buttons, text)    */
  --brand-navy-700: #141A5E;  /* hover state on navy                  */
  --brand-navy-600: #1E267A;  /* gradient midpoint                    */

  --brand-navy: var(--brand-navy-800);

  /* Orange (CTA only — buttons that sell). Never decorative. */
  --brand-orange-600: #C23F12;
  --brand-orange-500: #DD4A18;
  --brand-orange-400: #F06636;
  --brand-orange: var(--brand-orange-500);

  /* Accent green — reserved for verification/success. Legal-safe.    */
  /* Never use for decorative flourishes — see Phase 6 placeholder    */
  /* rules: green = verified, grey = absent.                          */
  --brand-green-700: #047857;
  --brand-green-600: #059669;
  --brand-green-500: #10B981;
  --brand-green: var(--brand-green-600);

  /* ── Neutral scale (slate) ────────────────────────────────────────── */
  --n-0:   #FFFFFF;
  --n-50:  #F8FAFC;
  --n-100: #F1F5F9;
  --n-200: #E2E8F0;
  --n-300: #CBD5E1;
  --n-400: #94A3B8;
  --n-500: #64748B;
  --n-600: #475569;
  --n-700: #334155;
  --n-800: #1E293B;
  --n-900: #0F172A;

  /* ── Semantic aliases (USE THESE in page code, not raw neutrals) ── */
  --surface:         var(--n-0);
  --surface-muted:   var(--n-50);
  --surface-sunken:  var(--n-100);
  --border:          var(--n-200);
  --border-strong:   var(--n-300);
  --text:            var(--n-900);
  --text-muted:      var(--n-600);
  --text-subtle:     var(--n-500);
  --text-on-brand:   var(--n-0);

  /* ── Status ──────────────────────────────────────────────────────── */
  --status-warn:     #B45309;  /* amber-700 */
  --status-warn-bg:  #FEF3C7;
  --status-error:    #B91C1C;  /* red-700   */
  --status-error-bg: #FEE2E2;
  --status-info:     var(--brand-navy);
  --status-info-bg:  #EEF2FF;
  --status-ok:       var(--brand-green-700);
  --status-ok-bg:    #ECFDF5;

  /* ── Typography ──────────────────────────────────────────────────── */
  /* Single canonical stack. "Segoe UI" is the fallback for Windows.  */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;

  /* Type ramp — major-third × 1.25 against 16px base */
  --fs-xs:   0.75rem;   /* 12px  — caption              */
  --fs-sm:   0.875rem;  /* 14px  — micro copy, nav      */
  --fs-base: 1rem;      /* 16px  — body                 */
  --fs-lg:   1.125rem;  /* 18px  — large body           */
  --fs-xl:   1.25rem;   /* 20px  — subhead              */
  --fs-2xl:  1.5rem;    /* 24px  — section title        */
  --fs-3xl:  1.875rem;  /* 30px  — page title           */
  --fs-4xl:  2.25rem;   /* 36px  — hero small           */
  --fs-5xl:  3rem;      /* 48px  — hero medium          */
  --fs-6xl:  3.75rem;   /* 60px  — hero large           */

  --fw-regular:  400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;
  --fw-black:    800;

  --lh-tight:   1.15;
  --lh-snug:    1.35;
  --lh-normal:  1.5;
  --lh-relaxed: 1.7;

  --tracking-tight:  -0.02em;
  --tracking-normal: 0;
  --tracking-wide:   0.05em;

  /* ── Spacing (4pt grid, aliased to common scale) ────────────────── */
  --sp-0:  0;
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  20px;
  --sp-6:  24px;
  --sp-8:  32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;
  --sp-20: 80px;
  --sp-24: 96px;
  --sp-32: 128px;

  /* ── Radii ───────────────────────────────────────────────────────── */
  --r-xs:   4px;
  --r-sm:   6px;
  --r-md:   10px;
  --r-lg:   14px;
  --r-xl:   20px;
  --r-2xl:  28px;
  --r-pill: 9999px;

  /* ── Shadows (constrained — 4 steps only) ─────────────────────────── */
  --shadow-xs: 0 1px 2px rgba(12, 18, 68, 0.06);
  --shadow-sm: 0 2px 6px rgba(12, 18, 68, 0.08);
  --shadow-md: 0 8px 24px rgba(12, 18, 68, 0.10);
  --shadow-lg: 0 24px 56px rgba(12, 18, 68, 0.14);

  /* ── Layout ──────────────────────────────────────────────────────── */
  --container:    1200px;
  --container-sm: 880px;
  --container-xs: 640px;
  --gutter:       5%;
  --nav-height:   68px;

  /* ── Motion ──────────────────────────────────────────────────────── */
  --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-in:  cubic-bezier(0.64, 0.04, 0.35, 1);
  --dur-fast: 120ms;
  --dur-med:  220ms;
  --dur-slow: 360ms;

  /* ── Brand gradient (used sparingly — hero-only) ─────────────────── */
  --grad-hero: linear-gradient(150deg, var(--brand-navy-900) 0%, var(--brand-navy-700) 52%, var(--n-900) 100%);
  --grad-cta:  linear-gradient(135deg, var(--brand-orange-500) 0%, var(--brand-orange-600) 100%);

  /* ────────────────────────────────────────────────────────────────────
   * LEGACY-NAME ALIASES
   * Existing pages (index.html, dashboard.html, sample-report.html,
   * etc.) define their own --navy, --orange, --t1… at page scope. While
   * we migrate them off, these aliases let tokens.css be loaded FIRST
   * and still have legacy references resolve to the canonical brand
   * values. After the full retrofit is done, delete this block and the
   * tests/tokens.test.js scan for bare hex codes will run green.
   * ──────────────────────────────────────────────────────────────────── */
  --navy:   var(--brand-navy);
  --indigo: var(--brand-navy);
  --orange: var(--brand-orange);
  --green:  var(--brand-green-700);
  --green2: var(--brand-green-500);
  --bg:     var(--surface-muted);
  --white:  var(--surface);
  --t1:     var(--text);
  --t2:     var(--text-muted);
  --t3:     var(--text-subtle);
}

/* ════════════════════════════════════════════════════════════════════
 * Base reset — light, non-destructive. Only rules every page needs.
 * ════════════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: var(--lh-normal);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--surface);
  font-feature-settings: "cv11" on, "ss01" on;  /* nicer Inter glyphs */
}

a { color: inherit; text-decoration: none; }

img, svg, video { max-width: 100%; display: block; }

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-tight);
  line-height: var(--lh-tight);
  color: var(--text);
}
p { margin: 0; }

/* ════════════════════════════════════════════════════════════════════
 * Component primitives
 * Prefix: .crp-  (so they never clash with page-local styles)
 * ════════════════════════════════════════════════════════════════════ */

/* Buttons ─────────────────────────────────────────────────────────── */
.crp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  font-family: var(--font-sans);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-base);
  line-height: 1;
  padding: 12px 20px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
  white-space: nowrap;
}
.crp-btn:hover   { transform: translateY(-1px); }
.crp-btn:active  { transform: translateY(0); }
.crp-btn:focus-visible {
  outline: 2px solid var(--brand-orange);
  outline-offset: 2px;
}

.crp-btn--primary {
  background: var(--brand-orange);
  color: var(--text-on-brand);
  box-shadow: var(--shadow-sm);
}
.crp-btn--primary:hover { background: var(--brand-orange-600); box-shadow: var(--shadow-md); }

.crp-btn--secondary {
  background: var(--brand-navy);
  color: var(--text-on-brand);
}
.crp-btn--secondary:hover { background: var(--brand-navy-700); }

.crp-btn--ghost {
  background: transparent;
  color: var(--brand-navy);
  border-color: var(--border);
}
.crp-btn--ghost:hover { border-color: var(--brand-navy); }

.crp-btn--lg { padding: 16px 28px; font-size: var(--fs-lg); border-radius: var(--r-lg); }
.crp-btn--sm { padding: 8px 14px; font-size: var(--fs-sm); }

/* Card ────────────────────────────────────────────────────────────── */
.crp-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-6);
  box-shadow: var(--shadow-xs);
}
.crp-card--elevated { box-shadow: var(--shadow-md); }

/* Badge ────────────────────────────────────────────────────────────── */
.crp-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  padding: 4px 10px;
  border-radius: var(--r-pill);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}
.crp-badge--ok   { background: var(--status-ok-bg);   color: var(--status-ok);   }
.crp-badge--warn { background: var(--status-warn-bg); color: var(--status-warn); }
.crp-badge--info { background: var(--status-info-bg); color: var(--status-info); }

/* Container ───────────────────────────────────────────────────────── */
.crp-container { max-width: var(--container); margin: 0 auto; padding: 0 var(--gutter); }

/* Eyebrow (small pre-heading label) ──────────────────────────────── */
.crp-eyebrow {
  display: inline-block;
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--brand-orange);
}

/* Navigation ──────────────────────────────────────────────────────── */
.crp-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-height);
  padding: 0 var(--gutter);
  background: rgba(12, 18, 68, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}
.crp-nav__logo img { height: 38px; width: auto; display: block; }
.crp-nav__links   { display: flex; gap: var(--sp-6); align-items: center; }
.crp-nav__link    { color: rgba(255,255,255,0.82); font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.crp-nav__link:hover { color: var(--n-0); }
.crp-nav__cta     { background: var(--brand-orange); color: var(--text-on-brand); padding: 10px 18px; border-radius: var(--r-md); font-size: var(--fs-sm); font-weight: var(--fw-bold); }

/* Footer ──────────────────────────────────────────────────────────── */
.crp-foot {
  background: var(--brand-navy-900);
  color: rgba(255,255,255,0.72);
  padding: var(--sp-16) var(--gutter) var(--sp-8);
  font-size: var(--fs-sm);
}
.crp-foot a { color: rgba(255,255,255,0.82); }
.crp-foot a:hover { color: var(--n-0); }
