/*
 * ALMOMANI CYBER SOLUTIONS — design tokens ("Obsidian")
 * --------------------------------------------------------------------------
 * Single source of truth for colour, type, spacing, shape, elevation and motion.
 *
 * Identity: BLACK, RED and WHITE with neutral grays only. Red is a *signal*: it marks the active item, the primary
 * action, progress, and anything that needs a decision. It is never a large decorative surface.
 *   Dark  = obsidian ground, graphite surfaces, luminous hairlines (no shadows), signal red.
 *   Light = paper-white ground, white surfaces, soft ink-gray hairlines and a whisper of shadow.
 * The two themes are tuned independently (different surface ladders, edge treatment and depth cues) — they are not
 * inversions of each other. The left rail stays black in both so the official white + red logo always reads.
 *
 * Themes are selected with [data-bs-theme="light|dark"] on <html> (set before first paint by static/js/theme-init.js).
 * Components must only use the semantic tokens below (never raw hex).
 * Contrast targets (WCAG 2.1 AA): text >= 4.5:1, large text / UI boundaries >= 3:1.
 * Brand red #BA0000 is sampled from the official logo.
 */

:root {
  /* ---------- Brand (theme-independent) ---------- */
  --brand-red: #ba0000;          /* exact logo red: fills (white text on it = 6.8:1) */
  --brand-red-strong: #a30000;   /* pressed fill */
  --brand-red-bright: #d40a0a;   /* hover fill on dark */
  --brand-red-deep: #7a0000;
  --on-brand: #ffffff;

  /* ---------- Typography ---------- */
  --font-sans: "Inter", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "IBM Plex Sans Arabic", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --font-label: var(--font-sans);   /* eyebrows, table heads, metric labels: sans, not mono (numbers keep --font-mono) */

  --fs-2xs: 0.75rem;    /* 12  smallest text: labels, metadata (no 11px text) */
  --fs-xs: 0.75rem;     /* 12 */
  --fs-sm: 0.8125rem;   /* 13 */
  --fs-md: 0.875rem;    /* 14  body / controls */
  --fs-lg: 1rem;        /* 16 */
  --fs-xl: 1.125rem;    /* 18  panel titles */
  --fs-2xl: 1.5rem;     /* 24  page title (mobile) */
  --fs-3xl: 1.875rem;   /* 30  page title / metric value */
  --fs-4xl: 2.5rem;     /* 40  hero numbers */
  --lh-body: 1.55;
  --lh-tight: 1.2;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
  --tracking-tight: -0.022em;
  --tracking-label: 0.05em;

  /* ---------- Spacing scale (4px base) ---------- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-14: 3.5rem;
  --space-18: 4.5rem;

  /* ---------- Shape ---------- */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 9px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-pill: 999px;
  --border-width: 1px;

  /* ---------- Layout / density ---------- */
  --sidebar-width: 256px;
  --sidebar-width-collapsed: 68px;
  --topbar-height: 60px;
  --content-max: 1440px;
  /* Layout widths (Phase A): wide = data-heavy lists & workspaces (the app-content cap); std = home / dashboards / forms with a summary rail;
     form = focused create/edit forms; narrow = settings-style pages. Pick a variant, don't hard-code a width. */
  --w-wide: var(--content-max);
  --w-std: 1120px;
  --w-form: 960px;
  --w-narrow: 760px;
  --page-pad: 32px;
  --section-gap: 24px;
  --touch-target: 44px;
  --control-h: 36px;
  --control-h-sm: 30px;
  --control-h-lg: 44px;
  --row-h: 52px;
  --card-pad: 18px;
  /* Phase C shared surface system */
  --surface-radius: var(--radius-lg);
  --surface-shadow: var(--edge), var(--card-shadow);
  --row-radius: var(--radius-md);
  --accent-line: 2px;
  --drawer-width: 460px;

  /* ---------- Motion ---------- */
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 120ms;
  --dur: 180ms;
  --dur-slow: 320ms;

  /* ---------- Z layers ---------- */
  --z-sticky: 1020;
  --z-rail: 1040;
  --z-drawer: 1060;
  --z-modal: 1080;
  --z-palette: 1090;
  --z-toast: 1100;

  /* =====================================================================
   *  LIGHT THEME — "paper"
   * ===================================================================== */
  color-scheme: light;

  --bg: #f4f4f5;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --surface-3: #f1f1f3;
  --surface-4: #e8e8ec;
  --border: #e6e6ea;
  --border-strong: #cfcfd6;
  --border-input: #8a8a95;       /* form-control boundary >= 3:1 (WCAG 1.4.11) */

  --text: #121215;               /* 18.5:1 on surface */
  --text-muted: #5a5a64;         /* 6.9:1 on surface */
  --text-faint: #6b6b76;         /* 5.2:1 on surface (AA) */
  --text-inverse: #ffffff;

  --link: #a30000;
  --link-hover: #7a0000;
  --brand-text: #ad0000;         /* red as text/icon: 7.3:1 on white */
  --brand-tint: rgba(186, 0, 0, 0.07);
  --brand-tint-strong: rgba(186, 0, 0, 0.13);
  --focus: #ba0000;
  --focus-ring: 0 0 0 3px rgba(186, 0, 0, 0.22);

  /* Status — brand palette only: ok = ink, warn = soft red, bad = brand red, info/neutral = gray */
  --success-bg: #e8f3ec;  --success-border: #b9d8c4;  --success-text: #1b5233;  --success-solid: #2e7a4b;
  --warning-bg: #fbf2de;  --warning-border: #e8d09a;  --warning-text: #6f4a00;  --warning-solid: #b07400;
  --info-bg: #e9eff7;     --info-border: #c3d2e6;     --info-text: #28496f;     --info-solid: #3f6a9e;
  --danger-bg: #fbe9e9;   --danger-border: #f0bcbc;   --danger-text: #8f0000;   --danger-solid: #ba0000;
  /* Progress (Phase B): slim, calm. Red is reserved for an ACTIVE goal (e.g. Continue Learning), never the default. */
  --progress-h: 4px; --progress-track: #e3e3e8; --progress-fill: #5b5b66; --progress-active: var(--brand-red);

  /* Rail: black in both themes (logo ground) */
  --sidebar-bg: #0a0a0c;
  --sidebar-border: #1d1d22;
  --sidebar-text: #b9b9c2;
  --sidebar-text-strong: #ffffff;
  --sidebar-muted: #84848f;
  --sidebar-hover-bg: rgba(255, 255, 255, 0.055);
  --sidebar-active-bg: rgba(255, 255, 255, 0.075);
  --sidebar-active-border: #ff4d4d;

  --topbar-bg: rgba(244, 244, 245, 0.82);
  --overlay: rgba(10, 10, 12, 0.5);

  /* Depth (light uses shadow; dark uses edge highlight) */
  --shadow-sm: 0 1px 2px rgba(18, 18, 21, 0.05);
  --shadow-md: 0 6px 20px -6px rgba(18, 18, 21, 0.14), 0 1px 2px rgba(18, 18, 21, 0.05);
  --shadow-lg: 0 24px 56px -12px rgba(18, 18, 21, 0.28), 0 2px 6px rgba(18, 18, 21, 0.06);
  --edge: 0 0 0 0 transparent;
  --card-shadow: var(--shadow-sm);
  --hairline: var(--border);

  /* Data-viz palette: red + grayscale only */
  --chart-1: #ba0000;
  --chart-2: #1f1f25;
  --chart-3: #6b6b76;
  --chart-4: #e07a7a;
  --chart-5: #a8a8b2;
  --chart-6: #3d3d46;
  --chart-grid: rgba(18, 18, 21, 0.08);

  /* Brand ground (auth panel, error plate): obsidian in both themes */
  --brand-ground: #08080a;
  --brand-ground-text: #c4c4cc;
  --brand-ground-strong: #f2f2f4;
  --brand-ground-muted: #8e8e99;

  /* Texture: faint dot grid used on brand panels and hero bands */
  --grid-dot: rgba(18, 18, 21, 0.1);
  --pattern-opacity: 0.05;
  --signal: linear-gradient(90deg, var(--brand-red) 0 2.5rem, var(--border) 2.5rem 100%);
}

[data-bs-theme="dark"] {
  color-scheme: dark;

  --bg: #09090b;
  --surface: #111114;
  --surface-2: #16161a;
  --surface-3: #1d1d22;
  --surface-4: #28282f;
  --border: #222227;
  --border-strong: #34343c;
  --border-input: #6b6b76;

  --text: #f3f3f5;               /* 16.9:1 on surface */
  --text-muted: #a3a3ad;         /* 7.5:1 on surface */
  --text-faint: #8a8a94;         /* 5.5:1 on surface (AA) */
  --text-inverse: #111114;

  --link: #ff5757;
  --link-hover: #ff7a7a;
  --brand-text: #ff4f4f;         /* 6.4:1 on surface */
  --brand-tint: rgba(255, 79, 79, 0.09);
  --brand-tint-strong: rgba(255, 79, 79, 0.17);
  --focus: #ff5757;
  --focus-ring: 0 0 0 3px rgba(255, 87, 87, 0.32);

  --success-bg: rgba(86, 184, 122, 0.12);  --success-border: rgba(86, 184, 122, 0.32);  --success-text: #86d6a3;  --success-solid: #46a56b;
  --warning-bg: rgba(226, 170, 62, 0.12);  --warning-border: rgba(226, 170, 62, 0.34);  --warning-text: #e8bd63;  --warning-solid: #d9a13a;
  --info-bg: rgba(116, 156, 208, 0.13);    --info-border: rgba(116, 156, 208, 0.32);    --info-text: #a3bfe3;     --info-solid: #6f98cc;
  --danger-bg: rgba(255, 79, 79, 0.13);    --danger-border: rgba(255, 79, 79, 0.36);    --danger-text: #ff7676;   --danger-solid: #ba0000;
  --progress-h: 4px; --progress-track: #2a2a31; --progress-fill: #8b8b96; --progress-active: var(--brand-red);

  --sidebar-bg: #060608;
  --sidebar-border: #18181c;

  --topbar-bg: rgba(9, 9, 11, 0.8);
  --overlay: rgba(0, 0, 0, 0.66);

  --shadow-sm: 0 0 0 rgba(0, 0, 0, 0);
  --shadow-md: 0 8px 24px -8px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 28px 64px -12px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.04);
  --edge: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --card-shadow: 0 0 0 rgba(0, 0, 0, 0);

  --chart-1: #ff4f4f;
  --chart-2: #e4e4e8;
  --chart-3: #8a8a95;
  --chart-4: #ff9a9a;
  --chart-5: #5a5a64;
  --chart-6: #3d3d46;
  --chart-grid: rgba(243, 243, 245, 0.08);

  --grid-dot: rgba(255, 255, 255, 0.09);
  --pattern-opacity: 0.07;
  --signal: linear-gradient(90deg, var(--brand-red) 0 2.5rem, var(--border) 2.5rem 100%);
}

/* No-JS fallback: Dark (the platform default) when no theme attribute has been set. Not OS-dependent. */
:root:not([data-bs-theme]) {
  color-scheme: dark;
  --bg: #09090b; --surface: #111114; --surface-2: #16161a; --surface-3: #1d1d22; --surface-4: #28282f;
  --border: #222227; --border-strong: #34343c; --border-input: #6b6b76;
  --text: #f3f3f5; --text-muted: #a3a3ad; --text-faint: #8a8a94; --text-inverse: #111114;
  --link: #ff5757; --link-hover: #ff7a7a; --brand-text: #ff4f4f;
  --brand-tint: rgba(255, 79, 79, 0.09); --brand-tint-strong: rgba(255, 79, 79, 0.17);
  --focus: #ff5757; --focus-ring: 0 0 0 3px rgba(255, 87, 87, 0.32);
  --success-bg: rgba(86, 184, 122, 0.12);  --success-border: rgba(86, 184, 122, 0.32);  --success-text: #86d6a3;  --success-solid: #46a56b;
  --warning-bg: rgba(226, 170, 62, 0.12);  --warning-border: rgba(226, 170, 62, 0.34);  --warning-text: #e8bd63;  --warning-solid: #d9a13a;
  --info-bg: rgba(116, 156, 208, 0.13);    --info-border: rgba(116, 156, 208, 0.32);    --info-text: #a3bfe3;     --info-solid: #6f98cc;
  --danger-bg: rgba(255, 79, 79, 0.13);    --danger-border: rgba(255, 79, 79, 0.36);    --danger-text: #ff7676;   --danger-solid: #ba0000;
  --progress-h: 4px; --progress-track: #2a2a31; --progress-fill: #8b8b96; --progress-active: var(--brand-red);
  --sidebar-bg: #060608; --sidebar-border: #18181c;
  --topbar-bg: rgba(9, 9, 11, 0.8); --overlay: rgba(0, 0, 0, 0.66);
  --shadow-sm: 0 0 0 rgba(0, 0, 0, 0); --shadow-md: 0 8px 24px -8px rgba(0, 0, 0, 0.6); --shadow-lg: 0 28px 64px -12px rgba(0, 0, 0, 0.75);
  --edge: inset 0 1px 0 rgba(255, 255, 255, 0.04); --card-shadow: 0 0 0 rgba(0, 0, 0, 0);
  --chart-1: #ff4f4f; --chart-2: #e4e4e8; --chart-3: #8a8a95; --chart-4: #ff9a9a; --chart-5: #5a5a64; --chart-6: #3d3d46;
  --chart-grid: rgba(243, 243, 245, 0.08); --grid-dot: rgba(255, 255, 255, 0.09); --pattern-opacity: 0.07;
}

@media (max-width: 991.98px) {
  :root { --page-pad: 20px; --section-gap: 20px; --topbar-height: 56px; }
}
@media (max-width: 575.98px) {
  :root { --page-pad: 16px; --section-gap: 16px; --fs-3xl: 1.625rem; --card-pad: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-fast: 0ms;
    --dur: 0ms;
    --dur-slow: 0ms;
  }
}
