/* =============================================================================
   ERP Holzbau – eigene Design-Tokens (Spezifikation D.3)
   -----------------------------------------------------------------------------
   Blueprint liefert alle UI-Tokens (--bp-…, Light + Dark über .bp6-dark bzw.
   [data-bp-color-scheme=dark]). Diese Datei ergänzt AUSSCHLIESSLICH:
     1. Layout-Maße (Navbar, Sidebar, Drawer, Bottom-Bar, Abstände)
     2. Dichte-Stufen (Body-Klassen density-compact | Standard | density-touch |
        density-halle)
     3. Daten-Visualisierung (--viz-*): Oberfläche/Tinte, kategorische Slots,
        sequenzielle Rampe, divergierend, Status, Meter-/Heatmap-Stufen
   Die --viz-*-Tokens werden NIE für UI-Chrome verwendet (Buttons, Tags, Callouts
   nutzen Blueprint-Intents). Dark-Mode: gleiche Token-Namen, eigene Werte –
   deklariert unter beiden Blueprint-Dark-Scopes (.bp6-dark und
   [data-bp-color-scheme="dark"]); Light zusätzlich unter dem expliziten
   Light-Scope, damit helle Inseln in dunkler Umgebung möglich sind.

   Abnahme H21 – validate_palette.js (dataviz-Skill) gegen die acht Slots,
   Paarliste „adjacent“, ausgeführt am 2026-09-19:
     Light  --surface #ffffff --mode light
       [PASS] Lightness band       alle 8 in L 0,43–0,77
       [PASS] Chroma floor         alle 8 >= 0,1
       [PASS] CVD separation       schlechtestes Nachbarpaar #eda100↔#1baf7a ΔE 9,1 (protan) · tritan 5,8
       [PASS] Normal-vision floor  schlechtestes Nachbarpaar #e87ba4↔#eda100 ΔE 19,6
       [WARN] Contrast vs surface  unter 3:1 → Relief-Regel (Direktlabels oder Tabellenansicht):
                                   #1baf7a 2,82 · #eda100 2,17 · #e87ba4 2,69
       → ALL CHECKS PASS, Exit-Code 0
     Dark   --surface #2f343c --mode dark
       [PASS] Lightness band       alle 8 in L 0,48–0,67
       [PASS] Chroma floor         alle 8 >= 0,1
       [PASS] CVD separation       schlechtestes Nachbarpaar #c98500↔#199e70 ΔE 8,4 (protan) · tritan 8,7
       [PASS] Normal-vision floor  schlechtestes Nachbarpaar #d55181↔#c98500 ΔE 19,3
       [WARN] Contrast vs surface  unter 3:1 → Relief-Regel: #008300 2,53 (Slot 6)
       → ALL CHECKS PASS, Exit-Code 0
     Folge (D.3): keine Hex-Änderung; Slots 3/4/5 (Light) und Slot 6 (Dark) nur mit
     Direktbeschriftung oder Tabellen-Zwilling einsetzen. Statusfarben sind in
     beiden Modi identisch und tragen immer Icon + Label.
   ============================================================================= */

:root {
  /* ---------------------------------------------------------------- Layout */
  --navbar-h: 50px;
  --sidebar-w: 60px;
  --sidebar-w-open: 220px;
  --drawer-w: 480px;
  --bottombar-h: 56px;
  --ws-pad: 16px;
  --ws-pad-sm: 12px;
  --grid-gap: 12px;
  --banner-h: 40px;

  /* Stapelreihenfolge (Blueprint: Overlay 20, Toast 40) */
  --z-banner: 12;
  --z-sidebar: 15;
  --z-drawer: 30;
  --z-dialog: 35;
  --z-palette: 36;
  --z-toast: 40;
  --z-login: 50;

  /* ---------------------------------------- Dichte (Standard = Blueprint 30 px) */
  --hit: 30px; /* Mindesthöhe Buttons/Inputs in Formularen des Workspace */
  --row-h: 30px; /* Tabellenzeile in Touch/Halle; bp6-compact 24 px bleibt in reinen Datentabellen */
  --fs-ui: 14px;
  --fs-scan: 18px;
  --fs-tile: 28px;
  --fs-hero: 48px;

  /* --------------------------- Chart-Oberfläche & Tinte (Light) = Blueprint-Karte */
  --viz-surface: #ffffff;
  --viz-page: #f6f7f9;
  --viz-ink-1: #1c2127;
  --viz-ink-2: #5f6b7c;
  --viz-ink-3: #8f99a8;
  --viz-grid: #e5e8eb;
  --viz-axis: #c5cbd3;
  --viz-ring: rgba(17, 20, 24, 0.1);
  --viz-deemph: #c5cbd3;
  --viz-other: #abb3bf;

  /* ------------- Kategorisch – feste Reihenfolge, Farbe hängt am Reihenschlüssel */
  --viz-s1: #2a78d6;
  --viz-s2: #eb6834;
  --viz-s3: #1baf7a;
  --viz-s4: #eda100;
  --viz-s5: #e87ba4;
  --viz-s6: #008300;
  --viz-s7: #4a3aa7;
  --viz-s8: #e34948;

  /* ------------------------------------------------- Sequenziell Blau 100–700 */
  --viz-seq-100: #cde2fb;
  --viz-seq-150: #b7d3f6;
  --viz-seq-200: #9ec5f4;
  --viz-seq-250: #86b6ef;
  --viz-seq-300: #6da7ec;
  --viz-seq-350: #5598e7;
  --viz-seq-400: #3987e5;
  --viz-seq-450: #2a78d6;
  --viz-seq-500: #256abf;
  --viz-seq-550: #1c5cab;
  --viz-seq-600: #184f95;
  --viz-seq-650: #104281;
  --viz-seq-700: #0d366b;

  /* ------------------------------ Divergierend: neg = rot, pos = blau, Mitte neutral */
  --viz-div-neg: #e34948;
  --viz-div-mid: #edeff2;
  --viz-div-pos: #2a78d6;

  /* ------------------------------------- Status – nie gethemt, immer Icon + Label */
  --viz-good: #0ca30c;
  --viz-warning: #fab219;
  --viz-serious: #ec835a;
  --viz-critical: #d03b3b;
  --viz-delta-good: #006300;

  /* --------------------- Meter/Heatmap-Stufen je Modus (werden im Dark Mode umgesetzt) */
  --viz-meter-fill: var(--viz-seq-450);
  --viz-meter-track: var(--viz-seq-100);
  --viz-seg-1: var(--viz-seq-500);
  --viz-seg-2: var(--viz-seq-300);
  --viz-seg-3: var(--viz-seq-200);
  --viz-heat-min: 100; /* Stufenfenster für heatmap() */
  --viz-heat-max: 700;
  --viz-ord-min: 250; /* Stufenfenster für ordinale Rampen */
  --viz-ord-max: 600;

  --viz-font: var(--bp-typography-family-default);
  --viz-font-mono: var(--bp-typography-family-mono);
}

/* Expliziter Light-Scope (helle Insel in dunkler Umgebung): dieselben Werte wie :root */
[data-bp-color-scheme='light'] {
  --viz-surface: #ffffff;
  --viz-page: #f6f7f9;
  --viz-ink-1: #1c2127;
  --viz-ink-2: #5f6b7c;
  --viz-ink-3: #8f99a8;
  --viz-grid: #e5e8eb;
  --viz-axis: #c5cbd3;
  --viz-ring: rgba(17, 20, 24, 0.1);
  --viz-deemph: #c5cbd3;
  --viz-other: #abb3bf;
  --viz-s1: #2a78d6;
  --viz-s2: #eb6834;
  --viz-s3: #1baf7a;
  --viz-s4: #eda100;
  --viz-s5: #e87ba4;
  --viz-s6: #008300;
  --viz-s7: #4a3aa7;
  --viz-s8: #e34948;
  --viz-div-neg: #e34948;
  --viz-div-mid: #edeff2;
  --viz-div-pos: #2a78d6;
  --viz-delta-good: #006300;
  --viz-meter-fill: var(--viz-seq-450);
  --viz-meter-track: var(--viz-seq-100);
  --viz-seg-1: var(--viz-seq-500);
  --viz-seg-2: var(--viz-seq-300);
  --viz-seg-3: var(--viz-seq-200);
  --viz-heat-min: 100;
  --viz-heat-max: 700;
  --viz-ord-min: 250;
  --viz-ord-max: 600;
  color-scheme: light;
}

/* -----------------------------------------------------------------------------
   Dark: eigene Werte, gleiche Token-Namen. Gilt bei body.bp6-dark (Voreinstellung)
   und – wie Blueprints eigene Tokens – bei [data-bp-color-scheme="dark"].
   Sequenzielle Rampe behält Namen und Werte; heatmap()/ordinale Charts lesen
   --viz-heat-min/max bzw. --viz-ord-min/max und nutzen nur 250–700 / 250–600.
   ----------------------------------------------------------------------------- */
.bp6-dark,
[data-bp-color-scheme='dark'] {
  --viz-surface: #2f343c;
  --viz-page: #252a31;
  --viz-ink-1: #f6f7f9;
  --viz-ink-2: #c5cbd3;
  --viz-ink-3: #8f99a8;
  --viz-grid: #404854;
  --viz-axis: #5f6b7c;
  --viz-ring: rgba(255, 255, 255, 0.1);
  --viz-deemph: #404854;
  --viz-other: #5f6b7c;

  --viz-s1: #3987e5;
  --viz-s2: #d95926;
  --viz-s3: #199e70;
  --viz-s4: #c98500;
  --viz-s5: #d55181;
  --viz-s6: #008300;
  --viz-s7: #9085e9;
  --viz-s8: #e66767;

  --viz-div-neg: #e66767;
  --viz-div-mid: #383e47;
  --viz-div-pos: #3987e5;

  --viz-delta-good: #0ca30c;

  --viz-meter-fill: var(--viz-seq-400);
  --viz-meter-track: var(--viz-seq-650);
  --viz-seg-1: var(--viz-seq-500);
  --viz-seg-2: var(--viz-seq-350);
  --viz-seg-3: var(--viz-seq-250);
  --viz-heat-min: 250;
  --viz-heat-max: 700;
  --viz-ord-min: 250;
  --viz-ord-max: 600;

  color-scheme: dark;
}

/* color-scheme folgt der Body-Klasse (Formularelemente, Scrollbalken) */
body {
  color-scheme: light;
}
body.bp6-dark {
  color-scheme: dark;
}

/* -----------------------------------------------------------------------------
   Dichte-Stufen als Body-Klassen. Standard (ohne Klasse) = Blueprint 30 px.
   density-halle ist Voreinstellung bei pointer: coarse (Vorabskript in index.html).
   ----------------------------------------------------------------------------- */
body.density-compact {
  --hit: 24px;
  --row-h: 24px;
  --fs-ui: 12px;
}
body.density-touch {
  --hit: 40px;
  --row-h: 40px;
  --fs-ui: 14px;
  --fs-scan: 18px;
}
body.density-halle {
  --hit: 56px;
  --row-h: 48px;
  --fs-ui: 16px;
  --fs-scan: 20px;
  --fs-hero: 56px;
}
