/* Hallmark · genre: modern-minimal · macrostructure: app working surfaces · theme: Cobalt (app adaptation)
 * tone: utilitarian · anchor hue: 262 · design-system: design.md · designed-as-app
 * contrast: pass (40–41) except warning-as-small-text (3.2:1, see design.md) · tokens: pass (48) for restyled surfaces
 */
/* Hallmark · pre-emit critique: P4 H4 E3 S4 R5 V5 */

/* Vision.Web design tokens. Vision.Web/design.md explains the system.

   Colour has one switch. The MudTheme palettes (Components/Layout/MainLayout/VisionThemeDefinition.cs)
   hold the light and dark values MudBlazor needs as hex, and MudThemeProvider swaps the
   --mud-palette-* variables when dark mode changes. The --color-* tokens below alias those
   variables, so anything styled with them follows the theme without its own dark rules.

   Colours MudBlazor has no slot for (status fills, schedule appointment ink) are defined here
   in OKLCH. The ones that need a different dark value are overridden under
   .vision-theme-scope[data-vision-theme="dark"], which MainLayout sets from its dark-mode state.
   Not a bare [data-theme]: the Fluent UI script writes data-theme="dark" on <body> from its own
   stored or system theme, which can disagree with Vision's toggle. */

:root {
    /* Type */
    --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    /* Dense app scale. 14px is the table and form size, 12px the floor for meta text. */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-md: 1rem;
    --text-lg: 1.25rem;
    --text-xl: 1.5625rem;
    --text-2xl: 1.953rem;

    --weight-regular: 400;
    --weight-medium: 500;
    --weight-strong: 600;

    --tracking-tight: -0.015em;
    --tracking-label: 0.04em;

    /* Space: 4pt scale */
    --space-3xs: 0.125rem;
    --space-2xs: 0.25rem;
    --space-xs: 0.5rem;
    --space-sm: 0.75rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2.5rem;
    --space-2xl: 4rem;

    /* Shape. --radius-md matches MudTheme DefaultBorderRadius, so custom containers and MudPaper
       cards share one corner. */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-card: var(--radius-md);
    --radius-pill: 999px;

    --rule-width: 1px;
    --rule-accent-width: 2px;

    /* Elevation. Cards sit on a rule, not a shadow; only floating layers (drawers, popovers)
       get the overlay shadow. */
    --shadow-whisper: 0 1px 2px oklch(20% 0.02 262 / 0.06);
    --shadow-overlay: 0 8px 24px oklch(20% 0.02 262 / 0.16);

    /* Motion */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in: cubic-bezier(0.7, 0, 0.84, 0);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --dur-micro: 120ms;
    --dur-short: 220ms;
    --dur-long: 420ms;

    /* Touch: minimum tap target under (any-pointer: coarse) */
    --tap-target: 44px;

    /* Surfaces and ink (theme aliases) */
    --color-paper: var(--mud-palette-background);
    --color-surface: var(--mud-palette-surface);
    --color-surface-2: var(--mud-palette-background-gray);
    --color-ink: var(--mud-palette-text-primary);
    --color-ink-2: var(--mud-palette-text-secondary);
    --color-ink-3: var(--mud-palette-text-disabled);
    --color-rule: var(--mud-palette-lines-default);
    --color-rule-strong: var(--mud-palette-lines-inputs);
    --color-hover: var(--mud-palette-action-default-hover);

    /* The one accent: actions, the active tab, links, focus */
    --color-accent: var(--mud-palette-primary);
    --color-accent-strong: var(--mud-palette-primary-darken);
    --color-accent-ink: var(--mud-palette-primary-text);
    --color-focus: var(--mud-palette-primary);

    /* Signal colours (theme aliases) */
    --color-success: var(--mud-palette-success);
    --color-warning: var(--mud-palette-warning);
    --color-error: var(--mud-palette-error);
    --color-info: var(--mud-palette-info);

    /* Washes: quiet tints for selected rows and urgency backgrounds. Mixed in oklab so the hue
       does not drift toward the surface's hue. */
    --color-accent-wash: color-mix(in oklab, var(--color-accent) 9%, var(--color-surface));
    --color-success-wash: color-mix(in oklab, var(--color-success) 10%, var(--color-surface));
    --color-warning-wash: color-mix(in oklab, var(--color-warning) 13%, var(--color-surface));
    --color-error-wash: color-mix(in oklab, var(--color-error) 9%, var(--color-surface));
    --color-info-wash: color-mix(in oklab, var(--color-info) 9%, var(--color-surface));

    /* Status chip fills. Each keeps the hue staff already know for that status; lightness is
       tuned so the paired ink passes 4.5:1. Solid fills read the same on light and dark pages. */
    --status-on-fill: oklch(99% 0.003 262);
    --status-on-fill-dark: oklch(22% 0.02 262);

    --status-pending: oklch(78% 0.15 77);
    --status-pending-ink: var(--status-on-fill-dark);
    --status-hold: oklch(68% 0.13 89);
    --status-hold-ink: var(--status-on-fill-dark);
    --status-needs-quote: oklch(52% 0.105 78);
    --status-needs-quote-ink: var(--status-on-fill);
    --status-quoted: oklch(49% 0.2 318);
    --status-quoted-ink: var(--status-on-fill);
    --status-quote-accepted: oklch(36% 0.17 296);
    --status-quote-accepted-ink: var(--status-on-fill);
    --status-dispatch: oklch(51% 0.125 245);
    --status-dispatch-ink: var(--status-on-fill);
    --status-parts: oklch(45% 0.18 293);
    --status-parts-ink: var(--status-on-fill);
    --status-field-complete: oklch(50% 0.13 144);
    --status-field-complete-ink: var(--status-on-fill);
    --status-work-complete: oklch(41% 0.11 144);
    --status-work-complete-ink: var(--status-on-fill);
    --status-invoiced: oklch(71% 0.17 50);
    --status-invoiced-ink: var(--status-on-fill-dark);
    --status-paid: oklch(50% 0.09 182);
    --status-paid-ink: var(--status-on-fill);
    --status-quote-expired: oklch(45% 0.05 40);
    --status-quote-expired-ink: var(--status-on-fill);
    --status-quote-canceled: oklch(52% 0.19 27);
    --status-quote-canceled-ink: var(--status-on-fill);

    /* Schedule appointments keep their original pastel hex fills (ScheduleColors.cs, and the
       month item blue below) in both themes, so the text on them stays dark in both themes too. */
    --appt-ink: oklch(23.5% 0.022 262);
    --appt-ink-2: oklch(40% 0.02 262);
    --appt-month: #8cc0e5;

    /* Year-view load heat: four steps of the accent */
    --heat-1: color-mix(in oklab, var(--color-accent) 14%, var(--color-surface));
    --heat-2: color-mix(in oklab, var(--color-accent) 34%, var(--color-surface));
    --heat-3: color-mix(in oklab, var(--color-accent) 64%, var(--color-surface));
    --heat-4: var(--color-accent-strong);

    /* Dim layer behind an in-page overlay panel */
    --color-scrim: oklch(17% 0.015 262 / 0.35);

    /* Route map markers sit on map tiles, which keep their colours in dark mode, so these are
       fixed in both themes. Origin green, destination red, stops and the route line blue with
       yellow numbers, the focused stop orange. Each label passes 4.5:1 on its fill. */
    --map-origin: #15803d;
    --map-destination: #b91c1c;
    --map-stop: #1d4ed8;
    --map-stop-ink: #fde047;
    --map-focus: #c2410c;
    --map-marker-ink: #ffffff;
    --map-marker-ring: #ffffff;
    --map-marker-shadow: 0 2px 8px oklch(20% 0.02 262 / 0.4);
}

.vision-theme-scope[data-vision-theme="dark"] {
    --shadow-whisper: 0 1px 2px oklch(0% 0 0 / 0.3);
    --shadow-overlay: 0 8px 24px oklch(0% 0 0 / 0.45);
}

/* VisionPb: the third theme, a light one with the customer portal's feel (Vision.Web/design.md,
   Variants). MainLayout sets data-vision-theme="visionpb" and hands MudThemeProvider the VisionPb
   MudTheme (VisionPbThemeDefinition.cs), whose hex palette matches the values below.

   The system tokens are set to the portal's warm values here rather than left to alias the
   palette, so every page outside the restyled areas gets the paper, ink, rule, accent and type from
   this block alone. The --vpb-* names are the portal's stock vocabulary (Vision.Consumer
   hallmark/tokens.css) for theme-visionpb.css and the area sheets in css/visionpb/; they exist only
   inside this scope. Status and appointment colours are not redefined: their solid fills carry
   their own ink, so they read the same on warm paper and keep the hues staff know. */
.vision-theme-scope[data-vision-theme="visionpb"] {
    color-scheme: light;

    /* Surfaces and ink */
    --color-paper: oklch(97% 0.006 55);
    --color-surface: oklch(98.8% 0.0045 80);
    --color-surface-2: oklch(94.5% 0.007 55);
    --color-ink: oklch(21% 0.012 38);
    --color-ink-2: oklch(47% 0.013 45);
    --color-ink-3: oklch(66% 0.01 50);
    --color-rule: oklch(87% 0.009 55);
    --color-rule-strong: oklch(60% 0.012 50);
    --color-hover: color-mix(in oklab, var(--color-ink) 6%, transparent);

    /* The one accent: the Poolblu logo blue, #105f9e */
    --color-accent: oklch(47.5% 0.124 249);
    --color-accent-strong: oklch(41% 0.115 250);
    --color-accent-ink: oklch(98.8% 0.0045 80);
    --color-focus: oklch(47.5% 0.124 249);

    /* Signal colours, as the VisionPb palette */
    --color-success: oklch(50% 0.12 150);
    --color-warning: oklch(55% 0.12 70);
    --color-error: oklch(52% 0.19 27);
    --color-info: oklch(47.5% 0.124 249);

    /* Washes re-mixed from this scope's accent and cotton */
    --color-accent-wash: color-mix(in oklab, var(--color-accent) 9%, var(--color-surface));
    --color-success-wash: color-mix(in oklab, var(--color-success) 10%, var(--color-surface));
    --color-warning-wash: color-mix(in oklab, var(--color-warning) 13%, var(--color-surface));
    --color-error-wash: color-mix(in oklab, var(--color-error) 9%, var(--color-surface));
    --color-info-wash: color-mix(in oklab, var(--color-info) 9%, var(--color-surface));
    --color-scrim: oklch(21% 0.012 38 / 0.35);

    /* Type: General Sans for body and headings, Geist Mono for identifiers and figures */
    --font-body: "General Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    /* Shape: the portal's 8px stock corner, which is also the VisionPb MudTheme radius */
    --radius-md: 8px;
    --radius-card: var(--vpb-radius-card);

    /* Elevation: warm shade instead of the cool one */
    --shadow-whisper: 0 1px 2px oklch(20% 0.01 35 / 0.05);
    --shadow-overlay: var(--vpb-edge-stock), var(--vpb-cast-stock-lift);

    /* The app bar sits on paper. MainLayout writes this variable on <html> for Light and Dark;
       a value on the scope wins for everything inside it. */
    --toolbar-header-background-color: var(--color-paper);

    /* Portal stock vocabulary, shared with the area sheets (names are a contract) */
    --vpb-cotton: oklch(98.8% 0.0045 80);
    --vpb-desk: oklch(94.3% 0.008 64);
    --vpb-paper-3: oklch(91.5% 0.009 55);
    --vpb-accent-2: oklch(41% 0.115 250);
    --vpb-accent-soft: oklch(95.5% 0.02 245);
    --vpb-board: oklch(22% 0.011 40);
    --vpb-board-type: oklch(96.5% 0.006 70);

    /* Light from the top left: --vpb-lit is the lit edge, --vpb-shade the cast. Both are bare
       OKLCH channels so each shadow sets its own alpha. */
    --vpb-shade: 32% 0.03 50;
    --vpb-lit: 100% 0.005 80;
    --vpb-edge-stock: inset 0 1px 0 oklch(var(--vpb-lit) / 0.9), inset 0 -1px 0 oklch(var(--vpb-shade) / 0.07), 0 0 0 0.5px oklch(var(--vpb-shade) / 0.22), 0 1px 0 oklch(var(--vpb-shade) / 0.12);
    --vpb-cast-stock: 6px 5px 10px -6px oklch(var(--vpb-shade) / 0.3);
    --vpb-cast-stock-lift: 12px 10px 18px -8px oklch(var(--vpb-shade) / 0.3);
    --vpb-press-groove: inset 1px 1.5px 2px oklch(var(--vpb-shade) / 0.16), inset -1px -1px 0 oklch(var(--vpb-lit) / 0.9), 0 0 0 0.5px oklch(var(--vpb-shade) / 0.2);
    --vpb-radius-card: 8px;

    /* Additions beyond the shared contract, used by theme-visionpb.css */
    --vpb-radius-input: 6px;
    --vpb-cast-dialog: 0 24px 48px -16px oklch(var(--vpb-shade) / 0.35);

    --vpb-font-body: "General Sans", ui-sans-serif, system-ui, sans-serif;
    --vpb-font-mono: "Geist Mono", ui-monospace, monospace;

    /* Status ink, one step darker than the signal fills so text holds 4.5:1 on its own tint */
    --vpb-state-ok: oklch(46% 0.11 150);
    --vpb-state-warn: oklch(46% 0.11 70);
    --vpb-state-bad: oklch(47% 0.18 27);
    --vpb-state-info: oklch(43% 0.12 250);
    --vpb-state-quiet: oklch(29% 0.013 40);
}

/* VisionPortal, a variant of VisionPb (design.md, Variants): the customer portal's clean look.
   It keeps data-vision-theme="visionpb", so every VisionPb sheet applies, and re-points the
   VisionPb vocabulary: white cards on a cool ground, hairline rules, soft modern shadows. The
   washes stay as VisionPb computes them; they re-mix from these values. */
.vision-theme-scope[data-vision-theme="visionpb"][data-vision-variant="portal"] {
    --color-paper: oklch(97.8% 0.003 250);
    --color-surface: oklch(100% 0 0);
    --color-surface-2: oklch(96% 0.004 250);
    --color-ink: oklch(22% 0.02 255);
    --color-ink-2: oklch(47% 0.02 255);
    --color-ink-3: oklch(64% 0.012 250);
    --color-rule: oklch(91.5% 0.006 250);
    --color-rule-strong: oklch(62% 0.012 250);
    --color-accent-ink: oklch(100% 0 0);
    --color-scrim: oklch(22% 0.02 255 / 0.35);
    --toolbar-header-background-color: var(--color-surface);

    --vpb-cotton: oklch(100% 0 0);
    --vpb-desk: oklch(100% 0 0);
    --vpb-paper-3: oklch(94% 0.005 250);
    --vpb-accent-soft: oklch(95.5% 0.025 245);
    --vpb-board: oklch(27% 0.06 250);
    --vpb-board-type: oklch(97% 0.01 250);

    --vpb-shade: 25% 0.03 255;
    --vpb-lit: 100% 0 0;
    --vpb-edge-stock: 0 0 0 1px var(--color-rule);
    --vpb-cast-stock: 0 1px 2px oklch(var(--vpb-shade) / 0.05), 0 2px 6px -2px oklch(var(--vpb-shade) / 0.06);
    --vpb-cast-stock-lift: 0 10px 24px -10px oklch(var(--vpb-shade) / 0.18);
    --vpb-press-groove: 0 0 0 1px var(--color-rule);
    --vpb-radius-card: 10px;
    --radius-md: 8px;
    --vpb-cast-dialog: 0 24px 48px -16px oklch(var(--vpb-shade) / 0.28);
    --shadow-whisper: 0 1px 2px oklch(var(--vpb-shade) / 0.05);
}
