/* =============================================================================
   Template.css — WiSDoM design tokens (single source of truth)
   -----------------------------------------------------------------------------
   One organised palette for the whole template. Change a value here (or override
   the matching --color-* below) and every chrome component — W7_top_bar,
   W7_left_menu, W7_button, W7_popup, W7_loader … — follows. There are NO raw
   colours in the components: they only read these tokens.

   LOADING: imported first by layout.css, which every consumer links as
   _content/wbi_core_layout/css/layout.css — so the tokens (and the DM Sans
   webfont) are available app-wide with no per-host wiring.

   ── THE LAYERS ────────────────────────────────────────────────────────────
   1. BRAND        --tpl-stl-blue / --tpl-stl-orange  (the raw STL brand hues),
                   also exposed under the --bs- namespace as --bs-STL-PRIMARY /
                   --bs-STL-SECONDARY (+ -rgb) for app/component use.
   2. BOOTSTRAP    Bootstrap's own --bs-primary (#0d6efd), --bs-secondary
                   (#6c757d), --bs-success, … are LEFT UNTOUCHED — we do not
                   override them. Use --bs-STL-PRIMARY/-SECONDARY for the brand.
   3. SEMANTIC     --tpl-primary, --tpl-secondary, … — what our own chrome reads.
                   Primary/secondary = the STL brand; the rest are standard.
   4. OVERRIDE     --color-*  (NOT declared here — shipped by the per-tenant CDN
                   colours.css, or written at runtime). Setting a --color-* feeds
                   the matching --tpl-* token. Full list at the bottom.

   So "let the user pick their primary colour" only has to set --color-primary
   (+ -rgb) on :root. The STL brand itself moves via --color-stl-blue/-orange.

   Hover/active/subtle shades are DERIVED with color-mix() so they automatically
   track whatever the base colour resolves to (brand default or tenant override).
   ========================================================================== */

/* DM Sans — the WiSDoM design typeface. Bundled locally (lib/fonts/dmsans/)
   instead of fetched from fonts.googleapis.com, so the template is self-contained.
   The two @font-face rules of lib/fonts/dmsans/dmsans.css, inlined: an @import here
   was a third sequential stylesheet request (page → layout.css → Template.css →
   dmsans.css) before the browser even knew the font files existed. */

/* latin */
@font-face {
    font-family: 'DM Sans';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('../lib/fonts/dmsans/dmsans-latin.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;
}

/* latin-ext */
@font-face {
    font-family: 'DM Sans';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('../lib/fonts/dmsans/dmsans-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
    /* ═══ 1. BRAND ════════════════════════════════════════════════════════════
       The raw STL brand colours. Overridable via --color-stl-blue/-orange. */
    --tpl-stl-blue: var(--color-stl-blue, #1946ba);
    --tpl-stl-blue-rgb: var(--color-stl-blue-rgb, 25, 70, 186);
    --tpl-stl-orange: var(--color-stl-orange, #f78c26);
    --tpl-stl-orange-rgb: var(--color-stl-orange-rgb, 247, 140, 38);

    /* ═══ 2a. STL BRAND under the --bs- namespace ═════════════════════════════
       Bootstrap's OWN 8 theme colours (--bs-primary #0d6efd, --bs-secondary
       #6c757d, --bs-success, …) are LEFT UNTOUCHED — we do not override them.
       The STL brand is exposed as its own explicit pair, so apps/components can
       opt into it on purpose. Overridable via --color-stl-blue/-orange. */
    --bs-STL-PRIMARY: var(--tpl-stl-blue);
    --bs-STL-PRIMARY-rgb: var(--tpl-stl-blue-rgb);
    --bs-STL-SECONDARY: var(--tpl-stl-orange);
    --bs-STL-SECONDARY-rgb: var(--tpl-stl-orange-rgb);

    /* ═══ 2c. WiSDoM 7 IDENTITY ═══════════════════════════════════════════════
       The deep navy + cyan pair of the WiSDoM 7 designs: the menu's app-name ink,
       the switch-confirmation pill, navy-tinted scrims and shades. Same values the
       screenshot annotator's toolbar uses literally. Overridable via
       --color-navy / --color-cyan (+ -rgb). */
    --tpl-navy: var(--color-navy, #0a1628);
    --tpl-navy-rgb: var(--color-navy-rgb, 10, 22, 40);
    --tpl-cyan: var(--color-cyan, #00b8f5);
    --tpl-cyan-rgb: var(--color-cyan-rgb, 0, 184, 245);

    /* ═══ 2b. SEMANTIC PALETTE (--tpl-*) — what our chrome reads ═══════════════
       Self-contained: base = var(--color-X, <default>); -rgb for rgba();
       -hover/-active/-subtle derived with color-mix(); -on = readable text on a
       solid fill. Primary/secondary stay the STL brand (the chrome is STL-branded,
       independent of Bootstrap's --bs-primary/-secondary). */

    /* Primary = STL blue */
    --tpl-primary: var(--color-primary, var(--bs-STL-PRIMARY));
    --tpl-primary-rgb: var(--color-primary-rgb, var(--bs-STL-PRIMARY-rgb));
    --tpl-primary-hover: color-mix(in srgb, var(--tpl-primary) 84%, #000);
    --tpl-primary-active: color-mix(in srgb, var(--tpl-primary) 72%, #000);
    --tpl-primary-subtle: color-mix(in srgb, var(--tpl-primary) 10%, transparent);
    --tpl-primary-light: color-mix(in srgb, var(--tpl-primary) 72%, #fff); /* legacy alias kept */
    --tpl-primary-dark: var(--tpl-primary-hover);                           /* legacy alias kept */
    --tpl-on-primary: var(--color-on-primary, #ffffff);

    /* Secondary = STL orange */
    --tpl-secondary: var(--color-secondary, var(--bs-STL-SECONDARY));
    --tpl-secondary-rgb: var(--color-secondary-rgb, var(--bs-STL-SECONDARY-rgb));
    --tpl-secondary-hover: color-mix(in srgb, var(--tpl-secondary) 86%, #000);
    --tpl-secondary-active: color-mix(in srgb, var(--tpl-secondary) 74%, #000);
    --tpl-secondary-subtle: color-mix(in srgb, var(--tpl-secondary) 12%, transparent);
    --tpl-secondary-light: color-mix(in srgb, var(--tpl-secondary) 74%, #fff); /* legacy alias */
    --tpl-secondary-dark: var(--tpl-secondary-hover);                          /* legacy alias */
    --tpl-on-secondary: var(--color-on-secondary, #212529);

    /* Success */
    --tpl-success: var(--color-success, #28a745);
    --tpl-success-rgb: var(--color-success-rgb, 40, 167, 69);
    --tpl-success-hover: color-mix(in srgb, var(--tpl-success) 85%, #000);
    --tpl-success-subtle: color-mix(in srgb, var(--tpl-success) 10%, transparent);
    --tpl-on-success: var(--color-on-success, #ffffff);

    /* Info */
    --tpl-info: var(--color-info, #17a2b8);
    --tpl-info-rgb: var(--color-info-rgb, 23, 162, 184);
    --tpl-info-hover: color-mix(in srgb, var(--tpl-info) 85%, #000);
    --tpl-info-subtle: color-mix(in srgb, var(--tpl-info) 10%, transparent);
    --tpl-on-info: var(--color-on-info, #ffffff);

    /* Warning */
    --tpl-warning: var(--color-warning, #ffc107);
    --tpl-warning-rgb: var(--color-warning-rgb, 255, 193, 7);
    --tpl-warning-hover: color-mix(in srgb, var(--tpl-warning) 88%, #000);
    --tpl-warning-subtle: color-mix(in srgb, var(--tpl-warning) 14%, transparent);
    --tpl-on-warning: var(--color-on-warning, #212529); /* dark text on yellow */

    /* Danger */
    --tpl-danger: var(--color-danger, #dc3545);
    --tpl-danger-rgb: var(--color-danger-rgb, 220, 53, 69);
    --tpl-danger-hover: color-mix(in srgb, var(--tpl-danger) 85%, #000);
    --tpl-danger-subtle: color-mix(in srgb, var(--tpl-danger) 10%, transparent);
    --tpl-on-danger: var(--color-on-danger, #ffffff);

    /* Light / Dark (neutral semantic fills) */
    --tpl-light: var(--color-light, var(--tpl-grey-100));
    --tpl-on-light: #212529;
    --tpl-dark: var(--color-dark, var(--tpl-grey-900));
    --tpl-on-dark: #ffffff;

    /* ═══ 3. NEUTRAL SCALE ════════════════════════════════════════════════════ */
    --tpl-white: #ffffff;
    --tpl-black: #000000;
    --tpl-grey-100: #f8f9fa;
    --tpl-grey-200: #e9ecef;
    --tpl-grey-300: #dee2e6;
    --tpl-grey-400: #ced4da;
    --tpl-grey-500: #adb5bd;
    --tpl-grey-600: #6c757d;
    --tpl-grey-700: #495057;
    --tpl-grey-800: #343a40;
    --tpl-grey-900: #212529;
    --tpl-grey-900-rgb: 33, 37, 41;

    /* ═══ 4. TEXT / SURFACES / BORDERS / FOCUS / SCRIM ════════════════════════ */
    --tpl-text: var(--color-text, var(--tpl-grey-900));        /* headings, body */
    --tpl-text-muted: var(--color-text-muted, #575757);        /* chrome item text */
    --tpl-text-subtle: var(--tpl-grey-600);                    /* captions, secondary */
    --tpl-text-disabled: var(--tpl-grey-500);                  /* placeholders, disabled */
    --tpl-heading: var(--color-heading, var(--tpl-navy));      /* chrome titles (menu app name) */

    --tpl-surface: var(--color-surface, var(--tpl-white));
    --tpl-surface-muted: var(--tpl-grey-100);          /* dropdown header panel, inputs */
    --tpl-surface-hover: #f5f7fa;                      /* row / button hover */
    --tpl-surface-hover-strong: #f1f3f5;               /* hamburger hover */
    --tpl-border: var(--color-border, var(--tpl-grey-200));
    --tpl-border-strong: var(--tpl-grey-300);
    --tpl-focus-ring: color-mix(in srgb, var(--tpl-primary) 25%, transparent);
    --tpl-scrim: rgba(var(--tpl-grey-900-rgb), 0.55);  /* modal/drawer backdrop */

    /* ═══ 5. TYPOGRAPHY ═══════════════════════════════════════════════════════ */
    --tpl-font-family: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;

    --tpl-fs-xs: 0.6875rem;  /* 11px — uppercase group / section labels */
    --tpl-fs-sm: 0.75rem;    /* 12px — version, meta */
    --tpl-fs-base: 0.8125rem;/* 13px — secondary text (email, sublabels) */
    --tpl-fs-md: 0.875rem;   /* 14px — body, inputs */
    --tpl-fs-lg: 0.9375rem;  /* 15px — nav items, user name, menu rows */
    --tpl-fs-icon: 1.1875rem;/* 19px — hamburger glyph */
    --tpl-fs-xl: 1.0625rem;  /* 17px — breadcrumb */
    --tpl-fs-brand: 1.25rem; /* 20px — brand wordmark / dropdown name (700) */

    --tpl-fw-regular: 400;
    --tpl-fw-medium: 500;
    --tpl-fw-semibold: 600;
    --tpl-fw-bold: 700;

    --tpl-tracking-label: 0.08em; /* uppercase group labels */
    --tpl-tracking-tight: -0.01em;/* brand wordmark / dropdown name */

    /* ═══ 6. SHAPE / ELEVATION / MOTION ═══════════════════════════════════════ */
    --tpl-radius-sm: 7px;
    --tpl-radius-md: 8px;
    --tpl-radius-lg: 9px;
    --tpl-radius-xl: 14px;
    --tpl-radius-pill: 100px;

    --tpl-shadow-sm: 0 4px 12px rgba(var(--tpl-grey-900-rgb), 0.12);
    --tpl-shadow-md: 0 6px 20px rgba(var(--tpl-grey-900-rgb), 0.12);
    --tpl-shadow-dropdown: 0 16px 44px rgba(var(--tpl-grey-900-rgb), 0.16);
    --tpl-shadow-drawer: 0 8px 40px rgba(var(--tpl-grey-900-rgb), 0.18);
    --tpl-shadow-topbar: 0 0 9px -1px rgba(0, 0, 0, 0.6);

    --tpl-ease: cubic-bezier(.2, .7, .2, 1);
    --tpl-dur: .28s;

    /* ═══ 7. CHROME COMPONENT DEFAULTS ════════════════════════════════════════
       Per-area knobs (each overridable by its own --color-* for granular
       theming), defaulting to the semantic/neutral tokens above so the chrome
       stays in one palette. */

    /* Top bar */
    --tpl-topbar-bg: var(--color-topbar-background, var(--tpl-surface));
    --tpl-topbar-bg-secondary: var(--color-topbar-background, var(--tpl-surface));
    --tpl-topbar-items: var(--color-topbar-items, var(--tpl-text-muted));
    --tpl-topbar-items-hover: var(--color-topbar-items-hover, var(--tpl-text));
    --tpl-topbar-breadcrumbs: var(--color-topbar-breadcrumbs, var(--tpl-text-muted));
    --tpl-topbar-breadcrumbs-hover: var(--color-topbar-breadcrumbs-hover, var(--tpl-text));
    --tpl-topbar-height: 60px;
    /* Menu & Top Bar v2 breadcrumb: the group crumbs are muted, the current crumb (and
       the caret before it) takes the active-menu-item colour, so the crumb and the
       highlighted menu row read as one. Own knobs: the legacy --color-topbar-breadcrumbs
       pair (#575757 / #000 in the tenant colours.css) no longer colours the trail. */
    --tpl-topbar-crumb: var(--color-topbar-crumb, var(--tpl-grey-500));
    --tpl-topbar-crumb-current: var(--color-topbar-crumb-current, var(--tpl-nav-active-fg));

    /* Left menu */
    --tpl-menu-bg: var(--color-menu-background, var(--tpl-surface));
    --tpl-menu-items: var(--tpl-text-muted);
    --tpl-menu-items-hover: var(--tpl-text);

    /* Side-navigation palette (now unified onto the neutral scale + brand accent).
       Menu & Top Bar v2: white panel, dark item labels with muted icons. */
    --tpl-nav-bg: var(--color-menu-background, var(--tpl-surface));
    --tpl-nav-border: var(--tpl-border);
    --tpl-nav-text: var(--tpl-text);
    --tpl-nav-text-muted: var(--tpl-text-subtle);
    --tpl-nav-item: var(--tpl-text);          /* row label */
    --tpl-nav-icon: var(--tpl-text-subtle);   /* row icon */
    --tpl-nav-section: var(--tpl-text-disabled);
    --tpl-nav-hover: var(--tpl-surface-hover);
    --tpl-nav-active-bg: var(--tpl-primary-subtle);
    --tpl-nav-active-fg: var(--tpl-primary);
    --tpl-nav-accent: var(--tpl-primary);
    --tpl-nav-width: 280px;

    /* Mastertemplate divider (legacy override knob, kept) */
    --tpl-mastertemplate-border: var(--color-mastertemplate-border, var(--tpl-border));
}

/* =============================================================================
   DARK MODE — opt-in via  <html data-theme="dark">.
   Demonstrates the token system: we only re-point the surface / text / border /
   chrome tokens at dark values; every component reads those tokens, so the whole
   chrome flips. The brand (primary/secondary) stays STL blue/orange — only the
   nav accent is lightened for contrast on dark. (No persistence — toggled live.)
   `:root[data-theme="dark"]` outranks the plain `:root` block above.
   ========================================================================== */
:root[data-theme="dark"] {
    /* ── OVERRIDE LAYER (--color-*) ───────────────────────────────────────────
       Set the SAME knobs a tenant theme uses. This is what fixes the chrome:
       the top bar / menu read var(--color-topbar-background ...) etc. DIRECTLY,
       so overriding --tpl-* alone left them on the tenant's (white) value. By
       overriding the --color-* layer here, both the direct usages AND every
       --tpl-* token that resolves them flip to dark in one place. */
    --color-surface: #1b1e24;
    --color-text: #e9ecef;
    --color-heading: #e9ecef;
    --color-text-muted: #b9bfc7;
    --color-border: #343a40;

    --color-topbar-background: #1b1e24;
    --color-topbar-items: #b9bfc7;
    --color-topbar-items-hover: #ffffff;
    --color-topbar-breadcrumbs: #b9bfc7;
    --color-topbar-breadcrumbs-hover: #ffffff;
    --color-menu-background: #1b1e24;
    --color-mastertemplate-border: #343a40;

    /* ── Tokens with no --color knob — set directly. ─────────────────────────
       (--tpl-surface/-border/-text/-text-muted, the topbar-* and menu/nav-bg/
       -text/-section/-hover tokens all auto-resolve from the --color-* above.) */
    --tpl-surface-muted: #23272f;
    --tpl-surface-hover: #2a2f37;
    --tpl-surface-hover-strong: #313742;
    --tpl-border-strong: #454c56;
    --tpl-text-subtle: #9aa0a8;
    --tpl-text-disabled: #868e96;
    --tpl-scrim: rgba(0, 0, 0, 0.70);
    --tpl-light: #2a2f37;
    --tpl-on-light: #e9ecef;
    --tpl-dark: #e9ecef;
    --tpl-on-dark: #1b1e24;

    /* Nav accent lightened for contrast on dark (rest of nav auto-resolves). */
    --tpl-nav-active-bg: rgba(var(--tpl-primary-rgb), 0.24);
    --tpl-nav-active-fg: #6ea8ff;
    --tpl-nav-accent: #6ea8ff;
}

/* =============================================================================
   CUSTOMIZATION SURFACE — set these --color-* on :root (tenant colours.css or a
   runtime theming UI) to re-skin the chrome. Each feeds the matching --tpl-*
   token; brand defaults apply when unset. DO NOT declare these here — contract
   only. (Bootstrap's own --bs-* theme colours are left at their defaults; the STL
   brand is available as --bs-STL-PRIMARY / --bs-STL-SECONDARY for app use.)
         Brand:     --color-stl-blue [+ -rgb]   --color-stl-orange [+ -rgb]
         WiSDoM 7:  --color-navy [+ -rgb]       --color-cyan [+ -rgb]
         Semantic:  --color-primary [+ -rgb]    --color-secondary [+ -rgb]
                    --color-success [+ -rgb]    --color-info [+ -rgb]
                    --color-warning [+ -rgb]    --color-danger [+ -rgb]
                    --color-light [+ -rgb]      --color-dark [+ -rgb]
         Contrast:  --color-on-primary  --color-on-secondary  --color-on-success
                    --color-on-info  --color-on-warning  --color-on-danger
         Text/surf: --color-text  --color-text-muted  --color-heading  --color-surface
                    --color-border
         Chrome:    --color-topbar-background  --color-topbar-items[-hover]
                    --color-topbar-breadcrumbs[-hover]  --color-menu-background
                    --color-topbar-crumb  --color-topbar-crumb-current
                    --color-mastertemplate-border
   ============================================================================= */
