/* ==========================================================================
   Iteas Hub · themes.css
   Design tokens and the six colour themes.
   Load order: themes.css → base.css → primitives.css → motion.css → IteasHub.styles.css

   Theme switch: two attributes on <html>
     data-theme = "papier" | "aubergine" | "wald"
     data-mode  = "light"  | "dark"
   No attributes = Papier light.
   Accent override (Erscheinungsbild): set --acc (light mode also --acc-text)
   inline on <html>. Hover and soft tones derive from --acc automatically.
   ========================================================================== */

/* ---------- 1. Scale-independent tokens (all themes) ---------- */
:root {
  /* type families */
  --font-sans: 'Schibsted Grotesk', system-ui, sans-serif;
  /* titles: the body font, heavier and tighter (HUB-30) */
  --font-display: var(--font-sans);
  --fw-display: 600;
  --ls-display: -0.03em;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  /* type scale (rem follows the fluid root size in base.css) */
  --fs-3xs: 0.679rem;
  --fs-2xs: 0.75rem;   /* labels, table heads */
  --fs-xs: 0.821rem;    /* mono meta, counts */
  --fs-sm: 0.893rem;    /* help text, secondary */
  --fs-base: 0.964rem;  /* body, inputs */
  --fs-md: 1.036rem;    /* lead text, search */
  --fs-h3: 1.429rem;
  --fs-h2: 1.714rem;
  --fs-h2-lg: 1.929rem;   /* drawer title */
  --fs-kpi: 2.571rem;
  --fs-display: clamp(2rem, 1.1rem + 1.7vw, 3.4rem);

  /* radii */
  --r-xs: 0.286rem;
  --r-sm: 0.357rem;
  --r: 0.429rem;
  --r-md: 0.571rem;
  --r-lg: 0.714rem;
  --r-pill: 100vmax;

  /* control heights */
  --h-xs: 1.857rem;
  --h-sm: 2.286rem;
  --h-input: 2.571rem;
  --h-btn: 2.714rem;
  --h-search: 3rem;

  /* hairlines: browsers snap these to at least one device pixel */
  --hair: 0.071rem;
  --hair-2: 0.143rem;
  --focus-ring: var(--hair-2) solid var(--acc);

  /* icons */
  --icon: 1.143rem;
  --icon-sm: 0.929rem;
  --icon-lg: 1.214rem;

  /* layout */
  --gutter: clamp(1rem, 2.6vw, 2.6rem);  /* page gutter */
  --tb: 3.7rem;                       /* topbar height */
  --page-pt: 0.429rem;                     /* page padding top */
  --page-pb: 2.857rem;                    /* page padding bottom, the sticky bar bleeds into it */
  --side-w: 17.7rem;                  /* sidebar expanded */
  --side-rail: 4.6rem;                /* sidebar collapsed */
  --drawer-min: 26rem;

  /* layers */
  --z-side: 3;
  --z-sticky: 5;
  --z-loader: 15;
  --z-scrim: 20;
  --z-drawer: 21;
  --z-modal: 30;
  --z-navscrim: 34;
  --z-nav: 35;
  --z-menu: 40;
  --z-toast: 50;

  /* motion */
  --ease: cubic-bezier(.2, .8, .2, 1);
  --dur-fast: .12s;
  --dur: .16s;
  --dur-slow: .24s;
}

/* ---------- 2. Status colours ---------- */
/* --x = dot/fill, --x-t = text on sheet, --x-soft = tinted background */
:root {
  --ok: oklch(0.6 0.15 155);    --ok-t: oklch(0.45 0.11 155);
  --warn: oklch(0.76 0.14 72);  --warn-t: oklch(0.48 0.11 65);
  --err: oklch(0.58 0.2 25);    --err-t: oklch(0.5 0.19 25);
  --info: oklch(0.62 0.14 250); --info-t: oklch(0.47 0.13 250);
  --prog: oklch(0.6 0.16 295);  --prog-t: oklch(0.47 0.15 295);
  --err-strong: oklch(0.52 0.2 25);
  --on-status: #fff;
}
:root[data-mode="dark"] {
  --ok: oklch(0.72 0.15 155);   --ok-t: oklch(0.82 0.13 155);
  --warn: oklch(0.8 0.14 75);   --warn-t: oklch(0.86 0.12 80);
  --err: oklch(0.66 0.19 25);   --err-t: oklch(0.78 0.14 25);
  --info: oklch(0.72 0.13 245); --info-t: oklch(0.82 0.1 245);
  --prog: oklch(0.7 0.15 295);  --prog-t: oklch(0.82 0.11 295);
  --err-strong: oklch(0.6 0.19 25);
}
:root {
  --ok-soft: color-mix(in oklch, var(--ok) 14%, transparent);
  --warn-soft: color-mix(in oklch, var(--warn) 20%, transparent);
  --err-soft: color-mix(in oklch, var(--err) 12%, transparent);
  --info-soft: color-mix(in oklch, var(--info) 13%, transparent);
  --prog-soft: color-mix(in oklch, var(--prog) 12%, transparent);
  --ok-line: color-mix(in oklch, var(--ok) 35%, transparent);
  --warn-line: color-mix(in oklch, var(--warn) 45%, transparent);
  --err-line: color-mix(in oklch, var(--err) 35%, transparent);
  --info-line: color-mix(in oklch, var(--info) 30%, transparent);
}

/* ---------- 3. Derived accent tones ---------- */
:root {
  --acc-hover: color-mix(in oklch, var(--acc) 88%, black);
  --acc-soft: color-mix(in oklch, var(--acc) 12%, transparent);
}
:root[data-mode="dark"] {
  --acc-hover: color-mix(in oklch, var(--acc) 80%, white);
  --acc-soft: color-mix(in oklch, var(--acc) 16%, transparent);
}

/* ---------- 4. Palettes ---------- */
/* Every palette sets the same 22 colour tokens plus shadows. */

/* Papier · light (default) */
:root,
:root[data-theme="papier"][data-mode="light"] {
  color-scheme: light;
  --paper: oklch(0.962 0.01 80);
  --sheet: oklch(0.994 0.004 85);
  --inset: oklch(0.975 0.007 80);
  --head: oklch(0.955 0.012 80);
  --row-alt: oklch(0.977 0.008 80);
  --hover: oklch(0.955 0.014 75);
  --line: oklch(0.9 0.012 80);
  --line-2: oklch(0.84 0.015 80);
  --cell-div: oklch(0.93 0.01 80);
  --ink: oklch(0.26 0.045 250);
  --dim: oklch(0.44 0.03 250);
  --faint: oklch(0.54 0.02 250);
  --spine: oklch(0.265 0.05 250);
  --spine-2: oklch(0.32 0.05 250);
  --spine-text: oklch(0.86 0.02 80);
  --spine-strong: #fff;
  --spine-muted: oklch(0.68 0.03 250);
  --nav-on: oklch(0.99 0.004 85);
  --nav-on-text: var(--ink);
  --acc: oklch(0.555 0.165 38);
  --acc-text: #fff;
  --toast-bg: oklch(0.26 0.045 250);
  --toast-text: oklch(0.994 0.004 85);
  --scrim: oklch(0.3 0.03 250 / .22);
  --scrim-modal: oklch(0.25 0.03 250 / .35);
  --knob: #fff;
  --knob-on: #fff;
  --shadow-c: oklch(0.3 0.04 250);
}

/* Malve · light (companion of Aubergine) */
:root[data-theme="aubergine"][data-mode="light"] {
  color-scheme: light;
  --paper: oklch(0.962 0.012 330);
  --sheet: oklch(0.993 0.005 330);
  --inset: oklch(0.973 0.009 330);
  --head: oklch(0.952 0.014 330);
  --row-alt: oklch(0.976 0.008 330);
  --hover: oklch(0.95 0.018 330);
  --line: oklch(0.9 0.016 330);
  --line-2: oklch(0.84 0.02 330);
  --cell-div: oklch(0.925 0.013 330);
  --ink: oklch(0.27 0.05 322);
  --dim: oklch(0.44 0.04 322);
  --faint: oklch(0.54 0.03 322);
  --spine: oklch(0.285 0.065 322);
  --spine-2: oklch(0.35 0.07 322);
  --spine-text: oklch(0.88 0.025 330);
  --spine-strong: #fff;
  --spine-muted: oklch(0.7 0.035 330);
  --nav-on: oklch(0.99 0.006 330);
  --nav-on-text: oklch(0.27 0.05 322);
  --acc: oklch(0.52 0.115 62);
  --acc-text: #fff;
  --toast-bg: oklch(0.285 0.065 322);
  --toast-text: oklch(0.98 0.008 330);
  --scrim: oklch(0.3 0.04 322 / .22);
  --scrim-modal: oklch(0.25 0.04 322 / .35);
  --knob: #fff;
  --knob-on: #fff;
  --shadow-c: oklch(0.3 0.05 322);
}

/* Salbei · light (companion of Waldgrün) */
:root[data-theme="wald"][data-mode="light"] {
  color-scheme: light;
  --paper: oklch(0.962 0.013 135);
  --sheet: oklch(0.994 0.005 125);
  --inset: oklch(0.973 0.01 135);
  --head: oklch(0.952 0.015 135);
  --row-alt: oklch(0.977 0.009 135);
  --hover: oklch(0.95 0.02 140);
  --line: oklch(0.9 0.018 140);
  --line-2: oklch(0.84 0.022 145);
  --cell-div: oklch(0.925 0.014 140);
  --ink: oklch(0.27 0.035 168);
  --dim: oklch(0.44 0.03 165);
  --faint: oklch(0.53 0.025 160);
  --spine: oklch(0.285 0.045 170);
  --spine-2: oklch(0.35 0.05 170);
  --spine-text: oklch(0.88 0.025 120);
  --spine-strong: #fff;
  --spine-muted: oklch(0.7 0.03 150);
  --nav-on: oklch(0.99 0.006 125);
  --nav-on-text: oklch(0.27 0.035 168);
  --acc: oklch(0.53 0.13 48);
  --acc-text: #fff;
  --toast-bg: oklch(0.285 0.045 170);
  --toast-text: oklch(0.98 0.008 125);
  --scrim: oklch(0.3 0.03 170 / .22);
  --scrim-modal: oklch(0.25 0.03 170 / .35);
  --knob: #fff;
  --knob-on: #fff;
  --shadow-c: oklch(0.3 0.04 170);
}

/* Nachtblau · dark (Papier family) */
:root[data-theme="papier"][data-mode="dark"],
:root:not([data-theme])[data-mode="dark"] {
  color-scheme: dark;
  --paper: oklch(0.205 0.032 258);
  --sheet: oklch(0.24 0.036 258);
  --inset: oklch(0.22 0.034 258);
  --head: oklch(0.265 0.038 258);
  --row-alt: oklch(0.228 0.035 258);
  --hover: oklch(0.29 0.042 258);
  --line: oklch(0.315 0.035 258);
  --line-2: oklch(0.39 0.04 258);
  --cell-div: oklch(0.285 0.035 258);
  --ink: oklch(0.93 0.018 85);
  --dim: oklch(0.8 0.022 80);
  --faint: oklch(0.66 0.025 250);
  --spine: oklch(0.165 0.032 262);
  --spine-2: oklch(0.25 0.04 260);
  --spine-text: oklch(0.84 0.025 85);
  --spine-strong: oklch(0.97 0.01 85);
  --spine-muted: oklch(0.66 0.03 250);
  --nav-on: oklch(0.3 0.045 258);
  --nav-on-text: oklch(0.95 0.015 85);
  --acc: oklch(0.74 0.15 48);
  --acc-text: oklch(0.2 0.035 258);
  --toast-bg: oklch(0.93 0.018 85);
  --toast-text: oklch(0.22 0.035 258);
  --scrim: oklch(0.08 0.02 260 / .5);
  --scrim-modal: oklch(0.08 0.02 260 / .55);
  --knob: var(--ink);
  --knob-on: var(--acc-text);
  --shadow-c: oklch(0.05 0.02 260);
}

/* Aubergine · dark */
:root[data-theme="aubergine"][data-mode="dark"] {
  color-scheme: dark;
  --paper: oklch(0.205 0.04 322);
  --sheet: oklch(0.245 0.045 322);
  --inset: oklch(0.225 0.042 322);
  --head: oklch(0.27 0.048 322);
  --row-alt: oklch(0.232 0.043 322);
  --hover: oklch(0.295 0.052 322);
  --line: oklch(0.32 0.045 322);
  --line-2: oklch(0.4 0.05 322);
  --cell-div: oklch(0.29 0.045 322);
  --ink: oklch(0.94 0.015 60);
  --dim: oklch(0.81 0.025 50);
  --faint: oklch(0.67 0.03 330);
  --spine: oklch(0.165 0.04 320);
  --spine-2: oklch(0.255 0.05 320);
  --spine-text: oklch(0.85 0.025 50);
  --spine-strong: oklch(0.97 0.01 60);
  --spine-muted: oklch(0.67 0.035 330);
  --nav-on: oklch(0.31 0.055 322);
  --nav-on-text: oklch(0.96 0.012 60);
  --acc: oklch(0.8 0.12 75);
  --acc-text: oklch(0.22 0.04 322);
  --toast-bg: oklch(0.94 0.015 60);
  --toast-text: oklch(0.23 0.045 322);
  --scrim: oklch(0.08 0.03 320 / .5);
  --scrim-modal: oklch(0.08 0.03 320 / .55);
  --knob: var(--ink);
  --knob-on: var(--acc-text);
  --shadow-c: oklch(0.05 0.03 320);
}

/* Waldgrün · dark */
:root[data-theme="wald"][data-mode="dark"] {
  color-scheme: dark;
  --paper: oklch(0.205 0.03 168);
  --sheet: oklch(0.24 0.034 168);
  --inset: oklch(0.22 0.032 168);
  --head: oklch(0.265 0.036 168);
  --row-alt: oklch(0.228 0.033 168);
  --hover: oklch(0.29 0.04 168);
  --line: oklch(0.315 0.033 168);
  --line-2: oklch(0.395 0.038 168);
  --cell-div: oklch(0.285 0.033 168);
  --ink: oklch(0.94 0.02 100);
  --dim: oklch(0.81 0.025 100);
  --faint: oklch(0.67 0.025 160);
  --spine: oklch(0.17 0.03 175);
  --spine-2: oklch(0.25 0.038 172);
  --spine-text: oklch(0.85 0.025 100);
  --spine-strong: oklch(0.97 0.01 100);
  --spine-muted: oklch(0.67 0.03 160);
  --nav-on: oklch(0.3 0.042 168);
  --nav-on-text: oklch(0.96 0.015 100);
  --acc: oklch(0.76 0.13 60);
  --acc-text: oklch(0.2 0.03 168);
  --toast-bg: oklch(0.94 0.02 100);
  --toast-text: oklch(0.22 0.03 168);
  --scrim: oklch(0.08 0.02 170 / .5);
  --scrim-modal: oklch(0.08 0.02 170 / .55);
  --knob: var(--ink);
  --knob-on: var(--acc-text);
  --shadow-c: oklch(0.05 0.02 170);
}

/* ---------- 5. Shadows (strength follows the mode) ---------- */
:root {
  --shadow-sm: 0 0.071rem 0.143rem color-mix(in oklch, var(--shadow-c) 12%, transparent);
  --shadow-pop: 0 1.286rem 3.571rem color-mix(in oklch, var(--shadow-c) 30%, transparent);
  --shadow-drawer: -1.286rem 0 4.286rem color-mix(in oklch, var(--shadow-c) 18%, transparent);
  --shadow-modal: 0 2.143rem 5.714rem color-mix(in oklch, var(--shadow-c) 28%, transparent);
  --shadow-toast: 0 0.857rem 2.429rem color-mix(in oklch, var(--shadow-c) 30%, transparent);
  --shadow-nav: 1rem 0 3rem color-mix(in oklch, var(--shadow-c) 30%, transparent);
  --inner-glow: none;
}
:root[data-mode="dark"] {
  --shadow-drawer: -1.286rem 0 4.286rem color-mix(in oklch, var(--shadow-c) 50%, transparent);
  --shadow-modal: 0 2.143rem 5.714rem color-mix(in oklch, var(--shadow-c) 50%, transparent);
  --shadow-pop: 0 1.286rem 3.571rem color-mix(in oklch, var(--shadow-c) 50%, transparent);
  --inner-glow: inset 0 0.071rem 0 oklch(1 0 0 / .03);
}

/* ---------- 6. Scrollbars (derived from the palette, so every family and mode fits) ---------- */
:root {
  --scroll-size: 0.571rem;
  --scroll-track: transparent;
  --scroll-thumb: color-mix(in oklch, var(--ink) 20%, transparent);
  --scroll-thumb-hover: color-mix(in oklch, var(--ink) 38%, transparent);
  /* for a dark surface such as the sidebar, set through .scroll-spine */
  --scroll-thumb-spine: color-mix(in oklch, var(--spine-text) 24%, transparent);
  --scroll-thumb-spine-hover: color-mix(in oklch, var(--spine-text) 44%, transparent);
}
