/*
 * den-ui tokens (UK-1). The kit's defaults are Den's theme (themes/den,
 * since 0.7.0: its type, shape and both modes), so a host on the kit's
 * defaults looks like Den. A theme laid on top overrides
 * colours (both modes), shadow, bar, type, radius, radius-button, density
 * and fonts; never spacing, motion or layers. Every rule here has zero
 * specificity (:where), so any theme rule wins.
 *
 * Mode: <html data-mode="light|dark">. With none set, light, or dark when
 * the system asks for it.
 */

/* Type, shape, space, depth, motion, layers, targets: one set, both modes. */
:where(:root) {
  /* prettier-ignore */
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  /* prettier-ignore */
  --display: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  /* prettier-ignore */
  --ja: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  --fs-xs: 12px;
  --fs-s: 13px;
  --fs-m: 14px;
  --fs-l: 15px;
  --fs-xl: 18px;
  --fs-2xl: 22px;
  --lh: 1.45;

  --radius: 8px;
  --radius-button: 6px;
  --r: var(--radius);
  --r-btn: var(--radius-button);

  --density: 1;
  --space-1: calc(4px * var(--density));
  --space-2: calc(8px * var(--density));
  --space-3: calc(12px * var(--density));
  --space-4: calc(16px * var(--density));
  --space-5: calc(24px * var(--density));
  --space-6: calc(32px * var(--density));

  --shadow-menu: var(--shadow);
  --shadow-dialog: var(--shadow);
  --shadow-bar: 0 6px 18px color-mix(in srgb, var(--text) 14%, transparent);

  --dur-fast: 120ms;
  --dur: 200ms;
  --dur-cue: 400ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);

  --z-menu: 10;
  --z-bar: 30;
  --z-drawer: 35;
  --z-dialog: 40;
  --z-palette: 45;
  --z-toast: 50;

  --tap: 44px;
  --tap-min: 36px;

  /* Veils behind a pop-up, the same in both modes: the ☰ drawer's and the
     status drawer's scrim, What's new's overlay, the Report form's backdrop. */
  --kit-scrim: rgb(0 0 0 / 0.35);
  --kit-veil: rgba(0, 0, 0, 0.65);
  --kit-backdrop: rgba(0, 0, 0, 0.3);
}

/* Light: the default. */
:where(:root),
:where(:root[data-mode="light"]) {
  color-scheme: light;
  --bg: #f2eee8;
  --surface: #fbf9f6;
  --raised: #ffffff;
  --sunken: #e8e2d9;
  --text: #241e18;
  --muted: #5c5247;
  --faint: #6d6358;
  --border: #dcd3c7;
  --border-strong: #8d7f6d;
  --accent: #557a2a;
  --accent-text: #415e1f;
  --accent-fill: #4a6b23;
  --on-accent: #ffffff;
  --ok: #27613b;
  --warn: #774c0e;
  --bad: #983124;
  --info: hsl(213 22% 36%);
  /* #0e7280 failed the pill rule over --sunken (4.20:1). #0d6b79 failed
     the disc rule (an agent's initial on its 16% tint) over --sunken
     (4.33:1); 4.56:1 now, the pill 4.84:1. */
  --remote: #205d6e;
  --violet: #6a4bc4;
  --shadow: 0 8px 24px rgb(48 36 24 / 0.14);
  /* A pop-up's or picker dialog's shadow (0.7.0). */
  --den-pop-shadow: 0 16px 40px rgb(0 0 0 / 0.25);
  /* The shared update pill's shadow (update-pill.css). */
  --upd-shadow:
    0 2px 4px rgba(32, 38, 29, 0.07), 0 10px 28px rgba(32, 38, 29, 0.1),
    inset 0 1px 0 color-mix(in srgb, var(--text) 14%, transparent);
  --bar: linear-gradient(90deg, #557a2a 0%, #8a6a48 100%);
}

/* Dark: asked for, or the system's choice when no mode is set. */
:where(:root[data-mode="dark"]) {
  color-scheme: dark;
  --bg: #1a1612;
  --surface: #221d18;
  --raised: #2b251f;
  --sunken: #14110e;
  --text: #ede6dc;
  --muted: #b5aa9b;
  --faint: #978b7e;
  --border: #3a322a;
  --border-strong: #7a6d5d;
  --accent: #9bbb63;
  --accent-text: #a8c672;
  --accent-fill: #9bbb63;
  --on-accent: #1a1612;
  --ok: #6fc28f;
  --warn: #e0a84e;
  --bad: #ef7f6a;
  --info: hsl(213 30% 74%);
  --remote: #74b8c8;
  --violet: #a993ff;
  --shadow: 0 12px 30px rgb(0 0 0 / 0.5);
  --den-pop-shadow: 0 16px 40px rgb(0 0 0 / 0.6);
  --upd-shadow:
    0 2px 4px rgba(0, 0, 0, 0.35), 0 10px 28px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 color-mix(in srgb, var(--text) 14%, transparent);
  --bar: linear-gradient(90deg, #9bbb63 0%, #a07c55 100%);
}

@media (prefers-color-scheme: dark) {
  :where(:root:not([data-mode])) {
    color-scheme: dark;
    --bg: #1a1612;
    --surface: #221d18;
    --raised: #2b251f;
    --sunken: #14110e;
    --text: #ede6dc;
    --muted: #b5aa9b;
    --faint: #978b7e;
    --border: #3a322a;
    --border-strong: #7a6d5d;
    --accent: #9bbb63;
    --accent-text: #a8c672;
    --accent-fill: #9bbb63;
    --on-accent: #1a1612;
    --ok: #6fc28f;
    --warn: #e0a84e;
    --bad: #ef7f6a;
    --info: hsl(213 30% 74%);
    --remote: #74b8c8;
    --violet: #a993ff;
    --shadow: 0 12px 30px rgb(0 0 0 / 0.5);
    --den-pop-shadow: 0 16px 40px rgb(0 0 0 / 0.6);
    --upd-shadow:
      0 2px 4px rgba(0, 0, 0, 0.35), 0 10px 28px rgba(0, 0, 0, 0.4),
      inset 0 1px 0 color-mix(in srgb, var(--text) 14%, transparent);
    --bar: linear-gradient(90deg, #9bbb63 0%, #a07c55 100%);
  }
}
