/* =============================================================
   Design tokens — single source of truth for the WorkTrack360 UI.
   Every color, radius, type step, elevation and motion value used
   in application CSS resolves to a token defined here.

   Legacy aliases are kept at the bottom so existing selectors keep
   working; prefer the scale names for new code.
   ============================================================= */

:root {
    /* ---- Typography ------------------------------------------------ */
    /* VS1: 16px root = Bootstrap native size, so 1rem is 16px for controls, labels and body on every page. */
    --root-font-size: 16px;
    /* Multiplier for every --text-* step; the member "Larger text" setting raises it (member-display.css). */
    --text-scale: 1;

    --font-sans: Inter, "Segoe UI", system-ui, -apple-system, Arial, sans-serif;

    --text-2xs: calc(12px * var(--text-scale));
    --text-xs: calc(13px * var(--text-scale));
    --text-sm: calc(14px * var(--text-scale));
    --text-base: calc(16px * var(--text-scale));
    --text-md: calc(16px * var(--text-scale));
    --text-lg: calc(16px * var(--text-scale));
    --text-xl: calc(18px * var(--text-scale));
    --text-2xl: calc(20px * var(--text-scale));
    --text-3xl: calc(22px * var(--text-scale));
    --text-4xl: calc(24px * var(--text-scale));
    --text-5xl: calc(26px * var(--text-scale));
    --text-6xl: calc(30px * var(--text-scale));
    --text-7xl: calc(34px * var(--text-scale));
    --text-8xl: calc(42px * var(--text-scale));

    /* ---- Type hierarchy (ONE scale, used by every shell) ----
       page title > card title > sub-heading > lead/summary > body > in-card list/table > meta > chip.
       A summary line is never smaller than the list it summarises; body text is never larger than its title. */
    --type-h1: calc(1.75rem * var(--text-scale));
    --type-h2: calc(1.25rem * var(--text-scale));
    --type-h3: calc(1.0625rem * var(--text-scale));
    --type-lead: calc(1rem * var(--text-scale));
    --type-body: calc(1rem * var(--text-scale));
    --type-table: calc(0.9375rem * var(--text-scale));
    --type-meta: calc(0.875rem * var(--text-scale));
    --type-chip: calc(0.8125rem * var(--text-scale));
    --type-nav: calc(1rem * var(--text-scale));

    --weight-regular: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;

    /* ---- Neutrals -------------------------------------------------- */
    --grey-25: #fcfcfd;
    --grey-50: #f9fafb;
    --grey-100: #f2f4f7;
    --grey-200: #eaecf0;
    --grey-300: #d0d5dd;
    --grey-400: #98a2b3;
    --grey-500: #667085;
    --grey-600: #475467;
    --grey-700: #344054;
    --grey-800: #1d2939;
    --grey-900: #101828;

    /* Cool neutrals used by the app shell (sidebar, canvas, rules) */
    --slate-50: #f7f9fb;
    --slate-100: #eef1f5;
    --slate-200: #e4e7ec;
    --slate-300: #cbd5e1;
    --slate-400: #8492a6;
    --slate-500: #5f697a;
    --slate-600: #4b5563;
    --slate-900: #111827;

    /* ---- Brand blue ------------------------------------------------ */
    --blue-25: #f5faff;
    --blue-50: #eff8ff;
    --blue-100: #d1e9ff;
    --blue-200: #b2ddff;
    --blue-300: #84c5ff;
    --blue-400: #2290ff;
    --blue-500: #1686e8;
    --blue-600: #0875df;
    --blue-700: #0668c6;
    --blue-800: #0b5cad;
    --blue-900: #0c4364;

    /* ---- Success --------------------------------------------------- */
    --green-50: #ecfdf3;
    --green-100: #dcfae6;
    --green-200: #abefc6;
    --green-400: #12b76a;
    --green-500: #067647;
    --green-600: #087f3e;
    --green-700: #08723a;

    /* ---- Danger ---------------------------------------------------- */
    --red-50: #fef3f2;
    --red-100: #fee4e2;
    --red-200: #fecdca;
    --red-300: #fda29b;
    --red-400: #f04438;
    --red-500: #d92d20;
    --red-600: #b42318;
    --red-700: #912018;

    /* ---- Warning --------------------------------------------------- */
    --amber-50: #fffaeb;
    --amber-100: #fef0c7;
    --amber-200: #fedf89;
    --amber-400: #fdb022;
    --amber-500: #f79009;
    --amber-600: #b54708;
    --amber-700: #93370d;

    /* ---- Semantic surfaces & text ---------------------------------- */
    --canvas: var(--slate-100);
    --surface: #fff;
    --surface-sunken: var(--grey-50);
    --surface-raised: #fff;
    --line: var(--slate-200);
    --line-strong: var(--grey-300);
    --line-input: var(--grey-500); /* field boundaries need 3:1 (WCAG 1.4.11) */

    --ink: var(--slate-900);
    --ink-strong: var(--grey-900);
    /* Muted text: grey-600 is 7.7:1 on white and 7.2:1 on the page canvas. grey-500 was 4.4:1 on the canvas,
       under the 4.5:1 floor (Docs/UI-STANDARDS.md, colour roles). */
    --ink-muted: var(--grey-600);
    --ink-subtle: var(--slate-500);
    --ink-inverse: #fff;

    --accent: var(--blue-600);
    --accent-hover: var(--blue-700);
    --accent-soft: var(--blue-50);
    --amber: var(--amber-600);
    --blue-soft: var(--blue-50);
    --green-soft: var(--green-50);
    --red-soft: var(--red-50);
    --amber-soft: var(--amber-50);
    --danger: var(--red-500);
    --success: var(--green-500);
    --warning: var(--amber-500);

    /* ---- Radius ---------------------------------------------------- */
    --radius-xs: 6px;
    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 20px;
    --radius-pill: 999px;
    --radius-circle: 50%;

    /* ---- Elevation ------------------------------------------------- */
    --shadow-xs: 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, .06);
    --shadow-md: 0 4px 12px rgba(16, 24, 40, .08);
    --shadow-lg: 0 8px 24px rgba(16, 24, 40, .12);
    --shadow-xl: 0 12px 28px rgba(16, 24, 40, .16);
    --shadow-2xl: 0 24px 60px rgba(16, 24, 40, .22);
    --shadow-drawer: 12px 0 30px rgba(16, 24, 40, .16);
    --shadow-drawer-left: -16px 0 38px rgba(16, 24, 40, .16);
    --ring-accent: 0 0 0 2px var(--accent); /* solid so focus meets 3:1 (WCAG 2.4.7 / 1.4.11) */
    --ring-danger: 0 0 0 2px var(--red-500);
    --ring-success: 0 0 0 2px var(--green-500);
    --ring-warning: 0 0 0 2px var(--amber-600);

    /* ---- Motion ---------------------------------------------------- */
    --ease: cubic-bezier(.4, 0, .2, 1);
    --duration-fast: .15s;
    --duration-base: .2s;
    --duration-slow: .3s;

    /* ---- Layout ---------------------------------------------------- */
    --sidebar: 240px;
    --categories: 390px;
    --topbar: 58px;
    --pagebar: 78px;

    /* ---- UI type scale (UF2): one scale for WT360 and G2 -------------
       Use these names for font sizes and control heights. Applied to
       headings, body text, buttons and form controls in a11y.css.     */
    --ui-text-body: var(--type-body);     /* body copy, table cells, card text   */
    --ui-text-small: var(--type-meta);    /* meta, captions, hints, badges       */
    --ui-text-nav: var(--type-nav);      /* nav and menu items                  */
    --ui-text-button: 16px;   /* buttons                             */
    --ui-text-control: 16px;  /* inputs, selects, textareas (1rem) */
    --ui-text-h1: var(--type-h1);       /* page title (24-28)                  */
    --ui-text-h2: var(--type-h2);       /* section title (20-22)               */
    --ui-text-h3: var(--type-h3);       /* card title (17-18)                  */
    --ui-button-height: 40px; /* 36-40 desktop; 44 on mobile         */
    --ui-control-height: 2.5rem;
    --ui-text-h4: var(--type-h3);
    --ui-check-size: 1.125rem;

    /* ---- UI layer scale (UF2): the only z-index values to use ------ */
    --z-base: 1;
    --z-raised: 10;
    --z-sticky: 20;        /* sticky table headers, page bars          */
    --z-header: 100;       /* top bar, side nav                        */
    --z-dropdown: 300;     /* menus, selects, popovers, tooltips       */
    --z-overlay: 900;      /* backdrops                                */
    --z-drawer: 1000;      /* right-side fly-ins                       */
    --z-modal: 1100;       /* dialogs                                  */
    --z-popover-top: 1200; /* menus opened from inside a dialog/fly-in */
    --z-toast: 1300;       /* notifications                            */

    /* =================================================================
       UI standards tokens (Docs/UI-STANDARDS.md). One set for every
       role. The role design systems (a-ds, cm-ds, p-ds, s-ds,
       member-ds) map their own --a-/--c-/--p-/--s-/--m- names to these.
       ================================================================= */

    /* Type scale: the --type-* tokens at the top of this file (text-hierarchy work). */
    --font-ui: var(--font-sans); /* one UI font; monospace only for code */
    --font-code: ui-monospace, "Cascadia Mono", Consolas, monospace;

    /* Spacing scale: 4, 8, 12, 16, 24, 32, 48 */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;

    /* Radius roles */
    --radius-control: 8px;   /* buttons, inputs, selects */
    --radius-card: 12px;     /* cards, panels, alerts, table frames */
    --radius-dialog: 16px;   /* dialogs and fly-in corners */
    --radius-chip: 999px;    /* chips, pills, badges */

    /* Elevation roles: cards sit flat with a 1px line; only floating things cast a shadow */
    --elevation-card: none;
    --elevation-raised: var(--shadow-sm);   /* hover on a clickable card */
    --elevation-menu: var(--shadow-lg);     /* menus, popovers, hints */
    --elevation-overlay: var(--shadow-2xl); /* dialogs and fly-ins */

    /* Controls */
    --control-height: 2.75rem;    /* 44px on phones and tablets */
    --control-height-sm: 2.25rem; /* small buttons in dense tables; still over the 24px target floor */
    --control-pad-x: 16px;
    --control-border: var(--line-input);
    --check-size: 1.125rem;

    /* Focus ring: 2px solid, 2px gap, 3:1 or more against the page */
    --focus-ring-width: 2px;
    --focus-ring-offset: 2px;

    /* Colour roles (contrast on white / on the canvas, WCAG 2.2) */
    --role-text: var(--grey-900);          /* 17.8:1 */
    --role-text-muted: var(--grey-600);    /* 7.7:1 / 7.2:1 */
    --role-link: var(--blue-800);          /* 6.7:1 */
    --role-primary: var(--blue-600);       /* fill; white text on it 4.6:1 */
    --role-primary-hover: var(--blue-700); /* 5.5:1 */
    --role-border: var(--slate-200);       /* decorative line */
    --role-border-input: var(--grey-500);  /* 5.0:1, over the 3:1 UI floor */
    --role-success-ink: var(--green-600);  /* 5.1:1 on white, 4.8:1 on its tint */
    --role-success-bg: var(--green-50);
    --role-success-line: var(--green-200);
    --role-warning-ink: #8a4b00;           /* 6.3:1 on its tint */
    --role-warning-bg: #fff6e5;
    --role-warning-line: #f5c46b;
    --role-danger-ink: var(--red-600);     /* 6.6:1 on white, 6.0:1 on its tint */
    --role-danger-bg: var(--red-50);
    --role-danger-line: var(--red-200);
    --role-info-ink: var(--blue-800);      /* 6.2:1 on its tint */
    --role-info-bg: var(--blue-50);
    --role-info-line: var(--blue-200);
    --role-on-dark: #fff;                  /* text and links on navy / dark bars */

    /* Layout */
    --container-max: 1480px;      /* staff pages */
    --container-narrow: 1100px;   /* member, partner and state pages */
    --container-text: 75ch;       /* paragraphs */
    --card-pad: 16px;
    --card-pad-lg: 24px;
    --section-gap: 24px;
    --grid-gap: 16px;

    /* ---- Legacy aliases (do not use in new code) -------------------- */
    --color-white: #fff;
    --color-black: #000;
    --white: #fff;
    --text-color: var(--ink);
    --body-bg: var(--canvas);
    --border-color: var(--line);
    --desc-color: var(--ink-muted);
    --light-grey-bg: var(--grey-100);
    --dark-grey: var(--ink-muted);
    --color-blue: var(--accent);
    --color-red: var(--red-600);
    --error-color: var(--red-600);
    --focus-color: var(--accent);
    --muted: var(--ink-subtle);
    --subtle: var(--ink-subtle);
    --soft: var(--slate-50);
    --blue: var(--accent);
    --blue-dark: var(--accent-hover);
    --green: var(--green-600);
    --red: var(--danger);
    --navy: var(--slate-900);
    --secondary: var(--slate-900);
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Desktop with room (1200px and up): controls and buttons are 40px; phones and tablets keep 44px targets. */
@media (min-width: 1200px) {
    :root {
        --control-height: 2.5rem;
    }
}
/* Type-hierarchy helpers: a lead is the one-line summary directly under a card title; meta is a source line, timestamp or hint. */
.t-lead { font-size: var(--type-lead); font-weight: 600; line-height: 1.4; }
.t-meta { font-size: var(--type-meta); font-weight: 400; line-height: 1.4; color: var(--ink-muted, #475467); }
