/* Beginner3D UI — warstwa tokenów.
   Jedyne miejsce, w którym wolno zapisać konkretny kolor, promień albo cień.
   Reszta arkuszy sięga wyłącznie po zmienne stąd. */

:root {
  color-scheme: light dark;

  /* Skala odstępów — krok 4px, nazwy od najmniejszego. */
  --space-3xs: 0.25rem;
  --space-2xs: 0.5rem;
  --space-xs: 0.75rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2rem;
  --space-xl: 3rem;
  --space-2xl: 4.5rem;

  /* Typografia — jeden stos systemowy, bez zależności sieciowej. */
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --text-2xs: 0.6875rem;
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-md: 1.0625rem;
  --text-lg: 1.375rem;
  --text-xl: 1.875rem;
  --text-2xl: 2.5rem;

  --leading-tight: 1.2;
  --leading-normal: 1.55;

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

  /* Promienie i obrysy. */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --border-width: 1px;

  /* Ruch — jeden czas i jedna krzywa dla całego UI. */
  --ease: cubic-bezier(0.2, 0.6, 0.3, 1);
  --duration-fast: 120ms;
  --duration: 200ms;

  --layer-base: 0;
  --layer-sticky: 100;
  --layer-popover: 200;
  --layer-dialog: 300;
  --layer-toast: 400;

  /* Szerokości układu. */
  --shell-max: 1440px;
  --prose-max: 68ch;

  /* Wysokość paska górnego. Pasek jest przyklejony do góry, więc wszystko,
     co ma się zatrzymać pod nim, musi znać tę liczbę. */
  --topbar-height: 3.5rem;
}

/* ── Motyw jasny (domyślny) ─────────────────────────────────────────── */
:root {
  --bg: #f6f7f9;
  --bg-sunken: #eceef2;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-hover: #f2f4f7;
  --surface-active: #e8ebf0;

  --border: #dfe3ea;
  --border-strong: #c6ccd8;

  --text: #12161d;
  --text-muted: #5c6675;
  --text-faint: #8b94a3;
  --text-inverted: #ffffff;

  --accent: #7c3aed;
  --accent-hover: #6a28d9;
  --accent-soft: #f4effd;
  --accent-border: #ddccf8;
  --accent-text: #5b21b6;

  --ok: #157347;
  --ok-soft: #e6f4ec;
  --ok-border: #b5dcc6;

  --warn: #9a6700;
  --warn-soft: #fdf3d8;
  --warn-border: #ecd9a0;

  --danger: #c02626;
  --danger-soft: #fdeaea;
  --danger-border: #f2c2c2;

  --focus-ring: #2563eb;

  --shadow-sm: 0 1px 2px rgb(16 22 31 / 0.06);
  --shadow-md: 0 4px 14px rgb(16 22 31 / 0.08);
  --shadow-lg: 0 18px 44px rgb(16 22 31 / 0.14);

  --skeleton: linear-gradient(
    90deg,
    var(--surface-hover) 25%,
    var(--surface-active) 37%,
    var(--surface-hover) 63%
  );
}

/* ── Motyw ciemny ───────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1016;
    --bg-sunken: #080a0f;
    --surface: #151a22;
    --surface-raised: #1b212b;
    --surface-hover: #1f2632;
    --surface-active: #28303d;

    --border: #262e3a;
    --border-strong: #3a4453;

    --text: #e8ecf2;
    --text-muted: #99a3b3;
    --text-faint: #6b7585;
    --text-inverted: #0d1016;

    --accent: #a78bfa;
    --accent-hover: #bda5fc;
    --accent-soft: #241b38;
    --accent-border: #453169;
    --accent-text: #c9b8fb;

    --ok: #4ade80;
    --ok-soft: #12241a;
    --ok-border: #1f4430;

    --warn: #fbbf24;
    --warn-soft: #251d0c;
    --warn-border: #4a3a14;

    --danger: #f87171;
    --danger-soft: #2a1414;
    --danger-border: #4d2222;

    --focus-ring: #7aa2ff;

    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-md: 0 4px 16px rgb(0 0 0 / 0.45);
    --shadow-lg: 0 20px 50px rgb(0 0 0 / 0.6);

    --skeleton: linear-gradient(
      90deg,
      var(--surface-hover) 25%,
      var(--surface-active) 37%,
      var(--surface-hover) 63%
    );
  }
}

/* Ręczny wybór motywu wygrywa z preferencją systemu w obie strony. */
:root[data-theme="dark"] {
  --bg: #0d1016;
  --bg-sunken: #080a0f;
  --surface: #151a22;
  --surface-raised: #1b212b;
  --surface-hover: #1f2632;
  --surface-active: #28303d;

  --border: #262e3a;
  --border-strong: #3a4453;

  --text: #e8ecf2;
  --text-muted: #99a3b3;
  --text-faint: #6b7585;
  --text-inverted: #0d1016;

  --accent: #a78bfa;
  --accent-hover: #bda5fc;
  --accent-soft: #241b38;
  --accent-border: #453169;
  --accent-text: #c9b8fb;

  --ok: #4ade80;
  --ok-soft: #12241a;
  --ok-border: #1f4430;

  --warn: #fbbf24;
  --warn-soft: #251d0c;
  --warn-border: #4a3a14;

  --danger: #f87171;
  --danger-soft: #2a1414;
  --danger-border: #4d2222;

  --focus-ring: #7aa2ff;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-md: 0 4px 16px rgb(0 0 0 / 0.45);
  --shadow-lg: 0 20px 50px rgb(0 0 0 / 0.6);
}
