/* ============================================================================
   SIP design tokens — the single source of truth for colour, space, shape and
   type in BOTH shells: the focused pages (focus.css) and the signed-in
   workspace (components.css, app.css). Loaded first, straight after Bootstrap,
   by App.razor.

   Rules the tokens encode (decisions: DESIGN):
   - White pages, black type, SIP yellow. Yellow is a fill, kept for the single
     primary action, the active navigation item, the next step and the logo mark.
     Selection otherwise uses neutral greys.
   - Text and control labels reach 4.5:1 on every surface they sit on, and the
     edge of a form field reaches 3:1 (checked by tests/Sip.Portal.Tests/Ui/
     DesignTokenTests, which reads this file — keep the hex values on one line
     each).
   - Sentence case everywhere; no uppercase micro-labels.

   Bootstrap 5.3 runs in light mode (<html data-bs-theme="light">) with its
   variables mapped onto these tokens at the bottom of this file, so no blue
   Bootstrap state can leak through.
   ========================================================================== */

:root {
    /* ---------- colour: surfaces ----------
       White pages with black type and SIP yellow (owner, 30 November 2026: "bold, clear, simple",
       "the black and yellow theming colours like the app", on a white background). */
    --sip-canvas: #FFFFFF;          /* the page */
    --sip-surface: #FAFAF9;         /* sidebar, top bar, wizard panels */
    --sip-card: #FFFFFF;            /* cards, dialogs, menus: set apart by a hairline, not a shade */
    --sip-raise: #F1F1EF;           /* hover on a row or card, pressed segment */
    --sip-input: #FFFFFF;           /* the inside of a field */

    /* ---------- colour: lines ---------- */
    --sip-hairline: #E6E7EA;        /* dividers and card edges (decorative) */
    --sip-line-strong: #CFD1D5;     /* quiet button edges, underlines */
    --sip-control-line: #80848B;    /* the edge of a field: 3:1 on every surface, raise included */

    /* ---------- colour: text ---------- */
    --sip-text: #0B0B0C;            /* 19.7:1 on white */
    --sip-text-2: #3F4247;          /* secondary text, 10:1 */
    --sip-muted: #5B5E65;           /* hints, footnotes, placeholders: 6.5:1 on white, 5.7:1 on raise */
    --sip-muted-decor: #9A9DA3;     /* icons and borders ONLY: under 4.5:1, so never text */

    /* ---------- colour: brand ----------
       Yellow is a FILL on white (the primary action, the active navigation item, the next step):
       black reads on it at 9.9:1. Yellow text would be 1.9:1 on white, so text that should look
       yellow uses --sip-amber-text. */
    --sip-amber: #F2B233;
    --sip-amber-hover: #E5A21E;
    --sip-on-amber: #1A1200;        /* text on amber: 9.9:1 */
    --sip-amber-text: #7A5000;      /* amber-toned text: 7:1 on white */

    /* ---------- colour: status tones (chips, alerts, toasts, stats) ---------- */
    --sip-danger: #B42318;          /* danger as text or an icon: 6.6:1 on white */
    --sip-danger-strong: #B42318;   /* filled danger buttons: white text 6.6:1 */
    --sip-danger-text: #8A1A10;     /* text on a danger tint */
    --sip-success: #127A46;
    --sip-success-text: #0B5A33;
    --sip-info: #175CD3;
    --sip-info-text: #0B4A9E;
    --sip-warning: #A84C0A;         /* orange, deliberately not the brand amber */
    --sip-warning-text: #7A3A07;

    /* The same tones as rgb triplets, for tints: rgba(var(--sip-danger-rgb), .12). */
    --sip-text-rgb: 11, 11, 12;
    --sip-amber-rgb: 242, 178, 51;
    --sip-danger-rgb: 180, 35, 24;
    --sip-success-rgb: 18, 122, 70;
    --sip-info-rgb: 23, 92, 211;
    --sip-warning-rgb: 168, 76, 10;

    /* ---------- space: 4 8 12 16 24 32 48 64 ---------- */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;
    --space-8: 64px;

    /* ---------- shape ---------- */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-pill: 999px;

    /* Kept for the pages written before the scale (app.css, scoped page CSS). */
    --sip-radius: var(--radius-lg);
    --sip-radius-sm: 10px;

    /* ---------- controls ---------- */
    --control-h: 44px;              /* buttons and fields */
    --control-h-sm: 36px;           /* compact buttons in dense tables */

    /* ---------- type: 12 14 16 18 22 28 34 ---------- */
    --sip-font: Inter, 'Segoe UI', Helvetica, Arial, sans-serif;
    --sip-font-display: 'Inter Tight', Inter, 'Segoe UI', Helvetica, Arial, sans-serif;  /* headings and big numbers */
    --sip-mono: 'IBM Plex Mono', Consolas, 'Courier New', monospace;
    --text-xs: 0.75rem;     /* 12 */
    --text-sm: 0.875rem;    /* 14 */
    --text-md: 1rem;        /* 16 */
    --text-lg: 1.125rem;    /* 18 */
    --text-xl: 1.375rem;    /* 22 */
    --text-2xl: 1.75rem;    /* 28 */
    --text-3xl: 2.125rem;   /* 34 */
    --leading-tight: 1.2;
    --leading-snug: 1.35;
    --leading-normal: 1.55;

    /* ---------- focus ----------
       A 2px gap in the canvas colour, then a 2px ring in the text colour: visible on every surface
       and on amber, and never confused with selection. Shown on :focus-visible only, so a mouse
       click does not leave a ring behind. */
    --focus-ring: 0 0 0 2px var(--sip-canvas), 0 0 0 4px var(--sip-text);

    /* ---------- elevation and motion ---------- */
    --shadow-pop: 0 10px 32px rgba(11, 11, 12, 0.12);
    --shadow-modal: 0 16px 48px rgba(11, 11, 12, 0.18);
    --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
    --dur-fast: 120ms;
    --dur: 200ms;

    /* ---------- layout ---------- */
    --shell-sidebar-w: 260px;
    --shell-top-h: 56px;
    --shell-max-w: 1280px;
    --z-sticky: 20;
    --z-drawer: 1030;
    --z-menu: 1060;
    --z-modal: 1050;
    --z-toast: 1090;

    color-scheme: light;
}

/* Fingers, gloves and styluses get 52px targets, as the focused shell always has. */
@media (pointer: coarse) {
    :root {
        --control-h: 52px;
        --control-h-sm: 44px;
    }
}

/* ============================================================================
   Bootstrap, mapped onto the tokens. The attribute selector matches the dark
   theme's own block at the same specificity, and this file loads later, so the
   SIP values win everywhere Bootstrap reads a variable.
   ========================================================================== */

:root,
[data-bs-theme="light"] {
    --bs-body-font-family: var(--sip-font);
    --bs-font-monospace: var(--sip-mono);
    --bs-body-bg: var(--sip-canvas);
    --bs-body-bg-rgb: 255, 255, 255;
    --bs-body-color: var(--sip-text);
    --bs-body-color-rgb: var(--sip-text-rgb);
    --bs-emphasis-color: var(--sip-text);
    --bs-emphasis-color-rgb: var(--sip-text-rgb);
    --bs-heading-color: var(--sip-text);
    --bs-secondary-color: var(--sip-text-2);
    --bs-secondary-color-rgb: 63, 66, 71;
    --bs-secondary-bg: var(--sip-card);
    --bs-secondary-bg-rgb: 255, 255, 255;
    --bs-tertiary-color: var(--sip-muted);
    --bs-tertiary-color-rgb: 91, 94, 101;
    --bs-tertiary-bg: var(--sip-surface);
    --bs-tertiary-bg-rgb: 250, 250, 249;
    --bs-border-color: var(--sip-hairline);
    --bs-border-color-translucent: rgba(11, 11, 12, 0.08);
    --bs-border-radius: var(--radius-sm);
    --bs-border-radius-sm: 6px;
    --bs-border-radius-lg: var(--radius-md);

    /* Links read as text with an underline (see components.css), never as amber or blue. */
    --bs-link-color: var(--sip-text);
    --bs-link-color-rgb: var(--sip-text-rgb);
    --bs-link-hover-color: var(--sip-text);
    --bs-link-hover-color-rgb: var(--sip-text-rgb);
    --bs-code-color: var(--sip-text);

    /* Bootstrap's "primary" is the SIP primary action; its blue never appears. */
    --bs-primary: var(--sip-amber);
    --bs-primary-rgb: var(--sip-amber-rgb);
    --bs-primary-text-emphasis: var(--sip-amber-text);
    --bs-primary-bg-subtle: rgba(var(--sip-amber-rgb), 0.12);
    --bs-primary-border-subtle: rgba(var(--sip-amber-rgb), 0.4);
    --bs-info: var(--sip-info);
    --bs-info-rgb: var(--sip-info-rgb);
    --bs-info-text-emphasis: var(--sip-info-text);
    --bs-info-bg-subtle: rgba(var(--sip-info-rgb), 0.12);
    --bs-info-border-subtle: rgba(var(--sip-info-rgb), 0.4);
    --bs-success: var(--sip-success);
    --bs-success-rgb: var(--sip-success-rgb);
    --bs-success-text-emphasis: var(--sip-success-text);
    --bs-success-bg-subtle: rgba(var(--sip-success-rgb), 0.12);
    --bs-success-border-subtle: rgba(var(--sip-success-rgb), 0.4);
    --bs-warning: var(--sip-warning);
    --bs-warning-rgb: var(--sip-warning-rgb);
    --bs-warning-text-emphasis: var(--sip-warning-text);
    --bs-warning-bg-subtle: rgba(var(--sip-warning-rgb), 0.1);
    --bs-warning-border-subtle: rgba(var(--sip-warning-rgb), 0.4);
    --bs-danger: var(--sip-danger);
    --bs-danger-rgb: var(--sip-danger-rgb);
    --bs-danger-text-emphasis: var(--sip-danger-text);
    --bs-danger-bg-subtle: rgba(var(--sip-danger-rgb), 0.12);
    --bs-danger-border-subtle: rgba(var(--sip-danger-rgb), 0.4);
    --bs-secondary: var(--sip-text-2);
    --bs-secondary-text-emphasis: var(--sip-text-2);
    --bs-secondary-bg-subtle: rgba(var(--sip-text-rgb), 0.06);
    --bs-secondary-border-subtle: var(--sip-line-strong);
    --bs-light-bg-subtle: var(--sip-card);
    --bs-dark-bg-subtle: var(--sip-canvas);

    /* Focus: the SIP ring, not a blue glow. */
    --bs-focus-ring-width: 2px;
    --bs-focus-ring-opacity: 1;
    --bs-focus-ring-color: var(--sip-text);

    /* Form controls. */
    --bs-form-valid-color: var(--sip-success);
    --bs-form-valid-border-color: var(--sip-success);
    --bs-form-invalid-color: var(--sip-danger);
    --bs-form-invalid-border-color: var(--sip-danger);

    color-scheme: light;
}

/* The select chevron, drawn in --sip-text-2 so it shows on the field. */
.form-select,
select.form-control {
    --bs-form-select-bg-img: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%233F4247' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}

/* Bootstrap's pills and tabs: neutral selection, as everywhere else. */
.nav-pills {
    --bs-nav-pills-link-active-color: var(--sip-text);
    --bs-nav-pills-link-active-bg: rgba(var(--sip-text-rgb), 0.1);
}

.nav {
    --bs-nav-link-color: var(--sip-text-2);
    --bs-nav-link-hover-color: var(--sip-text);
}

.nav-tabs {
    --bs-nav-tabs-border-color: var(--sip-hairline);
    --bs-nav-tabs-link-hover-border-color: var(--sip-hairline);
    --bs-nav-tabs-link-active-color: var(--sip-text);
    --bs-nav-tabs-link-active-bg: var(--sip-card);
    --bs-nav-tabs-link-active-border-color: var(--sip-hairline) var(--sip-hairline) var(--sip-card);
}

.dropdown-menu {
    --bs-dropdown-bg: var(--sip-card);
    --bs-dropdown-border-color: var(--sip-hairline);
    --bs-dropdown-link-color: var(--sip-text);
    --bs-dropdown-link-hover-bg: var(--sip-raise);
    --bs-dropdown-link-active-color: var(--sip-text);
    --bs-dropdown-link-active-bg: var(--sip-raise);
}

.list-group {
    --bs-list-group-bg: var(--sip-card);
    --bs-list-group-border-color: var(--sip-hairline);
    --bs-list-group-active-color: var(--sip-text);
    --bs-list-group-active-bg: var(--sip-raise);
    --bs-list-group-active-border-color: var(--sip-line-strong);
}

.pagination {
    --bs-pagination-bg: var(--sip-card);
    --bs-pagination-border-color: var(--sip-hairline);
    --bs-pagination-color: var(--sip-text);
    --bs-pagination-hover-bg: var(--sip-raise);
    --bs-pagination-hover-color: var(--sip-text);
    --bs-pagination-focus-box-shadow: var(--focus-ring);
    --bs-pagination-active-bg: var(--sip-raise);
    --bs-pagination-active-border-color: var(--sip-line-strong);
    --bs-pagination-active-color: var(--sip-text);
}

.progress {
    --bs-progress-bg: var(--sip-hairline);
    --bs-progress-bar-bg: var(--sip-text-2);
}
