/*
 * CowRoll design tokens for the web.
 *
 * Colour, radius and shadow tokens mirror DESIGN.md and
 * internal/ui/theme/tokens.go, name for name. Change a value there first,
 * then here. The type and spacing scales below the app's are the website's
 * own: a page is read from further away than a 13px tool.
 *
 * Three rules colour follows (DESIGN.md):
 *   1. Butter means "not in the database yet". Nothing else is butter.
 *   2. env-production red is production's only.
 *   3. Select is for attention: selection, focus, links, the primary button.
 */

:root {
  color-scheme: light;

  /* Surfaces, from the work area outward */
  --milk: #ffffff;
  --chrome: #f5f6f7;
  --sunken: #eef0f2;
  --rail: #e4e7ea;
  --raised: #ffffff;
  --line: #e3e5e8;
  --line-strong: #7f8790;

  /* Text */
  --hide: #17191c;
  --muted: #5b626b;
  --faint: #a3a9b0;

  /* Select: selection, focus, links, the primary non-write button */
  --select: #1f5fd1;
  --on-select: #ffffff;
  --select-soft: #e2ecfd;
  --focus: var(--select);

  /* Butter: not in the database yet */
  --butter: #f0ae1c;
  --on-butter: #2b1d00;
  --butter-soft: #fff1c9;
  --butter-ink: #8a5700;

  /* Status: always with a word or an icon */
  --ok: #1b7a46;
  --ok-soft: #e2f5ea;
  --danger: #c4262b;
  --danger-soft: #fde7e7;
  --warn: #c2410c;
  --on-warn: #ffffff;
  --warn-soft: #fdeadf;

  /* Environments */
  --env-local: #5d6773;
  --env-dev: #0c7568;
  --env-staging: #7044c4;
  --env-production: #c8231c;
  --on-env: #ffffff;

  /* SQL */
  --syn-keyword: #1f4fb5;
  --syn-string: #2a7a3b;
  --syn-number: #8b3aa8;
  --syn-comment: #646b75;
  --syn-function: #0c7568;

  /* Shadows: only for things floating above the page */
  --shadow-popover: 0 4px 14px rgba(16, 18, 22, 0.12), 0 0 0 1px rgba(16, 18, 22, 0.08);
  --shadow-dialog: 0 18px 48px rgba(16, 18, 22, 0.22), 0 0 0 1px rgba(16, 18, 22, 0.08);
  --scrim: rgba(23, 25, 28, 0.42);

  /* Families */
  --font-ui: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Web type scale (size / line) */
  --text-display: clamp(2.75rem, 1.2rem + 5.6vw, 5.25rem);
  --text-title: clamp(1.875rem, 1.3rem + 2vw, 2.75rem);
  --text-lede: clamp(1.0625rem, 1rem + 0.3vw, 1.1875rem);
  --text-body: 1rem;
  --text-label: 0.9375rem;
  --text-small: 0.8125rem;
  --text-overline: 0.6875rem;
  --text-statement: clamp(0.9375rem, 0.55rem + 1.5vw, 1.75rem);
  --text-code: clamp(0.8125rem, 0.72rem + 0.35vw, 0.9375rem);
  --text-cell: clamp(0.8125rem, 0.75rem + 0.25vw, 0.9375rem);

  /* Spacing: the app's 4px scale, carried on for page rhythm */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --space-16: 64px;
  --space-24: 96px;
  --space-section: clamp(64px, 9vw, 128px);

  /* Radius: stays small */
  --radius-xs: 3px;
  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Page metrics */
  --gutter: clamp(44px, 8.6vw, 124px); /* the editor's line-number column */
  --page-pad: clamp(16px, 4vw, 56px);
  --nav-height: 60px;
  --toolbar-height: 56px;
  --row-height: 44px;
  --control-height: 40px;
  --measure: 62ch;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* Dark mirrors every token. It applies when the system asks for it and the
   visitor has not chosen light, or when the visitor chose dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --milk: #18191b;
    --chrome: #1e2023;
    --sunken: #141517;
    --rail: #0e0f10;
    --raised: #232528;
    --line: #2b2e32;
    --line-strong: #6b727b;
    --hide: #e6e8eb;
    --muted: #9ba2ab;
    --faint: #5d636b;
    --select: #6b9fff;
    --on-select: #0b1220;
    --select-soft: #1c2c4a;
    --butter: #f3bb3d;
    --butter-soft: #3b2c08;
    --butter-ink: #f3bb3d;
    --ok: #4cc28a;
    --ok-soft: #14301f;
    --danger: #ff6b66;
    --danger-soft: #3c1818;
    --warn: #fb8a3c;
    --on-warn: #1f0e02;
    --warn-soft: #3a2213;
    --env-local: #8d96a1;
    --env-dev: #35bfae;
    --env-staging: #a88af2;
    --env-production: #ff5a4f;
    --on-env: #111214;
    --syn-keyword: #79a6ff;
    --syn-string: #86d196;
    --syn-number: #d49bf0;
    --syn-comment: #858d97;
    --syn-function: #3cc4b3;
    --shadow-popover: 0 6px 18px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.08);
    --shadow-dialog: 0 22px 56px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.1);
    --scrim: rgba(0, 0, 0, 0.6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --milk: #18191b;
  --chrome: #1e2023;
  --sunken: #141517;
  --rail: #0e0f10;
  --raised: #232528;
  --line: #2b2e32;
  --line-strong: #6b727b;
  --hide: #e6e8eb;
  --muted: #9ba2ab;
  --faint: #5d636b;
  --select: #6b9fff;
  --on-select: #0b1220;
  --select-soft: #1c2c4a;
  --butter: #f3bb3d;
  --butter-soft: #3b2c08;
  --butter-ink: #f3bb3d;
  --ok: #4cc28a;
  --ok-soft: #14301f;
  --danger: #ff6b66;
  --danger-soft: #3c1818;
  --warn: #fb8a3c;
  --on-warn: #1f0e02;
  --warn-soft: #3a2213;
  --env-local: #8d96a1;
  --env-dev: #35bfae;
  --env-staging: #a88af2;
  --env-production: #ff5a4f;
  --on-env: #111214;
  --syn-keyword: #79a6ff;
  --syn-string: #86d196;
  --syn-number: #d49bf0;
  --syn-comment: #858d97;
  --syn-function: #3cc4b3;
  --shadow-popover: 0 6px 18px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.08);
  --shadow-dialog: 0 22px 56px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.1);
  --scrim: rgba(0, 0, 0, 0.6);
}
