/*
 * Shared design tokens for Storyarr and Starboard (version 1, 2 November 2026).
 *
 * Role names only: components use these and nothing else, so both apps look like one family and a
 * theme is a change of values, not of components. Three themes: Light, Dark, High contrast (light and
 * dark). Display preferences (text size, wider spacing, reduced motion) are classes on <html>.
 *
 * The default design is Mica (owner, 18 November 2026, DASH-479): calm neutral greys, small round corners (6px), a
 * layered shadow on cards and menus, and one accent colour, Blue unless another is chosen (palettes/). The design
 * before it, teal on blue-grey with square corners, is the Classic style in Starboard's Styles plug-in.
 * Every text and control pair below meets WCAG 2.2 AA (4.5:1 text, 3:1 borders of controls, hover edges and focus)
 * in every theme and with every accent: tools/check_accents.py proves it.
 */

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("fonts/atkinson-hyperlegible-next.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  /* Type: one typeface, five sizes, scaled by the Text size setting. */
  --font: "Atkinson Hyperlegible Next", system-ui, sans-serif;
  --text-scale: 1;
  --text-xs: calc(0.75rem * var(--text-scale));
  --text-sm: calc(0.875rem * var(--text-scale));
  --text-md: calc(1rem * var(--text-scale));
  --text-lg: calc(1.25rem * var(--text-scale));
  --text-xl: calc(1.5rem * var(--text-scale));
  --text-2xl: calc(2rem * var(--text-scale));
  --leading: 1.5;
  --leading-tight: 1.25;
  --letter-spacing: normal;
  --word-spacing: normal;
  --weight-regular: 400;
  --weight-strong: 600;
  --weight-heading: 600;

  /* Space: a 4px scale. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Size. 44px is the control height and the touch target everywhere; 32px only inside dense tables,
     never for the only way to do something. */
  --control-h: 44px;
  --control-h-compact: 32px;
  --icon-sm: 16px;
  --icon-md: 18px;
  --icon-lg: 20px;
  --radius: 6px; /* Mica's corners, on every control, card, panel, menu and dialog */
  --radius-round: 50%;
  --header-h: 64px;
  --tabs-h: 48px;
  /* The side menu grows with the text, so its names never break in the middle of a word or run past its edge
     (DASH-437): room for the widest one-word name (Feedback, Starboard) at --text-xs, plus the menu's padding,
     its border and a thin scroll bar for short windows. Never narrower than 88px. Wider spacing needs more room. */
  --rail-name-em: 4.6;
  --rail-w: max(88px, calc(var(--text-xs) * var(--rail-name-em) + 28px));
  --panel-w: 420px;
  --dialog-w: 560px;
  --content-max: 1440px;
  --focus-w: 3px;
  --current-bar-w: 3px;
  --status-edge-w: 6px;

  /* Motion. Zero when the person asks for less motion. */
  --motion-fast: 120ms;
  --motion-panel: 200ms ease-out;

  /* Layers. */
  --layer-sticky: 10;
  --layer-header: 50;
  --layer-menu: 60;
  --layer-panel: 70;
  --layer-dialog: 80;
  --layer-toast: 90;

  /* Colour: Light (Mica). */
  --color-bg: #f3f3f3;
  --color-header: #f3f3f3;
  --color-surface: #fbfbfb;
  --color-surface-raised: #ffffff;
  --color-surface-sunken: #ebebeb;
  --color-text: #1a1a1a;
  --color-text-muted: #5d5d5d;
  --color-border: #767676;
  --color-divider: #898989; /* card edges and rules (hr) share it: the lightest grey with 3:1 on the tinted page and the card (owner, 18 November 2026) */
  --color-accent: #005fb8; /* Blue, Mica's accent; palettes/ has the others */
  --color-accent-text: #ffffff;
  --color-accent-soft: #e0eef9;
  --color-panel-header: #ffffff;
  /* Scroll bars: thin and in the border colour, so they show without shouting (TheMightyTRexUK, 2 November
     2026). They follow every theme because they point at other roles. */
  --color-scrollbar: var(--color-border);
  --color-scrollbar-hover: var(--color-text-muted);
  --color-slide-header: var(--color-surface-sunken); /* slide-out headers: the grey band of a dashboard card (DASH-479) */
  /* The chosen item in a menu or a group of buttons: the accent's soft tint, with the accent bar beside it. */
  --color-control-active: var(--color-accent-soft);
  /* Hover on every menu, tab and list item (owner, 18 November 2026): a light fill and an edge in the border colour,
     so the edge is at least 3:1 against whatever the item sits on, in every theme and with every accent. */
  --color-hover: color-mix(in srgb, var(--color-text) 7%, transparent);
  --color-hover-edge: var(--color-border);
  /* Glass (owner, 18 November 2026: "keep some of the transparency effects and a bit more glass effect"): the header,
     side menu, menus, slide-outs and dialogs are frosted layers. --glass-alpha is how much of the surface colour
     shows: the least that still gives secondary text 4.5:1 with black (or, in dark, white) right behind the glass,
     checked by tools/check_accents.py. Solid in High contrast, with Reduce transparency and where the browser has no
     backdrop-filter. --page-tint is the accent's share in the soft wash across the page. */
  --glass-alpha: 92%;
  --glass-filter: blur(24px) saturate(1.6);
  --page-tint: 3%;
  /* Focus is neutral (Mica): the text colour, so it stands out from every accent and every surface. */
  --color-focus: #1a1a1a;
  --color-count: #af4e24;
  --color-count-text: #ffffff;
  --color-backdrop: rgb(0 0 0 / 0.4);
  --color-logo-tile: #005fb8;
  --color-logo-star: #1a1a1a;
  --chart-1: #3a52b0;
  --chart-2: #b45a2b;
  /* Categorical series, in a fixed order that follows the thing (such as a media type); checked for colour
     blindness and 3:1 against the surface. --series-empty (with its hatch line) is free or unused space. */
  --series-1: #2a78d6; --series-2: #e0612f; --series-3: #138a60; --series-4: #b07800;
  --series-5: #d0577f; --series-6: #007a00; --series-7: #6250d6;
  --series-empty: #e3e3e3; --series-empty-line: #b5b5b5;
  /* Mica's layered lift: cards, menus, slide-outs and dialogs. */
  --shadow-raised: 0 1px 2px rgb(16 24 40 / 0.06), 0 4px 8px rgb(16 24 40 / 0.06), 0 12px 32px rgb(16 24 40 / 0.10);
  /* Cards stand off the page (owner, 18 November 2026: "the 3d effect drop shadows"): Mica's layered drop shadow,
     box-shadow only so it is cheap to draw. The border stays, so the shadow is never the only edge. */
  --shadow-card: 0 1px 2px rgb(16 24 40 / 0.08), 0 4px 8px rgb(16 24 40 / 0.07), 0 12px 32px rgb(16 24 40 / 0.11);

  /* Status: background and text pairs, always shown with words and an icon or shape too. */
  --status-success-bg: #dcf2e3;
  --status-success-fg: #135c2e;
  --status-info-bg: #dde9fb;
  --status-info-fg: #154a96;
  --status-neutral-bg: #eceef2;
  --status-neutral-fg: #3c4350;
  --status-warning-bg: #fdefc8;
  --status-warning-fg: #6b4500;
  --status-danger-bg: #fbe0de;
  --status-danger-fg: #9b1c14;
  --status-muted-bg: #eceef2;
  --status-muted-fg: #4a5160;

  color-scheme: light;
}

/* Dark: only when chosen (owner, 18 November 2026: "Light mode should be the default mode unless changed by the
   user"). Match device, where an app offers it, sets data-theme to the device's choice in script. */
:root[data-theme="dark"] {
  --color-bg: #202020;
  --color-header: #202020;
  --color-surface: #2b2b2b;
  --color-surface-raised: #323232;
  --color-surface-sunken: #1c1c1c;
  --color-text: #ffffff;
  --color-text-muted: #c5c5c5;
  --color-border: #949494;
  --color-divider: #747474;
  --color-accent: #60cdff;
  --color-accent-text: #000000;
  --color-accent-soft: #1f3a4d;
  --color-panel-header: #323232;
  --color-slide-header: var(--color-surface-sunken);
  --color-hover: color-mix(in srgb, var(--color-text) 9%, transparent);
  --glass-alpha: 90%;
  --color-hover-edge: var(--color-text-muted); /* lighter in dark, so the edge keeps 3:1 over glass */
  --color-focus: #ffffff;
  --color-count: #c0401a;
  --color-backdrop: rgb(0 0 0 / 0.6);
  --color-logo-tile: #60cdff;
  --color-logo-star: #ffffff;
  --chart-1: #8c9cf0;
  --chart-2: #e08a55;
  --series-1: #4a94ec; --series-2: #e5703f; --series-3: #2fae80; --series-4: #d39a1c;
  --series-5: #e0739a; --series-6: #3fb23f; --series-7: #9a8ff0;
  --series-empty: #3d3d3d; --series-empty-line: #5c5c5c;
  --shadow-raised: 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 8px rgb(0 0 0 / 0.25), 0 12px 32px rgb(0 0 0 / 0.4);
  --shadow-card: 0 1px 2px rgb(0 0 0 / 0.35), 0 4px 8px rgb(0 0 0 / 0.28), 0 12px 32px rgb(0 0 0 / 0.38);
  --status-success-bg: #12351f;
  --status-success-fg: #8fe0aa;
  --status-info-bg: #142a4b;
  --status-info-fg: #a8c8ff;
  --status-neutral-bg: #262a33;
  --status-neutral-fg: #c9ced8;
  --status-warning-bg: #3a2c09;
  --status-warning-fg: #f6cf6b;
  --status-danger-bg: #431816;
  --status-danger-fg: #ffaaa3;
  --status-muted-bg: #262a33;
  --status-muted-fg: #b3b9c5;
  color-scheme: dark;
}

/* High contrast: stronger text, borders and focus; borders instead of shadows. */
:root.pref-contrast {
  --color-scrollbar: var(--color-text);
  --color-scrollbar-hover: var(--color-text);
  --color-hover: color-mix(in srgb, var(--color-text) 10%, transparent);
  --color-hover-edge: var(--color-text);
  --color-bg: #f3f3f3;
  --color-header: #ffffff;
  --color-surface: #ffffff;
  --color-surface-raised: #ffffff;
  --color-surface-sunken: #f0f0f0;
  --color-text: #030304;
  --color-text-muted: #19212f;
  --color-border: #000000;
  --color-divider: #5c5c5c;
  --color-accent: #00396e;
  --color-accent-text: #ffffff;
  --color-accent-soft: #d9e9f7;
  --color-panel-header: #ffffff;
  --color-slide-header: var(--color-bg); /* slide-out headers: the page background over a white body */
  --chart-1: #1f2a8a;
  --chart-2: #8a3200;
  --series-1: #1f5fbf; --series-2: #c4471b; --series-3: #00806a; --series-4: #946000;
  --series-5: #b8336a; --series-6: #006b00; --series-7: #5440c8;
  --series-empty: #ffffff; --series-empty-line: #767676;
  --color-focus: #c4006a;
  --color-count: #863309;
  --color-logo-tile: #00396e;
  --color-logo-star: #000000;
  --shadow-raised: none;
  --shadow-card: none;
  --status-success-fg: #003d17;
  --status-info-fg: #00266e;
  --status-neutral-fg: #000000;
  --status-warning-fg: #3d2600;
  --status-danger-fg: #6e0000;
  --status-muted-fg: #000000;
}
:root.pref-contrast[data-theme="dark"],
:root.pref-contrast.is-dark {
  --color-bg: #000000;
  --color-header: #000000;
  --color-surface: #000000;
  --color-surface-raised: #000000;
  --color-surface-sunken: #111111;
  --color-text: #ffffff;
  --color-text-muted: #d5e0f4;
  --color-border: #ffffff;
  --color-divider: #8f8f8f;
  --color-accent: #a8e4ff;
  --color-accent-text: #000000;
  --color-accent-soft: #0a2a3d;
  --color-panel-header: #000000;
  --color-slide-header: var(--color-bg);
  --chart-1: #c2cbff;
  --chart-2: #ffb38a;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #2fa82f; --series-7: #9085e9;
  --series-empty: #000000; --series-empty-line: #8a8a8a;
  --color-focus: #ffd400;
  --color-count: #a44418;
  --color-logo-tile: #a8e4ff;
  --color-logo-star: #ffffff;
  --status-success-bg: #002b10;
  --status-success-fg: #a6ffc2;
  --status-info-bg: #001c45;
  --status-info-fg: #c2dbff;
  --status-neutral-bg: #1a1a1a;
  --status-neutral-fg: #ffffff;
  --status-warning-bg: #2e2000;
  --status-warning-fg: #ffe08a;
  --status-danger-bg: #330000;
  --status-danger-fg: #ffc2bd;
  --status-muted-bg: #1a1a1a;
  --status-muted-fg: #ffffff;
}

/* Display and accessibility preferences. */
:root.pref-text-125 { --text-scale: 1.25; }
:root.pref-text-150 { --text-scale: 1.5; }
:root.pref-text-175 { --text-scale: 1.75; }
:root.pref-spacing {
  --rail-name-em: 6;
  --leading: 1.8;
  --letter-spacing: 0.12em;
  --word-spacing: 0.16em;
}
:root.pref-motion {
  --motion-fast: 0ms;
  --motion-panel: 0ms;
}
/* Reduce motion: On (pref-motion) always stills movement; Match device follows the device; Off (pref-motion-off)
   means full movement even when the device asks for less (DASH-437). Every reduced-motion query in the library
   leaves out :root.pref-motion-off in the same way. */
@media (prefers-reduced-motion: reduce) {
  :root:not(.pref-motion-off) {
    --motion-fast: 0ms;
    --motion-panel: 0ms;
  }
}

/* Remove drop shadows (Starboard DASH-536; owner, 23 November 2026: "add a setting to remove the all drop shadows"):
   one switch sets every shadow token to none, so no component can forget it. Borders stay, so nothing loses its
   edge. Set data-shadows="off" on <html> (an app does it before first paint, as it does the theme), or on any
   element to turn the shadows off inside it. The root rule is doubled so it beats every theme. Inset edges and
   status bars (the 3px accent bar, the hover edge) are not drop shadows and stay. */
:root:root[data-shadows="off"],
[data-shadows="off"] {
  --shadow-raised: none;
  --shadow-card: none;
}
