/*
 * Josoor design system — tokens.
 * One calm brand colour, warm neutral surfaces (2026-11-27), no gradients. Every component reads these
 * variables only, so the brand colour (Settings → Branding) and dark mode are a token
 * swap, never a per-component change.
 */
:root {
  /* Brand — --brand-base comes from the branding setting (inc/branding.php emits it when
     set); every brand shade is derived from it, so one setting recolours the whole UI. */
  --brand-base: #1e3a5f;
  --brand: var(--brand-base);
  --brand-hover: color-mix(in srgb, var(--brand-base) 85%, #000);
  --brand-soft: color-mix(in srgb, var(--brand-base) 9%, #fff);   /* active nav, selected rows */
  --brand-ink: #ffffff;       /* text on --brand */

  /* Surfaces */
  --bg: #f3f2ef;              /* page */
  --surface: #ffffff;         /* cards, sidebar, top bar */
  --surface-2: #f8f7f4;       /* table header, inset areas */
  --border: #e5e2dc;
  --border-strong: #d3cfc7;

  /* Text */
  --text: #1c1b22;
  --text-2: #55525c;          /* secondary */
  --text-3: #6c6973;          /* hints, captions */

  /* Status (text on soft background) */
  --ok: #157c4d;   --ok-soft: #e4f4ec;   /* 4.59:1 on --ok-soft, 5.22:1 on --surface (was #157f4f: 4.41:1 on --ok-soft) */
  --warn: #9a6200; --warn-soft: #fdf1dc;
  --bad: #b42318;  --bad-soft: #fde8e6;
  --info: #1d5fae; --info-soft: #e5effb;
  --muted-soft: #eeece7;

  /* Type — IBM Plex Sans Arabic covers Arabic + Latin in one family. */
  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --fs-xs: .75rem; --fs-sm: .8125rem; --fs-md: .875rem; --fs-base: .9375rem;
  --fs-lg: 1.125rem; --fs-xl: 1.5rem; --fs-2xl: 1.875rem;
  --fw-regular: 400; --fw-medium: 500; --fw-semibold: 600; --fw-bold: 700;

  /* Space (4px grid) & shape */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;
  --radius-sm: 6px; --radius: 10px; --radius-lg: 14px; --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 4px 12px rgba(16, 24, 40, .06);
  --focus: 0 0 0 3px color-mix(in srgb, var(--brand-base) 25%, transparent);

  /* Layout */
  --sidebar-w: 256px;
  --topbar-h: 64px;

  /* Public side (assets/css/ds/public.css, catalog.css). Cover tones: one cool family (teal…steel) and one warm
     family (ochre…clay); a cover mixes its tone with the surface. Accents name the featured section's colour
     (a section profile stores the NAME, never a hex); --section-* are derived from the chosen accent in public.css. */
  --hue-teal: #2a7a72; --hue-blue: #3a6a9e; --hue-green: #4a7d55; --hue-sea: #2b7b8f; --hue-sage: #617f6c; --hue-steel: #4d5f93;
  --hue-ochre: #9b7432; --hue-plum: #7c5276; --hue-slate: #5b6478; --hue-clay: #9a5f48;
  --cover-bg: 15%; --cover-ink: 90%; --cover-ink-to: #000000; --cover-line: 32%;
  --acc-teal: #17736b; --acc-blue: #2d5f96; --acc-green: #3b7145; --acc-plum: #7a4870; --acc-ochre: #86601f; --acc-slate: #4e586c;
  --acc-teal-night: #5cbcb0; --acc-blue-night: #7fb0e6; --acc-green-night: #7cc08a; --acc-plum-night: #d39ac8; --acc-ochre-night: #ddb26a; --acc-slate-night: #a9b4c8;
  --section-base: var(--acc-teal); --section-night: var(--acc-teal-night);
  --scrim: color-mix(in srgb, #0b0a0d 46%, transparent);
  --shadow-lg: 0 18px 48px rgba(16, 24, 40, .14);
  --pub-hdr-h: 68px;
}

/* Dark — same structure, swapped values. Opt-in via data-theme or the OS preference. */
:root[data-theme="dark"] {
  --brand: color-mix(in srgb, var(--brand-base) 50%, #fff); --brand-hover: color-mix(in srgb, var(--brand-base) 40%, #fff); --brand-soft: color-mix(in srgb, var(--brand-base) 28%, #151416); --brand-ink: #0d1726;
  --bg: #151416; --surface: #1d1c1f; --surface-2: #242327;
  --border: #312f34; --border-strong: #423f46;
  --text: #ebe9ee; --text-2: #b3afb9; --text-3: #918d98;
  --ok: #4cc38a; --ok-soft: #143225; --warn: #e3a944; --warn-soft: #3a2c12;
  --bad: #f07167; --bad-soft: #3c1a18; --info: #6ea8f0; --info-soft: #172a44; --muted-soft: #28262b;
  --shadow-sm: none; --shadow: 0 4px 16px rgba(0, 0, 0, .35);
  --focus: 0 0 0 3px rgba(122, 167, 224, .35);
  --cover-bg: 20%; --cover-ink: 58%; --cover-ink-to: #ffffff; --cover-line: 34%;
  --scrim: color-mix(in srgb, #000 62%, transparent); --shadow-lg: 0 18px 48px rgba(0, 0, 0, .5);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --brand: color-mix(in srgb, var(--brand-base) 50%, #fff); --brand-hover: color-mix(in srgb, var(--brand-base) 40%, #fff); --brand-soft: color-mix(in srgb, var(--brand-base) 28%, #151416); --brand-ink: #0d1726;
    --bg: #151416; --surface: #1d1c1f; --surface-2: #242327;
    --border: #312f34; --border-strong: #423f46;
    --text: #ebe9ee; --text-2: #b3afb9; --text-3: #918d98;
    --ok: #4cc38a; --ok-soft: #143225; --warn: #e3a944; --warn-soft: #3a2c12;
    --bad: #f07167; --bad-soft: #3c1a18; --info: #6ea8f0; --info-soft: #172a44; --muted-soft: #28262b;
    --shadow-sm: none; --shadow: 0 4px 16px rgba(0, 0, 0, .35);
    --focus: 0 0 0 3px rgba(122, 167, 224, .35);
    --cover-bg: 20%; --cover-ink: 58%; --cover-ink-to: #ffffff; --cover-line: 34%;
    --scrim: color-mix(in srgb, #000 62%, transparent); --shadow-lg: 0 18px 48px rgba(0, 0, 0, .5);
  }
}

/* Dark brand that keeps its hue (2026-11-27). The color-mix above (50% white) turns a deep navy grey; where relative colour
   syntax exists, the dark brand is the brand's own hue at a fixed OKLCH lightness, with a chroma floor so a muted brand still
   reads as a colour (the floor scales down to 0 for a grey brand, which stays grey). Default navy #1e3a5f ⇒ ≈ #8bb4ea;
   --brand-ink (#0d1726) reads ≥ 7:1 on it for any brand. Same two selectors as the dark blocks above. */
@supports (color: oklch(from red l c h)) {
  :root:is([data-theme="dark"]) {
    --brand: oklch(from var(--brand-base) 0.76 clamp(min(calc(c * 3), 0.09), c, 0.16) h);
    --brand-hover: oklch(from var(--brand-base) 0.82 clamp(min(calc(c * 3), 0.09), c, 0.16) h);
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) {
      --brand: oklch(from var(--brand-base) 0.76 clamp(min(calc(c * 3), 0.09), c, 0.16) h);
      --brand-hover: oklch(from var(--brand-base) 0.82 clamp(min(calc(c * 3), 0.09), c, 0.16) h);
    }
  }
}
