/*
 * Mind design tokens ("Focused dark"). Reference: docs/DESIGN.md.
 *
 * Colour roles are named after Material 3 roles (primary, on-primary, surface-container-*, on-surface, outline ...), so the Android app
 * can use Material You (dynamic colour) and fall back to exactly these values. Seed colour: --color-brand (#7c6cff).
 * Theme: <html data-theme="dark|light"> (set before first paint by the script in index.html). Dark is the default.
 * Every text/background pair used by the components meets WCAG AA (4.5:1; 3:1 for borders of controls and focus rings); the e2e
 * "design" suite re-checks that against these values.
 */

:root {
    color-scheme: dark;

    /* ---- Colour: dark (default) ---- */
    --color-brand: #7c6cff;                       /* the identity colour: logo, focus ring, Android seed */
    --color-primary: #6a5af2;                     /* filled controls (white text 4.8:1) */
    --color-on-primary: #ffffff;
    --color-primary-container: #2c2766;           /* tonal fills: selected nav item, chips */
    --color-on-primary-container: #e3e0ff;
    --color-link: #a99fff;                        /* accent used as text/icon colour (8:1 on the page) */

    --color-surface-container-lowest: #0b0d12;    /* sunken: inputs, code */
    --color-surface: #10131a;                     /* page background */
    --color-surface-container-low: #141821;       /* sidebar, top bar */
    --color-surface-container: #181c27;           /* cards, panels */
    --color-surface-container-high: #1f2432;      /* menus, popovers, hover */
    --color-surface-container-highest: #282e3f;   /* dialogs, pressed, selected row */
    --color-on-surface: #e7e9f1;                  /* primary text (15:1) */
    --color-on-surface-variant: #a6adc2;          /* secondary text (8:1) */
    --color-on-surface-muted: #8e96ae;            /* tertiary: hints, placeholders, kbd (6:1, never below 4.5:1 on any surface) */
    --color-outline: #6f7893;                     /* borders of form controls (4:1) */
    --color-outline-variant: #2b3142;             /* dividers and card borders (decorative) */
    --color-scrim: rgb(5 6 10 / 0.62);

    --color-error: #ff7b86;                       /* error text and icons */
    --color-error-fill: #d63b4b;                  /* danger button (white text 4.6:1) */
    --color-on-error: #ffffff;
    --color-error-container: #4a1d26;
    --color-on-error-container: #ffd9dc;
    --color-success: #4cd39a;
    --color-success-container: #12382b;
    --color-on-success-container: #c3f5df;
    --color-warning: #f2b84b;
    --color-warning-container: #42310e;
    --color-on-warning-container: #ffe7b3;
    --color-info: #5fb4ff;
    --color-info-container: #12324f;
    --color-on-info-container: #cfe8ff;

    --focus-ring: #8f82ff;                        /* 5:1 on every surface */
    --shadow-color: 0 0 0;

    /* ---- Typography ---- */
    --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    --text-xs: 0.75rem;     /* 12px: kbd, badges, meta */
    --text-sm: 0.8125rem;   /* 13px: secondary, nav, rows */
    --text-base: 0.875rem;  /* 14px: body (compact density) */
    --text-md: 1rem;        /* 16px: inputs on touch devices, dialog titles */
    --text-lg: 1.125rem;
    --text-xl: 1.375rem;    /* page titles */
    --text-2xl: 1.75rem;    /* auth heading */
    --leading-tight: 1.25;
    --leading-normal: 1.5;
    --weight-regular: 400;
    --weight-medium: 500;
    --weight-semibold: 600;

    /* ---- Spacing (4px base) ---- */
    --space-0: 0;
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    /* ---- Shape ---- */
    --radius-xs: 4px;
    --radius-sm: 6px;       /* buttons, inputs, rows */
    --radius-md: 8px;       /* cards, menus */
    --radius-lg: 12px;      /* dialogs */
    --radius-full: 999px;

    /* ---- Density: control heights (compact; raised to 44px on touch devices below) ---- */
    --control-h-sm: 1.75rem;   /* 28px */
    --control-h-md: 2rem;      /* 32px */
    --control-h-lg: 2.5rem;    /* 40px */
    --row-h: 2.25rem;          /* list row */

    /* ---- Elevation: surface steps first, shadow second ---- */
    --shadow-1: 0 1px 2px rgb(var(--shadow-color) / 0.35);
    --shadow-2: 0 4px 14px rgb(var(--shadow-color) / 0.4), 0 1px 3px rgb(var(--shadow-color) / 0.3);
    --shadow-3: 0 16px 40px rgb(var(--shadow-color) / 0.5), 0 2px 8px rgb(var(--shadow-color) / 0.3);

    /* ---- Motion ---- */
    --duration-fast: 90ms;
    --duration-base: 150ms;
    --duration-slow: 240ms;
    --ease-standard: cubic-bezier(0.2, 0, 0, 1);
    --ease-emphasized: cubic-bezier(0.3, 0, 0, 1);

    /* ---- Layout ---- */
    --sidebar-w: 16rem;
    --topbar-h: 3rem;
    --bottom-nav-h: 3.5rem;
    --content-max: 64rem;
    --z-sticky: 10;
    --z-drawer: 40;
    --z-menu: 50;
    --z-toast: 60;
}

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

    --color-brand: #7c6cff;
    --color-primary: #5a49e0;
    --color-on-primary: #ffffff;
    --color-primary-container: #e6e3ff;
    --color-on-primary-container: #241c78;
    --color-link: #4a39cc;

    --color-surface-container-lowest: #ffffff;
    --color-surface: #f7f8fb;
    --color-surface-container-low: #f1f3f8;
    --color-surface-container: #ffffff;
    --color-surface-container-high: #eceff6;
    --color-surface-container-highest: #e3e7f1;
    --color-on-surface: #161a26;
    --color-on-surface-variant: #4b5268;
    --color-on-surface-muted: #5d6580;
    --color-outline: #7a829c;
    --color-outline-variant: #d9dde8;
    --color-scrim: rgb(20 24 38 / 0.45);

    --color-error: #b3261e;
    --color-error-fill: #c62f3d;
    --color-on-error: #ffffff;
    --color-error-container: #fde4e6;
    --color-on-error-container: #5c0f17;
    --color-success: #17794f;
    --color-success-container: #d8f5e8;
    --color-on-success-container: #0b3a27;
    --color-warning: #8a5a00;
    --color-warning-container: #fdefc9;
    --color-on-warning-container: #4a3000;
    --color-info: #1b64b0;
    --color-info-container: #dcecfb;
    --color-on-info-container: #0d3558;

    --focus-ring: #5a49e0;
    --shadow-color: 22 26 38;
    --shadow-1: 0 1px 2px rgb(var(--shadow-color) / 0.10);
    --shadow-2: 0 4px 14px rgb(var(--shadow-color) / 0.12), 0 1px 3px rgb(var(--shadow-color) / 0.08);
    --shadow-3: 0 16px 40px rgb(var(--shadow-color) / 0.18), 0 2px 8px rgb(var(--shadow-color) / 0.1);
}

/* Touch devices: keep the compact look, but make targets at least 44px (WCAG 2.5.5 / Material). */
@media (pointer: coarse) {
    :root {
        --control-h-sm: 2.25rem;
        --control-h-md: 2.75rem;
        --control-h-lg: 3rem;
        --row-h: 2.75rem;
        --text-base: 0.9375rem;
    }
}

/* Reduced motion: no transitions or animations, scrolling jumps. */
@media (prefers-reduced-motion: reduce) {
    :root {
        --duration-fast: 0.01ms;
        --duration-base: 0.01ms;
        --duration-slow: 0.01ms;
    }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
