/* ==========================================================================
   FOUNDEROWN · tokens.css
   2029 Obsidian Glass Design System — single source of every raw color/hex.
   Rule: this is the ONLY file allowed to contain hex/rgb literals.
   Everything else must reference var(--token).
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. SELF-HOSTED VARIABLE FONTS (zero third-party requests)
   Inter v4 Variable — SIL OFL 1.1 · JetBrains Mono Variable — SIL OFL 1.1
   -------------------------------------------------------------------------- */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  /* `optional` (not `swap`): a late font must never reflow painted text.
     Combined with the metric-matched fallbacks below this is what takes CLS
     to exactly 0. The font is served with a 1-year immutable cache, so after
     the first visit it is always ready before first paint. */
  font-display: optional;
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2-variations"),
       url("../fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: optional;
  src: url("../fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2-variations"),
       url("../fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------------------------------------------------------------------------
 * Metric-compatible fallbacks.
 *
 * When Inter has not arrived yet the browser paints Arial (or the local
 * equivalent) instead. Without these overrides Arial is ~6% narrower than
 * Inter at the same size, so every line re-wraps the moment the real font
 * lands — that is the layout shift. size-adjust + ascent/descent overrides
 * make the fallback occupy Inter's exact box, so the swap is invisible.
 *
 * Values derived from the public Inter/Arial and JetBrains Mono/Menlo metric
 * ratios. If the fonts are ever changed, these must be recomputed.
 * ------------------------------------------------------------------------ */
@font-face {
  font-family: "Inter Fallback";
  font-style: normal;
  font-weight: 100 900;
  src: local("Arial"), local("Helvetica Neue"), local("Liberation Sans"),
       local("Roboto"), local("Noto Sans");
  size-adjust: 107.12%;
  ascent-override: 90.44%;
  descent-override: 22.52%;
  line-gap-override: 0%;
}

@font-face {
  font-family: "JetBrains Mono Fallback";
  font-style: normal;
  font-weight: 100 800;
  src: local("Menlo"), local("Consolas"), local("DejaVu Sans Mono"),
       local("Liberation Mono"), local("Courier New");
  size-adjust: 100%;
  ascent-override: 102%;
  descent-override: 30%;
  line-gap-override: 0%;
}

/* --------------------------------------------------------------------------
   2. OBSIDIAN DEPTH — surfaces, glass, borders
   -------------------------------------------------------------------------- */
:root {
  color-scheme: dark;

  /* Canvas & elevation stack (0 = deepest) */
  --bg-void: #06090e;
  --bg-surface: #0b1019;
  --bg-elevated: #0f1520;
  --bg-overlay: #131a27;
  --bg-inset: #080c13;
  --bg-glass: rgba(15, 23, 42, 0.7);
  --bg-glass-heavy: rgba(8, 12, 19, 0.82);
  --bg-scrim: rgba(3, 5, 9, 0.72);

  /* Inverse neutrals */
  --white: #ffffff;
  --black: #000000;

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-default: rgba(255, 255, 255, 0.11);
  --border-strong: rgba(255, 255, 255, 0.18);
  --border-focus: rgba(99, 102, 241, 0.45);
  --border-inset: rgba(255, 255, 255, 0.04);

  /* Text */
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --text-inverse: #06090e;

  /* Accents — brand & semantic */
  --accent-indigo: #6366f1;
  --accent-indigo-strong: #818cf8;
  --accent-indigo-soft: rgba(99, 102, 241, 0.14);
  --accent-indigo-softer: rgba(99, 102, 241, 0.07);
  --accent-indigo-line: rgba(99, 102, 241, 0.34);

  --accent-emerald: #10b981;
  --accent-emerald-strong: #34d399;
  --accent-emerald-soft: rgba(16, 185, 129, 0.13);
  --accent-emerald-softer: rgba(16, 185, 129, 0.06);
  --accent-emerald-line: rgba(16, 185, 129, 0.32);

  --accent-amber: #f59e0b;
  --accent-amber-strong: #fbbf24;
  --accent-amber-soft: rgba(245, 158, 11, 0.13);
  --accent-amber-softer: rgba(245, 158, 11, 0.06);
  --accent-amber-line: rgba(245, 158, 11, 0.32);

  --accent-rose: #f43f5e;
  --accent-rose-strong: #fb7185;
  --accent-rose-soft: rgba(244, 63, 94, 0.13);
  --accent-rose-softer: rgba(244, 63, 94, 0.06);
  --accent-rose-line: rgba(244, 63, 94, 0.32);

  --accent-cyan: #22d3ee;
  --accent-cyan-soft: rgba(34, 211, 238, 0.12);
  --accent-violet: #a78bfa;
  --accent-violet-soft: rgba(167, 139, 250, 0.12);

  /* WhatsApp brand (share action only) */
  --brand-whatsapp: #25d366;
  --brand-whatsapp-ink: #07130b;

  /* Data-visualisation palette (ordered, colour-blind-aware) */
  --viz-1: #818cf8;
  --viz-2: #34d399;
  --viz-3: #fbbf24;
  --viz-4: #fb7185;
  --viz-5: #22d3ee;
  --viz-6: #a78bfa;
  --viz-7: #f472b6;
  --viz-8: #94a3b8;
  --viz-grid: rgba(148, 163, 184, 0.16);
  --viz-axis: rgba(148, 163, 184, 0.42);
  --viz-track: rgba(148, 163, 184, 0.14);

  /* Benchmark heat scale (tables) */
  --heat-0: rgba(16, 185, 129, 0.12);
  --heat-1: rgba(16, 185, 129, 0.2);
  --heat-2: rgba(245, 158, 11, 0.14);
  --heat-3: rgba(245, 158, 11, 0.22);
  --heat-4: rgba(244, 63, 94, 0.16);

  /* ------------------------------------------------------------------------
     3. TYPOGRAPHY
     ------------------------------------------------------------------------ */
  --font-sans: "Inter", "Inter Fallback", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "JetBrains Mono Fallback", ui-monospace, SFMono-Regular, "SF Mono", Menlo,
    Consolas, "Liberation Mono", monospace;

  --text-2xs: 0.6875rem;   /* 11px · micro-labels */
  --text-xs: 0.75rem;      /* 12px · captions, table footnotes */
  --text-sm: 0.8125rem;    /* 13px · UI labels, table body */
  --text-base: 0.9375rem;  /* 15px · body copy */
  --text-md: 1rem;         /* 16px · lead paragraphs */
  --text-lg: 1.125rem;     /* 18px · card titles */
  --text-xl: 1.375rem;     /* 22px · section heads */
  --text-2xl: clamp(1.5rem, 1.32rem + 0.8vw, 1.875rem);
  --text-3xl: clamp(1.875rem, 1.55rem + 1.4vw, 2.5rem);
  --text-4xl: clamp(2.25rem, 1.7rem + 2.4vw, 3.5rem);
  --text-kpi: clamp(1.75rem, 1.4rem + 1.5vw, 2.625rem);

  --leading-none: 1;
  --leading-tight: 1.18;
  --leading-snug: 1.35;
  --leading-normal: 1.55;
  --leading-relaxed: 1.7;

  --tracking-tight: -0.02em;
  --tracking-snug: -0.011em;
  --tracking-normal: 0;
  --tracking-wide: 0.04em;
  --tracking-caps: 0.09em;

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

  /* ------------------------------------------------------------------------
     4. SPACE · RADII · DEPTH · MOTION
     ------------------------------------------------------------------------ */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-7: 1.75rem;
  --sp-8: 2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-14: 3.5rem;
  --sp-16: 4rem;
  --sp-20: 5rem;
  --sp-24: 6rem;

  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-2xl: 24px;
  --r-full: 999px;

  --sh-raise: 0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 8px 24px -12px rgba(0, 0, 0, 0.55);
  --sh-lift: 0 1px 0 rgba(255, 255, 255, 0.05) inset,
    0 18px 44px -18px rgba(0, 0, 0, 0.7);
  --sh-pop: 0 24px 64px -24px rgba(0, 0, 0, 0.8);
  --sh-inset: inset 0 1px 0 rgba(255, 255, 255, 0.03),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25);
  --glow-indigo: 0 0 0 1px var(--accent-indigo-line),
    0 12px 40px -14px rgba(99, 102, 241, 0.5);
  --glow-emerald: 0 0 0 1px var(--accent-emerald-line),
    0 12px 40px -14px rgba(16, 185, 129, 0.45);
  --glow-rose: 0 0 0 1px var(--accent-rose-line),
    0 12px 40px -14px rgba(244, 63, 94, 0.4);
  --glow-amber: 0 0 0 1px var(--accent-amber-line),
    0 12px 40px -14px rgba(245, 158, 11, 0.42);
  --glow-violet: 0 0 0 1px var(--accent-violet-soft),
    0 12px 40px -14px rgba(167, 139, 250, 0.4);

  --blur-glass: 16px;
  --blur-heavy: 28px;

  /* Ambient rig accents (radial layers) */
  --ambient-indigo: rgba(99, 102, 241, 0.15);
  --ambient-emerald: rgba(16, 185, 129, 0.1);
  --ambient-violet: rgba(167, 139, 250, 0.09);
  --ambient-grid-line: rgba(148, 163, 184, 0.055);

  --dur-instant: 90ms;
  --dur-1: 140ms;
  --dur-2: 200ms;
  --dur-3: 260ms;
  --dur-4: 440ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* ------------------------------------------------------------------------
     5. LAYOUT · Z-INDEX · AD ENVELOPES
     ------------------------------------------------------------------------ */
  --container-max: 1240px;
  --container-narrow: 780px;
  --container-prose: 68ch;
  --gutter: clamp(1rem, 0.4rem + 2.4vw, 2rem);
  --header-h: 64px;
  --bento-gap: clamp(0.875rem, 0.6rem + 1vw, 1.25rem);

  /* Optional local hooks (documented, overridable per instance) */
  --stack-gap: var(--sp-4);
  --flow-gap: 1em;
  --cluster-gap: var(--sp-3);
  --field-cols: 1fr;
  --bench-w: 50%;
  --bench-color: var(--accent-emerald);
  --swatch: var(--viz-1);
  --fill: 50%;
  --mx: 50%;
  --my: 0%;

  --z-base: 0;
  --z-raised: 10;
  --z-dropdown: 300;
  --z-sticky: 200;
  --z-header: 400;
  --z-modal: 600;
  --z-toast: 700;

  /* Zero-CLS ad envelopes (strict reservation) */
  --ad-home-h: 100px;
  --ad-pre-result-h: 280px;
  --ad-after-result-h: 250px;
  --ad-sidebar-h: 600px;
  --ad-feed-h: 250px;
}

/* --------------------------------------------------------------------------
   6. LIGHT THEME — [data-theme="light"] (WCAG AA adjusted accents)
   -------------------------------------------------------------------------- */
:root[data-theme="light"] {
  color-scheme: light;

  --bg-void: #f3f5fa;
  --bg-surface: #ffffff;
  --bg-elevated: #ffffff;
  --bg-overlay: #ffffff;
  --bg-inset: #eef1f7;
  --bg-glass: rgba(255, 255, 255, 0.78);
  --bg-glass-heavy: rgba(255, 255, 255, 0.92);
  --bg-scrim: rgba(15, 23, 42, 0.38);

  --border-subtle: rgba(15, 23, 42, 0.08);
  --border-default: rgba(15, 23, 42, 0.13);
  --border-strong: rgba(15, 23, 42, 0.22);
  --border-focus: rgba(79, 70, 229, 0.4);
  --border-inset: rgba(15, 23, 42, 0.04);

  --text-primary: #0b1220;
  --text-secondary: #334155;
  --text-muted: #55637a;
  --text-faint: #7b879c;
  --text-inverse: #f8fafc;

  --accent-indigo: #4f46e5;
  --accent-indigo-strong: #4338ca;
  --accent-indigo-soft: rgba(79, 70, 229, 0.1);
  --accent-indigo-softer: rgba(79, 70, 229, 0.05);
  --accent-indigo-line: rgba(79, 70, 229, 0.3);

  --accent-emerald: #059669;
  --accent-emerald-strong: #047857;
  --accent-emerald-soft: rgba(5, 150, 105, 0.1);
  --accent-emerald-softer: rgba(5, 150, 105, 0.05);
  --accent-emerald-line: rgba(5, 150, 105, 0.28);

  --accent-amber: #b45309;
  --accent-amber-strong: #92400e;
  --accent-amber-soft: rgba(180, 83, 9, 0.1);
  --accent-amber-softer: rgba(180, 83, 9, 0.05);
  --accent-amber-line: rgba(180, 83, 9, 0.28);

  --accent-rose: #be123c;
  --accent-rose-strong: #9f1239;
  --accent-rose-soft: rgba(190, 18, 60, 0.09);
  --accent-rose-softer: rgba(190, 18, 60, 0.05);
  --accent-rose-line: rgba(190, 18, 60, 0.26);

  --accent-cyan: #0e7490;
  --accent-cyan-soft: rgba(14, 116, 144, 0.1);
  --accent-violet: #6d28d9;
  --accent-violet-soft: rgba(109, 40, 217, 0.1);

  --viz-1: #4f46e5;
  --viz-2: #059669;
  --viz-3: #b45309;
  --viz-4: #be123c;
  --viz-5: #0e7490;
  --viz-6: #6d28d9;
  --viz-7: #be185d;
  --viz-8: #64748b;
  --viz-grid: rgba(15, 23, 42, 0.1);
  --viz-axis: rgba(15, 23, 42, 0.4);
  --viz-track: rgba(15, 23, 42, 0.1);

  --heat-0: rgba(5, 150, 105, 0.09);
  --heat-1: rgba(5, 150, 105, 0.16);
  --heat-2: rgba(180, 83, 9, 0.1);
  --heat-3: rgba(180, 83, 9, 0.17);
  --heat-4: rgba(190, 18, 60, 0.1);

  --sh-raise: 0 1px 2px rgba(15, 23, 42, 0.05), 0 8px 24px -14px rgba(15, 23, 42, 0.18);
  --sh-lift: 0 2px 4px rgba(15, 23, 42, 0.06), 0 18px 44px -20px rgba(15, 23, 42, 0.24);
  --sh-pop: 0 24px 64px -28px rgba(15, 23, 42, 0.3);
  --sh-inset: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  --glow-indigo: 0 0 0 1px var(--accent-indigo-line), 0 12px 40px -16px rgba(79, 70, 229, 0.35);
  --glow-emerald: 0 0 0 1px var(--accent-emerald-line), 0 12px 40px -16px rgba(5, 150, 105, 0.3);

  --ambient-indigo: rgba(79, 70, 229, 0.09);
  --ambient-emerald: rgba(5, 150, 105, 0.07);
  --ambient-violet: rgba(109, 40, 217, 0.06);
  --ambient-grid-line: rgba(15, 23, 42, 0.045);
}

/* --------------------------------------------------------------------------
   7. PREFERENCE-SAFE OVERRIDES
   -------------------------------------------------------------------------- */
@media (prefers-contrast: more) {
  :root {
    --border-subtle: rgba(255, 255, 255, 0.16);
    --border-default: rgba(255, 255, 255, 0.24);
    --text-muted: #b6c2d4;
    --text-faint: #93a1b5;
  }
  :root[data-theme="light"] {
    --border-subtle: rgba(15, 23, 42, 0.18);
    --border-default: rgba(15, 23, 42, 0.28);
    --text-muted: #3d4b61;
    --text-faint: #56637a;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-instant: 0ms;
    --dur-1: 0ms;
    --dur-2: 0ms;
    --dur-3: 0ms;
    --dur-4: 0ms;
  }
}
