/* ─────────────────────────────────────────────────────────────────────────────
   Qooe Tunes Design System · tokens
   Three layers, each only referencing the one above it:
     1. primitives  — raw values (scales). Never used by components directly.
     2. semantic    — meaning (surface, text, line, accent, status). Themed: dark (default) and light.
     3. component   — per-component decisions mapped onto semantic tokens.
   One primary colour (violet). Everything else is neutral. Status colours are muted and used sparingly.
   ───────────────────────────────────────────────────────────────────────────── */

/* 1 · PRIMITIVES ─────────────────────────────────────────────────────────── */
:root {
  /* neutral — a cool, very slightly violet grey so the primary sits naturally */
  --n-0: #ffffff;  --n-25: #fafafb; --n-50: #f4f4f6; --n-100: #ececf0; --n-150: #e2e2e8; --n-200: #d4d4dc;
  --n-300: #b4b4bf; --n-400: #8d8d99; --n-500: #6c6c78; --n-600: #50505b; --n-700: #36363f; --n-750: #2a2a32;
  --n-800: #212128; --n-850: #19191f; --n-900: #131317; --n-950: #0c0c0f; --n-1000: #000000;

  /* violet — the only brand colour */
  --v-50: #f4f1ff; --v-100: #ebe5ff; --v-200: #d9ceff; --v-300: #bba8ff; --v-400: #9b7bff;
  --v-500: #8257ff; --v-600: #6e3df5; --v-700: #5b2ed6; --v-800: #4a27ab; --v-900: #3a2185;

  /* status (muted) */
  --g-400: #4fd19a; --g-600: #0f7a50; --r-400: #ff7a8a; --r-600: #c02c45; --a-400: #f5b454; --a-600: #8a5a00;

  /* reference-kind hues (#tags) — distinguishable, never louder than the primary */
  --hue-trim: #e7b45a; --hue-character: #f08bbd; --hue-place: #4cc3b0; --hue-look: #a98bff; --hue-step: #7f9cff;
  --hue-comment: #a2a2ae; --hue-object: #f09a62; --hue-inspiration: #5fc4ef; --hue-file: #9ccf74; --hue-hook: #ff6f86;

  /* song sections on the timeline (the stage is dark in both themes) */
  --sec-quiet: #7c8496; --sec-verse: #5fa8a0; --sec-pre: #7a95ff; --sec-chorus: #f2b84b; --sec-bridge: #c48af2;

  /* type */
  --font-sans: "Geist", "Vazirmatn", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;   /* Vazirmatn carries Persian wherever it is typed */
  --font-mono: "Geist Mono", "JetBrains Mono", ui-monospace, Menlo, monospace;
  --font-fa: "Vazirmatn", Tahoma, sans-serif;
  --fs-11: 11px; --fs-12: 12px; --fs-13: 13px; --fs-14: 14px; --fs-15: 15px; --fs-16: 16px; --fs-18: 18px;
  --fs-20: 20px; --fs-24: 24px; --fs-32: 32px;
  --lh-tight: 1.2; --lh-snug: 1.35; --lh-body: 1.55;
  --fw-regular: 400; --fw-medium: 500; --fw-semibold: 600;
  --tracking-tight: -0.011em; --tracking-wide: 0.06em;

  /* space — 4 px 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;

  /* radius */
  --r-xs: 6px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 20px; --r-2xl: 24px; --r-pill: 999px;

  /* motion — ease-out for things arriving, standard for things moving */
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-standard: cubic-bezier(.4, 0, .2, 1);
  --ease-spring: cubic-bezier(.34, 1.36, .64, 1);
  --dur-1: 120ms; --dur-2: 200ms; --dur-3: 320ms; --dur-4: 480ms; --dur-slow: 1600ms;

  /* sizes */
  --tap: 44px; --tap-lg: 48px; --top: 64px; --content-max: 720px; --chat-w: clamp(440px, 32vw, 520px);
  --icon-stroke: 1.8;   /* one stroke for every 24-unit icon */
}

/* 2 · SEMANTIC — dark (default) ─────────────────────────────────────────── */
:root, :root[data-theme="dark"] {
  color-scheme: dark;
  --surface-app: var(--n-950);       /* page */
  --surface-1: var(--n-900);         /* panes, bars */
  --surface-2: var(--n-850);         /* cards, widgets */
  --surface-3: var(--n-800);         /* hover / pressed / inputs */
  --surface-sunken: var(--n-950);    /* wells inside cards */
  --surface-media: var(--n-1000);    /* behind video and images */
  --surface-overlay: rgb(12 12 15 / .72);
  --surface-glass: color-mix(in srgb, var(--n-850) 82%, transparent);

  --line: var(--n-800);
  --line-strong: var(--n-700);
  --line-focus: var(--v-400);

  --text: var(--n-100);
  --text-2: var(--n-300);            /* secondary · 9.0:1 on surface-1 */
  --text-3: var(--n-400);            /* tertiary, hints · 5.6:1 on surface-1, 4.9:1 on surface-3 */
  --text-on-media: var(--n-0);

  --accent: var(--v-600);            /* white on it is 5.75:1 (v-500 was 4.42:1) */
  --accent-hover: var(--v-700);      /* hover goes darker, never below AA */
  --accent-press: var(--v-800);
  --accent-text: var(--v-300);       /* accent as text on dark surfaces */
  --accent-soft: color-mix(in srgb, var(--v-500) 14%, transparent);
  --accent-softer: color-mix(in srgb, var(--v-500) 8%, transparent);
  --on-accent: var(--n-0);

  --success: var(--g-400); --danger: var(--r-400); --warning: var(--a-400);
  --success-soft: color-mix(in srgb, var(--g-400) 14%, transparent);
  --danger-soft: color-mix(in srgb, var(--r-400) 14%, transparent);
  --warning-soft: color-mix(in srgb, var(--a-400) 14%, transparent);

  --shadow-1: 0 1px 2px rgb(0 0 0 / .35);
  --shadow-2: 0 8px 24px rgb(0 0 0 / .35), 0 1px 2px rgb(0 0 0 / .3);
  --shadow-3: 0 24px 64px rgb(0 0 0 / .5), 0 2px 6px rgb(0 0 0 / .3);
}

/* 2 · SEMANTIC — light ───────────────────────────────────────────────────── */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --surface-app: var(--n-50); --surface-1: var(--n-0); --surface-2: var(--n-25); --surface-3: var(--n-100);
    --surface-sunken: var(--n-50); --surface-media: var(--n-1000);
    --surface-overlay: rgb(250 250 251 / .78); --surface-glass: color-mix(in srgb, var(--n-0) 86%, transparent);
    --line: var(--n-150); --line-strong: var(--n-200); --line-focus: var(--v-500);
    --text: var(--n-900); --text-2: var(--n-600); --text-3: var(--n-500);
    --accent: var(--v-600); --accent-hover: var(--v-700); --accent-press: var(--v-800); --accent-text: var(--v-700);
    --accent-soft: color-mix(in srgb, var(--v-500) 11%, transparent); --accent-softer: color-mix(in srgb, var(--v-500) 6%, transparent);
    --success: var(--g-600); --danger: var(--r-600); --warning: var(--a-600);
    --shadow-1: 0 1px 2px rgb(20 20 30 / .06);
    --shadow-2: 0 8px 24px rgb(20 20 30 / .08), 0 1px 2px rgb(20 20 30 / .06);
    --shadow-3: 0 24px 64px rgb(20 20 30 / .14), 0 2px 6px rgb(20 20 30 / .06);
    --hue-trim: #6f4f19; --hue-character: #8d335f; --hue-place: #135f55; --hue-look: #5942ab; --hue-step: #354ea7;
    --hue-comment: #55555e; --hue-object: #83451d; --hue-inspiration: #1a5a76; --hue-file: #385f1f; --hue-hook: #98293d;
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --surface-app: var(--n-50); --surface-1: var(--n-0); --surface-2: var(--n-25); --surface-3: var(--n-100);
  --surface-sunken: var(--n-50); --surface-media: var(--n-1000);
  --surface-overlay: rgb(250 250 251 / .78); --surface-glass: color-mix(in srgb, var(--n-0) 86%, transparent);
  --line: var(--n-150); --line-strong: var(--n-200); --line-focus: var(--v-500);
  --text: var(--n-900); --text-2: var(--n-600); --text-3: var(--n-500);
  --accent: var(--v-600); --accent-hover: var(--v-700); --accent-press: var(--v-800); --accent-text: var(--v-700);
  --accent-soft: color-mix(in srgb, var(--v-500) 11%, transparent); --accent-softer: color-mix(in srgb, var(--v-500) 6%, transparent);
  --success: var(--g-600); --danger: var(--r-600); --warning: var(--a-600);
  --shadow-1: 0 1px 2px rgb(20 20 30 / .06);
  --shadow-2: 0 8px 24px rgb(20 20 30 / .08), 0 1px 2px rgb(20 20 30 / .06);
  --shadow-3: 0 24px 64px rgb(20 20 30 / .14), 0 2px 6px rgb(20 20 30 / .06);
  --hue-trim: #6f4f19; --hue-character: #8d335f; --hue-place: #135f55; --hue-look: #5942ab; --hue-step: #354ea7;
  --hue-comment: #55555e; --hue-object: #83451d; --hue-inspiration: #1a5a76; --hue-file: #385f1f; --hue-hook: #98293d;
}

/* 3 · COMPONENT TOKENS ───────────────────────────────────────────────────── */
:root {
  /* button */
  --btn-h: var(--tap); --btn-px: var(--sp-4); --btn-radius: var(--r-md); --btn-fs: var(--fs-14); --btn-fw: var(--fw-medium);
  --btn-bg: var(--surface-3); --btn-bg-hover: color-mix(in srgb, var(--surface-3) 70%, var(--text) 8%); --btn-line: transparent;
  --btn-primary-bg: var(--accent); --btn-primary-bg-hover: var(--accent-hover); --btn-primary-fg: var(--on-accent);
  /* input */
  --input-h: var(--tap-lg); --input-bg: var(--surface-3); --input-line: transparent; --input-radius: var(--r-pill); --input-fs: var(--fs-16);
  /* message */
  --msg-gap: var(--sp-5); --msg-me-bg: var(--accent-soft); --msg-me-fg: var(--text); --msg-radius: var(--r-xl);
  --widget-bg: var(--surface-2); --widget-line: var(--line); --widget-radius: var(--r-xl);
  /* badge (#tag) */
  --badge-h: 24px; --badge-radius: var(--r-xs); --badge-fs: var(--fs-13);
  /* progress */
  --progress-h: 4px; --progress-track: var(--surface-3); --progress-fill: var(--accent); --progress-done: var(--success);
  /* your turn */
  --turn-bg: var(--accent-softer); --turn-line: color-mix(in srgb, var(--accent) 35%, transparent);
  /* sheets / popovers */
  --sheet-bg: var(--surface-1); --sheet-radius: var(--r-xl); --sheet-shadow: var(--shadow-3);
  /* top bar */
  --topbar-bg: var(--surface-glass); --topbar-line: var(--line);

  /* reference kinds → hue (components use --k-*) */
  --k-trim: var(--hue-trim); --k-character: var(--hue-character); --k-place: var(--hue-place); --k-look: var(--hue-look);
  --k-step: var(--hue-step); --k-comment: var(--hue-comment); --k-object: var(--hue-object); --k-inspiration: var(--hue-inspiration);
  --k-file: var(--hue-file); --k-hook: var(--hue-hook);

  /* legacy aliases (inline styles in the app still read these) → semantic */
  --bg: var(--surface-sunken); --panel: var(--surface-1); --raise: var(--surface-2); --muted: var(--text-2);
  --ok: var(--success); --bad: var(--danger); --warn: var(--warning); --blue: var(--hue-step);
  --ui: var(--font-sans); --mono: var(--font-mono); --fa: var(--font-fa); --disp: var(--font-sans);
}
