/*
 * src/css/tokens.css
 *
 * All design decisions live here as CSS custom properties.
 * Components reference only these tokens — no hardcoded values anywhere else.
 *
 * Naming convention:
 *   --color-{role}-{variant}   e.g. --color-surface-raised
 *   --space-{n}                4-point scale
 *   --text-{n}                 type scale in rem
 *   --radius-{n}               border radii
 *   --shadow-{n}               elevation
 *   --transition-{n}           motion
 */

/* ── Light mode (default) ──────────────────────────────────────────────────── */
:root {
  /* Brand */
  --color-brand-500: #5b4af7;
  --color-brand-600: #4736d6;
  --color-brand-100: #eeecfe;
  --color-brand-50:  #f6f5ff;

  /* Neutrals */
  --color-neutral-0:   #ffffff;
  --color-neutral-50:  #f8f8f7;
  --color-neutral-100: #f0efed;
  --color-neutral-200: #e4e2de;
  --color-neutral-300: #c9c6c0;
  --color-neutral-500: #7c7972;
  --color-neutral-700: #3d3c38;
  --color-neutral-900: #1a1917;

  /* Semantic surfaces */
  --color-bg:             var(--color-neutral-50);
  --color-surface:        var(--color-neutral-0);
  --color-surface-raised: var(--color-neutral-0);
  --color-border:         var(--color-neutral-200);
  --color-border-strong:  var(--color-neutral-300);

  /* Semantic text */
  --color-text-primary:   var(--color-neutral-900);
  --color-text-secondary: var(--color-neutral-500);
  --color-text-disabled:  var(--color-neutral-300);
  --color-text-on-brand:  #ffffff;
  --color-text-link:      var(--color-brand-600);

  /* Status */
  --color-success-bg:   #edfbf3;
  --color-success-text: #166534;
  --color-warning-bg:   #fffbeb;
  --color-warning-text: #92400e;
  --color-danger-bg:    #fef2f2;
  --color-danger-text:  #991b1b;
  --color-info-bg:      var(--color-brand-50);
  --color-info-text:    var(--color-brand-600);

  /* Sidebar */
  --color-sidebar-bg:      var(--color-neutral-900);
  --color-sidebar-text:    var(--color-neutral-200);
  --color-sidebar-muted:   var(--color-neutral-500);
  --color-sidebar-active:  var(--color-neutral-0);
  --color-sidebar-hover:   rgba(255 255 255 / 0.07);
  --color-sidebar-active-bg: rgba(255 255 255 / 0.12);

  /* Spacing — 4pt base */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Typography */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "Cascadia Code", ui-monospace, monospace;

  --text-xs:   0.75rem;   /* 12px */
  --text-sm:   0.875rem;  /* 14px */
  --text-base: 1rem;      /* 16px */
  --text-lg:   1.125rem;  /* 18px */
  --text-xl:   1.25rem;   /* 20px */
  --text-2xl:  1.5rem;    /* 24px */

  --leading-tight:  1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.7;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0 0 0 / 0.07), 0 2px 4px -1px rgba(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0 0 0 / 0.08), 0 4px 6px -2px rgba(0 0 0 / 0.04);

  /* Motion */
  --transition-fast:   100ms ease;
  --transition-normal: 180ms ease;
  --transition-slow:   280ms ease;

  /* Layout */
  --sidebar-width:    240px;
  --topbar-height:    56px;
  --content-max-width: 860px;
}

/* ── Dark mode ─────────────────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg:             #0f0f0e;
    --color-surface:        #1a1917;
    --color-surface-raised: #242320;
    --color-border:         #2e2d2a;
    --color-border-strong:  #3d3c38;

    --color-text-primary:   #f0efed;
    --color-text-secondary: #7c7972;
    --color-text-disabled:  #3d3c38;
    --color-text-link:      #9b8ffa;

    --color-brand-500: #7b6cf9;
    --color-brand-100: #2a2460;
    --color-brand-50:  #1e1a4a;

    --color-success-bg:   #052e16;
    --color-success-text: #4ade80;
    --color-warning-bg:   #1c1004;
    --color-warning-text: #fbbf24;
    --color-danger-bg:    #1c0606;
    --color-danger-text:  #f87171;
    --color-info-bg:      var(--color-brand-50);
    --color-info-text:    #9b8ffa;

    --shadow-sm: 0 1px 2px 0 rgba(0 0 0 / 0.4);
    --shadow-md: 0 4px 6px -1px rgba(0 0 0 / 0.5), 0 2px 4px -1px rgba(0 0 0 / 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0 0 0 / 0.6), 0 4px 6px -2px rgba(0 0 0 / 0.4);
  }
}

/* ── Base reset ────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--color-text-link);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

img, svg { display: block; max-width: 100%; }

button {
  font-family: inherit;
  cursor: pointer;
}

/* Focus ring — visible for keyboard, hidden for mouse */
:focus-visible {
  outline: 2px solid var(--color-brand-500);
  outline-offset: 2px;
}
:focus:not(:focus-visible) { outline: none; }
