/**
 * Design tokens — the single source of every colour, size and timing in web2.
 *
 * Values carried over verbatim from web/assets/css/style.css:4-131 so web2 is
 * visually the same product. Three divergences in the old web are resolved
 * here rather than reproduced:
 *
 *   1. auth/login.php:94-142 defined its own token block with a different
 *      accent (#22C55E instead of #00C853). web2 has one accent.
 *   2. card.php forced a light-only palette with differently-named variables.
 *   3. --color-surface-hover was used (style.css:768) but never defined. It is
 *      defined here.
 *
 * Theme selection is server-side: PHP writes data-theme on <html> from the
 * w2_theme cookie. There is no inline bootstrap script, which is what lets web2
 * run under script-src 'self' with no exceptions, and it removes the flash of
 * the wrong theme entirely.
 */

/**
 * The typeface, served from our own origin.
 *
 * --font-family has always named Plus Jakarta Sans, inherited from the old
 * web's token block, but web2 never shipped it: the old web pulls it from
 * fonts.googleapis.com, and web2 holds font-src to 'self'. The result was
 * every page quietly rendering in the system sans - the single largest visual
 * difference from the old web, on every screen at once.
 *
 * Self-hosting answers both: the design matches and the policy does not move.
 * It is also faster than the old web's version of the same font - no second
 * origin to connect to, and no stylesheet to fetch before the font request can
 * even start.
 *
 * One variable file per subset covers weights 400-800 (49 KB for both), where
 * static files would have been five per subset. Latin alone carries Icelandic;
 * latin-ext is here for the Polish and Czech names that turn up in driver and
 * passenger records.
 */
@font-face {
    font-family: 'Plus Jakarta Sans';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url('../fonts/plus-jakarta-sans-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;
}

@font-face {
    font-family: 'Plus Jakarta Sans';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url('../fonts/plus-jakarta-sans-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-20C4, U+2113, U+2C60-2C7F,
        U+A720-A7FF;
}

:root {
    /* Surfaces */
    --color-background: #0a0a0a;
    --color-surface: #141414;
    --color-surface-variant: #1a1a1a;
    --color-surface-hover: #202020;
    --color-border: #2a2a2a;

    /* Brand */
    --color-accent: #00C853;
    --color-accent-hover: #00a344;
    --color-accent-light: rgba(0, 200, 83, 0.15);
    --color-on-accent: #000000;

    /* Text */
    --color-text-primary: #ffffff;
    --color-text-secondary: #a0a0a0;
    --color-text-muted: #666666;

    /* Status */
    --color-error: #F85149;
    --color-warning: #D29922;
    --color-info: #58A6FF;
    --color-success: #22C55E;

    /* Forms */
    --color-input-bg: #1a1a1a;
    --color-input-border: #333333;

    /* Elevation */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.7);
    --shadow-accent: 0 4px 20px rgba(0, 200, 83, 0.4);

    /* Type */
    --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;

    /* Space */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;

    /* Motion */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;

    /* Layout. The bar is 16px of padding around a 42px logo plus its border,
       which is what the old web measures (style.css:433) — pages that size
       themselves against the viewport need the number, not just the padding. */
    --header-height: 75px;
    --content-max: 1200px;

    /* How much the two strips under the bar are taking up right now. Zero until
       one of them is shown, when assets/js/chrome.js puts a class on <body> and
       app.css gives this a height — so a page that fills the viewport can
       subtract the bar and whatever is hanging below it in one expression. */
    --banner-stack: 0px;
}

/* Light palette. Only what actually differs; everything else inherits. */
[data-theme="light"] {
    --color-background: #f5f5f5;
    --color-surface: #ffffff;
    --color-surface-variant: #f0f0f0;
    --color-surface-hover: #e8e8e8;
    --color-border: #e0e0e0;

    --color-accent-light: rgba(0, 200, 83, 0.1);

    --color-text-primary: #1a1a1a;
    --color-text-secondary: #555555;
    --color-text-muted: #888888;

    --color-error: #dc3545;
    --color-warning: #f59e0b;
    --color-info: #0ea5e9;
    --color-success: #16a34a;

    --color-input-bg: #ffffff;
    --color-input-border: #d0d0d0;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
    --shadow-accent: 0 4px 20px rgba(0, 200, 83, 0.25);
}

/**
 * "System" theme: no data-theme attribute at all, so the OS decides. Written as
 * a duplicate of the light block rather than a variable indirection because CSS
 * cannot alias a whole block, and duplication here is visible and checkable.
 */
@media (prefers-color-scheme: light) {
    :root:not([data-theme]) {
        --color-background: #f5f5f5;
        --color-surface: #ffffff;
        --color-surface-variant: #f0f0f0;
        --color-surface-hover: #e8e8e8;
        --color-border: #e0e0e0;

        --color-accent-light: rgba(0, 200, 83, 0.1);

        --color-text-primary: #1a1a1a;
        --color-text-secondary: #555555;
        --color-text-muted: #888888;

        --color-error: #dc3545;
        --color-warning: #f59e0b;
        --color-info: #0ea5e9;
        --color-success: #16a34a;

        --color-input-bg: #ffffff;
        --color-input-border: #d0d0d0;

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.08);
        --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
        --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
        --shadow-accent: 0 4px 20px rgba(0, 200, 83, 0.25);
    }
}

/**
 * The landing page's own green.
 *
 * The old web's two front pages disagree about it: /login carries its own
 * accent and its own greys (auth/login.php:94-128), the rest of the site takes
 * the shared ones from assets/css/style.css. Neither is more correct than the
 * other, and a visitor only ever compares a page with the page it replaces, so
 * web2 keeps whichever palette the page being cloned uses.
 *
 * Both themes of the old page use the same accent, hence no per-theme block.
 */
.page-landing {
    --color-background: #000000;
    --color-surface-variant: #1f1f1f;
    --color-accent: #22C55E;
    --color-accent-hover: #16A34A;
    --color-accent-light: rgba(34, 197, 94, 0.15);
    --color-text-secondary: #a3a3a3;
    --color-text-muted: #737373;
    --shadow-accent: 0 4px 20px rgba(34, 197, 94, 0.25);
}

[data-theme="light"] .page-landing {
    --color-background: #f5f5f5;
    --color-surface-variant: #f0f0f0;
    --color-accent-light: rgba(34, 197, 94, 0.1);
    --color-text-secondary: #555555;
    --color-text-muted: #888888;
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme]) .page-landing {
        --color-background: #f5f5f5;
        --color-surface-variant: #f0f0f0;
        --color-accent-light: rgba(34, 197, 94, 0.1);
        --color-text-secondary: #555555;
        --color-text-muted: #888888;
    }
}

/* Tighter rhythm on small screens, as in the old web. */
@media (max-width: 768px) {
    :root {
        --spacing-md: 0.875rem;
        --spacing-lg: 1.25rem;
        /* 14px of padding instead of 16, because --spacing-md shrinks here. */
        --header-height: 73px;
    }
}
