/*
 * CDSlides design tokens (D40–D45). Source of truth for the operator app,
 * editors and web controller. Slide themes (D17, D18) are separate.
 *
 * Appearance: set data-appearance="dark" | "light" on the app root.
 * Present mode defaults to dark; Edit mode follows the system (D41).
 * Without the attribute, the system preference decides.
 *
 * Contrast (checked): body text >= 7:1, muted/subtle text >= 4.5:1,
 * control boundaries >= 3:1, in both appearances.
 */

:root {
  /* ---------- Typography ---------- */
  --font-ui: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --font-mono: "Source Code Pro", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --text-xs: 0.8125rem;   /* 13px   shortcut hints, captions */
  --text-sm: 0.875rem;    /* 14px   secondary text, table cells */
  --text-md: 0.96875rem;  /* 15.5px body, list items, buttons */
  --text-lg: 1.125rem;    /* 18px   panel titles */
  --text-xl: 1.375rem;    /* 22px   dialog titles */
  --text-2xl: 1.75rem;    /* 28px   empty states, onboarding */
  --text-timer: 2rem;     /* 32px   timers and clocks (tabular numerals) */

  --weight-regular: 400;
  --weight-semibold: 600;
  --weight-bold: 700;

  --leading-tight: 1.2;   /* headings */
  --leading-body: 1.45;   /* body text */

  /* Section labels: small caps-style uppercase. */
  --label-size: 0.75rem;
  --label-tracking: 0.09em;

  /* ---------- Spacing (4px grid) ---------- */
  --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;

  /* ---------- Shape ---------- */
  --radius-sm: 4px;       /* chips, badges, thumbnails */
  --radius-md: 6px;       /* buttons, inputs, list items (default) */
  --radius-lg: 10px;      /* panels, dialogs, popovers */
  --radius-full: 999px;   /* pills, toggles */
  --border-width: 1px;

  /* ---------- Sizing ---------- */
  --icon-md: 24px;        /* standard (D45) */
  --icon-sm: 20px;        /* dense rows only */
  --icon-xs: 16px;        /* minimum */
  --target-min: 32px;     /* pointer hit target */
  --target-touch: 44px;   /* touch hit target (web controller) */
  --shell-top: 56px;
  --shell-left: 300px;
  --shell-right: 340px;
  --thumb-min: 190px;     /* slide thumbnail minimum width (D42) */

  /* ---------- Focus ---------- */
  --focus-width: 2px;
  --focus-offset: 2px;

  /* ---------- Motion ---------- */
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --duration-fast: 120ms;   /* hover, press */
  --duration-base: 200ms;   /* panels, popovers */
  --duration-slow: 320ms;   /* dialogs */

  /* ---------- Colour: light (Edit default on light systems) ---------- */
  --color-bg: #f3f3f4;
  --color-surface: #ffffff;
  --color-raised: #f7f7f8;
  --color-overlay: #ffffff;
  --color-border: #dfdfe3;
  --color-border-strong: #85858e;   /* input and control boundaries */

  --color-text: #18181b;
  --color-text-muted: #55555e;
  --color-text-subtle: #6b6b74;

  /* Accent: sage (D43). Never red, pink or orange. */
  --color-accent: #3e6d4a;
  --color-accent-hover: #335c3e;
  --color-on-accent: #ffffff;
  --color-accent-soft: #e6efe8;     /* selected-row tint */

  /* Live: reserved exclusively for "on screen now" (D43). */
  --color-live: #c8323a;
  --color-live-fill: #c8323a;
  --color-on-live: #ffffff;

  /* Status. Always paired with an icon and text. */
  --color-ok: #1b7a50;
  --color-warn: #8a5a0c;
  --color-danger: #c8323a;          /* shares live's hue; never shown without icon + words */
  --color-info: #1f5e99;

  --shadow-popover: 0 8px 24px rgb(0 0 0 / 0.12), 0 1px 2px rgb(0 0 0 / 0.08);
  --scrim: rgb(0 0 0 / 0.35);

  color-scheme: light;
}

/* ---------- Colour: dark (Present default, D41) ---------- */
:root[data-appearance="dark"] {
  --color-bg: #141517;
  --color-surface: #18191c;
  --color-raised: #202125;
  --color-overlay: #26272c;
  --color-border: #2e3035;
  --color-border-strong: #72757e;

  --color-text: #ececee;
  --color-text-muted: #a0a2aa;
  --color-text-subtle: #868993;

  --color-accent: #93c49c;
  --color-accent-hover: #a6d1ad;
  --color-on-accent: #0c1f11;
  --color-accent-soft: #1f2a22;

  --color-live: #ff5a5f;
  --color-live-fill: #d93a40;
  --color-on-live: #ffffff;

  --color-ok: #45c08a;
  --color-warn: #e3ab45;
  --color-danger: #ff5a5f;
  --color-info: #7fb0e0;

  --shadow-popover: 0 12px 32px rgb(0 0 0 / 0.5), 0 0 0 1px var(--color-border);
  --scrim: rgb(0 0 0 / 0.6);

  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-appearance]) {
    --color-bg: #141517;
    --color-surface: #18191c;
    --color-raised: #202125;
    --color-overlay: #26272c;
    --color-border: #2e3035;
    --color-border-strong: #72757e;
    --color-text: #ececee;
    --color-text-muted: #a0a2aa;
    --color-text-subtle: #868993;
    --color-accent: #93c49c;
    --color-accent-hover: #a6d1ad;
    --color-on-accent: #0c1f11;
    --color-accent-soft: #1f2a22;
    --color-live: #ff5a5f;
    --color-live-fill: #d93a40;
    --color-on-live: #ffffff;
    --color-ok: #45c08a;
    --color-warn: #e3ab45;
    --color-danger: #ff5a5f;
    --color-info: #7fb0e0;
    --shadow-popover: 0 12px 32px rgb(0 0 0 / 0.5), 0 0 0 1px var(--color-border);
    --scrim: rgb(0 0 0 / 0.6);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-fast: 0ms;
    --duration-base: 0ms;
    --duration-slow: 0ms;
  }
}

:focus-visible {
  outline: var(--focus-width) solid var(--color-accent);
  outline-offset: var(--focus-offset);
}
