/*
 * Workroom's design tokens (site/DESIGN.md).
 *
 * Hex and rgb literals belong here only. All other CSS consumes tokens through var(--*).
 *
 * One source of truth per palette:
 *   - Colours resolve through `light-dark()`, which picks by `color-scheme`.
 *   - `:root` declares `color-scheme: light dark`, so the OS preference wins by default.
 *   - `:root[data-theme="light|dark"]` (the header's theme button, js/theme.js) forces one.
 *   - An element that sets its own `color-scheme` (a code block, the footer) re-resolves every
 *     token inside it, so a dark surface needs no colours of its own.
 *
 * Shadows can't go through `light-dark()` (it only takes a <color>), so they come as
 * `--shadow-*-light` / `--shadow-*-dark` pairs, and the active one is aliased per scheme.
 */

@font-face {
  font-family: "Inter Variable";
  font-weight: 100 900;
  font-display: swap;
  font-style: normal;
  src:
    local("Inter Variable"),
    url(../fonts/InterVariable.woff2) format("woff2");
}

@font-face {
  font-family: "Inter Variable";
  font-weight: 100 900;
  font-display: swap;
  font-style: italic;
  src:
    local("Inter Variable Italic"),
    url(../fonts/InterVariable-Italic.woff2) format("woff2");
}

:root {
  color-scheme: light dark;

  --radius: 0.375rem;
  --space: 1rem;
  --measure: 65ch;
  --font-sans:
    "Inter Variable", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  --font-mono:
    ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* Surfaces, from the page (--bg-0) up to the most raised (--bg-4). */
  --bg-0: light-dark(#f6f5f1, #0b0b0e);
  --bg-1: light-dark(#fbfaf6, #111116);
  --bg-2: light-dark(#ffffff, #15151c);
  --bg-3: light-dark(#f3f2ec, #1c1c25);
  --bg-4: light-dark(#e9e7df, #232331);

  /* Hairlines, faintest first. */
  --line-1: light-dark(rgba(20, 18, 12, 0.06), rgba(255, 255, 255, 0.06));
  --line-2: light-dark(rgba(20, 18, 12, 0.1), rgba(255, 255, 255, 0.1));
  --line-3: light-dark(rgba(20, 18, 12, 0.16), rgba(255, 255, 255, 0.16));

  /* Text. --text-1 is primary and --text-2 secondary; --text-3 is for labels too small to read
     as sentences, and --text-4 for marks that are not text at all. */
  --text-1: light-dark(#1a1813, #ecedf2);
  --text-2: light-dark(#5b574d, #a6a8b3);
  --text-3: light-dark(#8b8678, #74767f);
  --text-4: light-dark(#b8b3a4, #51535b);

  /* Orange: focus rings, selection and links. --accent's light value reads at about 2.3:1 on
     --bg-0, too faint for text, so link text takes --link, about 5.3:1. */
  --accent: light-dark(#cc5a1f, #f08a4b);
  --accent-2: light-dark(#e08a3a, #f0b25c);
  --accent-soft: light-dark(rgba(204, 90, 31, 0.12), rgba(240, 138, 75, 0.2));
  --link: light-dark(#a9481a, #f08a4b);

  /* Workroom's yellow, from its mark. Too light to read as text on the light page, so it is only
     ever a fill, with --on-workroom-yellow on it, or a wash of it behind text. */
  --workroom-yellow: #ffea00;
  --on-workroom-yellow: #050505;

  /* Develop with Style's pink, behind "style" in its wordmark (the footer). Only ever a fill,
     with --on-dws-pink on it. */
  --dws-pink: #ff5fa2;
  --on-dws-pink: #10111c;

  /* The default button: a mid grey, darker than the page in light mode and lighter in dark. */
  --accent-button: light-dark(#5b574d, #c9cad2);
  --on-accent-button: var(--bg-0);

  /* Roles: the docs' alerts, and the code they colour. Each light value reads at 4.5:1 or more
     on --bg-0, as an alert's title is text. */
  --note: light-dark(#2e6cd1, #6ca8ff);
  --tip: light-dark(#237a3b, #5fc97a);
  --important: light-dark(#7b52c7, #b394f5);
  --warning: light-dark(#9a5a0c, #f0a13a);
  --danger: light-dark(#b91c1c, #f06464);
  --info: light-dark(#0b7584, #45c4d4);

  /* Syntax colours, by role. Code blocks are dark in either theme (css/site.css), so the dark
     values are the ones a reader sees there; inline code keeps the page's scheme. */
  --code-comment: light-dark(#7a7668, #8d8f99);
  --code-keyword: var(--note);
  --code-string: var(--tip);
  --code-constant: var(--warning);
  --code-function: var(--accent-2);
  --code-builtin: var(--info);
  --code-variable: var(--important);
  --code-deleted: var(--danger);
  --code-inserted: var(--tip);

  --overlay: light-dark(rgba(20, 18, 12, 0.45), rgba(0, 0, 0, 0.6));

  --shadow-card-light: 0 0 0 0.5px rgba(20, 18, 12, 0.04), 0 1px 0 rgba(20, 18, 12, 0.02) inset;
  --shadow-card-dark:
    0 0 0 0.5px rgba(255, 255, 255, 0.04), 0 1px 0 rgba(255, 255, 255, 0.03) inset;
  --shadow-dropdown-light:
    0 1px 2px rgba(20, 18, 12, 0.06), 0 8px 24px rgba(20, 18, 12, 0.1),
    0 16px 40px rgba(20, 18, 12, 0.08);
  --shadow-dropdown-dark:
    0 0 0 1px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.5), 0 12px 28px rgba(0, 0, 0, 0.55),
    0 24px 48px rgba(0, 0, 0, 0.45);

  --shadow-button: 0 1px 0 rgba(0, 0, 0, 0.15) inset, 0 0 0 0.5px rgba(0, 0, 0, 0.06);
  --shadow-card: var(--shadow-card-light);
  --shadow-dropdown: var(--shadow-dropdown-light);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --shadow-card: var(--shadow-card-dark);
    --shadow-dropdown: var(--shadow-dropdown-dark);
  }
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --shadow-card: var(--shadow-card-dark);
  --shadow-dropdown: var(--shadow-dropdown-dark);
}
