/*
 * edify-tokens.css — SINGLE SOURCE OF TRUTH for all design tokens.
 * Token block copied verbatim from /docs/mockups/03-app-dashboard.html (and 17-transport-routes.html).
 * All 17 mockups share the same token block. This file is canonical.
 * NEVER hard-code hex/size/radius/font anywhere else — consume var(--token).
 */

:root {
  /* ── Iris (brand violet) ─────────────────────────────────────────── */
  --iris-50:  #EEEDFC;
  --iris-100: #DEDBFA;
  --iris-200: #C0BAF5;
  --iris-300: #A097EF;
  --iris-400: #8174E9;
  --iris-500: #6957E4;
  --iris-600: #5646E0;
  --iris-700: #4536C7;
  --iris-800: #382CA0;
  --iris-900: #2C2480;

  /* ── Aqua (brand teal) ───────────────────────────────────────────── */
  --aqua-50:  #E6FAF6;
  --aqua-400: #2DCFB9;
  --aqua-500: #16B8A6;
  --aqua-600: #0E9C8C;

  /* ── Neutral / Ink ───────────────────────────────────────────────── */
  --n-0:   #FFFFFF;
  --n-25:  #FBFCFE;
  --n-50:  #F7F8FB;
  --n-100: #EFF1F6;
  --n-150: #E6E9F0;
  --n-200: #DCE0EA;
  --n-300: #C2C8D6;
  --n-400: #9AA2B5;
  --n-500: #6E7689;
  --n-600: #515A6E;
  --n-700: #3A4256;
  --n-800: #232A3B;
  --n-900: #0F1729;
  --n-950: #0A1020;

  /* ── Semantic (base / -bg / -fg) ─────────────────────────────────── */
  --success:    #15A34A;
  --success-bg: #E7F6EC;
  --success-fg: #0E7A37;

  --warning:    #F59E0B;
  --warning-bg: #FEF3E2;
  --warning-fg: #B4730B;

  --danger:    #E5484D;
  --danger-bg: #FDECEC;
  --danger-fg: #C03338;

  --info:    #3B82F6;
  --info-bg: #E8F1FE;
  --info-fg: #1D6AE0;

  /* ── Semantic role tokens — LIGHT ───────────────────────────────── */
  --bg:             var(--n-50);
  --surface:        var(--n-0);
  --surface-2:      var(--n-25);
  --surface-sunken: var(--n-100);

  --border:        var(--n-200);
  --border-strong: var(--n-300);

  --text:       var(--n-900);
  --text-soft:  var(--n-600);
  --text-muted: var(--n-500);

  --primary:             var(--iris-600);
  --primary-hover:       var(--iris-700);
  --primary-soft:        var(--iris-50);
  --primary-soft-border: var(--iris-200);

  --secondary: var(--aqua-500);

  /* CR-034 — text and icons on a --primary (and danger, WhatsApp) fill. */
  --on-primary: var(--n-0);

  /* ── Subject palette (S15 §1b(i)) — Subject.Color is a KEY "subject-1".."subject-8"
   * (Byteforce.Edify.Domain/Academics/Subject.cs) mapping 1:1 to these custom properties.
   * Aliases onto the existing brand/semantic ramp — no new raw hex — so each hue already
   * carries the product's accessibility/contrast vetting. --subject-default covers a null
   * Color (honest-empty, no color assigned yet). ───────────────────────────────────── */
  --subject-1: var(--iris-600);
  --subject-2: var(--aqua-500);
  --subject-3: var(--warning);
  --subject-4: var(--aqua-600);
  --subject-5: var(--iris-400);
  --subject-6: var(--info);
  --subject-7: var(--warning-fg);
  --subject-8: var(--success);
  --subject-default: var(--text-muted);

  /* ── Sidebar (always dark, both light and dark modes) ────────────── */
  --sidebar:          #0F1729;
  --sidebar-2:        #0A1020;
  --sb-text:          #AFB6C7;
  --sb-text-strong:   #FFFFFF;
  --sb-border:        rgba(255, 255, 255, 0.07);

  /* ── WhatsApp brand ──────────────────────────────────────────────── */
  --whatsapp:      #25D366;
  --whatsapp-deep: #075E54;
  /* CR-034 — the mirrored WhatsApp message bubble and chat background (mobile MP-07, MT-05). */
  --whatsapp-bubble: #FFFFFF;
  --whatsapp-bg: #E5DDD4;

  /* ── Mini-map (S17 §1b — representational road-grid backdrop only,
   * never a real map tile provider) ───────────────────────────────── */
  --map-bg: #E8EDF2;
  --road:   #FFFFFF;

  /* ── Brand gradients ─────────────────────────────────────────────── */
  --brand-gradient: linear-gradient(135deg, var(--iris-500) 0%, var(--aqua-500) 100%);
  --brand-deep:     linear-gradient(140deg, #4536C7, #5646E0 55%, #0E9C8C);

  /* ── Sidebar upsell gradient ────────────────────────────────────── */
  --upsell-gradient: linear-gradient(150deg, rgba(105, 87, 228, 0.25), rgba(22, 184, 166, 0.18));

  /* ── Typography stacks ───────────────────────────────────────────── */
  /* FIX-6b R2-3 (Gate D reviewer N1 + Lead ruling, 2026-09-02; POSITION
   * CORRECTED Gate D round 3, Lead live-effectiveness probe): 'Noto Naskh
   * Arabic' sits immediately AFTER the primary Latin face and BEFORE any
   * system/full-coverage font, so Urdu/Arabic script inside `dir="auto"`
   * bilingual-name fields on otherwise-LTR pages (StudentProfile.razor:145,
   * Admissions.razor:544, StaffHr.razor:1333 — none of which matches
   * [dir="rtl"]) renders in-face instead of falling through to the OS
   * default. A TAIL placement measured as LIVE-DEAD (round 3 finding): CSS
   * font matching walks the stack PER CHARACTER, and 'Segoe UI' — mid-stack,
   * ships Arabic glyphs — (and -apple-system/BlinkMacSystemFont, which cover
   * Arabic on macOS) claims Arabic-script characters long before the walk
   * ever reaches a tail-positioned Naskh entry. Measured live (Lead,
   * 'ٹڈڑںھیے پاکستان' at 32px): width under the OLD tail-positioned
   * --font-sans = 225.0px = pure 'Segoe UI' (225.2px) — Naskh never won a
   * single character. (A same-round comparison figure of 173.2px for "pure
   * Naskh" was itself a PRE-LOAD FALLBACK ARTIFACT -- font-display: swap
   * briefly renders the fallback face before the woff2 finishes loading --
   * and was discarded as unreliable; the STABLE value, measured after full
   * load, is 190.7px -- the position-2 fix below was re-measured at 191.3px
   * ~ that stable value, confirming Naskh now wins every Arabic-script
   * character.) Repositioning
   * fixes this because font matching stops at the FIRST family in the list
   * that has a glyph for a given character, so Naskh must be tried before
   * any full-coverage system font, not after. Safety is UNCHANGED by
   * position: the Noto Naskh Arabic woff2 (edify-fonts.css) ships NO Latin
   * glyphs AND each @font-face's unicode-range excludes the Latin block
   * entirely — both verified directly from the binaries (Gate D reviewer)
   * — so moving it earlier cannot cause it to claim a Latin character; Sora/
   * Inter still win every Latin character because they're listed first. The
   * [lang=ur]/[lang=ar]/[dir=rtl] remap below is unaffected — it already put
   * Naskh FIRST (before Sora/Inter) for RTL pages/content. */
  --font-display: 'Sora', 'Noto Naskh Arabic', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-sans:    'Inter', 'Noto Naskh Arabic', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:    'IBM Plex Mono', ui-monospace, Menlo, monospace;
  /* CR-034 — an Arabic-script run inside an LTR page (language chips, RTL labels). Whole RTL pages use the remap below. */
  --font-arabic: 'Noto Naskh Arabic', var(--font-sans);

  /* ── Radii ───────────────────────────────────────────────────────── */
  --r-sm:   8px;
  --r-md:   10px;
  --r-lg:   14px;
  --r-xl:   18px;
  --r-2xl:  24px;
  --r-full: 999px;

  /* ── Shadows (light) ─────────────────────────────────────────────── */
  --sh-xs: 0 1px 2px rgba(15, 23, 41, 0.06);
  --sh-sm: 0 1px 3px rgba(15, 23, 41, 0.08), 0 1px 2px rgba(15, 23, 41, 0.04);
  --sh-md: 0 4px 12px rgba(15, 23, 41, 0.08), 0 2px 4px rgba(15, 23, 41, 0.04);
  --sh-lg: 0 12px 28px rgba(15, 23, 41, 0.12), 0 4px 10px rgba(15, 23, 41, 0.05);
  /* CR-034 — the largest elevation (bottom sheets) and the sheet/dialog backdrop. */
  --sh-xl: 0 24px 48px rgba(15, 23, 41, 0.18), 0 8px 16px rgba(15, 23, 41, 0.06);
  --scrim: rgba(10, 16, 32, 0.5);

  /* ── Focus ring (CR-038) ─────────────────────────────────────────── */
  /* --ring        the keyboard focus ring of CONTROLS (buttons, links, tabs, menu items, switch and checkbox boxes): a 2px gap in the
   *               surface colour, then a 2px solid ring. 3:1 or more against --surface and --bg in both themes (WCAG 2.2 SC 1.4.11);
   *               SharedUi3_FocusRingTests computes and prints the four numbers.
   * --ring-inset  the same ring drawn INSIDE the element, for tabs and for rows that a parent's overflow would clip (.edify-focus-inset).
   * --ring-field  the soft Iris halo of FIELDS (inputs, selects, textareas, outlined MudBlazor inputs) and of selected-state halos. A field
   *               also turns its border Iris on focus; the border carries the contrast and the halo is polish. It is the old --ring value.
   * --ring-danger / --ring-success   the halo of an invalid / a successful field.
   * --ring-color and --ring-offset are what a theme changes: the dark block below re-declares both. */
  --ring-color: var(--iris-600);
  --ring-offset: var(--surface);
  --ring: 0 0 0 2px var(--ring-offset), 0 0 0 4px var(--ring-color);
  --ring-inset: inset 0 0 0 2px var(--ring-color);
  --ring-field: 0 0 0 3px rgba(86, 70, 224, 0.30);
  --ring-danger: 0 0 0 3px rgba(229, 72, 77, 0.28);
  --ring-success: 0 0 0 3px rgba(21, 163, 74, 0.30);

  /* ── Motion ──────────────────────────────────────────────────────── */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  /* ── Layout ──────────────────────────────────────────────────────── */
  --sb-w: 260px;

  /* CR-049 / LAYOUT-FW-1 - the content frame has NO maximum width: it fills the main column.
   * --page-gutter  the frame's side/top padding as ONE fluid value (16px at phone width, ~27px at 1400px, 28px from ~1500px up) so
   *                it never steps while the window is dragged. Pages add no gutter of their own.
   * --measure-prose  the comfortable line length for free prose (descriptions, help text); the page around it still fills. */
  --page-gutter: clamp(16px, 1.2vw + 10px, 28px);
  --measure-prose: 75ch;
}

/* ── Dark mode overrides ─────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:             #090E1B;
  --surface:        #121829;
  --surface-2:      #161D30;
  --surface-sunken: #0F1526;

  --border:        #252D42;
  --border-strong: #323B54;

  --text:       #EAEDF5;
  --text-soft:  #A8B0C4;
  --text-muted: #7E879C;

  --primary:             var(--iris-400);
  --primary-hover:       var(--iris-300);
  --primary-soft:        rgba(129, 116, 233, 0.14);
  --primary-soft-border: rgba(129, 116, 233, 0.3);

  --secondary: var(--aqua-400);

  --sidebar:   #0A0F1C;
  --sidebar-2: #070B16;

  --map-bg: #0E1626;
  --road:   #1C2638;

  /* CR-038 — the focus ring in dark: Iris 400 (4.7:1 on --surface) and the dark surface as the gap. --ring and --ring-inset are
   * composed in :root from these two and need no dark value; --ring-field is a fixed Iris 600 halo at 30 % (a literal, not built from
   * these two) and needs none either. That works only because data-theme is always set on
   * <html>, the same element as :root (edify-theme.js): --ring is substituted on :root, so a nested [data-theme="dark"] scope would
   * keep the light ring. data-theme must stay on <html>; a scope that needs its own ring re-composes --ring and --ring-inset, like
   * .edify-sidebar and the Students .bulk bar do. */
  --ring-color: var(--iris-400);
  --ring-offset: var(--surface);

  /* CR-034 — the mirrored WhatsApp bubble and chat background, dark values. */
  --whatsapp-bubble: #1F2C34;
  --whatsapp-bg: #0C1A17;

  /* Semantic tints — low-alpha in dark */
  --success-bg: rgba(21, 163, 74, 0.14);
  --success-fg: #56D98A;

  --warning-bg: rgba(245, 158, 11, 0.14);
  --warning-fg: #F6BE5C;

  --danger-bg: rgba(229, 72, 77, 0.15);
  --danger-fg: #F4888C;

  --info-bg: rgba(59, 130, 246, 0.15);
  --info-fg: #7FB0FA;

  /* Subject palette (S15 §1b(i)) — same aliases as :root; --subject-7 tracks --warning-fg's
   * dark value automatically via var() lazy resolution, redeclared here for explicitness. */
  --subject-1: var(--iris-600);
  --subject-2: var(--aqua-500);
  --subject-3: var(--warning);
  --subject-4: var(--aqua-600);
  --subject-5: var(--iris-400);
  --subject-6: var(--info);
  --subject-7: var(--warning-fg);
  --subject-8: var(--success);
  --subject-default: var(--text-muted);

  /* Shadows — deeper in dark */
  --sh-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --sh-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --sh-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --sh-lg: 0 12px 28px rgba(0, 0, 0, 0.5);
  --sh-xl: 0 24px 48px rgba(0, 0, 0, 0.55);

  /* ── Neutral / Ink ramp is INTENTIONALLY NOT overridden here (UI-DM-1) ──
   * Per the binding mockups (docs/mockups/*.html), dark mode flips SEMANTIC
   * role tokens only (--bg/--surface*/--text*/--border*/--primary/…); the
   * --n-* scale is a FIXED palette that keeps its light values in both
   * themes. A dark --n-* ramp would regress every sealed page that relies
   * on a fixed neutral step (e.g. drawer-overlay scrims built on --n-900).
   * Surfaces that must change in dark do so via per-page [data-theme="dark"]
   * overrides to semantic tokens — see the sealed-page idiom (S11/S12/S13)
   * and A-UIDM1-010. The T_NoNeutralRampInDarkBlock guard locks this in. */
}

/* ── FIX-6b (ed-5zq7.6.2, D-041) — Urdu/Arabic screen typography ─────────
 * Remap --font-display/--font-sans to a 'Noto Naskh Arabic'-FIRST stack
 * under [lang=ur], [lang=ar] and [dir=rtl]. The existing Latin stack
 * (Sora/Inter/system) is RETAINED as fallback: Noto Naskh Arabic's woff2
 * subset (edify-fonts.css) carries no Latin glyphs, so per-character CSS
 * font-fallback lets Arabic-script runs render in Naskh while Latin runs
 * (school names, codes, "cgs") keep rendering in Sora/Inter — no separate
 * per-script rule needed (AR4). --font-mono is UNCHANGED (IDs/codes/figures
 * are direction-neutral and Latin-numeral; A3/AR6 — no Arabic-Indic digits
 * introduced by this slice).
 * Qualified with the `html` element type (html[lang=...]/html[dir=...],
 * specificity 0,1,1) for the SAME reason as the --mud-typography-* block
 * below — a bare [lang="ur"] (0,1,0) only survives by source-order luck
 * against anything else declaring these vars at 0,1,0 (e.g. :root); the
 * element-qualified form wins unconditionally (Gate D reviewer N-hardening,
 * 2026-09-02). */
html[lang="ur"],
html[lang="ar"],
html[dir="rtl"] {
  --font-display: 'Noto Naskh Arabic', 'Sora', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-sans:    'Noto Naskh Arabic', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── FIX-6b R2-2 (Gate D, Lead live finding, 2026-09-02; ATTRIBUTION
 * CORRECTED Gate D round 4, reviewer confirm N-c): the app shell's
 * INHERITED default font is literal `Inter, -apple-system, BlinkMacSystem
 * Font, Segoe UI, sans-serif` even on ur/ar pages. The winning rule is
 * MudBlazor's OWN `body{font-family:var(--mud-typography-default-family)}`
 * (MudBlazor.min.css, part of the AbpStyles bundle) — NOT a LeptonX/
 * Bootstrap literal (Bootstrap's own body rule resolves --bs-font-sans-
 * serif, a hardcoded system-ui stack with no "Inter" anywhere in its
 * static CSS — grepped and confirmed). `--mud-typography-default-family`
 * is set at RUNTIME by <MudThemeProvider Theme="EdifyTheme.Theme"> from
 * EdifyTheme.cs's Typography.Default.FontFamily = ["Inter",
 * "-apple-system", "BlinkMacSystemFont", "Segoe UI", "sans-serif"] (same
 * mechanism as the AC3/A1 finding below) — the literal string "Inter"
 * therefore exists ONLY in EdifyTheme.cs (C#), never in any static CSS
 * package, which is exactly why a package-content search for "Inter"
 * finds nothing: it is injected into the DOM at runtime, not shipped in a
 * file. It beats our own `body{font-family:var(--font-sans)}` (edify-
 * base.css) by LOAD ORDER (both are plain `body` selectors, 0,0,1
 * specificity — edify-base.css is linked directly early in App.razor's
 * <head>, but MudBlazor.min.css loads later via the AbpStyles bundle and
 * wins the tie). Content that merely INHERITS from body (e.g. the Students
 * table's <td> text) never re-resolves --font-sans and stays on the
 * MudBlazor/EdifyTheme.cs literal in ur/ar. Fix (mechanism unchanged by
 * the attribution correction): re-assert `body{font-family:var(
 * --font-sans)}` under an element+attribute selector on <html> (0,1,1
 * specificity) so it beats ANY 0,0,1-specificity body rule — MudBlazor's
 * included — regardless of load order; the same specificity technique as
 * the token blocks above, applied one level further down the inheritance
 * chain where it is actually consumed. */
html[lang="ur"] body,
html[lang="ar"] body,
html[dir="rtl"] body {
  font-family: var(--font-sans);
}

/* ── FIX-6b AC3 (A1) — MudBlazor typography does NOT consume --font-display/
 * --font-sans. MudBlazor 9.4.0's shipped stylesheet (MudBlazor.min.css)
 * reads its OWN CSS custom properties — e.g. `body{font-family:var(
 * --mud-typography-default-family)}`, `.mud-typography-h1{font-family:var(
 * --mud-typography-h1-family)}` — for all 14 Typography variants (default,
 * h1-h6, subtitle1-2, body1-2, button, caption, overline). None of these
 * vars has a static value in the shipped stylesheet (grounded: no `:root{`
 * block exists in MudBlazor.min.css at all); <MudThemeProvider Theme=
 * "EdifyTheme.Theme"> (EdifyMainLayout.razor / DevStyleGuide.razor) sets
 * them at RUNTIME via a generated `:root{...}` <style> block, built from
 * EdifyTheme.cs's Typography.*.FontFamily string arrays (confirmed: the
 * Roboto/Helvetica/Arial/sans-serif DEFAULT literal is baked into
 * MudBlazor.dll as MudBlazor's own built-in Typography default — the same
 * shape our EdifyTheme.cs overrides with Inter/Sora arrays). Below, each
 * --mud-typography-*-family's Latin FALLBACK TAIL mirrors the family choice
 * (Sora for h1-h4, Inter for the rest) EdifyTheme.cs actually declares for
 * that variant, but is NOT a byte-for-byte copy of the C# FontFamily array
 * — it mirrors the existing --font-sans/--font-display TOKEN stacks instead
 * (which already carry a Roboto safety-net fallback that EdifyTheme.cs's
 * arrays themselves omit for Default/body-ish variants), so one canonical
 * Latin tail is reused everywhere rather than fourteen slightly different
 * ones. So our own [lang]/[dir] remap of --font-display/--font-sans above NEVER reaches
 * Mud-rendered text (MudButton/MudTable/MudTypography/…) — it is a
 * different variable namespace entirely; this is NOT a specificity fight
 * over the SAME variable, so !important would not even apply to the right
 * property. Fix: remap the --mud-typography-*-family vars directly, at the
 * SAME theme-token level (pure CSS, zero MudTheme.cs change — stays inside
 * "typography mapping", the non-escalation lane per spec §7).
 *
 * Selector note: MudThemeProvider's generated block targets `:root` (0,1,0
 * specificity). A bare `[lang="ur"]` attribute selector is ALSO (0,1,0) —
 * a tie that would fall back to DOM order, and MudThemeProvider's <style>
 * (rendered inside <body>, after this file's <head> <link>) would win that
 * tie. Qualifying with the element type — `html[lang="ur"]` — raises
 * specificity to (0,1,1), which beats a bare `:root` rule regardless of
 * source order. No !important required (see escalation list, spec §7). */
html[lang="ur"],
html[lang="ar"],
html[dir="rtl"] {
  --mud-typography-default-family:   'Noto Naskh Arabic', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mud-typography-h1-family:        'Noto Naskh Arabic', 'Sora', -apple-system, BlinkMacSystemFont, sans-serif;
  --mud-typography-h2-family:        'Noto Naskh Arabic', 'Sora', -apple-system, BlinkMacSystemFont, sans-serif;
  --mud-typography-h3-family:        'Noto Naskh Arabic', 'Sora', -apple-system, BlinkMacSystemFont, sans-serif;
  --mud-typography-h4-family:        'Noto Naskh Arabic', 'Sora', -apple-system, BlinkMacSystemFont, sans-serif;
  --mud-typography-h5-family:        'Noto Naskh Arabic', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mud-typography-h6-family:        'Noto Naskh Arabic', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mud-typography-subtitle1-family: 'Noto Naskh Arabic', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mud-typography-subtitle2-family: 'Noto Naskh Arabic', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mud-typography-body1-family:     'Noto Naskh Arabic', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mud-typography-body2-family:     'Noto Naskh Arabic', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mud-typography-button-family:    'Noto Naskh Arabic', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mud-typography-caption-family:   'Noto Naskh Arabic', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mud-typography-overline-family:  'Noto Naskh Arabic', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}
