/* BellRun Markets design tokens. This is the only file that may write a colour out.

   Three layers:
     1. primitives: the raw palette and scales. The style sheets do not use the palette directly.
     2. semantic tokens: one complete block per theme, with the same names in both. Use these.
     3. Bootstrap's variables, mapped to the semantic tokens.

   Meanings: emerald = up, red = down, blue = navigation, actions, links and focus, amber = warning or simulated.
   DesignSystemTests checks every text and surface pair in both themes. A colour that is added here and used for
   text, or as a surface, has to be added to that test as well (the test fails until it is). */

/* ---------- 1. Primitives ---------- */
:root {
    --white: #ffffff;
    --black: #000000;

    --navy-980: #0a1222;
    --navy-940: #121b2b;
    --navy-850: #14294a;
    --navy-900: #14213a;
    --charcoal-850: #1c2533;
    --charcoal-750: #29354a;

    --slate-100: #f3f6fa;
    --slate-150: #eaeff5;
    --slate-180: #e6edf6;
    --slate-250: #d0d9e4;
    --slate-400: #a0aec1;
    --slate-500: #8092a9;
    --slate-550: #5f6e83;
    --slate-650: #46556a;

    --blue-100: #e1ebfa;
    --blue-200: #b3d1ff;
    --blue-300: #8dbbff;
    --blue-350: #84b4ff;
    --blue-600: #2e6fe0;
    --blue-650: #2862ca;
    --blue-700: #2156b5;
    --blue-720: #1f5fcc;
    --blue-760: #1a52b3;
    --blue-800: #15469b;
    --blue-820: #1550b0;
    --blue-900: #0d3b86;

    --emerald-100: #dff3e9;
    --emerald-300: #5fdcb0;
    --emerald-400: #34d399;
    --emerald-450: #25bd85;
    --emerald-600: #23896a;
    --emerald-650: #418169;
    --emerald-800: #07603f;
    --emerald-850: #05503a;
    --emerald-880: #04422f;
    --emerald-950: #0f2f2a;
    --emerald-990: #04210f;

    --red-100: #fbe6e6;
    --red-300: #ffa3a3;
    --red-350: #ff8f8f;
    --red-400: #f47979;
    --red-500: #c25f5f;
    --red-550: #c4606c;
    --red-700: #a61b1b;
    --red-750: #8f1616;
    --red-800: #781010;
    --red-950: #38202b;
    --red-990: #2a0606;

    --amber-100: #f8ecd2;
    --amber-400: #f5bd4f;
    --amber-800: #704700;
    --amber-950: #30291c;

    /* Type: system fonts only, nothing is downloaded. */
    --font-sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif;
    --font-mono: ui-monospace, "Cascadia Mono", Consolas, SFMono-Regular, Menlo, "Liberation Mono", monospace;
    --type-2xs: .6875rem;
    --type-xs: .75rem;
    --type-sm: .8125rem;
    --type-md: .875rem;
    --type-base: 1rem;
    --type-lg: 1.125rem;
    --type-xl: 1.25rem;
    --type-2xl: 1.5rem;
    --type-3xl: 2rem;
    --type-4xl: 2.5rem;
    --type-display: clamp(2rem, 5vw, 3.25rem);
    --leading-tight: 1.15;
    --leading-snug: 1.35;
    --leading-body: 1.5;
    --leading-prose: 1.65;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;
    --weight-heavy: 800;
    --tracking-tight: -.02em;
    --tracking-wide: .05em;

    /* Spacing, on a 4px grid with two half steps. */
    --space-half: .125rem;
    --space-1: .25rem;
    --space-1-5: .375rem;
    --space-2: .5rem;
    --space-3: .75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    /* Sizes */
    --content-max: 1280px;
    --content-x: 1.5rem;
    --prose-max: 47.5rem;
    --control-size: 2.5rem;
    --target-min: 24px;
    --header-height: 3.75rem;
    --toast-room: 12rem;

    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-pill: 999px;

    /* Layers */
    --z-raised: 2;
    --z-note: 3;
    --z-header: 20;
    --z-toast: 40;
    --z-menu: 50;
    --z-dialog: 1050;
    --z-error: 1060;
    --z-skip: 1100;

    /* Motion */
    --motion-fast: .12s;
    --motion-base: .3s;
    --motion-flash: .9s;
    --motion-shimmer: 1.6s;
    --motion-ticker: 60s;
    --motion-fade: .5s;
    --motion-rise: 1.5s;
    --ease-out: cubic-bezier(.2, .8, .2, 1);

    /* Focus ring */
    --focus-width: 2px;
    --focus-offset: 2px;

    /* Edge fade of the ticker: only its opacity is used. */
    --mask: var(--black);
}

/* The dimmed layer behind a dialog, the same in both themes. ::backdrop is named because older browsers do not
   pass custom properties down to it. */
:root, ::backdrop {
    --scrim: rgba(4, 8, 16, .72);
}

/* ---------- 2. Semantic tokens: dark (the default) ---------- */
:root, [data-bs-theme="dark"] {
    color-scheme: dark;

    --bg: var(--navy-980);
    --header: var(--navy-940);
    --panel: var(--navy-940);
    --panel-2: var(--charcoal-850);
    --up-bg: var(--emerald-950);
    --down-bg: var(--red-950);
    --warn-bg: var(--amber-950);
    --info-bg: var(--navy-850);

    --text: var(--slate-180);
    --muted: var(--slate-400);
    --flat: var(--slate-400);
    --link: var(--blue-350);
    --link-hover: var(--blue-200);
    --up: var(--emerald-400);
    --down: var(--red-350);
    --warn: var(--amber-400);

    --line: var(--charcoal-750);
    --control-line: var(--slate-500);
    --focus: var(--blue-300);

    --action: var(--blue-600);
    --action-hover: var(--blue-650);
    --action-active: var(--blue-700);
    --action-ink: var(--white);
    --buy: var(--emerald-400);
    --buy-hover: var(--emerald-300);
    --buy-active: var(--emerald-450);
    --buy-ink: var(--emerald-990);
    --sell: var(--red-350);
    --sell-hover: var(--red-300);
    --sell-active: var(--red-400);
    --sell-ink: var(--red-990);

    --chart-grid: var(--charcoal-850);
    --volume-up: var(--emerald-600);
    --volume-down: var(--red-550);

    /* The same colours as "r, g, b", for Bootstrap's utilities that build rgba(). */
    --bg-rgb: 10, 18, 34;
    --panel-2-rgb: 28, 37, 51;
    --text-rgb: 230, 237, 246;
    --muted-rgb: 160, 174, 193;
    --link-rgb: 132, 180, 255;
    --link-hover-rgb: 179, 209, 255;
    --up-rgb: 52, 211, 153;
    --down-rgb: 255, 143, 143;
    --warn-rgb: 245, 189, 79;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-2: 0 .75rem 2rem rgba(0, 0, 0, .45);
    --shadow-3: 0 1rem 3rem rgba(0, 0, 0, .6);
}

/* ---------- 2. Semantic tokens: light ---------- */
[data-bs-theme="light"] {
    color-scheme: light;

    --bg: var(--slate-100);
    --header: var(--white);
    --panel: var(--white);
    --panel-2: var(--slate-150);
    --up-bg: var(--emerald-100);
    --down-bg: var(--red-100);
    --warn-bg: var(--amber-100);
    --info-bg: var(--blue-100);

    --text: var(--navy-900);
    --muted: var(--slate-650);
    --flat: var(--slate-650);
    --link: var(--blue-820);
    --link-hover: var(--blue-900);
    --up: var(--emerald-800);
    --down: var(--red-700);
    --warn: var(--amber-800);

    --line: var(--slate-250);
    --control-line: var(--slate-550);
    --focus: var(--blue-820);

    --action: var(--blue-720);
    --action-hover: var(--blue-760);
    --action-active: var(--blue-800);
    --action-ink: var(--white);
    --buy: var(--emerald-800);
    --buy-hover: var(--emerald-850);
    --buy-active: var(--emerald-880);
    --buy-ink: var(--white);
    --sell: var(--red-700);
    --sell-hover: var(--red-750);
    --sell-active: var(--red-800);
    --sell-ink: var(--white);

    --chart-grid: var(--slate-150);
    --volume-up: var(--emerald-650);
    --volume-down: var(--red-500);

    --bg-rgb: 243, 246, 250;
    --panel-2-rgb: 234, 239, 245;
    --text-rgb: 20, 33, 58;
    --muted-rgb: 70, 85, 106;
    --link-rgb: 21, 80, 176;
    --link-hover-rgb: 13, 59, 134;
    --up-rgb: 7, 96, 63;
    --down-rgb: 166, 27, 27;
    --warn-rgb: 112, 71, 0;

    --shadow-1: 0 1px 2px rgba(20, 33, 58, .12);
    --shadow-2: 0 .75rem 2rem rgba(20, 33, 58, .18);
    --shadow-3: 0 1rem 3rem rgba(20, 33, 58, .28);
}

/* ---------- 3. Bootstrap's variables ----------
   This file loads after Bootstrap, so these win over both of its theme blocks. */
:root, [data-bs-theme="dark"], [data-bs-theme="light"] {
    --bs-font-sans-serif: var(--font-sans);
    --bs-font-monospace: var(--font-mono);
    --bs-body-font-family: var(--font-sans);
    --bs-body-font-size: var(--type-base);
    --bs-body-line-height: var(--leading-body);
    --bs-body-color: var(--text);
    --bs-body-color-rgb: var(--text-rgb);
    --bs-body-bg: var(--bg);
    --bs-body-bg-rgb: var(--bg-rgb);
    --bs-emphasis-color: var(--text);
    --bs-emphasis-color-rgb: var(--text-rgb);
    --bs-heading-color: var(--text);
    --bs-secondary-color: var(--muted);
    --bs-secondary-color-rgb: var(--muted-rgb);
    --bs-secondary-bg: var(--panel-2);
    --bs-secondary-bg-rgb: var(--panel-2-rgb);
    --bs-tertiary-color: var(--muted);
    --bs-tertiary-color-rgb: var(--muted-rgb);
    --bs-tertiary-bg: var(--panel-2);
    --bs-tertiary-bg-rgb: var(--panel-2-rgb);
    --bs-border-color: var(--line);
    --bs-border-color-translucent: var(--line);
    --bs-border-radius: var(--radius-md);
    --bs-border-radius-sm: var(--radius-sm);
    --bs-border-radius-lg: var(--radius-lg);
    --bs-border-radius-pill: var(--radius-pill);
    --bs-box-shadow: var(--shadow-2);
    --bs-box-shadow-sm: var(--shadow-1);
    --bs-box-shadow-lg: var(--shadow-3);
    --bs-link-color: var(--link);
    --bs-link-color-rgb: var(--link-rgb);
    --bs-link-hover-color: var(--link-hover);
    --bs-link-hover-color-rgb: var(--link-hover-rgb);
    --bs-code-color: var(--text);
    --bs-highlight-color: var(--text);
    --bs-highlight-bg: var(--warn-bg);
    --bs-focus-ring-color: var(--focus);

    /* As text (.text-danger and the like), so each is the theme's text shade of that meaning. */
    --bs-primary: var(--action);
    --bs-primary-rgb: var(--link-rgb);
    --bs-secondary: var(--muted);
    --bs-secondary-rgb: var(--muted-rgb);
    --bs-success: var(--up);
    --bs-success-rgb: var(--up-rgb);
    --bs-info: var(--link);
    --bs-info-rgb: var(--link-rgb);
    --bs-warning: var(--warn);
    --bs-warning-rgb: var(--warn-rgb);
    --bs-danger: var(--down);
    --bs-danger-rgb: var(--down-rgb);

    --bs-primary-text-emphasis: var(--link);
    --bs-primary-bg-subtle: var(--info-bg);
    --bs-primary-border-subtle: var(--link);
    --bs-secondary-text-emphasis: var(--muted);
    --bs-secondary-bg-subtle: var(--panel-2);
    --bs-secondary-border-subtle: var(--control-line);
    --bs-success-text-emphasis: var(--up);
    --bs-success-bg-subtle: var(--up-bg);
    --bs-success-border-subtle: var(--up);
    --bs-info-text-emphasis: var(--text);
    --bs-info-bg-subtle: var(--info-bg);
    --bs-info-border-subtle: var(--link);
    --bs-warning-text-emphasis: var(--warn);
    --bs-warning-bg-subtle: var(--warn-bg);
    --bs-warning-border-subtle: var(--warn);
    --bs-danger-text-emphasis: var(--down);
    --bs-danger-bg-subtle: var(--down-bg);
    --bs-danger-border-subtle: var(--down);
    --bs-light-text-emphasis: var(--text);
    --bs-light-bg-subtle: var(--panel-2);
    --bs-light-border-subtle: var(--control-line);
    --bs-dark-text-emphasis: var(--text);
    --bs-dark-bg-subtle: var(--panel-2);
    --bs-dark-border-subtle: var(--control-line);

    --bs-form-valid-color: var(--up);
    --bs-form-valid-border-color: var(--up);
    --bs-form-invalid-color: var(--down);
    --bs-form-invalid-border-color: var(--down);
}

@media (max-width: 991.98px) {
    :root { --content-x: 1rem; }
}

/* Less motion: transitions and one-off animations take no time. The looping ones are switched off where they are defined. */
@media (prefers-reduced-motion: reduce) {
    :root {
        --motion-fast: 0s;
        --motion-base: 0s;
        --motion-flash: 0s;
    }
}
