/*
 * base.css – „Audit-Report“ design system
 * Agent-Readiness-Check von Online-Marketing.ai
 *
 * Shared foundation for the landing page and the results report: tokens (light + dark), self-hosted
 * fonts, reset, typography, layout, buttons, form controls, tables, tags, Ampel status dots, score bar,
 * level ladder, focus, utilities, reduced motion and print basics.
 *
 * Spec: docs/design/DESIGN.md · Mocks: docs/design/mock-landing.html, docs/design/mock-results.html
 * base.css holds the tokens and reset for the whole page (landing.css and results.css build on it).
 * No external requests: fonts come from /fonts, icons are inline SVG or data: masks (CSP img-src allows data:).
 */

/* ======================================================================
   1. Fonts (self-hosted variable fonts, latin + latin-ext subsets)
   ====================================================================== */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/inter-latin-ext-wght-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/inter-latin-wght-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Geist';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/geist-latin-ext-wght-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Geist';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/geist-latin-wght-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ======================================================================
   2. Tokens – light (default, primary look)
   ====================================================================== */

:root {
  color-scheme: light;

  /* Brand scale (Online-Marketing.ai blue, 600 = #033FCD) */
  --blue-50: #eef3ff;
  --blue-100: #dce6ff;
  --blue-200: #b9ccff;
  --blue-300: #8eabfb;
  --blue-400: #5c83f2;
  --blue-500: #2f62f0;
  --blue-600: #033fcd;
  --blue-700: #0333a8;
  --blue-800: #052a85;
  --blue-900: #071f5e;
  --blue-950: #06143a;

  /* Neutral scale (cool, slightly blue-tinted „paper & ink“) */
  --gray-0: #ffffff;
  --gray-25: #fafbff;
  --gray-50: #f4f6fb;
  --gray-100: #eef1f6;
  --gray-200: #e3e7f0;
  --gray-300: #cbd2e0;
  --gray-400: #a3acbf;
  --gray-500: #7d879b;
  --gray-600: #5b6578;
  --gray-700: #3d4759;
  --gray-800: #232c40;
  --gray-850: #161d2f;
  --gray-900: #111726;
  --gray-950: #0b0f1a;
  --gray-ink: #0e1424;

  /* Surfaces */
  --color-bg: var(--gray-25); /* page */
  --color-paper: var(--gray-0); /* report sheet, cards, inputs */
  --color-sunken: var(--gray-50); /* table heads, code, quiet panels */
  --color-tint: var(--blue-50); /* brand-tinted panels */
  --color-overlay: rgb(14 20 36 / 0.44); /* drawer backdrop */

  /* Text */
  --color-ink: var(--gray-ink); /* headings, body – 18.3:1 on paper */
  --color-ink-2: var(--gray-700); /* secondary text – 9.4:1 */
  --color-ink-3: var(--gray-600); /* meta, captions – 5.7:1 on bg */
  --color-ink-4: #6b7487; /* placeholder, minimum text – 4.7:1 */

  /* Lines */
  --color-line: var(--gray-200); /* hairlines, table rows (decorative) */
  --color-line-strong: var(--gray-300); /* card borders, dividers */
  --color-line-input: var(--gray-500); /* form control borders – 3.6:1 (WCAG 1.4.11) */
  --color-rule: var(--gray-ink); /* document rules (report header, table head) */

  /* Brand roles */
  --color-brand: var(--blue-600); /* primary button, key accents – white text 8.1:1 */
  --color-brand-hover: var(--blue-700);
  --color-brand-active: var(--blue-800);
  --color-on-brand: #ffffff;
  --color-link: var(--blue-600); /* 7.8:1 on bg */
  --color-brand-soft: var(--blue-50);
  --color-brand-soft-2: var(--blue-100);
  --color-brand-line: var(--blue-200);
  --color-brand-panel: var(--blue-600); /* solid CTA panels with white text – stays deep in dark mode */

  /* Ampel (text colors pass AA 4.5:1 on paper and on their -bg; dots pass 3:1 non-text) */
  --color-ok: #0f7a3d;
  --color-ok-dot: #138a47;
  --color-ok-bg: #e8f6ee;
  --color-warn: #9a5b00;
  --color-warn-dot: #c27803;
  --color-warn-bg: #fff4e0;
  --color-bad: #c2261d;
  --color-bad-dot: #d92d20;
  --color-bad-bg: #fdeceb;
  --color-na: var(--gray-600); /* informativ / nicht gewertet */
  --color-na-dot: var(--gray-500);
  --color-na-bg: var(--gray-100);
  --color-on-ampel: #ffffff; /* glyph inside filled dots */

  /* Focus */
  --color-focus: var(--blue-600);
  --color-focus-halo: rgb(3 63 205 / 0.18);
  --color-selection: var(--blue-100);

  /* Typography */
  --font-display: 'Geist', 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-text: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
    sans-serif;
  --font-mono: ui-monospace, 'SFMono-Regular', 'Cascadia Mono', 'Segoe UI Mono', Menlo, Consolas, monospace;

  --text-2xs: 0.6875rem; /* 11 – print footers only */
  --text-xs: 0.75rem; /* 12 – eyebrows, table heads, footnotes */
  --text-sm: 0.875rem; /* 14 – meta, captions, table cells (mobile) */
  --text-base: 1rem; /* 16 – body */
  --text-md: 1.125rem; /* 18 – lead, card titles */
  --text-lg: 1.25rem; /* 20 – h4 */
  --text-xl: 1.5rem; /* 24 – h3 */
  --text-2xl: clamp(1.625rem, 1.3rem + 1.2vw, 2rem); /* 26→32 – h2 */
  --text-3xl: clamp(2rem, 1.5rem + 2vw, 2.75rem); /* 32→44 – report domain, big section titles */
  --text-display: clamp(2.25rem, 1.45rem + 3.4vw, 3.75rem); /* 36→60 – hero h1 */
  --text-score: clamp(4rem, 3rem + 4vw, 6rem); /* 64→96 – Gesamtergebnis */

  --leading-tight: 1.08;
  --leading-snug: 1.25;
  --leading-normal: 1.55;
  --leading-relaxed: 1.65;

  --tracking-display: -0.025em;
  --tracking-heading: -0.015em;
  --tracking-eyebrow: 0.08em;

  /* Spacing (4 px base) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --section-y: clamp(3.5rem, 2rem + 6vw, 7rem); /* vertical rhythm between landing sections */

  /* Layout */
  --container: 1200px;
  --container-narrow: 760px;
  --report-width: 1040px;
  --gutter: clamp(1rem, 0.5rem + 2.2vw, 2rem); /* 16 px at 360, 32 px desktop */
  --header-h: 64px;

  /* Radii – small, document-like */
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 6px; /* buttons, inputs, cards */
  --radius-lg: 8px; /* largest radius in the system (report sheet, drawer) */
  --radius-round: 999px; /* dots only – never for buttons or inputs */

  /* Borders */
  --border-hair: 1px solid var(--color-line);
  --border-strong: 1px solid var(--color-line-strong);
  --border-rule: 1px solid var(--color-rule);

  /* Shadows – paper, not glow */
  --shadow-paper: 0 1px 0 rgb(14 20 36 / 0.03), 0 1px 2px rgb(14 20 36 / 0.05),
    0 12px 32px -18px rgb(14 20 36 / 0.18);
  --shadow-sheet: 0 1px 2px rgb(14 20 36 / 0.06), 0 24px 48px -28px rgb(14 20 36 / 0.28);
  --shadow-raised: 0 2px 4px rgb(14 20 36 / 0.06), 0 32px 64px -24px rgb(14 20 36 / 0.32);
  --shadow-button: 0 1px 0 rgb(255 255 255 / 0.14) inset, 0 1px 2px rgb(14 20 36 / 0.16);

  /* Motion */
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-1: 120ms;
  --dur-2: 200ms;
  --dur-3: 320ms;

  /* Layers */
  --z-header: 50;
  --z-sticky: 40;
  --z-overlay: 90;
  --z-drawer: 100;
  --z-toast: 120;
}

/* ======================================================================
   3. Tokens – dark (system preference unless data-theme="light"; or forced via data-theme="dark")
   ====================================================================== */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --color-bg: var(--gray-950);
    --color-paper: var(--gray-900);
    --color-sunken: #0e1320;
    --color-tint: #15203f;
    --color-overlay: rgb(3 6 12 / 0.66);
    --color-ink: #e8ecf5;
    --color-ink-2: #b7c0d3;
    --color-ink-3: #8d97ad;
    --color-ink-4: #8590a8;
    --color-line: var(--gray-800);
    --color-line-strong: #33405a;
    --color-line-input: #6b7896;
    --color-rule: #b7c0d3;
    --color-brand: var(--blue-500);
    --color-brand-hover: var(--blue-400);
    --color-brand-active: #4a78f5;
    --color-on-brand: #ffffff;
    --color-link: #7c9dff;
    --color-brand-soft: #15203f;
    --color-brand-soft-2: #1c2a52;
    --color-brand-line: #2b3f7a;
    --color-brand-panel: var(--blue-700);
    --color-ok: #4bc27d;
    --color-ok-dot: #3fb872;
    --color-ok-bg: #0f2a1c;
    --color-warn: #e3a43a;
    --color-warn-dot: #e3a43a;
    --color-warn-bg: #2e2210;
    --color-bad: #ff7a70;
    --color-bad-dot: #f0645a;
    --color-bad-bg: #321618;
    --color-na: #8d97ad;
    --color-na-dot: #6b7896;
    --color-na-bg: #1a2133;
    --color-on-ampel: #0b0f1a;
    --color-focus: #7c9dff;
    --color-focus-halo: rgb(124 157 255 / 0.24);
    --color-selection: #23376e;
    --shadow-paper: 0 1px 0 rgb(255 255 255 / 0.03) inset, 0 12px 32px -18px rgb(0 0 0 / 0.6);
    --shadow-sheet: 0 1px 0 rgb(255 255 255 / 0.04) inset, 0 24px 48px -28px rgb(0 0 0 / 0.7);
    --shadow-raised: 0 32px 64px -24px rgb(0 0 0 / 0.75);
    --shadow-button: 0 1px 0 rgb(255 255 255 / 0.12) inset, 0 1px 2px rgb(0 0 0 / 0.4);
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --color-bg: var(--gray-950);
  --color-paper: var(--gray-900);
  --color-sunken: #0e1320;
  --color-tint: #15203f;
  --color-overlay: rgb(3 6 12 / 0.66);
  --color-ink: #e8ecf5;
  --color-ink-2: #b7c0d3;
  --color-ink-3: #8d97ad;
  --color-ink-4: #8590a8;
  --color-line: var(--gray-800);
  --color-line-strong: #33405a;
  --color-line-input: #6b7896;
  --color-rule: #b7c0d3;
  --color-brand: var(--blue-500);
  --color-brand-hover: var(--blue-400);
  --color-brand-active: #4a78f5;
  --color-on-brand: #ffffff;
  --color-link: #7c9dff;
  --color-brand-soft: #15203f;
  --color-brand-soft-2: #1c2a52;
  --color-brand-line: #2b3f7a;
  --color-brand-panel: var(--blue-700);
  --color-ok: #4bc27d;
  --color-ok-dot: #3fb872;
  --color-ok-bg: #0f2a1c;
  --color-warn: #e3a43a;
  --color-warn-dot: #e3a43a;
  --color-warn-bg: #2e2210;
  --color-bad: #ff7a70;
  --color-bad-dot: #f0645a;
  --color-bad-bg: #321618;
  --color-na: #8d97ad;
  --color-na-dot: #6b7896;
  --color-na-bg: #1a2133;
  --color-on-ampel: #0b0f1a;
  --color-focus: #7c9dff;
  --color-focus-halo: rgb(124 157 255 / 0.24);
  --color-selection: #23376e;
  --shadow-paper: 0 1px 0 rgb(255 255 255 / 0.03) inset, 0 12px 32px -18px rgb(0 0 0 / 0.6);
  --shadow-sheet: 0 1px 0 rgb(255 255 255 / 0.04) inset, 0 24px 48px -28px rgb(0 0 0 / 0.7);
  --shadow-raised: 0 32px 64px -24px rgb(0 0 0 / 0.75);
  --shadow-button: 0 1px 0 rgb(255 255 255 / 0.12) inset, 0 1px 2px rgb(0 0 0 / 0.4);
}

/* ======================================================================
   4. Reset
   ====================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + var(--space-4));
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  min-height: 100vh;
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-text);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  font-feature-settings: 'cv11', 'ss01'; /* Inter: single-storey a off, open digits – calm, technical */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

img,
svg,
video,
canvas,
picture {
  display: block;
  max-width: 100%;
}

svg {
  flex-shrink: 0;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}

button:disabled {
  cursor: not-allowed;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

ul[role='list'],
ol[role='list'] {
  list-style: none;
  padding: 0;
}

[hidden] {
  display: none !important;
}

::selection {
  background: var(--color-selection);
  color: var(--color-ink);
}

/* ======================================================================
   5. Typography
   ====================================================================== */

h1,
h2,
h3,
h4,
.h1,
.h2,
.h3,
.h4 {
  font-family: var(--font-display);
  color: var(--color-ink);
  font-weight: 600;
  text-wrap: balance;
}

h1,
.h1 {
  font-size: var(--text-display);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-display);
}

h2,
.h2 {
  font-size: var(--text-2xl);
  line-height: 1.15;
  letter-spacing: var(--tracking-heading);
}

h3,
.h3 {
  font-size: var(--text-xl);
  line-height: var(--leading-snug);
  letter-spacing: -0.01em;
}

h4,
.h4 {
  font-size: var(--text-md);
  line-height: var(--leading-snug);
  letter-spacing: -0.005em;
}

p,
li,
dd {
  text-wrap: pretty;
}

.lead {
  font-size: var(--text-md);
  line-height: var(--leading-relaxed);
  color: var(--color-ink-2);
}

.small,
small {
  font-size: var(--text-sm);
}

.caption {
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--color-ink-3);
}

.footnote {
  font-size: var(--text-xs);
  line-height: 1.5;
  color: var(--color-ink-3);
}

/* Numbered eyebrow: „01 — Warum jetzt“ (mono numerals + label) */
.eyebrow {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--color-ink-3);
}

.eyebrow-num {
  color: var(--color-link);
  font-weight: 600;
}

.eyebrow-num::after {
  content: '—';
  margin-left: var(--space-2);
  color: var(--color-ink-4);
  font-weight: 400;
}

a {
  color: var(--color-link);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
  transition: text-decoration-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out);
}

a:hover {
  text-decoration-color: currentColor;
}

/* Quiet link (navigation, footer): no underline until hover */
.link-quiet {
  color: inherit;
  text-decoration: none;
}

.link-quiet:hover {
  color: var(--color-link);
  text-decoration: underline;
}

/* External link marker for text links (target=_blank); pair with sr-only „(öffnet in neuem Tab)“ */
.link-ext::after {
  content: '';
  display: inline-block;
  width: 0.7em;
  height: 0.7em;
  margin-left: 0.25em;
  vertical-align: 0.05em;
  background: currentColor;
  -webkit-mask: var(--icon-ext) center / contain no-repeat;
  mask: var(--icon-ext) center / contain no-repeat;
}

code,
kbd,
samp,
pre,
.mono {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

:not(pre) > code {
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
  background: var(--color-sunken);
  border: 1px solid var(--color-line);
  color: var(--color-ink);
  overflow-wrap: anywhere; /* long paths must never cause horizontal scroll at 360 px */
}

pre {
  overflow-x: auto;
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-sunken);
  border: 1px solid var(--color-line);
  font-size: var(--text-sm);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Tabular numbers for every figure that is compared or aligned */
/* Note: apply only to figures – Inter's tnum also widens hyphens, so never set it on running text or whole tables */
.num,
.is-num,
.scorebar-scale,
.tnum {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1, 'cv11', 'ss01';
}

strong,
b {
  font-weight: 600;
}

hr,
.rule {
  border: 0;
  border-top: var(--border-hair);
}

.rule--ink {
  border-top: var(--border-rule);
}

/* ======================================================================
   6. Layout
   ====================================================================== */

.container {
  width: 100%;
  max-width: calc(var(--container) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.container--narrow {
  max-width: calc(var(--container-narrow) + 2 * var(--gutter));
}

.container--report {
  max-width: calc(var(--report-width) + 2 * var(--gutter));
}

/* 12-column grid; children span with .col-* from 960 px, stacked below */
.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--space-6);
  row-gap: var(--space-8);
}

.grid > * {
  grid-column: 1 / -1;
}

@media (min-width: 960px) {
  .grid {
    column-gap: var(--space-8);
  }
  .col-3 { grid-column: span 3; }
  .col-4 { grid-column: span 4; }
  .col-5 { grid-column: span 5; }
  .col-6 { grid-column: span 6; }
  .col-7 { grid-column: span 7; }
  .col-8 { grid-column: span 8; }
  .col-9 { grid-column: span 9; }
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--stack-gap, var(--space-4));
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--cluster-gap, var(--space-3));
}

/* Paper surface: cards, report sheet, panels */
.paper {
  background: var(--color-paper);
  border: var(--border-hair);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-paper);
}

.panel-quiet {
  background: var(--color-sunken);
  border: var(--border-hair);
  border-radius: var(--radius-md);
}

/* ======================================================================
   7. Buttons  (.btn + --primary / --secondary / --ghost / --link; sizes --sm / --lg; --block)
   ====================================================================== */

.btn {
  --btn-h: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--btn-h);
  padding: 0 var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: var(--font-text);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.005em;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background-color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out),
    color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out);
}

.btn svg {
  width: 1.05em;
  height: 1.05em;
}

.btn--primary {
  background: var(--color-brand);
  color: var(--color-on-brand);
  box-shadow: var(--shadow-button);
}

.btn--primary:hover {
  background: var(--color-brand-hover);
  color: var(--color-on-brand);
}

.btn--primary:active {
  background: var(--color-brand-active);
}

.btn--secondary {
  background: var(--color-paper);
  color: var(--color-ink);
  border-color: var(--color-line-input);
}

.btn--secondary:hover {
  border-color: var(--color-ink-2);
  background: var(--color-sunken);
  color: var(--color-ink);
}

.btn--ghost {
  background: transparent;
  color: var(--color-link);
  padding-inline: var(--space-3);
}

.btn--ghost:hover {
  background: var(--color-brand-soft);
  color: var(--color-link);
}

.btn--link {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-link);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
}

.btn--link:hover {
  text-decoration-color: currentColor;
}

.btn--sm {
  --btn-h: 36px;
  padding-inline: var(--space-3);
  font-size: var(--text-sm);
}

.btn--lg {
  --btn-h: 52px;
  padding-inline: var(--space-6);
  font-size: var(--text-base);
}

.btn--block {
  display: flex;
  width: 100%;
}

.btn[disabled],
.btn[aria-disabled='true'] {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

/* Square icon button (theme toggle, drawer close) */
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  color: var(--color-ink-2);
  border: 1px solid transparent;
  transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out);
}

.icon-btn:hover {
  background: var(--color-sunken);
  border-color: var(--color-line);
  color: var(--color-ink);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* ======================================================================
   8. Form controls
   ====================================================================== */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field-label {
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-ink);
}

.field-hint {
  font-size: var(--text-sm);
  color: var(--color-ink-3);
}

.field-error {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-bad);
}

.input {
  width: 100%;
  min-height: 48px;
  padding: 0 var(--space-4);
  background: var(--color-paper);
  color: var(--color-ink);
  border: 1px solid var(--color-line-input);
  border-radius: var(--radius-md);
  font-size: var(--text-base); /* ≥ 16 px: no iOS zoom */
  transition: border-color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out);
}

.input::placeholder {
  color: var(--color-ink-4);
  opacity: 1;
}

.input:hover {
  border-color: var(--color-ink-3);
}

.input:focus {
  outline: none;
  border-color: var(--color-focus);
  box-shadow: 0 0 0 3px var(--color-focus-halo);
}

.input:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 1px;
}

.input[aria-invalid='true'] {
  border-color: var(--color-bad);
}

/*
 * Document-style input group: [https:// | url field | Button]
 * Square-ish, joined, no glow. Stacks below 560 px (button full width).
 */
.input-group {
  display: flex;
  align-items: stretch;
  width: 100%;
  background: var(--color-paper);
  border: 1px solid var(--color-line-input);
  border-radius: var(--radius-md);
  transition: border-color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out);
}

.input-group:hover {
  border-color: var(--color-ink-3);
}

.input-group:focus-within {
  border-color: var(--color-focus);
  box-shadow: 0 0 0 3px var(--color-focus-halo);
}

.input-group-prefix {
  display: flex;
  align-items: center;
  padding: 0 var(--space-3) 0 var(--space-4);
  border-right: 1px solid var(--color-line);
  background: var(--color-sunken);
  border-radius: calc(var(--radius-md) - 1px) 0 0 calc(var(--radius-md) - 1px);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-ink-3);
  white-space: nowrap;
}

.input-group .input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 54px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.input-group .input:focus {
  box-shadow: none;
}

.input-group .input:focus-visible {
  outline: none; /* ring is on .input-group:focus-within */
}

.input-group .btn {
  --btn-h: auto;
  margin: 5px;
  border-radius: var(--radius-sm);
  padding-inline: var(--space-5);
}

@media (max-width: 559px) {
  .input-group {
    flex-wrap: wrap;
  }
  .input-group-prefix {
    display: none;
  }
  .input-group .input {
    flex-basis: 100%;
  }
  .input-group .btn {
    flex: 1 1 100%;
    min-height: 48px;
    margin: 0 5px 5px;
  }
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  cursor: pointer;
}

.checkbox input {
  width: 18px;
  height: 18px;
  accent-color: var(--color-brand);
}

/* Segmented choice (Website-Typ): rectangular, not pills */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  border: 1px solid var(--color-line-input);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-paper);
}

.segmented > button,
.segmented > label {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-ink-2);
  border-right: 1px solid var(--color-line);
}

.segmented > :last-child {
  border-right: 0;
}

.segmented > [aria-checked='true'],
.segmented > [aria-pressed='true'] {
  background: var(--color-ink);
  color: var(--color-paper);
}

/* ======================================================================
   9. Tables
   ====================================================================== */

.table {
  width: 100%;
  font-size: var(--text-sm);
  line-height: 1.45;
  text-align: left;
}

.table caption {
  caption-side: top;
  text-align: left;
  padding-bottom: var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-ink-3);
}

.table th {
  padding: var(--space-3) var(--space-3);
  border-bottom: var(--border-rule);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-ink-3);
  white-space: nowrap;
  vertical-align: bottom;
}

.table td {
  padding: var(--space-4) var(--space-3);
  border-bottom: var(--border-hair);
  vertical-align: top;
  color: var(--color-ink-2);
}

.table th:first-child,
.table td:first-child {
  padding-left: 0;
}

.table th:last-child,
.table td:last-child {
  padding-right: 0;
}

.table tbody th {
  /* row headers (Bereich, Maßnahme) */
  font-family: var(--font-text);
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--color-ink);
  border-bottom: var(--border-hair);
  white-space: normal;
  vertical-align: top;
  padding-top: var(--space-4);
}

.table .is-num {
  text-align: right;
  white-space: nowrap;
}

.table tfoot td {
  border-bottom: 0;
  border-top: var(--border-rule);
  font-weight: 600;
  color: var(--color-ink);
}

/* Stacked rows below 640 px: each <td data-label="…"> prints its column label */
@media (max-width: 639px) {
  .table--stack thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .table--stack,
  .table--stack tbody,
  .table--stack tr,
  .table--stack th,
  .table--stack td {
    display: block;
    width: 100%;
  }
  .table--stack tr {
    padding: var(--space-4) 0;
    border-bottom: var(--border-hair);
  }
  .table--stack tbody th,
  .table--stack td {
    padding: var(--space-1) 0;
    border: 0;
    text-align: left;
  }
  .table--stack td[data-label] {
    display: grid;
    grid-template-columns: 7.5rem 1fr;
    gap: var(--space-3);
    align-items: center;
  }
  .table--stack td[data-label]::before {
    content: attr(data-label);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-ink-3);
  }
  .table--stack .is-num {
    text-align: left;
  }
}

/* ======================================================================
   10. Tags (rectangular labels) and keys
   ====================================================================== */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 0.2em 0.5em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-line-strong);
  background: var(--color-paper);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0.01em;
  color: var(--color-ink-2);
  white-space: nowrap;
}

.tag--brand {
  background: var(--color-brand-soft);
  border-color: var(--color-brand-line);
  color: var(--color-link);
}

.tag--ok {
  background: var(--color-ok-bg);
  border-color: transparent;
  color: var(--color-ok);
}

.tag--warn {
  background: var(--color-warn-bg);
  border-color: transparent;
  color: var(--color-warn);
}

.tag--bad {
  background: var(--color-bad-bg);
  border-color: transparent;
  color: var(--color-bad);
}

.tag--na {
  background: var(--color-na-bg);
  border-color: transparent;
  color: var(--color-na);
}

.tag--solid {
  background: var(--color-ink);
  border-color: var(--color-ink);
  color: var(--color-paper);
}

/* ======================================================================
   11. Ampel status dots
   Always pair with a text label (visible or sr-only) – color + glyph + text, never color alone.
   States: --ok (erfüllt), --warn (teilweise / Hinweis), --bad (nicht erfüllt),
           --na (informativ, nicht gewertet), --skip (nicht geprüft)
   ====================================================================== */

:root {
  --icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.4 6.6 11.4 12.5 4.8' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --icon-x: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.6 4.6l6.8 6.8M11.4 4.6l-6.8 6.8' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E");
  --icon-bang: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 3.6v5.6' fill='none' stroke='%23000' stroke-width='2.3' stroke-linecap='round'/%3E%3Ccircle cx='8' cy='12.1' r='1.35'/%3E%3C/svg%3E");
  --icon-dash: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.8 8h6.4' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E");
  --icon-ext: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M6 3.5h6.5V10M12.2 3.8 4 12' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.ampel {
  --ampel-size: 16px;
  --ampel-color: var(--color-na-dot);
  position: relative;
  display: inline-block;
  flex: none;
  width: var(--ampel-size);
  height: var(--ampel-size);
  border-radius: var(--radius-round);
  background: var(--ampel-color);
  vertical-align: -0.2em;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

/* glyph layer – only for states that carry a glyph (ok, warn, bad, na) */
.ampel--ok::after,
.ampel--warn::after,
.ampel--bad::after,
.ampel--na::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--color-on-ampel);
  -webkit-mask: var(--ampel-glyph) center / 80% no-repeat;
  mask: var(--ampel-glyph) center / 80% no-repeat;
}

.ampel--ok {
  --ampel-color: var(--color-ok-dot);
  --ampel-glyph: var(--icon-check);
}

.ampel--warn {
  --ampel-color: var(--color-warn-dot);
  --ampel-glyph: var(--icon-bang);
}

.ampel--bad {
  --ampel-color: var(--color-bad-dot);
  --ampel-glyph: var(--icon-x);
}

/* informativ: hollow ring with dash */
.ampel--na {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--color-na-dot);
}

.ampel--na {
  --ampel-glyph: var(--icon-dash);
}

.ampel--na::after {
  background: var(--color-na-dot);
}

/* nicht geprüft: thin empty ring (lighter than --na, no glyph) */
.ampel--skip {
  background: transparent;
  box-shadow: inset 0 0 0 1.25px var(--color-na-dot);
  opacity: 0.85;
}

.ampel--sm {
  --ampel-size: 12px;
}

.ampel--sm::after {
  -webkit-mask-size: 90%;
  mask-size: 90%;
}

.ampel--lg {
  --ampel-size: 20px;
}

/* Dot + label: <span class="status status--bad"><span class="ampel ampel--bad"></span>Nicht erfüllt</span> */
.status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

.status--ok { color: var(--color-ok); }
.status--warn { color: var(--color-warn); }
.status--bad { color: var(--color-bad); }
.status--na { color: var(--color-na); }
.status--skip { color: var(--color-na); font-weight: 500; }

/* Row of dots (one per check) in the Bereichs-Tabelle */
.ampel-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
  list-style: none;
}

/* ======================================================================
   12. Score bar (segmented 0–100) and level ladder (Stufe 0–5)
   ====================================================================== */

/*
 * <div class="scorebar" role="meter" aria-valuemin="0" aria-valuemax="100" aria-valuenow="60"
 *      aria-valuetext="60 von 100 Punkten" style="--value: 60"></div>
 * 20 segments à 5 points; filled segments in brand blue, empty ones as quiet track.
 */
.scorebar {
  --value: 0;
  --segments: 20;
  --gap: 3px;
  --bar-h: 12px;
  position: relative;
  height: var(--bar-h);
  width: 100%;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

.scorebar::before,
.scorebar::after {
  content: '';
  position: absolute;
  inset: 0 calc(-1 * var(--gap)) 0 0; /* the trailing gap of the last segment falls outside */
  background-image: repeating-linear-gradient(
    90deg,
    var(--seg-color) 0,
    var(--seg-color) calc(100% / var(--segments) - var(--gap)),
    transparent calc(100% / var(--segments) - var(--gap)),
    transparent calc(100% / var(--segments))
  );
}

.scorebar::before {
  --seg-color: var(--color-line-strong);
  opacity: 0.7;
}

.scorebar::after {
  --seg-color: var(--color-brand);
  /* identical segment grid, clipped at the score: multiples of 5 end exactly on a segment edge,
     other values show an honestly partial segment */
  clip-path: inset(0 calc(100% - var(--value) * 1% + 1px) 0 0); /* +1px hides the anti-aliased edge of the next segment */
}

.scorebar--sm {
  --bar-h: 8px;
  --gap: 2px;
}

/*
 * Report variant with one element per segment (crisp in Chrome's PDF output, where the repeating
 * gradient prints with blurred gaps): <div class="scorebar scorebar--seg">
 * <span class="on"></span> … <span style="--f: 0.6"></span> … <span></span></div>
 */
.scorebar--seg {
  display: flex;
  gap: var(--gap);
}

.scorebar--seg::before,
.scorebar--seg::after {
  content: none;
}

.scorebar--seg > span {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  background: color-mix(in srgb, var(--color-line-strong) 70%, transparent);
}

.scorebar--seg > span::after {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(var(--f, 0) * 100%);
  background: var(--color-brand);
}

.scorebar--seg > span.on::after {
  width: 100%;
}

.scorebar-scale {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-ink-3);
}

/*
 * Level ladder: <ol class="ladder" aria-label="Stufen 0 bis 5"> six <li class="ladder-step">,
 * states .is-done / .is-current (aria-current="step") / default (open).
 */
.ladder {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
  padding: 0;
  margin: 0;
  list-style: none;
  counter-reset: none;
}

.ladder-step {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.ladder-bar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  height: 28px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-xs);
  background: var(--color-sunken);
  border: 1px solid var(--color-line);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-ink-3);
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}

.ladder-name {
  font-size: var(--text-xs);
  line-height: 1.3;
  color: var(--color-ink-3);
  hyphens: auto;
}

.ladder-step.is-done .ladder-bar {
  background: var(--color-brand-soft-2);
  border-color: var(--color-brand-line);
  color: var(--color-link);
}

.ladder-step.is-current .ladder-bar {
  background: var(--color-brand);
  border-color: var(--color-brand);
  color: var(--color-on-brand);
}

.ladder-step.is-current .ladder-name {
  color: var(--color-ink);
  font-weight: 600;
}

@media (max-width: 559px) {
  .ladder-name {
    display: none; /* only numbers on phones; the current level name is printed next to the ladder */
  }
  .ladder-bar {
    justify-content: center;
  }
}

/* ======================================================================
   13. Focus, skip link, accessibility helpers
   ====================================================================== */

:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

.btn:focus-visible,
.icon-btn:focus-visible {
  outline-offset: 3px;
  border-radius: var(--radius-md);
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -100px;
  z-index: var(--z-toast);
  padding: var(--space-2) var(--space-4);
  background: var(--color-ink);
  color: var(--color-paper);
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: var(--space-3);
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ======================================================================
   14. Utilities
   ====================================================================== */

.muted { color: var(--color-ink-3); }
.ink-2 { color: var(--color-ink-2); }
.brand { color: var(--color-link); }
.nowrap { white-space: nowrap; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.uppercase-mono {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.flow > * + * { margin-top: var(--flow-space, 1em); }
.mt-0 { margin-top: 0 !important; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mt-12 { margin-top: var(--space-12); }
.max-prose { max-width: 66ch; }
.only-print { display: none !important; }

/* ======================================================================
   15. Reduced motion
   ====================================================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ======================================================================
   16. Print basics (the report-specific print layout lives in results.css – see DESIGN.md §9)
   ====================================================================== */

@media print {
  /* same specificity as the dark-mode selectors and later in the file → print is always light */
  :root,
  :root:not([data-theme='light']),
  :root[data-theme='dark'] {
    color-scheme: light;
    --color-bg: #ffffff;
    --color-paper: #ffffff;
    --color-sunken: #f4f6fb;
    --color-ink: #0e1424;
    --color-ink-2: #3d4759;
    --color-ink-3: #5b6578;
    --color-line: #e3e7f0;
    --color-line-strong: #cbd2e0;
    --color-rule: #0e1424;
    --color-brand: #033fcd;
    --color-link: #033fcd;
    --color-brand-soft: #eef3ff;
    --color-brand-soft-2: #dce6ff;
    --color-brand-line: #b9ccff;
    --color-ok: #0f7a3d;
    --color-ok-dot: #138a47;
    --color-ok-bg: #e8f6ee;
    --color-warn: #9a5b00;
    --color-warn-dot: #c27803;
    --color-warn-bg: #fff4e0;
    --color-bad: #c2261d;
    --color-bad-dot: #d92d20;
    --color-bad-bg: #fdeceb;
    --color-na: #5b6578;
    --color-na-dot: #7d879b;
    --color-na-bg: #eef1f6;
    --color-on-ampel: #ffffff;
    --shadow-paper: none;
    --shadow-sheet: none;
    --shadow-raised: none;
  }

  html {
    font-size: 10pt;
  }

  body {
    background: #fff;
  }

  .no-print,
  .skip-link {
    display: none !important;
  }

  .only-print {
    display: revert !important;
  }

  a {
    color: inherit;
    text-decoration: none;
  }

  h1,
  h2,
  h3,
  h4 {
    break-after: avoid;
  }

  tr,
  .avoid-break {
    break-inside: avoid;
  }
}

/* ======================================================================
   17. Phones and touch screens
   Phones: < 640 px. Touch: (pointer: coarse) at any width. Screen only – a fine pointer at ≥ 640 px
   (desktop) and the A4 print layout are not affected.
   ====================================================================== */

/* Safe areas (index.html sets viewport-fit=cover): nothing sits under a notch or rounded corner in
   landscape. env() is 0 without a notch, so the gutter stays as it is. */
.container {
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}

/* the sticky header grows by the top inset (landing.css) – anchors and focus stay clear of it */
html {
  scroll-padding-top: calc(var(--header-h) + var(--space-4) + env(safe-area-inset-top));
}

@media screen and (pointer: coarse) {
  /* square icon buttons (theme toggle, drawer close): 44 px touch target */
  .icon-btn {
    width: 44px;
    height: 44px;
  }
}

/* Landscape phones: the sticky header is not sticky there (landing.css), so anchors need no header offset */
@media screen and (max-height: 500px) and (orientation: landscape) and (pointer: coarse) {
  html {
    scroll-padding-top: var(--space-4);
  }
}

/*
 * Long lists on phones (app.js): the first items stay, the rest waits behind one button.
 * <ol data-collapse-mobile="3"> → .is-collapsed on the list, .is-extra on the hidden items,
 * button.collapse-toggle after the list. Static markup may carry the classes already (no jump
 * after first paint); html.js (set in <head>) keeps everything visible when JavaScript is off.
 * Desktop and print always show everything.
 */
.collapse-toggle {
  display: none;
}

@media screen and (max-width: 639px) {
  html.js .is-collapsed > .is-extra {
    display: none;
  }
  html.js .collapse-toggle {
    display: flex;
    width: 100%;
    margin-top: var(--space-5);
  }
  .collapse-toggle svg {
    transition: transform var(--dur-2) var(--ease-out);
  }
  .collapse-toggle[aria-expanded='true'] svg {
    transform: rotate(180deg);
  }
}
