/* tinymoon — design tokens. The single source of truth for color, spacing,
   and typography. Every other stylesheet — and any canvas-rendering JS, via
   cssVar() — references these custom properties; raw palette values appear
   nowhere else. */

/* ---------- tokens ---------- */

:root {
  color-scheme: dark;
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-2: #191919;
  --surface-3: #1f1f1f;
  --border: #1e1e1e;
  --border-2: #646464;
  --text: #e6e6e6;
  --text-dim: #9c9ca3;
  --text-faint: #8a8a94;
  --accent: #2d6cf4;
  --accent-hi: #5c9dff;
  --accent-soft: color-mix(in srgb, var(--accent) 14%, transparent);
  --accent-glow: color-mix(in srgb, var(--accent) 35%, transparent);
  /* accent alpha scale: translucent accent variants for borders and glows */
  --accent-a12: color-mix(in srgb, var(--accent) 12%, transparent);
  --accent-a18: color-mix(in srgb, var(--accent) 18%, transparent);
  --accent-a35: color-mix(in srgb, var(--accent) 35%, transparent);
  --accent-a40: color-mix(in srgb, var(--accent) 40%, transparent);
  /* text/icon color on top of solid accent fills */
  --on-accent: #ffffff;
  --green: #2fbf71;
  --red: #e5484d;
  /* red ladder: --red is the error ACCENT (badge/toast/field borders + small
     error text). The danger BUTTON needs a solid fill dark enough for white
     text, so --red-solid is a deeper red (--red itself is too light: white on
     it is only 3.9:1). --red-solid-hi is the darker hover; --on-red is the
     button label; --red-glow mirrors --accent-glow for the hover shadow. */
  --red-solid: #cc2f35;
  --red-solid-hi: #b3282d;
  --on-red: #ffffff;
  --red-glow: color-mix(in srgb, var(--red-solid) 35%, transparent);
  /* gold: the warn/caution status color. Mirrors the accent ladder — a solid
     shade for text and borders, a translucent soft fill, and an alpha step for
     glows. The badge warn variant and "neutral"/caution stat deltas pull it.
     Kept legible as text (>=4.5:1) on bg and the surfaces, so it also clears
     the 3:1 non-text UI floor for borders. */
  --gold: #d9a91e;
  --gold-soft: color-mix(in srgb, var(--gold) 14%, transparent);
  --gold-a35: color-mix(in srgb, var(--gold) 35%, transparent);
  /* theme-dependent surfaces the components pull instead of literals */
  --input-bg: #0a0a0a;
  --hover-border: #3a3a3a;
  --scroll-thumb: #242424;
  --backdrop: rgba(0, 0, 0, 0.65);
  --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.6);
  --shadow-modal: 0 24px 64px rgba(0, 0, 0, 0.7), 0 0 40px color-mix(in srgb, var(--accent) 6%, transparent);
  --grain-opacity: 0.05;
  /* Non-Latin font policy: Latin scripts use vendored faces (Plex, Plex Mono,
     Grotesk); non-Latin falls back to system fonts tuned to approximate the
     identity weight and feel. The system-ui / -apple-system / Segoe UI chain
     provides decent CJK, Arabic, Devanagari, etc. coverage on every major OS. */
  --font-ui: "Plex", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Plex Mono", ui-monospace, "Cascadia Code", "Source Code Pro", monospace;
  --font-brand: "Grotesk", system-ui, sans-serif;
  --sidebar-w: 216px;
  /* height of the optional footer slot; mountShell sets it when a footer is
     configured, 0 means no footer */
  --footer-h: 0px;
  --topbar-h: 56px;
  /* single-character brand mark for the collapsed sidebar; mountShell sets
     it from the configured brand name */
  --brand-initial: "";

  /* ---------- type scale ---------- */
  --text-3xl: 1.375rem;   /* 22px */
  --text-2xl: 1.25rem;    /* 20px */
  --text-xl: 1.0625rem;   /* 17px */
  --text-lg: 1rem;         /* 16px */
  --text-base: 0.875rem;  /* 14px — body text */
  --text-sm: 0.84375rem;  /* 13.5px */
  --text-xs: 0.8125rem;   /* 13px — dominant UI text */
  --text-2xs: 0.75rem;    /* 12px (also covers 12.5px) */
  --text-3xs: 0.71875rem; /* 11.5px (also covers 11px) */
  --text-micro: 0.65625rem; /* 10.5px */
  --text-label: 0.625rem; /* 10px (also covers 9.5px) */

  /* ---------- font weight ---------- */
  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* ---------- line height ---------- */
  --leading-tight: 1.35;
  --leading-normal: 1.5;
  --leading-relaxed: 1.6; /* also covers 1.65 */

  /* ---------- spacing ---------- */
  --space-1: 0.0625rem;  /* 1px */
  --space-2: 0.125rem;   /* 2px */
  --space-3: 0.1875rem;  /* 3px */
  --space-4: 0.25rem;    /* 4px */
  --space-5: 0.3125rem;  /* 5px */
  --space-6: 0.375rem;   /* 6px */
  --space-7: 0.4375rem;  /* 7px */
  --space-8: 0.5rem;     /* 8px */
  --space-9: 0.5625rem;  /* 9px */
  --space-10: 0.625rem;  /* 10px */
  --space-12: 0.75rem;   /* 12px */
  --space-14: 0.875rem;  /* 14px */
  --space-16: 1rem;      /* 16px */
  --space-18: 1.125rem;  /* 18px */
  --space-20: 1.25rem;   /* 20px */
  --space-24: 1.5rem;    /* 24px */
  --space-26: 1.625rem;  /* 26px */
  --space-28: 1.75rem;   /* 28px */
  --space-48: 3rem;      /* 48px */

  /* ---------- duration ---------- */
  /* The motion vocabulary is 100–180ms one-shot eases; the 0.8s spinner is a
     deliberate exception (continuous rotation, not a transition).
     JS coupling: toast.js uses a 200ms removal delay that must exceed
     --dur-slow so the fade-out animation finishes before DOM removal. */
  --dur-fast: 100ms;
  --dur-quick: 120ms;
  --dur-base: 150ms;  /* dominant — standard transition */
  --dur-mid: 160ms;
  --dur-slow: 180ms;

  /* ---------- z-index ---------- */
  --z-menu: 320;
  --z-modal: 340;
  --z-ctx: 360;
  --z-popover: 370;
  --z-toast: 380;
  /* Grain is page texture — overlays float above it (enforced by
     top-layer migration in Phase 3). */
  --z-grain: 400;
  --z-tooltip: 500;
}

/* Light theme: not an inversion — a paper-and-ink workbench with the same
   accent. Surfaces go white/light-gray, text goes near-black, shadows and
   glows soften. */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #eef0f3;
  --surface: #ffffff;
  --surface-2: #f4f5f8;
  --surface-3: #e9ebf0;
  --border: #e2e4ea;
  --border-2: #8e9298;
  --text: #191b1f;
  --text-dim: #565b66;
  --text-faint: #636b7a;
  --accent: #2d6cf4;
  --accent-hi: #0a4bb0;
  --accent-soft: color-mix(in srgb, var(--accent) 10%, transparent);
  --accent-glow: color-mix(in srgb, var(--accent) 22%, transparent);
  --on-accent: #ffffff;
  --green: #1d9d5c;
  --red: #d93a40;
  /* Light theme needs a much darker gold: on white/near-white surfaces a bright
     gold fails legibility, so this drops to a deep amber that clears 4.5:1 as
     text. The soft fill mirrors accent-soft's lighter 10% mix. --gold-a35
     inherits automatically (color-mix over the overridden --gold). */
  --gold: #7a5f00;
  --gold-soft: color-mix(in srgb, var(--gold) 10%, transparent);
  --input-bg: #ffffff;
  --hover-border: #b7bcc7;
  --scroll-thumb: #c6cad3;
  --backdrop: rgba(23, 27, 34, 0.4);
  --shadow-card: 0 8px 24px rgba(23, 27, 34, 0.1);
  --shadow-pop: 0 12px 32px rgba(23, 27, 34, 0.18);
  --shadow-modal: 0 24px 64px rgba(23, 27, 34, 0.22);
  --grain-opacity: 0.025;
}
