/*
 * THE DESIGN TOKENS. This file is the source of truth - edit it directly.
 *
 * Every colour, space, size and shape the application uses is named here once. Nothing else in
 * wwwroot may carry a colour or a measurement of its own: add a name here and reference it, so
 * the palette stays re-cuttable in one file. ThemeTokenTests enforces that, and enforces that
 * every var() a stylesheet reaches for is one that exists - a misspelt custom property resolves
 * to nothing and renders as a surface with no background at all, which no compiler can see.
 *
 * IT USED TO BE GENERATED, out of Resources/Styles/Colors.xaml and Metrics.xaml, by
 * tools/build_css_tokens.py. That was right while there was a MAUI XAML interface reading those
 * dictionaries through {StaticResource}: two heads, two languages, one set of values, and a
 * generator so the hexes could not be typed twice. The XAML views went when the head became
 * Blazor, and the dictionaries outlived them by a phase - merged into PosApplication.xaml and
 * read by nobody, their only remaining job being to feed this file. The Phase 8 Android head
 * renders the same Razor components, so it reads this stylesheet too; there was no second
 * consumer coming. The generator was deleted and the values moved here.
 *
 * TWO THINGS THE GENERATOR ENFORCED ARE NOW TESTS, because they are worth keeping and nothing
 * in CSS checks them:
 *
 *   - Every colour on :root has a twin under [data-theme="dark"]. Dark mode is built and inert -
 *     nothing sets that attribute yet, matching PosApplication forcing AppTheme.Light - and a
 *     colour added to one block and not the other is invisible until the day it is switched on.
 *   - The type ramp and the row heights are composed with var(--text-scale), declared in app.css,
 *     so a reader who turns the type up gets boxes that grow with it. Padding, radii and icon
 *     sizes deliberately do not scale: they are the shape of the interface rather than the size
 *     of its text.
 *
 * ONE WHOLE CLASS OF BUG WENT WITH THE GENERATOR. MAUI writes #AARRGGBB and CSS writes #RRGGBBAA;
 * the two are indistinguishable by eye and the script existed largely to reorder them. With no
 * XAML left there is one notation, and it is the one written here.
 */

:root {
    /* ===== Palette ===== */
    --pos-bg: #F3F6F9;
    --pos-bg-tint: #ECF1F5;
    --pos-surface: #FFFFFF;
    --pos-surface-sunken: #E8EEF3;
    --pos-surface-hover: #0F38560E;
    --pos-border: #D8E1E8;
    --pos-border-strong: #C2CED8;
    --pos-legend-border: #0B7A5F;
    --pos-mark-deep: #081425;
    --pos-mark-navy: #0D3956;
    --pos-mark-teal: #09B9A8;
    --pos-mark-plate: #FFFFFF;
    --pos-rail-bg-soft: #FFFFFF14;
    --pos-rail-text: #CFE0D8;
    --pos-rail-text-strong: #FFFFFF;
    --pos-rail-border: #1B4F40;
    --pos-rail-active: #079183;
    --pos-rail-top: #082F26;
    --pos-rail-bottom: #051A15;
    --pos-rail-icon: #A3BFB2;
    --pos-rail-nav-active: #09B9A8;
    --pos-rail-nav-fill: #09B9A840;
    --pos-rail-nav-fill-soft: #09B9A826;
    --pos-rail-nav-line: #09B9A880;
    --pos-rail-flyout: #0D3A2F;
    --pos-rail-flyout-border: #FFFFFF24;
    --pos-rail-plate-ring: #FFFFFF40;
    --pos-rail-scroll: #FFFFFF33;
    --pos-rail-sheen: #FFFFFF14;
    --pos-rail-flyout-shadow: #00000080;
    --pos-text: #142B3D;
    --pos-text-muted: #142B3DD1;
    --pos-text-subtle: #142B3D9E;
    --pos-text-inverse: #FFFFFF;
    --pos-primary: #075B46;
    --pos-primary-hover: #0A6E56;
    --pos-primary-active: #054636;
    --pos-primary-soft: #075B461A;
    --pos-on-brand: #FFFFFF;
    --pos-accent: #06786D;
    --pos-accent-bright: #09B9A8;
    --pos-accent-soft: #09B9A81A;
    --pos-warning: #B26B21;
    --pos-warning-soft: #FCF2E4;
    --pos-danger: #BC3838;
    --pos-danger-soft: #FBEBEB;
    --pos-success: #06786D;
    --pos-success-soft: #0AB5A31A;
    --pos-info: #2C6E9B;
    --pos-info-soft: #E6F0F7;
    --pos-overlay: #08142573;
    --pos-grid-header-bg: #075B46;
    --pos-grid-header-bg-hover: #086B53;
    --pos-grid-line: #D8E1E8;
    /* Between columns: fainter than the row line, so a wide table reads across without a cage. */
    --pos-grid-cell-line: #E6ECF1;
    /* The divider between header cells on the filled band. */
    --pos-grid-header-divider: #FFFFFF26;
    --pos-grid-row-hover: #0F38560A;
    --pos-grid-row-selected: #0AB5A314;
    --pos-grid-row-stripe: #0F385624;
    --pos-grid-row-in: #0AB5A314;
    --pos-grid-row-out: #BC38380F;
    --pos-grid-row-draft: #2C6E9B14;
    --pos-grid-row-job: #3D7BD126;
    --pos-chart-1: #0F3856;
    --pos-chart-2: #09B9A8;
    --pos-chart-3: #C98A2E;
    --pos-chart-4: #4A90C2;
    --pos-chart-5: #12695F;
    --pos-chart-6: #86A5BC;
    --pos-chart-7: #B5605A;
    /* Five more, so a report pie of up to twelve slices never repeats a colour. */
    --pos-chart-8: #7A5195;
    --pos-chart-9: #3E8E41;
    --pos-chart-10: #D65F8A;
    --pos-chart-11: #5C6B73;
    --pos-chart-12: #8FB339;
    --pos-chart-grid: #0F385624;
    /* Soft washes off the categorical set, for a KPI section tinted by an entity that has no
       semantic status colour of its own (Inventory, Receivables & Payables) - the same alpha-
       suffix idiom --pos-primary-soft already uses on its own base hex. */
    --pos-chart-3-soft: #C98A2E1A;
    --pos-chart-7-soft: #B5605A1A;
    --pos-shadow-soft: #0F385614;
    --pos-shadow-medium: #0F38561A;
    --pos-shadow-strong: #0F385621;
    --pos-glass: #FFFFFFF5;
    --pos-glass-border: #FFFFFFE6;
    --pos-glass-top: #FFFFFFE6;
    --pos-glass-bottom: #FFFFFFBD;
    --pos-glass-sheen: #FFFFFFFF;
    --pos-glass-shade: #0F38560A;
    --pos-glass-gloss: #FFFFFF9E;
    --pos-rail-active-fill: #0AB5A342;
    --pos-rail-active-fill-soft: #0AB5A31A;
    --pos-rail-active-line: #0AB5A357;
    --pos-on-accent-soft: #064C44;
    --pos-accent-glow-soft: #0AB5A32E;
    --pos-control-fill: #FFFFFF9E;
    --pos-control-fill-hover: #FFFFFFF5;
    --pos-primary-lit: #0B7A5F;
    --pos-primary-glow: #075B4647;
    --pos-focus: #079183;

    /* A tinted tile's own colour, an alias rather than a fixed hue - .widget--tinted sets both
       per instance from an inline style, and this default is what a tinted tile falls back to if
       one is ever applied with the other left unset. An alias to an existing pair rather than a
       colour of its own, so it needs no dark twin: it already changes when --pos-primary does. */
    --tile-accent: var(--pos-primary);
    --tile-accent-soft: var(--pos-primary-soft);

    /* ===== Spacing, type, shape and structure ===== */
    --space-1: 4px;
    --space-2: 6px;
    --space-3: 8px;
    --space-4: 12px;
    --space-5: 20px;
    --space-6: 26px;
    --space-7: 36px;

    /* The charts. Heights, not colours: a chart colour is a --pos-chart-N and is resolved by charts.js. */
    --bi-chart-height: 300px;
    /* A report's pie, and the height its legend scrolls inside so the card never grows. */
    --report-pie-size: 200px;
    --bi-chart-height-tall: 360px;
    /* A report table drawn as a card: how tall its rows may grow before they scroll inside it. */
    --report-card-max-height: 360px;
    /* The time box beside a document's date: wide enough for 23:59 and its clock button. */
    --date-time-width: 112px;
    --bi-spark-height: 56px;
    --bi-card-min-width: 220px;
    /* Each parent card sets its own, inline; this is only what a card with none falls back to. */
    --bi-card-colour: var(--pos-chart-1);
    --card-padding: 10px;
    --toolbar-padding: 8px 12px 8px 12px;
    --card-padding-tight: 6px 12px 6px 12px;
    --toolbar-padding-tight: 6px 14px 6px 14px;
    --tab-padding: 0px 18px 0px 18px;
    /* The point cut into a vertical tab's outer edge - Settings' own strip, the one place a tab
       is a filled block rather than an outlined chip. Geometry rather than a colour, but still a
       name rather than a figure typed into the shape twice. */
    --tab-arrow-depth: 14px;
    --pos-font: Segoe UI;
    --pos-font-mono: Consolas;
    --text-xs: calc(11px * var(--text-scale));
    --text-sm: calc(13px * var(--text-scale));
    --text-base: calc(14px * var(--text-scale));
    --text-lg: calc(16px * var(--text-scale));
    --text-xl: calc(18px * var(--text-scale));
    --text-2xl: calc(21px * var(--text-scale));
    --text-3xl: calc(30px * var(--text-scale));
    --radius-sm: 3px;
    --radius: 4px;
    --radius-lg: 4px;
    --radius-xl: 6px;
    --radius-pill: 999px;
    --radius-surface: 6px;
    --rail-width: 224px;

    /* How wide the rail shrinks to in compact mode - icons only. Wide enough for the 36px plate
       (--space-7) plus its own breathing room, narrow enough that "thin bar" is true. */
    --rail-width-compact: 64px;
    --shell-padding: 4px;
    --dialog-compact: 460px;
    --dialog-wide: 720px;
    --dialog-full: 980px;
    --dialog-xl: 1400px;
    --filter-width: 300px;
    /* The product box on a report toolbar: names run long and the list is drawn at the box's width. */
    --filter-width-wide: 440px;
    /* The narrowest a lookup's result list is drawn, whatever the box it opened from. */
    --lookup-min-width: 440px;
    --menu-width: 260px;
    --menu-name-width: 160px;
    /* Where the toast strip starts: just under the top bar, so a message never covers the screen's own controls. */
    --toast-top: 56px;
    --control-height: calc(33px * var(--text-scale));
    --control-height-sm: calc(30px * var(--text-scale));
    --control-height-lg: calc(46px * var(--text-scale));
    --field-height: calc(30px * var(--text-scale));

    /* A clock-time box (check-in, check-out, shift start) - wide enough for "12:45 PM" and no wider. */
    --time-field-width: 120px;
    --grid-row-height: calc(34px * var(--text-scale));
    --grid-header-height: calc(34px * var(--text-scale));
    --grid-row-padding: 5px;
    --grid-edge-padding: 10px;
    /* The parked-drafts panel above the Sales list: about three rows, then it scrolls inside. */
    --list-pinned-max-height: 200px;
    /* The least the list under a pinned panel keeps - about eight rows. Short of that the page
       scrolls rather than squeezing the list to nothing. */
    --list-under-pinned-min-height: 380px;
    /* How wide a column of prose is allowed to get. In ch rather than px because it is a measure
       of TEXT - about thirty characters, which is two lines of a normal address - so it follows
       the reader's own type size without being wired to --text-scale, which is for heights. */
    --grid-cell-prose: 30ch;
    /* The narrowest a summary tile over a list may get - a caption, a count and a seven-figure
       amount side by side. The row is auto-fill over this, so tiles stay this size and never
       stretch into banners. */
    --stat-tile-width: 150px;
    --check-box-size: 16px;
    /* A tick that has to sit on one line beside a caption rather than stand on its own - the
       totals table's On account header is the only one so far. Unscaled like every other shape
       token: it follows the box it rides in, not the reader's type size. */
    --check-box-size-sm: 13px;
    --icon-size: 15px;
    --icon-size-tile: 28px;
    --gate-mark-size: 48px;
    --picture-preview-size: 260px;

    /* Touch: the least a finger can reliably hit, and the round button that starts a new document
       on a phone. Applied only by the narrow / touch block below. */
    --touch-target: 44px;
    --fab-size: 56px;
}

/*
 * A PHONE, OR A TOUCH TABLET, GETS BIGGER BOXES AND BUTTONS. Both queries are needed and neither
 * is enough alone: width finds a phone, pointer finds a tablet, and a wide touchscreen TILL
 * (over 1100px) is deliberately left out - New Sale is built to a dense counter layout and a
 * 44px control would cost it lines of the sale. Only the heights move; the type ramp is
 * untouched, so the interface does not zoom.
 */
@media (max-width: 860px), (max-width: 1100px) and (pointer: coarse) {
    :root {
        --control-height: calc(var(--touch-target) * var(--text-scale));
        --control-height-sm: calc(40px * var(--text-scale));
        --field-height: calc(var(--touch-target) * var(--text-scale));
    }
}

[data-theme="dark"] {
    --pos-bg: #0E2438;
    --pos-bg-tint: #153349;
    --pos-surface: #12293D;
    --pos-surface-sunken: #0C1E30;
    --pos-surface-hover: #FFFFFF14;
    --pos-border: #FFFFFF24;
    --pos-border-strong: #FFFFFF3D;
    --pos-legend-border: #2F9E6E;
    --pos-mark-deep: #081425;
    --pos-mark-navy: #0D3956;
    --pos-mark-teal: #09B9A8;
    --pos-mark-plate: #FFFFFF;
    --pos-rail-bg-soft: #FFFFFF14;
    --pos-rail-text: #CFE0D8;
    --pos-rail-text-strong: #FFFFFF;
    --pos-rail-border: #1B4F40;
    --pos-rail-active: #2ED9C6;
    --pos-rail-top: #082F26;
    --pos-rail-bottom: #051A15;
    --pos-rail-icon: #A3BFB2;
    --pos-rail-nav-active: #09B9A8;
    --pos-rail-nav-fill: #09B9A840;
    --pos-rail-nav-fill-soft: #09B9A826;
    --pos-rail-nav-line: #09B9A880;
    --pos-rail-flyout: #0D3A2F;
    --pos-rail-flyout-border: #FFFFFF24;
    --pos-rail-plate-ring: #FFFFFF40;
    --pos-rail-scroll: #FFFFFF33;
    --pos-rail-sheen: #FFFFFF14;
    --pos-rail-flyout-shadow: #00000080;
    --pos-text: #F2F7FA;
    --pos-text-muted: #F2F7FAD6;
    --pos-text-subtle: #F2F7FAA3;
    --pos-text-inverse: #0A1420;
    --pos-primary: #3FBE85;
    --pos-primary-hover: #5ACE99;
    --pos-primary-active: #7ADCB0;
    --pos-primary-soft: #075B4640;
    --pos-on-brand: #06121C;
    --pos-accent: #3FE3D0;
    --pos-accent-bright: #2ED9C6;
    --pos-accent-soft: #0AB5A31F;
    --pos-warning: #D9954B;
    --pos-warning-soft: #33261A;
    --pos-danger: #E4736F;
    --pos-danger-soft: #331E1F;
    --pos-success: #3FE3D0;
    --pos-success-soft: #0AB5A31F;
    --pos-info: #6FAAD6;
    --pos-info-soft: #12293B;
    --pos-overlay: #0000008C;
    --pos-grid-header-bg: #075B46;
    --pos-grid-header-bg-hover: #086B53;
    --pos-grid-line: #FFFFFF1F;
    --pos-grid-cell-line: #FFFFFF12;
    --pos-grid-header-divider: #FFFFFF26;
    --pos-grid-row-hover: #FFFFFF0F;
    --pos-grid-row-selected: #0AB5A31F;
    --pos-grid-row-stripe: #FFFFFF1C;
    --pos-grid-row-in: #0AB5A31F;
    --pos-grid-row-out: #BC38382B;
    --pos-grid-row-draft: #6FAAD61F;
    --pos-grid-row-job: #5B9BEB2E;
    --pos-chart-1: #4FA3D8;
    --pos-chart-2: #2ED9C6;
    --pos-chart-3: #DFA65A;
    --pos-chart-4: #7FC0E4;
    --pos-chart-5: #3FA396;
    --pos-chart-6: #9FBBCF;
    --pos-chart-7: #DE8A83;
    --pos-chart-8: #B48EDB;
    --pos-chart-9: #6CC070;
    --pos-chart-10: #F08CB0;
    --pos-chart-11: #9AA8B0;
    --pos-chart-12: #B5D66B;
    --pos-chart-grid: #FFFFFF24;
    --pos-chart-3-soft: #DFA65A26;
    --pos-chart-7-soft: #DE8A8326;
    --pos-shadow-soft: #030A145C;
    --pos-shadow-medium: #030A147A;
    --pos-shadow-strong: #030A1499;
    --pos-glass: #163049D9;
    --pos-glass-border: #FFFFFF24;
    --pos-glass-top: #FFFFFF2B;
    --pos-glass-bottom: #FFFFFF16;
    --pos-glass-sheen: #FFFFFF42;
    --pos-glass-shade: #FFFFFF0D;
    --pos-glass-gloss: #FFFFFF29;
    --pos-rail-active-fill: #0AB5A357;
    --pos-rail-active-fill-soft: #0AB5A324;
    --pos-rail-active-line: #2ED9C64D;
    --pos-on-accent-soft: #FFFFFF;
    --pos-accent-glow-soft: #0AB5A32E;
    --pos-control-fill: #FFFFFF12;
    --pos-control-fill-hover: #FFFFFF26;
    --pos-primary-lit: #4FCF95;
    --pos-primary-glow: #075B4647;
    --pos-focus: #2ED9C6;
}
