/* Everything the dashboard and the WordPress plugin's admin bundle must agree
   on to render these components the same (ACC-403): the design system's
   tokens, the custom variants the class strings use, and the pointer-focus
   rule. One copy, imported by both — apps/dashboard/src/app/globals.css and
   src/wp/styles.css.

   Tailwind directives, so only usable through a stylesheet that imports
   Tailwind first. */

/* The user last pressed a key (not a shortcut) rather than the pointer: set by
   `useInputModality` (src/input-modality.ts). For focus that `:focus-visible`
   cannot attribute to the keyboard, like the item a Radix menu focuses on hover. */
@custom-variant keyboard (&:where([data-input-modality="keyboard"] *));

/* A window too short for the dashboard side menu's pinned parts (logo, site,
   foot: about 380px) to leave room for its list: a phone on its side, a
   desktop zoomed to 400%. There the whole menu scrolls instead of the list
   alone. */
@custom-variant short-window (@media (max-height: 599px));

/* A label that names a checkbox, a radio or a switch: it wraps the control,
   follows it or comes right before it. ui/label.tsx draws it as
   the text of that option (14px, regular) instead of the title of a field.
   `:where()` keeps the specificity of a plain class. */
@custom-variant choice-label {
  &:where(
    :has(:is([role="checkbox"], [role="radio"], [role="switch"])),
    :is([role="checkbox"], [role="radio"], [role="switch"]) ~ *,
    :has(+ :is([role="checkbox"], [role="radio"], [role="switch"]))
  ) {
    @slot;
  }
}

/* ── AccessiBit design system ─────────────────────────────────────────────
   The typefaces, palette, shadows, radii and type scale of the design system,
   as theme variables so that each has its utilities (`font-heading`,
   `bg-primary-blue-10`, `shadow-large`, `rounded-xl`, `text-page-title`).
   `static` keeps every one on :root even when no class uses it: tour.css, the
   SVG charts and inline styles read them as `var(--color-…)`.

   Not here, on purpose. The spacing steps (4, 8, 12, 16, 24, 32, 48, 64 px)
   are Tailwind's 1, 2, 3, 4, 6, 8, 12 and 16 already: a `--spacing-4: 4px`
   would turn every `p-4` from 16px into 4px. Tailwind's own font sizes
   (`text-sm`, `text-base`, …) stay as they are. And the design system's
   `--color-background-primary`-style aliases are the semantic tokens of
   :root below, under the names the code already uses.
   Guarded by the dashboard's src/test/design-system-guard.test.ts. */
@theme static {
  /* Plus Jakarta Sans for headings, navigation and figures; IBM Plex Sans for
     everything read or pressed. The dashboard's app/fonts.ts loads them and
     sets the two variables on <html>; elsewhere the system's sans stands in.
     Monospace is the system's, as in the design system. */
  --font-heading:
    var(--font-plus-jakarta-sans), ui-sans-serif, system-ui, sans-serif;
  --font-sans: var(--font-ibm-plex-sans), ui-sans-serif, system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --color-primary-blue-100: #071c4d;
  --color-primary-blue-80: #394971;
  --color-primary-blue-60: #6a7794;
  --color-primary-blue-40: #9ca4b8;
  --color-primary-blue-20: #cdd2db;
  --color-primary-blue-10: #e6e8ed;
  --color-primary-blue-5: #f3f4f6;
  --color-primary-electric-blue-120: #144fdb;
  --color-primary-electric-blue-100: #175cff;
  --color-primary-electric-blue-80: #457dff;
  --color-primary-electric-blue-60: #749dff;
  --color-primary-electric-blue-40: #a2beff;
  --color-primary-electric-blue-20: #d1deff;
  --color-primary-electric-blue-10: #e8efff;
  --color-primary-electric-blue-5: #f3f7ff;
  --color-primary-black-100: #1b1b1c;
  --color-primary-black-80: #494949;
  --color-primary-black-60: #767677;
  --color-primary-black-40: #a4a4a4;
  --color-primary-black-20: #d1d1d2;
  --color-primary-black-10: #e8e8e8;
  --color-primary-black-5: #f4f4f4;
  --color-primary-white: #ffffff;
  --color-secondary-teal-100: #00b3a4;
  --color-secondary-teal-80: #33c2b6;
  --color-secondary-teal-60: #66d1c8;
  --color-secondary-teal-40: #99e1db;
  --color-secondary-teal-20: #ccf0ed;
  --color-secondary-teal-10: #e5f7f6;
  --color-secondary-teal-5: #f2fbfa;
  --color-secondary-violet-100: #6c3cff;
  --color-secondary-violet-80: #8963ff;
  --color-secondary-violet-60: #a78aff;
  --color-secondary-violet-40: #c4b1ff;
  --color-secondary-violet-20: #e2d8ff;
  --color-secondary-violet-10: #f0ebff;
  --color-secondary-violet-5: #f8f5ff;
  --color-secondary-cyan-100: #00c2ff;
  --color-secondary-cyan-80: #33ceff;
  --color-secondary-cyan-60: #66daff;
  --color-secondary-cyan-40: #99e7ff;
  --color-secondary-cyan-20: #ccf3ff;
  --color-secondary-cyan-10: #e5f9ff;
  --color-secondary-cyan-5: #f2fcff;
  /* Success and warning at 100 are fills and borders; on white they reach
     1.7:1 and 1.5:1, so icons, field borders and text take the 120 step. */
  --color-semantic-success-120: #367a41;
  --color-semantic-success-100: #63de77;
  --color-semantic-success-80: #82e592;
  --color-semantic-success-60: #a1ebad;
  --color-semantic-success-40: #c1f2c9;
  --color-semantic-success-20: #e0f8e4;
  --color-semantic-success-10: #effcf1;
  --color-semantic-success-5: #f7fdf8;
  --color-semantic-warning-120: #8c6d00;
  --color-semantic-warning-100: #ffc700;
  --color-semantic-warning-80: #ffd233;
  --color-semantic-warning-60: #ffdd66;
  --color-semantic-warning-40: #ffe999;
  --color-semantic-warning-20: #fff4cc;
  --color-semantic-warning-10: #fff9e5;
  --color-semantic-warning-5: #fffcf2;
  /* Error at 100 is for borders and icons (3.7:1 on white). 120 is the red
     that holds under white text (the button that confirms a removal) and as
     text where the product writes an error in red: 5.2:1 both ways. */
  --color-semantic-error-120: #cd2a47;
  --color-semantic-error-100: #ff2d46;
  --color-semantic-error-80: #ff576b;
  --color-semantic-error-60: #ff8190;
  --color-semantic-error-40: #ffabb5;
  --color-semantic-error-20: #ffd5da;
  --color-semantic-error-10: #ffeaec;
  --color-semantic-error-5: #fff4f6;

  /* Navy shadows lift neutral cards, blue ones mark the featured card. A card
     takes a hairline, a shadow or the blue border, not all three. */
  --shadow-xs: 0 1px 2px 0 #0000000d;
  --shadow-medium: 0 24px 60px 0 #071c4d1a;
  --shadow-large: 0 12px 30px 1px #071c4d1a;
  --shadow-blue-pricing: 0 24px 50px 0 #175cff29;
  --shadow-mobile: 0 16px 40px 0 #071c4d1a;
  --shadow-blue-mobile: 0 14px 35px 0 #175cff29;

  /* The design system's radii under the names the code already uses: 4, 8,
     12, 16 and 24px (`rounded-full` is Tailwind's). Buttons, inputs and alerts
     are `rounded-md`, cards `rounded-xl`, tables and banners `rounded-2xl`. */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;

  /* The Dashboard group of the type tokens. Titles and figures are set in
     `font-heading`; a class of these carries size, line height and, where the
     style has one, weight and tracking. New names, so that `cn()` can tell
     them from colours: register each in lib/cn.ts. */
  --text-page-title: 2rem;
  --text-page-title--line-height: 1.25;
  --text-page-title--font-weight: 700;
  --text-page-title-phone: 1.625rem;
  --text-page-title-phone--line-height: calc(32 / 26);
  --text-page-title-phone--font-weight: 700;
  --text-section-title: 1.25rem;
  --text-section-title--line-height: 1.4;
  --text-section-title--font-weight: 700;
  --text-card-title: 1rem;
  --text-card-title--line-height: 1.5;
  --text-card-title--font-weight: 700;
  --text-figure: 2rem;
  --text-figure--line-height: 1.2;
  --text-figure--font-weight: 800;
  --text-figure-lg: 3rem;
  --text-figure-lg--line-height: calc(52 / 48);
  --text-figure-lg--font-weight: 800;
  --text-ui-text: 1rem;
  --text-ui-text--line-height: 1.5;
  --text-ui-small: 0.875rem;
  --text-ui-small--line-height: 1.6;
  --text-ui-caption: 0.75rem;
  --text-ui-caption--line-height: 1.5;
  --text-ui-overline: 0.75rem;
  --text-ui-overline--line-height: 1.35;
  --text-ui-overline--font-weight: 700;
  --text-ui-overline--letter-spacing: 0.08em;
}

/* The semantic colours as utilities (`bg-card`, `text-muted-foreground`).
   `inline` makes each class read the :root token below directly. */
@theme inline {
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --color-sidebar-border: var(--sidebar-border);
  --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
  --color-sidebar-accent: var(--sidebar-accent);
  --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
  --color-sidebar-primary: var(--sidebar-primary);
  --color-sidebar-foreground: var(--sidebar-foreground);
  --color-sidebar: var(--sidebar);
  --color-chart-5: var(--chart-5);
  --color-chart-4: var(--chart-4);
  --color-chart-3: var(--chart-3);
  --color-chart-2: var(--chart-2);
  --color-chart-1: var(--chart-1);
  --color-ring: var(--ring);
  --color-input: var(--input);
  --color-border: var(--border);
  --color-destructive: var(--destructive);
  --color-destructive-hover: var(--destructive-hover);
  --color-destructive-foreground: var(--destructive-foreground);
  --color-warning: var(--warning);
  --color-warning-foreground: var(--warning-foreground);
  --color-status-pass: var(--status-pass);
  --color-status-warn: var(--status-warn);
  --color-status-fail: var(--status-fail);
  --color-accent-foreground: var(--accent-foreground);
  --color-accent: var(--accent);
  --color-muted-foreground: var(--muted-foreground);
  --color-muted: var(--muted);
  --color-placeholder: var(--placeholder);
  --color-secondary-foreground: var(--secondary-foreground);
  --color-secondary: var(--secondary);
  --color-primary-foreground: var(--primary-foreground);
  --color-primary: var(--primary);
  --color-popover-foreground: var(--popover-foreground);
  --color-popover: var(--popover);
  --color-card-foreground: var(--card-foreground);
  --color-card: var(--card);
}

/* The semantic tokens: what each colour of the palette is for. One theme, the
   light one. Contrast of the text tokens is guarded by
   the dashboard's src/test/a11y/token-contrast.test.ts. */
:root {
  /* The page is the tinted ground; what sits on it (cards, popovers, the
     sidebar) is white with a navy 10% hairline. */
  --background: var(--color-primary-electric-blue-5);
  --foreground: var(--color-primary-black-100);
  --card: var(--color-primary-white);
  --card-foreground: var(--color-primary-black-100);
  --popover: var(--color-primary-white);
  --popover-foreground: var(--color-primary-blue-100);
  /* Electric Blue is the one colour of action: primary buttons, links, focus. */
  --primary: var(--color-primary-electric-blue-100);
  --primary-foreground: var(--color-primary-white);
  /* The neutral fill (the neutral Badge): navy 10% under navy text. */
  --secondary: var(--color-primary-blue-10);
  --secondary-foreground: var(--color-primary-blue-100);
  /* Quiet grounds (a table head, a neutral notice): navy 5%. Secondary text is
     navy 80%, 8.3:1 on the page; `primary-black-60` would stop at 4.2:1. */
  --muted: var(--color-primary-blue-5);
  --muted-foreground: var(--color-primary-blue-80);
  /* The example inside an empty field (`placeholder:text-placeholder`). Lighter
     than secondary text, which would read like a value already typed: 4.5:1
     on the white of a field. */
  --placeholder: var(--color-primary-black-60);
  /* Hover and the chosen item of a menu. The 10% tint, because the 5% one is
     the page itself and would not show on it. */
  --accent: var(--color-primary-electric-blue-10);
  --accent-foreground: var(--color-primary-blue-100);
  /* Red as text, and as a fill under white text. Borders and icons of an
     error use `semantic-error-100`. */
  --destructive: var(--color-semantic-error-120);
  /* The red button under the pointer: the red a fifth towards the navy, as
     the design system's `.ab-btn--danger:hover`. */
  --destructive-hover: color-mix(
    in srgb,
    var(--color-semantic-error-120) 80%,
    var(--color-primary-blue-100)
  );
  --destructive-foreground: var(--color-primary-white);
  --warning: var(--color-semantic-warning-120);
  --warning-foreground: var(--color-primary-white);
  /* One accent per outcome, for the icon, the border and the figure of a
     verdict: >= 4.5:1 on the page and on white. On a tint the message itself
     stays `foreground`, as in the Badge and the Notice. */
  --status-pass: var(--color-semantic-success-120);
  --status-warn: var(--color-semantic-warning-120);
  --status-fail: var(--color-semantic-error-120);
  --border: var(--color-primary-blue-10);
  /* The border of a field: 4.5:1 on white, where a 10% hairline gave 1.2:1. */
  --input: var(--color-primary-black-60);
  /* The keyboard focus colour, drawn opaque. It has to reach 3:1 (WCAG 1.4.11)
     against every surface a control sits on, tinted panels included: >= 4.2:1.
     Guarded by the dashboard's src/test/a11y/focus-ring-contrast.test.ts. */
  --ring: var(--color-primary-electric-blue-100);
  /* Series of a chart, in order. Teal and cyan are below 3:1 on white: a
     series in them needs its label on the line. */
  --chart-1: var(--color-primary-electric-blue-100);
  --chart-2: var(--color-primary-blue-100);
  --chart-3: var(--color-secondary-violet-100);
  --chart-4: var(--color-secondary-teal-100);
  --chart-5: var(--color-secondary-cyan-100);
  /* White, navy for the current item, the 5% tint on hover. */
  --sidebar: var(--color-primary-white);
  --sidebar-foreground: var(--color-primary-blue-100);
  --sidebar-primary: var(--color-primary-blue-100);
  --sidebar-primary-foreground: var(--color-primary-white);
  --sidebar-accent: var(--color-primary-electric-blue-5);
  --sidebar-accent-foreground: var(--color-primary-blue-100);
  --sidebar-border: var(--color-primary-blue-10);
}

/* Radix selects and menus hand focus back to their trigger by script when
   they close, and Chrome then matches :focus-visible even for a mouse user
   who typed somewhere earlier. While the pointer was the last input, the
   trigger shows no focus indicator; the next key press brings it back. This
   relies on every keyboard move firing a keydown on this document (modified
   navigation keys included, see src/input-modality.ts). Unlayered so it wins
   over the utilities. */
[data-input-modality="pointer"]
  :is([aria-haspopup], [data-slot="select-trigger"]):focus-visible {
  outline-style: none;
  --tw-ring-shadow: 0 0 #0000;
}
