/* Stoa design tokens (Paper and Ink), copied from Stoa Markets. They hold color, type,
   spacing, radius and motion. Tier 1 holds the only raw colors. Tier 2 holds the names a
   stylesheet reads. Dark is the default. Both desk sites pin the light theme with
   data-theme="light" on <html>. */

/* Geist, under the SIL Open Font License, served from static/fonts with its licence. Serving
   it from this origin keeps the CSP at font-src 'self'. Variable weight 100 to 900. */
@font-face {
    font-family: 'Geist';
    src: url('/static/fonts/geist-variable.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Geist Mono';
    src: url('/static/fonts/geist-mono-variable.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

:root {
    color-scheme: dark;

    /* ---- Tier 1: primitives (a rebrand edits only this tier) ----------------
       A 12-step dark ramp, from the darkest surface to the brightest text. */
    --gray-1: #181818;   /* app bg (brand ramp, Paper & Ink 2026-07) */
    --gray-2: #1d1d1d;   /* sticky table header bg */
    --gray-3: #202020;   /* faint row divider */
    --gray-4: #232323;   /* card / surface (Ink) */
    /* --field-border on --bg-card-hover (this shade) measures 3.0014:1 dark and 3.0806:1
       light, just above the 3:1 floor for edges. Measure both themes before changing it. */
    --gray-5: #2b2b2a;   /* card hover */
    --gray-6: #323231;   /* subtle border */
    --gray-7: #3b3b3a;   /* border */
    --gray-8: #535352;   /* strong/emphasis border */
    --gray-9: #757371;   /* form-field edge (3.33:1 on card) */
    --gray-10: #9c9b99;  /* muted text (5.66:1 on card) */
    --gray-11: #b4b3b1;  /* secondary text */
    --gray-12: #ebeaea;  /* primary text (Paper-toned) */
    --black-cool: #181818;         /* the warm brand retires the cool-black auth variant */
    --white: #ffffff;
    --green-9: #34d399;            /* status green */
    --red-9: #f57272;              /* sell / destructive / negative (4.52:1 on the worst lifted ground, 5.64 on card) */
    --amber-9: #eab308;            /* pending / caution */
    --sand: #ded6ca;               /* brand highlight: quiet emphasis fields/buttons */
    --sand-rgb: 222, 214, 202;     /* channel of --sand, for rgba() tints of the accent */
    --clay: #aba297;               /* brand highlight: mid earth tone */
    --wood: #464036;               /* brand highlight: deep earth tone */
    /* Channel triplets for rgba(var(--x-rgb), a) tints. In light the red chip channel stays the
       brighter 217,45,32, not #b42318 (border tint vs text); in dark they coincide. */
    --black-rgb: 0, 0, 0;
    --white-rgb: 255, 255, 255;
    --gray-12-rgb: 235, 234, 234;      /* channel of --gray-12 (Paper-tinted lighten) */
    --gray-1-rgb: 24, 24, 24;         /* channel of --gray-1 (translucent shells) */
    --green-9-rgb: 52, 211, 153;
    --red-9-rgb: 245, 114, 114;
    --amber-9-rgb: 234, 179, 8;

    /* ---- Tier 2: semantic tokens (the names every stylesheet reads) ---------- */
    --bg: var(--gray-1);
    --bg-card: var(--gray-4);
    --bg-card-hover: var(--gray-5);
    --border: var(--gray-6);
    --border-light: var(--gray-7);
    --text-primary: var(--gray-12);
    --text-secondary: var(--gray-11);
    --text-muted: var(--gray-10);
    --green: var(--text-primary); /* green is not a brand color, so it maps to off-white */
    /* The buy channel mirrors --red-rgb, so buy and sell tint alike. */
    --green-rgb: var(--gray-12-rgb);
    --red: var(--red-9);
    --red-rgb: var(--red-9-rgb);
    --on-red: var(--gray-1);          /* on --red: 5.26:1 dark, 6.4:1 light, AA at badge size */
    --status-green: var(--green-9);          /* completed and verified accents */
    --status-green-rgb: var(--green-9-rgb);
    /* Opaque fills for an active toggle. A translucent tint would let the track show through
       and push the label under 4.5:1. */
    --buy-fill: color-mix(in srgb, var(--status-green) 8%, var(--bg-card));
    --sell-fill: color-mix(in srgb, var(--red) 8%, var(--bg-card));
    --amber: var(--amber-9);
    --amber-rgb: var(--amber-9-rgb);
    /* Primary button: light chip on dark, inverted in light mode so it is never invisible. */
    --btn-primary-bg: var(--gray-12);
    --btn-primary-text: var(--gray-1);
    /* Channel for rgba(var(--shade-rgb), a) overlays: lightens on dark, darkens on light. */
    --shade-rgb: var(--gray-12-rgb);
    --shadow: rgba(var(--black-rgb), 0.5);
    /* Auth screens use a slightly cooler black behind a faint top glow. */
    --auth-bg: var(--black-cool);
    /* Structural surfaces that must flip but are not a plain fg/bg pair. */
    --nav-bg: rgba(var(--gray-1-rgb), 0.9);  /* translucent fixed nav over blurred content (warm; pure black retired) */
    --bg-th: var(--gray-2);
    --divider: var(--gray-3);
    --border-strong: var(--gray-8);
    --field-border: var(--gray-9);
    --scrim: rgba(var(--black-rgb), 0.5);    /* modal/popup overlay */

    /* Roles. */
    --accent: var(--sand);                   /* the brand's quiet emphasis (Paper & Ink) */
    --accent-fg: var(--gray-1);
    --ring: color-mix(in srgb, var(--text-primary) 55%, transparent);  /* focus ring */
    --danger-bg: color-mix(in srgb, var(--red) 12%, transparent);      /* error fills */
    --warn-bg: color-mix(in srgb, var(--amber) 12%, transparent);      /* caution fills */
    /* Status chips: green for done, sand for in progress. Each ingredient flips with the
       theme. */
    --ok-bg: color-mix(in srgb, var(--status-green) 10%, transparent);
    --live-bg: color-mix(in srgb, var(--accent) 14%, transparent);
    --live-border: color-mix(in srgb, var(--accent) 45%, var(--border));

    /* Motion and elevation. */
    --shadow-1: 0 1px 2px rgba(var(--black-rgb), 0.5);
    --shadow-2: 0 4px 12px rgba(var(--black-rgb), 0.45);
    --ease-out: cubic-bezier(0, 0, 0.2, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --dur-1: 150ms;  /* matches the installed transition base (0.15s throughout) */
    --dur-2: 200ms;
}

:root[data-theme="light"] {
    color-scheme: light;
    /* Tier 1, light ramp for the data desk: white surfaces and ink text. The step semantics
       are the same as in dark. */
    --gray-1: #ffffff;            /* app bg */
    --gray-2: #fafafa;            /* table header, quiet fills */
    --gray-3: #efefef;            /* faint row divider */
    --gray-4: #ffffff;            /* card */
    --gray-5: #f4f4f4;            /* hover, icon tiles, neutral chips */
    --gray-6: #e6e6e6;            /* subtle border */
    --gray-7: #d6d6d6;            /* border */
    --gray-8: #b5b5b5;            /* strong border */
    --gray-9: #8c8c8c;            /* form-field edge (3.36:1 on white) */
    --gray-10: #6b6b6b;           /* muted text (5.33:1 on white) */
    --gray-11: #474747;           /* secondary text (9.3:1) */
    --gray-12: #111111;           /* primary text and the filled button (Ink) */
    --black-cool: #ffffff;
    --green-9: #05704f;           /* status green (6.1:1 on white) */
    --red-9: #b42318;
    --amber-9: #8a5a00;           /* 5.9:1 on white */
    --ink-rgb: 17, 17, 17;        /* the light theme's darkening channel */
    --gray-1-rgb: 255, 255, 255;  /* channel of --gray-1 (translucent shells) */
    --green-9-rgb: 5, 112, 79;
    --red-9-rgb: 217, 45, 32;
    --amber-9-rgb: 138, 90, 0;
    --sand: #ded6ca;
    --clay: #aba297;
    --wood: #464036;
    /* Tier 2 overrides that do not follow the ramp mapping. */
    --live-bg: var(--gray-5);
    --live-border: var(--gray-6);
    --green-rgb: var(--ink-rgb);
    --btn-primary-bg: var(--gray-12);
    --btn-primary-text: #ffffff;
    --accent-fg: var(--gray-12);
    --shade-rgb: var(--ink-rgb);
    --shadow: rgba(var(--ink-rgb), 0.08);
    --nav-bg: rgba(var(--gray-1-rgb), 0.9);
    --scrim: rgba(var(--ink-rgb), 0.4);
    --shadow-1: 0 1px 2px rgba(var(--ink-rgb), 0.06);
    --shadow-2: 0 1px 2px rgba(var(--ink-rgb), 0.06), 0 8px 24px rgba(var(--ink-rgb), 0.08);
}

        :root {
            /* Font, type-scale, radius and spacing tokens (colors are the two blocks above). */
            --font: 'Geist', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
            --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
            /* Type scale: 0.75rem (12px) is the floor for visible text. Body is 1rem. */
            --fs-min: 0.75rem; /* 12px - dense/secondary text floor */
            --fs-sm: 0.8125rem; /* 13px */
            --fs-base: 1rem; /* 16px body */
            --fs-md: 0.875rem; /* 14px - buttons, emphasized body */
            --fs-lg: 1.25rem; /* 20px - section titles / h2 */
            --fs-xl: 1.5rem; /* 24px - page titles / h1 */
            --fs-2xl: 2rem; /* 32px - the title of a seller page */
            /* Radius scale: three steps and full. An inner radius is the outer one minus the
               padding. */
            --r-full: 999px; /* pill / dot */
            --r-sm: 6px;
            --r-md: 8px;
            --r-lg: 12px;
            /* Spacing scale on a 4px grid. */
            --space-xs: 0.25rem; /* 4px */
            --space-sm: 0.5rem; /* 8px */
            --space-md: 0.75rem; /* 12px */
            --space-lg: 1rem; /* 16px */
            --space-xl: 1.5rem; /* 24px */
        }
