/* Tailwind design tokens: colors, type, spacing, radius and focus ring, light and dark.
   Every text pair is at least 4.5:1 and every control edge or focus ring is at least 3:1 (checked by design-tokens.test.mjs).
   Names are role based (surface, text, accent), never trade or competitor based. */
:root {
    color-scheme: light dark;

    --tk-bg: #f6f7f9;
    --tk-surface: #ffffff;
    --tk-surface-2: #eef1f5;
    --tk-text: #1a2230;
    --tk-text-2: #4a5362;
    --tk-edge: #6f7a8b;            /* control borders: 3:1 or better on surface and bg */
    --tk-line: #d5d9e0;            /* decorative dividers only */
    --tk-accent: #1d4ed8;
    --tk-on-accent: #ffffff;
    --tk-accent-soft: #e4ebfc;
    --tk-focus: #1d4ed8;           /* focus ring colour, 3:1 against surface and bg */
    --tk-focus-halo: #ffffff;
    --tk-focus-on-dark: #8cb4ff;   /* ring on dark brand chrome such as the sidebar: 3:1 on #16202e and on any navy at least that dark */
    --tk-ok: #11693f;
    --tk-warn: #8a5300;
    --tk-danger: #b42318;
    --tk-busy: #4a5362;

    --tk-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --tk-fs-xs: 0.8125rem;
    --tk-fs-sm: 0.9375rem;
    --tk-fs-md: 1rem;
    --tk-fs-lg: 1.25rem;
    --tk-fs-xl: 1.5rem;
    --tk-lh: 1.45;

    --tk-space-1: 0.25rem;
    --tk-space-2: 0.5rem;
    --tk-space-3: 0.75rem;
    --tk-space-4: 1rem;
    --tk-space-5: 1.5rem;
    --tk-space-6: 2rem;
    --tk-space-7: 3rem;

    --tk-radius-sm: 4px;
    --tk-radius-md: 8px;
    --tk-radius-lg: 12px;

    --tk-hit: 3rem;             /* minimum touch target */
    --tk-focus-width: 3px;
    --tk-focus-offset: 2px;
}

:root[data-theme="light"] {
    color-scheme: light;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --tk-bg: #0f1621;
    --tk-surface: #17202e;
    --tk-surface-2: #202b3c;
    --tk-text: #e8edf5;
    --tk-text-2: #b4becf;
    --tk-edge: #8391a6;
    --tk-line: #2d3a4e;
    --tk-accent: #8cb4ff;
    --tk-on-accent: #0f1621;
    --tk-accent-soft: #1d2d4d;
    --tk-focus: #8cb4ff;
    --tk-focus-halo: #0f1621;
    --tk-ok: #5bd28f;
    --tk-warn: #f0b45a;
    --tk-danger: #ff8f84;
    --tk-busy: #b4becf;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --tk-bg: #0f1621;
        --tk-surface: #17202e;
        --tk-surface-2: #202b3c;
        --tk-text: #e8edf5;
        --tk-text-2: #b4becf;
        --tk-edge: #8391a6;
        --tk-line: #2d3a4e;
        --tk-accent: #8cb4ff;
        --tk-on-accent: #0f1621;
        --tk-accent-soft: #1d2d4d;
        --tk-focus: #8cb4ff;
        --tk-focus-halo: #0f1621;
        --tk-ok: #5bd28f;
        --tk-warn: #f0b45a;
        --tk-danger: #ff8f84;
        --tk-busy: #b4becf;
    }
}

/* One visible focus ring for every interactive element: solid ring plus a halo so it reads on any background. */
:where(a, button, input, select, textarea, summary, [tabindex], [role="button"]):focus-visible {
    outline: var(--tk-focus-width) solid var(--tk-focus);
    outline-offset: var(--tk-focus-offset);
    box-shadow: 0 0 0 calc(var(--tk-focus-offset) + 1px) var(--tk-focus-halo);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* Dark brand chrome (the sidebar) keeps a light ring so the indicator holds 3:1 whatever the page theme. */
.desktop-nav { --tk-focus: var(--tk-focus-on-dark); --focus-ring: var(--tk-focus-on-dark); --tk-focus-halo: var(--bg-deep-navy, #16202e); }
