/* ============================================================================
 * Clever Transco · Design Tokens · v1.0
 *
 * Single source of truth for brand colors, typography, spacing, and
 * common UI variables. Any page that wants brand-accurate styling should:
 *
 *     <link rel="stylesheet" href="../assets/clever-transco-tokens.css" />
 *
 * Then reference the variables instead of literal hex codes:
 *
 *     background: var(--ct-navy);
 *     color: var(--ct-gold);
 *     border-color: var(--ct-sky-tint);
 *
 * Changing a brand color is now one edit in this file. No more 135-file find-
 * and-replace when the brand evolves.
 *
 * Owner: CARRIER chat · Audit P2 #23 (2026-05-29)
 * ============================================================================ */

:root {
  /* ===== Brand bridge — settable by Setup → Branding (Publish writes these via
     element.style.setProperty so they win over our defaults). They mirror the
     canonical --ct-* palette so the page is brand-correct even BEFORE Publish
     ever runs. Keep these in sync with --ct-navy / --ct-blue-deep / --ct-blue-sky. */
  --brand-navy:     #003258;   /* synced from CT canonical; --ct-navy mirror */
  --brand-primary:  #1C74A6;   /* --ct-blue-deep mirror */
  --brand-accent:   #56C2EF;   /* --ct-blue-sky mirror */
  --brand-sky:      #56C2EF;   /* --ct-blue-sky alias */

  /* ===== Brand palette · the 5 official colors =====
     Bridged through --brand-* so Setup → Branding Publish flows through
     instantly without touching every consumer. Hex fallback is the canonical
     value so unbridged pages still render brand-correct. */
  --ct-navy:        var(--brand-navy, #003258);    /* Primary brand · headers · text on light bg */
  --ct-blue-deep:   var(--brand-primary, #1C74A6); /* Buttons · accent · link hover */
  --ct-blue-mid:    #4599D4;                       /* Hover · subtle backgrounds */
  --ct-blue-sky:    var(--brand-accent, #56C2EF);  /* Light accent · doc-block who · highlights */

  /* ===== CTA (primary action) palette =====
     Despite the legacy name, the brand "gold" has resolved to brand-blue for
     a long time. New code uses --ct-cta / --ct-cta-deep / --ct-cta-tint-*.
     --ct-gold / --ct-gold-deep / --ct-gold-tint-* are kept as deprecated
     aliases so 135 existing pages don't break. */
  --ct-cta:         #1C74A6;   /* Primary CTA · key data · borders */
  --ct-cta-deep:    #1C74A6;   /* Gradient pair for ct-cta */
  --ct-gold:        var(--ct-cta);       /* deprecated: use --ct-cta */
  --ct-gold-deep:   var(--ct-cta-deep);  /* deprecated: use --ct-cta-deep */
  /* BC1 2026-06-03 · Correctly-named aliases. "gold" is technical debt from the
     pre-rebrand era — the value has been blue for a long time. New code should
     use the *-cta names; legacy refs to --ct-gold-* still work via the alias. */
  --ct-blue-cta:      var(--ct-cta);
  --ct-blue-cta-deep: var(--ct-cta-deep);

  /* ===== Brand tints (transparent variants for layered UI) ===== */
  --ct-navy-tint-04:  rgba(0,50,88,0.04);
  --ct-navy-tint-08:  rgba(0,50,88,0.08);
  --ct-navy-tint-20:  rgba(0,50,88,0.20);
  /* CTA tints — canonical name. --ct-gold-tint-* below are deprecated aliases. */
  --ct-cta-tint-04:   rgba(28,116,166,0.04);
  --ct-cta-tint-08:   rgba(28,116,166,0.08);
  --ct-cta-tint-15:   rgba(28,116,166,0.15);
  --ct-cta-tint-30:   rgba(28,116,166,0.30);
  --ct-cta-tint-40:   rgba(28,116,166,0.40);
  --ct-gold-tint-04:  var(--ct-cta-tint-04);  /* deprecated: use --ct-cta-tint-04 */
  --ct-gold-tint-08:  var(--ct-cta-tint-08);  /* deprecated: use --ct-cta-tint-08 */
  --ct-gold-tint-15:  var(--ct-cta-tint-15);  /* deprecated: use --ct-cta-tint-15 */
  --ct-gold-tint-30:  var(--ct-cta-tint-30);  /* deprecated: use --ct-cta-tint-30 */
  --ct-gold-tint-40:  var(--ct-cta-tint-40);  /* deprecated: use --ct-cta-tint-40 */
  --ct-blue-tint-08:  rgba(28,116,166,0.08);
  --ct-blue-tint-18:  rgba(28,116,166,0.18);
  --ct-sky-tint-20:   rgba(86,194,239,0.20);
  --ct-sky-tint-30:   rgba(86,194,239,0.30);

  /* ===== Semantic colors (status / severity) =====
     Color = STATUS only (per 3.0 standard). One palette across all pages.
     Dark-mode variants are declared in the :root[data-theme="dark"] block below. */
  --ct-success:     #047857;   /* AR paid · COI valid · synced */
  --ct-success-bg:  #dcfce7;
  --ct-warn:        #f59e0b;   /* Aging · degraded · attention (amber, real warn hue) */
  --ct-warn-bg:     #fef3c7;
  --ct-danger:      #b91c1c;   /* DNU · escalate · failure */
  --ct-danger-bg:   #fef2f2;
  --ct-info:        #1e40af;   /* Neutral info · system messages */
  --ct-info-bg:     #dbeafe;

  /* ===== Neutrals (gray scale) ===== */
  --ct-bg-page:     #f7f8fa;   /* App page background */
  --ct-bg-card:     #ffffff;   /* Card / panel background */
  --ct-bg-muted:    #fafbfc;   /* Subtle row stripe / muted card */
  --ct-border:      #e8eaed;   /* Card / panel border */
  --ct-border-mute: #f1f3f6;   /* Soft divider · hover row */
  --ct-text:        #1a1d21;   /* Primary body text */
  --ct-text-mute:   #475569;   /* Secondary text */
  --ct-text-faint:  #6b7280;   /* Helper text */
  --ct-text-ghost:  #9ca3af;   /* Disabled / placeholder */

  /* ===== Typography · 3.0 standard ===== */
  /* Display + chrome (h1-h3, topbar, tabs, card headers) — Archivo is "the single biggest
     3.0 signal" per clever-transco-3.0.css. Inter is the production fallback. */
  --ct-font-display: "Archivo", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  /* Body (paragraphs, table cells, form labels). Loaded weights: 400 · 500 · 600 · 700 · 800 · 900 */
  --ct-font-body:    "Inter", "Archivo", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  /* Monospace (PRO #, MC, EDI, $ values). Loaded weights: 500 · 600 */
  --ct-font-mono:    "JetBrains Mono", "Menlo", "Monaco", ui-monospace, monospace;

  /* ===== Spacing scale (used by .qa buttons, .cs-card, etc.) ===== */
  --ct-space-1:  4px;
  --ct-space-2:  8px;
  --ct-space-3:  12px;
  --ct-space-4:  16px;
  --ct-space-5:  20px;
  --ct-space-6:  24px;

  /* ===== Radius ===== */
  --ct-radius-sm: 4px;
  --ct-radius-md: 6px;
  --ct-radius-lg: 10px;
  --ct-radius-xl: 16px;

  /* ===== Shadows ===== */
  --ct-shadow-card: 0 1px 2px rgba(0,0,0,0.04), 0 0 0 1px var(--ct-border);
  --ct-shadow-pop:  0 10px 30px rgba(5,8,16,0.10);
  --ct-shadow-doc:  0 12px 36px rgba(0,0,0,0.35), 0 0 0 1px var(--ct-gold-tint-15);

  /* ===== Gradients ===== */
  --ct-grad-hero:   linear-gradient(135deg, #0a1929 0%, var(--ct-navy) 50%, var(--ct-blue-deep) 100%);
  --ct-grad-cta:    linear-gradient(135deg, var(--ct-cta), var(--ct-cta-deep));
  --ct-grad-gold:   var(--ct-grad-cta);  /* deprecated: use --ct-grad-cta */
  --ct-grad-blue:   linear-gradient(90deg, var(--ct-navy) 0%, var(--ct-blue-deep) 100%);
  --ct-grad-sky:    linear-gradient(180deg, var(--ct-blue-sky), var(--ct-blue-deep));

  /* ============================================================
   * Z-INDEX SCALE — single source of truth for stacking order.
   *
   * Anything that uses raw z-index numbers should switch to one of
   * these tokens. The scale is sparse on purpose so callers can
   * nudge ±1 if they need to sit just above/below a layer without
   * jumping a whole tier (e.g. a sticky filter bar at calc(var(--z-tabnav) + 1)).
   *
   *   base       (1)     — generic raised content above static flow
   *   topbar     (100)   — global topbar / brand chrome
   *   tabnav     (90)    — second nav under the topbar
   *   dropdown   (200)   — open menu panels from topbar/tabnav
   *   fab        (300)   — floating action buttons (help, +new, etc.)
   *   modal      (400)   — dialogs, drawers, sheet overlays
   *   toast      (500)   — transient confirmation messages
   *   popover    (600)   — picker/tooltip-style popovers anchored to UI
   *   tooltip    (700)   — last-mile hover hints
   *   spotlight  (9999)  — onboarding spotlights, takeover banners
   * ============================================================ */
  --z-base:      1;
  --z-topbar:    100;
  --z-tabnav:    90;
  --z-dropdown:  200;
  --z-fab:       300;
  --z-modal:     400;
  --z-toast:     500;
  --z-popover:   600;
  --z-tooltip:   700;
  --z-spotlight: 9999;
}

/* ============================================================
 * DARK-MODE TOKEN PARALLELS
 *
 * Re-declares the neutrals + semantic-bg tokens for dark theme so
 * any consumer that uses raw --ct-text / --ct-bg-card / --ct-border /
 * etc. flips automatically without per-page overrides. The brand
 * palette + brand bridge above is theme-agnostic and unaffected.
 *
 * Pages that already roll their own dark surfaces (surface-card,
 * etc. in tms-shell.css) continue to win — these are the safety
 * net for everything else.
 * ============================================================ */
:root[data-theme="dark"] {
  /* Neutrals */
  --ct-text:        #e6f0fa;
  --ct-text-mute:   rgba(255,255,255,0.7);
  --ct-text-faint:  rgba(255,255,255,0.5);
  --ct-text-ghost:  rgba(255,255,255,0.3);
  --ct-bg-page:     #050810;
  --ct-bg-card:     rgba(15,28,45,0.55);
  --ct-bg-muted:    rgba(255,255,255,0.04);
  --ct-border:      rgba(255,255,255,0.10);
  --ct-border-mute: rgba(255,255,255,0.06);

  /* Semantic backgrounds (status pills, banners) */
  --ct-success-bg: rgba(34,197,94,0.12);
  --ct-warn-bg:    rgba(245,158,11,0.12);
  --ct-danger-bg:  rgba(220,38,38,0.12);
  --ct-info-bg:    rgba(56,189,248,0.12);
}

/* ===== Dark-doc context (matches CTDoc dark theme) ===== */
.doc, .doc-watermark {
  --ct-text-on-dark:     #e2e8f0;
  --ct-text-on-dark-65:  rgba(255,255,255,0.65);
  --ct-text-on-dark-50:  rgba(255,255,255,0.50);
  --ct-text-on-dark-35:  rgba(255,255,255,0.35);
  --ct-doc-canvas:       #0a1929;
}
