/* ============================================================
   Bravex — gemeinsame Produkt-Schicht über tokens.css
   Design System v2.0. Schwarz, Weiss, vier Grautöne. Sonst nichts.

   Diese Datei setzt `tokens.css` voraus und definiert keine eigenen
   Farbwerte: jede Deklaration greift auf eine Variable zu. Unterschiede
   entstehen über Gewicht, Größe, Abstand und Form — nie über Farbe.

   Reihenfolge im <head>:  tokens.css  ->  bravex.css  ->  stil.css
   ============================================================ */

/* ------------------------------------------------------------
   1 · Grundlage
   ------------------------------------------------------------ */
:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

html, body { min-height: 100%; }

body {
  /* tokens setzt 300 — im dichten Produkt-UI trägt 400 besser. */
  font-weight: var(--weight-regular);
  text-rendering: optimizeLegibility;
}

img, svg { max-width: 100%; }

/* Verborgen bleibt verborgen — auch wenn eine Komponente display:flex setzt. */
[hidden] { display: none !important; }

.sprungmarke {
  position: absolute;
  left: var(--space-4);
  top: calc(-1 * var(--space-16));
  z-index: 100;
  background: var(--accent);
  color: var(--accent-inverse);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--type-small);
  font-weight: var(--weight-medium);
  text-decoration: none;
  transition: top var(--duration-fast) var(--ease);
}
.sprungmarke:focus { top: var(--space-4); }

/* ------------------------------------------------------------
   2 · Typografie
   Outfit für alles im UI. Geist Mono ausschließlich für Metadaten.
   Instrument Serif kommt im Produkt-UI bewusst nicht vor.
   ------------------------------------------------------------ */

/* Signature-Element: Section-Tag mit 32px-Hairline. Steht über jedem Block. */
.tag {
  display: block;
  font-family: var(--font-mono);
  font-weight: var(--weight-medium);
  font-size: var(--type-mono);
  letter-spacing: var(--tracking-mono);
  line-height: 1.4;
  text-transform: uppercase;
  color: var(--text-mute);
}
.tag::before {
  content: '';
  display: inline-block;
  width: 32px;
  height: 1px;
  background: currentColor;
  vertical-align: middle;
  margin-right: 14px;
  opacity: 0.6;
}
/* Gleiche Stimme, ohne Hairline — für Kopfzeilen und enge Leisten. */
.tag--nackt::before { display: none; }

/* Metadaten: Kennungen, Zeitstempel, Versionen. Mono, aber lesbar eng gesetzt —
   die weite 0.3em-Laufweite bleibt dem Section-Tag als Signatur vorbehalten. */
.meta {
  font-family: var(--font-mono);
  font-size: var(--type-mono);
  font-weight: var(--weight-regular);
  letter-spacing: 0.04em;
  line-height: 1.6;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.meta--gross { font-size: var(--type-small); }

.zahl {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  white-space: nowrap;
}

.dezent { color: var(--text-dim); }
.leise  { color: var(--text-mute); }

.t-h1 {
  font-family: var(--font-sans);
  font-weight: var(--weight-bold);
  font-size: clamp(1.75rem, 3vw, var(--type-display));
  line-height: var(--lh-display);
  letter-spacing: var(--tracking-tight);
  color: var(--text);
}

a { color: var(--text); text-underline-offset: 4px; text-decoration-thickness: 1px; }
a:hover { text-decoration-color: var(--text-mute); }

/* ------------------------------------------------------------
   3 · Flächen
   ------------------------------------------------------------ */
.karte {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-6);
}
.karte--gross { border-radius: var(--radius-2xl); padding: var(--space-8); }
.karte--flach { box-shadow: none; background: var(--surface-3); }

/* Anklickbare Karte: Fläche bleibt ruhig, die Kante reagiert. */
.karte--klickbar {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition: border-color var(--duration-base) var(--ease),
              transform var(--duration-base) var(--ease),
              box-shadow var(--duration-base) var(--ease);
}
.karte--klickbar:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow-xl); }
:root[data-theme="dark"] .karte--klickbar:hover { border-color: var(--accent); transform: translateY(-2px); }

.hairline { border: 0; border-top: 1px solid var(--border); }

/* Ruhiger Hinweiskasten. Kein farbiges Feld — eine kräftige Kante links. */
.notiz {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  font-size: var(--type-body);
  line-height: var(--lh-body);
  color: var(--text);
}
.notiz strong { font-weight: var(--weight-semibold); }
.notiz--still { border-left-color: var(--border-strong); color: var(--text-dim); }

/* ------------------------------------------------------------
   4 · Knöpfe
   Primär: schwarze Fläche. Sekundär: 1.5px Kante. Tertiär: Unterstreichung.
   Keine Ghost-Buttons, keine Pillen, keine Farbe.
   ------------------------------------------------------------ */
.knopf {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-size: var(--type-body);
  font-weight: var(--weight-medium);
  line-height: 1.2;
  padding: 16px 32px;
  min-height: 48px;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-lg);
  background: var(--accent);
  color: var(--accent-inverse);
  cursor: pointer;
  text-decoration: none;
  transition: opacity var(--duration-fast) var(--ease),
              transform var(--duration-fast) var(--ease);
}
.knopf:hover { opacity: 0.84; }
.knopf:active { transform: translateY(1px); }
.knopf[disabled] { opacity: 0.35; cursor: not-allowed; transform: none; }

.knopf--sekundaer {
  background: transparent;
  color: var(--text);
  border: 1.5px solid var(--border-strong);
}
.knopf--sekundaer:hover { opacity: 1; border-color: var(--accent); }

.knopf--tertiaer {
  background: transparent;
  border: none;
  color: var(--text);
  padding: var(--space-3) 0;
  min-height: 44px;
  font-weight: var(--weight-medium);
}
.knopf--tertiaer:hover { opacity: 1; text-decoration: underline; text-underline-offset: 5px; }

/* Kompakte Variante für Leisten und Zeilen — Klickfläche bleibt >= 44px. */
.knopf--klein { padding: 11px 20px; min-height: 44px; font-size: var(--type-small); }

.ikon-knopf {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease);
}
.ikon-knopf:hover { border-color: var(--accent); }

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

/* ------------------------------------------------------------
   5 · Eingaben
   ------------------------------------------------------------ */
.feld-name {
  display: block;
  font-family: var(--font-sans);
  font-size: var(--type-small);
  font-weight: var(--weight-medium);
  color: var(--text-dim);
  margin-bottom: var(--space-2);
}

input, select, textarea {
  width: 100%;
  font-family: var(--font-sans);
  font-size: var(--type-body);
  font-weight: var(--weight-regular);
  line-height: 1.5;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  min-height: 48px;
  transition: border-color var(--duration-fast) var(--ease);
}
textarea { min-height: 128px; resize: vertical; line-height: var(--lh-body); }
input:hover, select:hover, textarea:hover { border-color: var(--text-mute); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
::placeholder { color: var(--text-mute); opacity: 1; }

input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
input[type="file"] { padding: 10px 12px; }

/* Eigener Pfeil, damit das Auswahlfeld in beiden Modi zur Sprache passt. */
.wahl { position: relative; display: block; }
.wahl > select { appearance: none; -webkit-appearance: none; padding-right: 42px; }
.wahl::after {
  content: '';
  position: absolute;
  right: 17px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--text-dim);
  border-bottom: 1.5px solid var(--text-dim);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

/* Schalter als Zeile — die ganze Zeile ist Klickfläche. */
.schalter {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 44px;
  cursor: pointer;
  font-size: var(--type-small);
  color: var(--text-dim);
}

/* ------------------------------------------------------------
   6 · Tabellen — randlos, Hairlines, Mono-Köpfe, keine Zebrastreifen
   ------------------------------------------------------------ */
.tabelle { width: 100%; border-collapse: collapse; }
.tabelle th {
  font-family: var(--font-mono);
  font-weight: var(--weight-medium);
  font-size: var(--type-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  /* --text-mute bleibt dem Section-Tag als Ornament vorbehalten; alles, was
     eine Spalte benennt, steht in --text-dim und damit gut lesbar. */
  color: var(--text-dim);
  text-align: left;
  white-space: nowrap;
  padding: 0 var(--space-5) var(--space-3) 0;
  border-bottom: 1px solid var(--border-strong);
}
.tabelle td {
  font-size: var(--type-small);
  line-height: 1.6;
  color: var(--text-dim);
  padding: var(--space-3) var(--space-5) var(--space-3) 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.tabelle td:first-child { color: var(--text); }
.tabelle th:last-child, .tabelle td:last-child { padding-right: 0; }
.tabelle tr:last-child td { border-bottom: none; }
.tabelle .zahl, .tabelle th.zahl { text-align: right; }
.tabelle .mono { font-family: var(--font-mono); letter-spacing: 0.02em; }

/* Breites scrollt in seinem Kasten, nie die Seite. */
.rollt { overflow-x: auto; max-width: 100%; }

/* ------------------------------------------------------------
   7 · Status ohne Farbe
   Form und Gewicht tragen die Bedeutung: gefüllt / halb / offen.
   ------------------------------------------------------------ */
.ring {
  display: inline-block;
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border: 1.5px solid currentColor;
  border-radius: var(--radius-pill);
  background: transparent;
}
.ring--voll  { background: currentColor; }
.ring--halb  { background: linear-gradient(90deg, currentColor 0 50%, transparent 50% 100%); }
.ring--offen { background: transparent; }
.ring--gross { width: 16px; height: 16px; border-width: 2px; }

.zustand { display: inline-flex; align-items: center; gap: var(--space-3); color: var(--text); }
.zustand .ring { color: var(--text); }
.zustand--still .ring { color: var(--text-dim); }

/* Chips: die einzige Pillenform im System. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--type-mono);
  font-weight: var(--weight-regular);
  letter-spacing: 0.06em;
  line-height: 1;
  white-space: nowrap;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-dim);
}
/* Ein Problem ist fett mit einem schwarzen Punkt — kein rotes Feld. */
.chip--stark {
  font-weight: var(--weight-bold);
  color: var(--text);
  border-color: var(--text);
}
.chip--stark::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: var(--radius-pill);
  background: currentColor;
}
.chip--gesperrt { border-style: dashed; color: var(--text-dim); }
.chip--gross { font-size: var(--type-small); padding: 9px 16px; }

/* Fortschritt: ruhig, grau/schwarz. Bei Überlast trägt die Schraffur, nicht Rot. */
.balken {
  display: block;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--border);
  overflow: hidden;
}
.balken > span {
  display: block;
  height: 100%;
  background: var(--text);
  border-radius: var(--radius-pill);
  transition: width var(--duration-slow) var(--ease);
}
.balken--hoch > span {
  background: repeating-linear-gradient(
    -45deg, var(--text) 0 3px, var(--surface-2) 3px 6px);
}
.balken--gross { height: 10px; }

/* ------------------------------------------------------------
   8 · Aufklappbares
   ------------------------------------------------------------ */
.klappe > summary {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  list-style: none;
  min-height: 44px;
  padding: var(--space-2) 0;
  font-size: var(--type-small);
  font-weight: var(--weight-medium);
  color: var(--text);
}
.klappe > summary::-webkit-details-marker { display: none; }
.klappe > summary::before {
  content: '';
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform var(--duration-fast) var(--ease);
}
.klappe[open] > summary::before { transform: rotate(45deg); }
.klappe > summary:hover { color: var(--text); text-decoration: underline; text-underline-offset: 5px; }

pre, code {
  font-family: var(--font-mono);
  font-size: var(--type-small);
  letter-spacing: 0;
}
pre {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  overflow: auto;
  max-height: 420px;
  color: var(--text-dim);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ------------------------------------------------------------
   9 · Meldungen
   ------------------------------------------------------------ */
.meldung {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border: 1px solid var(--text);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  font-size: var(--type-body);
  font-weight: var(--weight-medium);
  color: var(--text);
  background: var(--surface-2);
}
.meldung::before {
  content: '';
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border: 1.5px solid currentColor;
  border-radius: var(--radius-pill);
}
.meldung[data-art="ok"]::before { background: currentColor; }
.meldung[data-art="fehler"] { font-weight: var(--weight-bold); }
.meldung[data-art="fehler"]::before { border-radius: 0; background: currentColor; }

.fehler { color: var(--text); font-weight: var(--weight-semibold); }
.fehler::before { content: '■'; margin-right: var(--space-2); font-size: 0.7em; vertical-align: 0.15em; }

/* ------------------------------------------------------------
   10 · Bewegung
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  .karte--klickbar:hover { transform: none; }
  .knopf:active { transform: none; }
}
