/* ============================================================
   m13n — design tokens
   ============================================================ */

/* ---- typography -------------------------------------------- */
/* JetBrains Mono: SIL OFL 1.1 — see fonts/OFL.txt. */
@font-face {
  font-family: 'JetBrains Mono';
  src: url('./fonts/JetBrainsMono-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

:root {
  /* type families — brand fonts only, locally bundled */
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --font-body: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* type scale — tight modular scale, mono-forward */
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-base: 14px;
  /* body */
  --fs-md: 16px;
  --fs-lg: 18px;
  --fs-xl: 22px;
  --fs-2xl: 28px;
  --fs-3xl: 36px;
  --fs-4xl: 48px;
  --fs-display: 72px;

  --lh-tight: 1.15;
  --lh-snug: 1.3;
  --lh-body: 1.5;
  --lh-loose: 1.7;

  --tracking-mono: 0;
  --tracking-ui: 0.01em;
  --tracking-caps: 0.12em;
  /* terminal-style all-caps labels */

  /* ---- brand scale (amber) -------------------------------- */
  --brand-50: #fff8eb;
  --brand-100: #fdecc8;
  --brand-200: #fde3a7;
  --brand-300: #fcd34d;
  --brand-400: #fbbf24;
  --brand-500: #f59e0b;
  --brand-600: #d97706;
  --brand-700: #b45309;
  --brand-800: #92400e;
  --brand-900: #78350f;

  /* ---- status (mode-independent) -------------------------- */
  --color-success: #10b981;
  --color-warn: #eab308;
  --color-error: #ef4444;
  --color-info: #3b82f6;

  /* ---- accents (no amber) --------------------------------- */
  --accent-blue: #3b82f6;
  --accent-emerald: #10b981;
  --accent-fuchsia: #d946ef;
  --accent-cyan: #06b6d4;
  --accent-violet: #a855f7;
  --accent-rose: #f43f5e;
  --accent-lime: #84cc16;
  --accent-teal: #14b8a6;

  /* ---- spacing scale (4px base) --------------------------- */
  --sp-0: 0;
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;
  --sp-20: 80px;
  --sp-24: 96px;

  /* ---- radii — sharp, CRT/terminal forward ---------------- */
  --radius-none: 0;
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-pill: 999px;

  /* ---- motion --------------------------------------------- */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in: cubic-bezier(0.64, 0, 0.78, 0);
  --ease-std: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 120ms;
  --dur-med: 220ms;
  --dur-slow: 400ms;

  /* ---- z-layers ------------------------------------------- */
  --z-base: 1;
  --z-overlay: 10;
  --z-modal: 100;
  --z-toast: 1000;
}

/* ---- LIGHT (default) --------------------------------------- */
:root,
:root[data-theme="light"] {
  --bg: #faf8f3;
  --surface: #ffffff;
  --surface-alt: #f3f0e8;
  --surface-sunken: #ede9dc;
  --border: #e5e2d8;
  --border-strong: #c9c5b8;
  --text: #1a1a1a;
  --text-muted: #5c5c5c;
  --text-subtle: #888070;

  --brand-primary: var(--brand-600);
  --brand-hover: var(--brand-700);
  --brand-tint: var(--brand-50);
  --brand-tint-strong: var(--brand-100);

  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--brand-600);

  /* subtle paper shadows */
  --shadow-xs: 0 1px 0 rgba(26, 26, 26, 0.04);
  --shadow-sm: 0 1px 2px rgba(26, 26, 26, 0.06), 0 1px 1px rgba(26, 26, 26, 0.04);
  --shadow-md: 0 4px 12px rgba(26, 26, 26, 0.08), 0 2px 4px rgba(26, 26, 26, 0.04);
  --shadow-lg: 0 12px 32px rgba(26, 26, 26, 0.12), 0 4px 8px rgba(26, 26, 26, 0.06);

  /* CRT phosphor glow — off in light mode */
  --glow-brand: none;
  --scanline-opacity: 0;
}

/* ---- DARK -------------------------------------------------- */
:root[data-theme="dark"] {
  --bg: #0b0d10;
  --surface: #14171c;
  --surface-alt: #1b1f27;
  --surface-sunken: #070809;
  --border: #252a33;
  --border-strong: #3a4050;
  --text: #e6e8ed;
  --text-muted: #8a94a6;
  --text-subtle: #5c6472;

  --brand-primary: var(--brand-400);
  --brand-hover: var(--brand-300);
  --brand-tint: rgba(245, 158, 11, 0.10);
  --brand-tint-strong: rgba(245, 158, 11, 0.18);

  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--brand-400);

  --shadow-xs: 0 1px 0 rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.02);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.02);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.03);

  /* CRT phosphor glow — the signature dark-mode effect */
  --glow-brand: 0 0 12px rgba(251, 191, 36, 0.45);
  --scanline-opacity: 0.035;
}

/* ---- base element reset ------------------------------------ */
* {
  box-sizing: border-box;
}

html,
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  letter-spacing: var(--tracking-mono);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0;
}

/* Optional CRT scanlines — apply with .crt-surface on dark backgrounds */
.crt-surface {
  position: relative;
}

.crt-surface::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(to bottom,
      rgba(255, 255, 255, 0.06) 0,
      rgba(255, 255, 255, 0.06) 1px,
      transparent 1px,
      transparent 3px);
  opacity: var(--scanline-opacity);
  pointer-events: none;
  mix-blend-mode: overlay;
}