/* IST design system · tokens v0.5.1 (draft, 2026-10-27)
   Plain CSS custom properties in layers. Apps use the semantic names (layers 3–11), never the raw values.
   A theme (brand, department or another brand altogether) changes layer 1 only; check_tokens.py derives
   the five values from one hex colour and proves their contrast.
   Load after assets/fonts/fonts.css. Values are derived, not copied from the PoCs: see principles.md. */

:root {
  /* 1 · Brand: the only layer a theme changes ------------------------------------------------------ */
  --brand: #79b51c;          /* IST-Grün, CD 2024. A fill, never text on white (2.49:1) */
  --brand-on: var(--ink);    /* label on a brand fill: whichever of ink/white reaches 4.5:1 */
  --brand-strong: #4d760d;   /* text, links, state marks on white (5.37:1), the page ground and grey areas (4.63:1) */
  --brand-bright: #79b51c;   /* the brand as text or mark on dark chrome (7.89:1 on ink) */
  --brand-subtle: #ebf9dd;   /* quiet tint: selected rows, highlights */
  --brand-name: "IST";       /* for content: brand is a parameter, never hard-coded in a page */

  /* 2 · Neutrals: the CD's online grey scale (manual p. 8) where it exists, computed steps in between.
         No brand tint, so they fit every theme. The scale stays complete even where no component uses a step
         (DS-51); apps reach it through the semantic names of layer 3. */
  --white: #ffffff;
  --neutral-25: #fbfbfb;
  --neutral-50: #f6f6f6;     /* CD Snow */
  --neutral-100: #eeeeee;    /* CD Pale-Gray */
  --neutral-200: #e2e2e2;    /* CD Light-Gray */
  --neutral-300: #c6c6c6;    /* CD "Empty" */
  --neutral-400: #a7a7a7;    /* CD Gray */
  --neutral-500: #858688;    /* computed: lightest grey that still outlines a control (3.64:1) */
  --neutral-600: #757677;    /* CD Dark-Gray; IST-Grau (#707173 / #6f6f6e) sits here */
  --neutral-700: #656668;    /* computed: secondary text, ≥ 4.5:1 on every light surface */
  --neutral-800: #424549;    /* CD Super-Dark-Gray */
  --neutral-900: #22252a;
  --ink: #080c0f;            /* CD Black: text and focus ring, 19.6:1 on white */
  --ink-chrome: #0e1b2a;     /* Night blue: dark chrome and dark surfaces (Martin, 2026-10-07) */
  --ink-burgundy: #39061c;   /* Burgundy: the security ink, as dark as night blue (Martin, 2026-10-27; data-ink below) */

  /* 3 · Surfaces, text, lines ------------------------------------------------------------------------ */
  --page: var(--neutral-50);           /* the ground behind cards and panels */
  --surface: var(--white);             /* cards, panels, inputs */
  --surface-sunken: var(--neutral-100);/* wells, table headers, the reader behind a page image */
  --surface-ink: var(--ink-chrome);    /* dark surfaces: tooltips, toasts, the selected segment */
  --surface-hover: var(--neutral-25);  /* a hovered row or list item (DS-50) */
  --scrim: color-mix(in srgb, var(--ink-chrome) 50%, transparent); /* behind the drawer, sheets, dialogs (DS-60) */
  --text: var(--ink);
  --text-muted: var(--neutral-700);    /* 5.75 on white, 5.32 on page, 4.95 on sunken */
  --text-on-ink: var(--white);
  --border: var(--neutral-200);        /* hairlines between things; decorative */
  --border-strong: var(--neutral-500); /* input and control outlines: 3.64:1, WCAG 1.4.11 */
  --focus: var(--ink);                 /* focus ring: never blue, never the brand (brands vary in contrast) */
  --focus-on-ink: var(--white);
  --badge-ring-on-ink: var(--ink-chrome); /* the ring of a count badge on dark chrome: the chrome itself; white on burgundy */
  --link: var(--brand-strong);
  --selected-bg: var(--brand-subtle);
  --selected-mark: var(--brand-strong);
  --highlight: #fff0a6;                /* search hits in text: not a status, so not the warning yellow */
  --mark-strong: var(--ink);           /* a strong mark: priority dot, the frame of a selected pin (DS-40) */
  --control-accent: var(--surface-ink);/* checked checkbox and radio: the dark fill other controls use (DS-40) */
  --handle: var(--neutral-300);        /* the grip of a sheet; decoration only (1.71:1), the sheet isn't dragged */
  --paper: var(--white);               /* a page sheet in a reader (DS-16): white in every theme */
  --on-paper: var(--ink);
  --paper-edge: var(--neutral-300);    /* the hairline around a page sheet */

  /* 4 · Status: fixed across all themes, always with shape + label --------------------------------------
     Chosen for distance from each other under colour-vision deficiency (worst pair ΔE ≥ 8) and from every
     department colour; check_tokens.py reports both. Info has no hue: there is no blue in the system. */
  --status-success: #0f7a5c;          --status-success-text: #0f7a5c;  --status-success-subtle: #e2f9ef;  --status-success-on: var(--white);
  --status-warning: #ffd23f;          --status-warning-text: #826700;  --status-warning-subtle: #f9f2de;  --status-warning-on: var(--ink);
  --status-danger: #8e1515;           --status-danger-text: #8e1515;   --status-danger-subtle: #ffeeec;   --status-danger-on: var(--white);
  /* neutral ("kein Eintrag", not started) is a ring: the --surface inside it with the ink outline (DS-48).
     Every status keeps its -on label colour, also where no component fills a label yet (DS-51). */
  --status-info: var(--ink);          --status-info-subtle: var(--neutral-100);  --status-info-on: var(--white);
  --status-outline: var(--ink);       /* every status mark gets this outline: the yellow alone is 1.44:1 */
  /* shapes (for markers and icons): success ● circle · warning ▲ triangle · danger ■ square · neutral ○ ring · info i
     What a mark means is set per use case (status-meanings.json), so a use case looks the same in every app. */

  /* Categories (partner status, document type …) are not an Ampel: no hue, and diamonds instead of the status
     shapes. One dark fill, told apart by form: solid · half · outline · dashed · plus (see CHANGELOG.md, v0.2). */
  --category-fill: var(--surface-ink); /* the filled part: 17.4:1 on white */
  --category-ground: var(--surface);   /* the empty part */

  /* 5 · Type ----------------------------------------------------------------------------------------- */
  --font-sans: Poppins, "Segoe UI", system-ui, -apple-system, sans-serif;  /* font decision open: change here */
  --font-mono: "Cascadia Mono", Consolas, ui-monospace, monospace;
  --text-xs: 0.75rem;    /* 12 · the floor, also on phones */
  --text-sm: 0.875rem;   /* 14 · controls, tables, dense lists */
  --text-md: 1rem;       /* 16 · reading text */
  --text-lg: 1.125rem;   /* 18 */
  --text-xl: 1.25rem;    /* 20 · section titles */
  --text-2xl: 1.5rem;    /* 24 · page titles in tools */
  --text-3xl: 1.875rem;  /* 30 · page titles in learner apps */
  --text-4xl: 2.5rem;    /* 40 · the numbers of the key-figure bar (DS-105) */
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --weight-display: 800; /* italic page titles only (CD: headlines in heavy italic) */
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --tracking-caps: 0.06em; /* small caps labels; CD: Poppins with wider spacing */

  /* 6 · Space: 4 px steps ------------------------------------------------------------------------------ */
  --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;
  --gutter: var(--space-6);  /* page side margin; 16 px on phones */
  --content-max: 1280px;
  --measure: 68ch;       /* the reading width of running text (DS-27) */

  /* 7 · Shape, from the CD: bars and colour areas are square; frames (thin lines) have rounded corners
         (manual p. 15: 2 mm on a 0.5 pt line ≈ 0.66 × body size ≈ 8 px on screen); circles for status and
         people. No pill shapes. */
  --radius-bar: 0;       /* the Balken, colour areas, the header */
  --radius-sm: 4px;      /* small frames: controls, chips, tags */
  --radius-md: 8px;      /* frames: cards, panels, menus, dialogs, sheets */
  --radius-round: 50%;   /* circles only: status marks, avatars, the assistant */
  --line: 1px;
  --bar: 4px;            /* the Balken as a line: marks the active place and the selection */

  /* 8 · Sizes ---------------------------------------------------------------------------------------- */
  --control-h: 40px;     /* buttons, inputs, selects */
  --control-h-sm: 32px;  /* toolbars, table actions, chips */
  --control-h-lg: 48px;  /* the one main search field or call to action on a page */
  --target-min: 44px;    /* touch targets on phones */
  --icon: 20px;
  --icon-sm: 16px;
  --icon-stroke: 1.75;   /* line width of icons, in units of their 24-unit grid */
  --icon-lg: 28px;       /* icons in start-page tiles and icon fields (DS-60) */
  --icon-stroke-lg: 1.5; /* the same line looks heavier at 28 px */
  --logo-h: 36px;        /* the logo in the header; 30 px on phones (DS-60, DS-62) */
  --sheet-w: 420px;      /* a side sheet, e.g. the assistant panel */
  --drawer-w: min(320px, 86vw); /* the phone menu */
  --paper-max: 794px;    /* a page sheet at 100 %: A4 at 96 dpi (DS-16) */

  /* 9 · Elevation: flat by default; shadows only for things that float -------------------------------- */
  --shadow-overlay: 0 12px 32px rgb(8 12 15 / 0.18), 0 2px 6px rgb(8 12 15 / 0.10);  /* menus, dialogs, sheets */
  --shadow-sticky: 0 1px 0 var(--border), 0 4px 12px rgb(8 12 15 / 0.06);            /* bars that stay on scroll */

  /* 10 · Motion -------------------------------------------------------------------------------------- */
  --duration-fast: 120ms;
  --duration: 200ms;     /* also used by apps (the Vertriebskarte's map) */
  --ease: cubic-bezier(0.3, 0, 0.2, 1);

  /* 11 · Map: for apps that show places (with map.css and map.js) ------------------------------------------
     The base map turns grey, so the marks are the only colour on it; marks get a light rim and a soft shadow. */
  --map-ground: var(--page);           /* behind the tiles while they load */
  --map-tiles-filter: grayscale(1) brightness(1.04) contrast(0.92);
  --map-mark-rim: var(--surface);      /* keeps a mark readable on any tile */
  --map-mark-shadow: rgb(8 12 15 / 0.25);
  --map-pin-sm: 11px;    /* country: web-map zoom ≤ 7 */
  --map-pin-md: 16px;    /* region: zoom 8–9 */
  --map-pin-lg: 22px;    /* town and closer: zoom ≥ 10 */

  /* 12 · Breakpoints: phone below 760 px, wide from 1,100 px (DS-32) ----------------------------------------
         @media can't read custom properties, so components write 759px/760px and 1099px/1100px literally;
         check_tokens.py fails on any other width. These copies are for scripts (ds.js). Parts that adapt to
         their own width (reading pane, list with pane) use container queries instead. */
  --bp-phone: 760px;
  --bp-wide: 1100px;

  /* 13 · Stacking: dialogs and popovers use the browser's top layer and need none of these -------------------- */
  --z-sticky: 10;        /* bars that stay on scroll */
  --z-float: 20;         /* the assistant button, map controls */
  --z-sheet: 30;         /* the drawer, sheets and their scrim */
  --z-toast: 40;

  /* 14 · Charts: the data-display layer (D1, Martin 2026-10-23; charts.css) ----------------------------------
         Series: s1 is what the chart is about (the strong brand step), s2 and s3 are greys, told apart also by
         line style. A Fachbereich's colour only when the rows are the Fachbereiche, the status colours (with their
         marks) only when the rows mean states. The ramp runs from the brand tint to the strong step in six steps;
         check_tokens.py checks each theme's steps and their labels. */
  --chart-grid: var(--border);           /* recessive grid lines */
  --chart-axis: var(--border-strong);    /* the axis line */
  --chart-label: var(--text-muted);      /* ticks, axis text and notes, 12 px or more */
  --chart-s1: var(--brand-strong);       /* the series the chart is about */
  --chart-s2: var(--text-muted);         /* a comparison */
  --chart-s3: var(--border-strong);      /* a third series, dashed */
  --chart-ref: var(--text);              /* a target or reference line, dashed */
  --chart-band: var(--surface-sunken);   /* a shaded band: service hours, a period */
  --chart-r0: color-mix(in oklab, var(--brand-subtle), var(--brand-strong) 0%);
  --chart-r1: color-mix(in oklab, var(--brand-subtle), var(--brand-strong) 20%);
  --chart-r2: color-mix(in oklab, var(--brand-subtle), var(--brand-strong) 40%);
  --chart-r3: color-mix(in oklab, var(--brand-subtle), var(--brand-strong) 60%);
  --chart-r4: color-mix(in oklab, var(--brand-subtle), var(--brand-strong) 80%);
  --chart-r5: color-mix(in oklab, var(--brand-subtle), var(--brand-strong) 100%);
  --chart-r4-on: var(--text);            /* the label on step 4; steps 0 to 3 take --text */
  --chart-r5-on: var(--text-on-ink);     /* the label on step 5 */
}

/* Density: learner apps use the default; internal tools may switch to compact */
[data-density="compact"] {
  --control-h: 32px;
  --control-h-sm: 28px;
}

@media (max-width: 759px) {
  :root { --gutter: var(--space-4); --logo-h: 30px; }
}

/* Touch wins over density, also when the density is set on <body> rather than on <html> */
@media (pointer: coarse) {
  :root, [data-density="compact"] { --control-h: 44px; --control-h-sm: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  :root { --duration-fast: 0ms; --duration: 0ms; }
}

/* Chrome: how the brand meets the app frame. Both pilots use ink, in night blue (2026-10-07); light and
   brand stay available. Each block also applies where a theme is set, so a theme on <body> recolours the chrome
   too (the order matters: ink and brand come after light). */
:root, [data-theme], [data-chrome="light"] {
  --chrome-bg: var(--surface);  --chrome-text: var(--text);      --chrome-mark: var(--brand);       --chrome-focus: var(--focus);
  --chrome-nav-mark: var(--selected-mark);   /* the current nav item's bar: on white the strong step, 3:1 */
  --chrome-badge-ring: var(--chrome-bg);
}
[data-chrome="brand"], [data-chrome="brand"] [data-theme] {
  --chrome-bg: var(--brand);    --chrome-text: var(--brand-on);  --chrome-mark: var(--brand-on);    --chrome-focus: var(--brand-on);
  --chrome-nav-mark: var(--brand-on);
  --chrome-badge-ring: var(--chrome-bg);
}
[data-chrome="ink"], [data-chrome="ink"] [data-theme] {
  --chrome-bg: var(--ink-chrome); --chrome-text: var(--text-on-ink); --chrome-mark: var(--brand-bright); --chrome-focus: var(--focus-on-ink);
  --chrome-nav-mark: var(--brand-bright);
  --chrome-badge-ring: var(--badge-ring-on-ink);
}

/* Ink: night blue by default. Burgundy is reserved for security alerts (Martin, 2026-10-27): no app uses it as
   its frame, so burgundy keeps meaning "security". Set data-ink="burgundy" on <html>: the dark chrome and every dark surface follow (toasts, tooltips, the pressed
   segment, checked boxes, category marks, the scrim). As dark as night blue, so every theme's bright step keeps
   4.6:1 on it (check_tokens.py checks both inks). A red count badge gets a white ring, since red on red sinks. */
[data-ink="burgundy"] {
  --ink-chrome: var(--ink-burgundy);
  --surface-ink: var(--ink-chrome); --scrim: color-mix(in srgb, var(--ink-chrome) 50%, transparent);
  --control-accent: var(--surface-ink); --category-fill: var(--surface-ink);
  --badge-ring-on-ink: var(--text-on-ink);
}

/* Themes: layer 1 only. Generated with `python check_tokens.py derive <hex>`. ---------------------------
   CD: never two department colours in one layout, so a page carries exactly one theme. It can sit on <html>,
   <body> or a container: the aliases that read the brand resolve again wherever a theme is set. */
[data-theme] { --link: var(--brand-strong); --selected-bg: var(--brand-subtle); --selected-mark: var(--brand-strong);
  --chart-s1: var(--brand-strong);
  --chart-r0: color-mix(in oklab, var(--brand-subtle), var(--brand-strong) 0%);
  --chart-r1: color-mix(in oklab, var(--brand-subtle), var(--brand-strong) 20%);
  --chart-r2: color-mix(in oklab, var(--brand-subtle), var(--brand-strong) 40%);
  --chart-r3: color-mix(in oklab, var(--brand-subtle), var(--brand-strong) 60%);
  --chart-r4: color-mix(in oklab, var(--brand-subtle), var(--brand-strong) 80%);
  --chart-r5: color-mix(in oklab, var(--brand-subtle), var(--brand-strong) 100%); }
[data-theme="ist"] {
  --brand: #79b51c; --brand-on: var(--ink); --brand-strong: #4d760d; --brand-bright: #79b51c; --brand-subtle: #ebf9dd; --brand-name: "IST";
}
[data-theme="fitness"] {
  --brand: #ffb600; --brand-on: var(--ink); --brand-strong: #8c6306; --brand-bright: #ffb600; --brand-subtle: #fff2dd;
}
[data-theme="gesundheit"] {
  --brand: #ff8c00; --brand-on: var(--ink); --brand-strong: #a15807; --brand-bright: #ff8c00; --brand-subtle: #fff0e6;
}
[data-theme="kommunikation"] {
  --brand: #b71e3f; --brand-on: var(--white); --brand-strong: #b71e3f; --brand-bright: #e54f64; --brand-subtle: #ffefef;
}
[data-theme="sport"] {
  --brand: #1ba138; --brand-on: var(--ink); --brand-strong: #047c25; --brand-bright: #1ba138; --brand-subtle: #e3fbe4;
}
[data-theme="tourismus"] {
  --brand: #0069b4; --brand-on: var(--white); --brand-strong: #0069b4; --brand-bright: #3188d5; --brand-subtle: #ebf5ff;
}
/* A made-up second brand, only to prove that a colour outside the IST palette works */
[data-theme="example"] {
  --brand: #5b3fa0; --brand-on: var(--white); --brand-strong: #5b3fa0; --brand-bright: #8c74da; --brand-subtle: #f3f2ff; --brand-name: "Beispiel"; --chart-r4-on: var(--text-on-ink);
}
