/* ============================================================================
   Insight design tokens — GENERATED FILE, DO NOT EDIT IN THE CONSUMING APP.
   Source of truth: insight-repos/insight-brand/dist/insight-brand.css
   Edit there, then run `node scripts/sync.mjs` to propagate to all apps.

   Usage in a Tailwind v4 app's globals.css:

       @import "tailwindcss";
       @import "./insight-brand.css";

   Light is the default theme. Dark is opt-in per user, applied by setting
   data-theme="dark" on <html> (see react/theme-init.js).
   ========================================================================= */

/* ---------------------------------------------------------------------------
   1. Brand constants — identical in every theme.
   These are the July 2025 style-sheet values. Never redefine them per-theme.
   --------------------------------------------------------------------------- */
:root {
  --brand-blue:      #2485ba;
  --brand-navy:      #082947;
  --brand-teal:      #36a899;
  --brand-magenta:   #da31a4;
  --brand-orange:    #ff960e;
  --brand-black:     #171d1a;
  --brand-gray:      #f0f0f0;

  /* Accents that are legible ON THE NAVY SIDEBAR. The sidebar is brand navy in
     both themes, so these need one definition, not two. Brand hues lightened
     until each clears AA on #082947 — a raw brand accent does not: magenta is
     3.49:1 there, and navy-on-navy is of course 1.00:1.
     Use these for role chips, badges and any colour-coded item in the sidebar. */
  --sidebar-magenta: #e88ec9;  /* 6.45:1 on navy */
  --sidebar-teal:    #4cc4b3;  /* 6.95:1 */
  --sidebar-orange:  #f5c068;  /* 8.90:1 */

  /* Radius scale */
  --radius-sm: 4px;
  --radius:    6px;
  --radius-lg: 10px;
  --radius-xl: 14px;

  /* Chrome dimensions — shared so every app's shell lines up */
  --sidebar-w:          260px;
  --sidebar-w-collapsed: 64px;
  --topbar-h:           52px;

  /* Motion. Product register: 150-250ms, ease-out, no bounce. */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-fast: 120ms;
  --dur:      180ms;
  --dur-slow: 240ms;

  /* Semantic z-index scale. Never write arbitrary 999/9999. */
  --z-base: 0;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-modal-backdrop: 300;
  --z-modal: 400;
  --z-toast: 500;
  --z-tooltip: 600;
}

/* ---------------------------------------------------------------------------
   2. LIGHT theme — the default.
   Every text/background pair below is verified >= 4.5:1 (WCAG AA body).
   --------------------------------------------------------------------------- */
:root {
  color-scheme: light;

  /* Surfaces — page is tinted toward the brand hue, cards are pure white. */
  --background: #f5f7fa;
  --surface:    #ffffff;
  --surface-2:  #eef2f7;  /* hover, nested panels, table stripe */
  --surface-3:  #e4eaf1;  /* highest elevation, pressed */

  /* Borders */
  --border:   #dce3ec;
  --border-2: #c2ccd9;

  /* Text — all AA on both --background and --surface */
  --foreground: #171d1a;  /* 15.95:1 on bg */
  --text-2:     #566472;  /* 5.65:1 on bg, 6.07:1 on white */
  --text-3:     #5f6b78;  /* 5.07:1 on bg — placeholders need AA too */

  /* Brand blue.
     NOTE: #2485ba is only 4.09:1 on white, so it CANNOT carry body text or
     small white button labels. --primary keeps brand identity for fills,
     borders, icons and active states; --primary-strong is the accessible
     variant for solid buttons and link text. See BRAND.md "The blue rule". */
  --primary:            #2485ba;
  --primary-strong:     #1d6c98;  /* 5.75:1 on white — buttons, links */
  --primary-hover:      #175a80;
  --primary-foreground: #ffffff;
  --primary-tint:       #e8f2f9;  /* selected rows, badges */
  --primary-border:     #a8cde5;

  /* Sidebar — brand navy in BOTH themes. This is the suite's signature and
     keeps the white logo colorway valid everywhere. */
  --sidebar-bg:        #082947;
  --sidebar-fg:        #e8eef4;  /* 12.67:1 */
  --sidebar-fg-2:      #a9c0d4;  /* 7.88:1 */
  --sidebar-hover:     #0e3a5f;
  --sidebar-active-bg: #14486f;
  --sidebar-active-fg: #ffffff;
  --sidebar-border:    #123c5e;
  --sidebar-accent:    #4a9fd0;  /* 5.05:1 on navy — active rail, links */

  /* Status */
  --success:       #14724a;
  --success-light: #e7f6ee;
  --success-text:  #14724a;  /* 5.32:1 on tint */
  --warning:       #8a5a00;
  --warning-light: #fdf3e0;
  --warning-text:  #8a5a00;  /* 5.38:1 on tint */
  --destructive:       #b3271e;
  --destructive-light: #fdecea;
  --destructive-text:  #b3271e;  /* 5.69:1 on tint */

  /* Label colour for a SOLID status fill. Light fills are dark, so the label is
     white (5.9-6.5:1). Dark mode inverts these — always use the token. */
  --success-foreground:     #ffffff;
  --warning-foreground:     #ffffff;
  --destructive-foreground: #ffffff;
  --info:       #1d6c98;
  --info-light: #e8f2f9;
  --info-text:  #1d6c98;

  /* Brand teal is 2.91:1 on white, so it cannot carry text here. Use --teal
     for fills/dots and --teal-text whenever the colour becomes type. */
  --teal-text: #1f7d70;  /* 4.97:1 on white, 4.63:1 on --background */

  /* Focus ring — one definition, used everywhere */
  --ring: #2485ba;

  --shadow-sm: 0 1px 2px rgb(8 41 71 / 0.06);
  --shadow:    0 1px 3px rgb(8 41 71 / 0.10), 0 1px 2px rgb(8 41 71 / 0.06);
  --shadow-lg: 0 10px 24px rgb(8 41 71 / 0.12), 0 2px 6px rgb(8 41 71 / 0.06);
}

/* ---------------------------------------------------------------------------
   3. DARK theme — opt-in, set data-theme="dark" on <html>.
   --------------------------------------------------------------------------- */
[data-theme="dark"] {
  color-scheme: dark;

  --background: #0d0d10;
  --surface:    #141418;
  --surface-2:  #1c1c22;
  --surface-3:  #25252d;

  --border:   #26262e;
  --border-2: #38383f;

  --foreground: #f0f0f5;  /* 17.08:1 */
  --text-2:     #8c8c9c;  /* 5.86:1 */
  --text-3:     #9a9aa6;  /* 5.46:1 on --surface-3, the lightest surface it lands on */

  /* On dark, brand blue clears AA as TEXT on the page (4.75:1), so --primary
     carries links and icons. A solid fill inverts: white on #2485ba is only
     4.09:1, so a filled button becomes the lighter blue with a NAVY label
     (6.06:1) — the standard dark-mode treatment. This is why components must
     write text-primary-foreground and never a hardcoded text-white. */
  --primary:            #4a9fd0;
  --primary-strong:     #4a9fd0;
  --primary-hover:      #6ab6de;
  --primary-foreground: #06192b;
  --primary-tint:       #0d2f47;
  --primary-border:     #175679;

  --sidebar-bg:        #06192b;
  --sidebar-fg:        #e8eef4;  /* 15.20:1 */
  --sidebar-fg-2:      #a9c0d4;  /* 9.46:1 */
  --sidebar-hover:     #0d2942;
  --sidebar-active-bg: #14486f;
  --sidebar-active-fg: #ffffff;
  --sidebar-border:    #0f2c47;
  --sidebar-accent:    #4a9fd0;

  --success:       #3ecf8e;
  --success-light: #0b2018;
  --success-text:  #6edba8;
  --warning:       #f0a840;
  --warning-light: #211608;
  --warning-text:  #f5c068;
  --destructive:       #f56565;
  --destructive-light: #220d0d;
  --destructive-text:  #fa9191;

  /* Solid status fills are LIGHT here, so a white label would sit at 2.0-3.0:1.
     Brand near-black clears AA on all three (5.65 / 8.57 / 8.46). */
  --success-foreground:     #171d1a;
  --warning-foreground:     #171d1a;
  --destructive-foreground: #171d1a;
  --info:       #87bcd9;
  --info-light: #0d2f47;
  --info-text:  #87bcd9;

  /* Brand teal already clears AA on dark surfaces (6.31:1). */
  --teal-text: #36a899;

  --ring: #4a9fd0;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.40);
  --shadow:    0 1px 3px rgb(0 0 0 / 0.50), 0 1px 2px rgb(0 0 0 / 0.40);
  --shadow-lg: 0 10px 24px rgb(0 0 0 / 0.55), 0 2px 6px rgb(0 0 0 / 0.40);
}

/* ---------------------------------------------------------------------------
   4. Compatibility aliases.
   Token names the three apps already reference. Keep these so existing markup
   keeps working; prefer the semantic names above in NEW code.
   --------------------------------------------------------------------------- */
:root,
[data-theme="dark"] {
  --navy:    var(--brand-navy);
  --teal:    var(--brand-teal);
  --magenta: var(--brand-magenta);
  --orange:  var(--brand-orange);

  --blue:        var(--primary);
  --blue-dim:    var(--primary);
  --blue-light:  var(--primary-tint);
  --blue-border: var(--primary-border);

  --muted:            var(--surface-2);
  --muted-foreground: var(--text-2);

  --green:       var(--success);
  --green-light: var(--success-light);
  --green-text:  var(--success-text);
  --amber:       var(--warning);
  --amber-light: var(--warning-light);
  --amber-text:  var(--warning-text);
  --red:         var(--destructive);
  --red-light:   var(--destructive-light);
  --red-text:    var(--destructive-text);

  /* Contract Manager risk ramp */
  --risk-low:      var(--success);
  --risk-medium:   var(--warning);
  --risk-high:     var(--brand-orange);
  --risk-critical: var(--destructive);

  /* DEPRECATED: --cyan was never a brand colour. Aliased to teal so old
     markup doesn't break. Replace `cyan` usages with `teal` on sight. */
  --cyan: var(--brand-teal);
}

/* ---------------------------------------------------------------------------
   5. Tailwind v4 theme mapping.
   `inline` is required: it makes utilities emit var(--x) directly, so they
   re-resolve when data-theme flips. Without it, dark mode would not apply.
   --------------------------------------------------------------------------- */
@theme inline {
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --color-surface:    var(--surface);
  --color-surface-2:  var(--surface-2);
  --color-surface-3:  var(--surface-3);
  --color-border:     var(--border);
  --color-border-2:   var(--border-2);
  --color-text-2:     var(--text-2);
  --color-text-3:     var(--text-3);

  --color-primary:            var(--primary);
  --color-primary-strong:     var(--primary-strong);
  --color-primary-hover:      var(--primary-hover);
  --color-primary-foreground: var(--primary-foreground);
  --color-primary-tint:       var(--primary-tint);
  --color-primary-border:     var(--primary-border);

  --color-sidebar:           var(--sidebar-bg);
  --color-sidebar-bg:        var(--sidebar-bg);
  --color-sidebar-fg:        var(--sidebar-fg);
  --color-sidebar-fg-2:      var(--sidebar-fg-2);
  --color-sidebar-hover:     var(--sidebar-hover);
  --color-sidebar-active-bg: var(--sidebar-active-bg);
  --color-sidebar-active-fg: var(--sidebar-active-fg);
  --color-sidebar-border:    var(--sidebar-border);
  --color-sidebar-accent:    var(--sidebar-accent);
  --color-sidebar-magenta:   var(--sidebar-magenta);
  --color-sidebar-teal:      var(--sidebar-teal);
  --color-sidebar-orange:    var(--sidebar-orange);

  --color-success:       var(--success);
  --color-success-light: var(--success-light);
  --color-success-text:  var(--success-text);
  --color-warning:       var(--warning);
  --color-warning-light: var(--warning-light);
  --color-warning-text:  var(--warning-text);
  --color-destructive:       var(--destructive);
  --color-destructive-light: var(--destructive-light);
  --color-destructive-text:  var(--destructive-text);
  --color-success-foreground:     var(--success-foreground);
  --color-warning-foreground:     var(--warning-foreground);
  --color-destructive-foreground: var(--destructive-foreground);
  --color-info:       var(--info);
  --color-info-light: var(--info-light);
  --color-info-text:  var(--info-text);

  --color-navy:    var(--brand-navy);
  --color-teal:    var(--brand-teal);
  --color-teal-text: var(--teal-text);
  --color-magenta: var(--brand-magenta);
  --color-orange:  var(--brand-orange);
  --color-cyan:    var(--brand-teal);

  --color-muted:            var(--muted);
  --color-muted-foreground: var(--muted-foreground);
  --color-blue:        var(--blue);
  --color-blue-dim:    var(--blue-dim);
  --color-blue-light:  var(--blue-light);
  --color-blue-border: var(--blue-border);
  --color-green:       var(--green);
  --color-green-light: var(--green-light);
  --color-green-text:  var(--green-text);
  --color-amber:       var(--amber);
  --color-amber-light: var(--amber-light);
  --color-amber-text:  var(--amber-text);
  --color-red:         var(--red);
  --color-red-light:   var(--red-light);
  --color-red-text:    var(--red-text);
  --color-risk-low:      var(--risk-low);
  --color-risk-medium:   var(--risk-medium);
  --color-risk-high:     var(--risk-high);
  --color-risk-critical: var(--risk-critical);

  --radius-sm: var(--radius-sm);
  --radius-lg: var(--radius-lg);
  --radius-xl: var(--radius-xl);

  --shadow-sm: var(--shadow-sm);
  --shadow-lg: var(--shadow-lg);

  /* Avenir is licensed and ships with Apple devices, so it is used where installed and never
     downloaded; Plus Jakarta Sans, loaded by each app, is the fallback everywhere else. */
  --font-sans: "Avenir Next", Avenir, var(--font-insight-sans), "Plus Jakarta Sans",
    ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

/* ---------------------------------------------------------------------------
   6. Base layer.
   --------------------------------------------------------------------------- */
body {
  background-color: var(--background);
  color: var(--foreground);
  font-family: "Avenir Next", Avenir, var(--font-insight-sans), "Plus Jakarta Sans", ui-sans-serif,
    system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* One focus ring for the whole suite. Never remove without a replacement. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::selection {
  background: var(--primary-tint);
  color: var(--foreground);
}

::placeholder {
  color: var(--text-3);
  opacity: 1; /* Firefox dims placeholders by default, breaking the AA ratio */
}

/* The options inside an open <select>. `color-scheme` above already gets Chrome to
   paint the popup for the active theme; naming the colours here pins them to our
   tokens on Firefox and Linux too, where the popup does not inherit the control's
   own background — that is how a dark-mode select ends up as near-white text on a
   white popup. */
select option,
select optgroup {
  background-color: var(--surface);
  color: var(--foreground);
}

/* Numeric columns must not jitter as values change. */
.tabular,
table td,
table th {
  font-variant-numeric: tabular-nums;
}

/* Theme transition: colour only, never layout properties. */
@media (prefers-reduced-motion: no-preference) {
  body,
  [data-theme] {
    transition: background-color var(--dur) var(--ease-out),
                color var(--dur) var(--ease-out);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
