/*
  PatchDue – Gestaltung der Grafikseite „Schwachstellen in Zahlen“.
  Baut auf marke.css und site.css auf. Reihenfarben sind mit dem Prüfskript der
  Diagramm-Richtlinie gegen die Flächen #FFFFFF (hell) und #201F3F (dunkel) geprüft:
  benachbarte Farben bleiben auch bei Rot-Grün-Schwäche unterscheidbar. Drei helle
  Farben liegen unter 3 : 1 zur Fläche; deshalb gibt es immer Legende mit Namen,
  Hinweisfeld und Tabelle.
*/

:root {
  --reihe-1: #6250d6;
  --reihe-2: #eb6834;
  --reihe-3: #1baf7a;
  --reihe-4: #eda100;
  --reihe-5: #e87ba4;
  --reihe-6: #008300;
  --grafik-ruhig: #948dcf;
}

@media (prefers-color-scheme: dark) {
  :root {
    --reihe-1: #9085e9;
    --reihe-2: #d95926;
    --reihe-3: #199e70;
    --reihe-4: #c98500;
    --reihe-5: #d55181;
    --reihe-6: #0ca30c;
    --grafik-ruhig: #726dae;
  }
}

.farbe-1 { --farbe: var(--reihe-1); }
.farbe-2 { --farbe: var(--reihe-2); }
.farbe-3 { --farbe: var(--reihe-3); }
.farbe-4 { --farbe: var(--reihe-4); }
.farbe-5 { --farbe: var(--reihe-5); }
.farbe-6 { --farbe: var(--reihe-6); }

/* ---------- Karte ---------- */

.grafik-karte {
  background: var(--pd-surface);
  border: 1px solid var(--pd-border);
  border-radius: calc(var(--pd-radius) * 2);
  padding: 1.1rem 0.9rem 1.2rem;
}

@media (min-width: 40rem) {
  .grafik-karte {
    padding: 1.5rem 1.5rem 1.6rem;
  }
}

.grafik-karte h3 {
  font-size: 1.125rem;
}

.grafik-kopf {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.grafik-steuerung {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.5rem;
}

.grafik-hinweis {
  font-size: 0.9375rem;
  color: var(--pd-muted);
}

.grafik-knopf,
.chip {
  font: inherit;
  font-size: 0.9375rem;
  line-height: 1.2;
  color: var(--pd-text);
  background: var(--pd-surface);
  border: 1px solid var(--pd-muted);
  border-radius: var(--pd-radius);
  padding: 0.5rem 0.75rem;
  min-height: 2.25rem;
  cursor: pointer;
}

.grafik-knopf:hover:not(:disabled),
.chip:hover {
  border-color: var(--pd-primary);
  color: var(--pd-primary);
}

.grafik-knopf:disabled {
  opacity: 0.45;
  cursor: default;
}

.grafik-knopf[aria-pressed="true"] {
  background: var(--pd-primary);
  border-color: var(--pd-primary);
  color: var(--pd-primary-text);
  font-weight: 600;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.chips[hidden] {
  display: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.chip[aria-pressed="true"] {
  border-color: var(--pd-text);
  box-shadow: inset 0 0 0 1px var(--pd-text);
  background: var(--site-toenung);
  font-weight: 600;
  color: var(--pd-text);
}

.chip-farbe {
  display: none;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 2px;
  background: var(--farbe);
}

.chip[aria-pressed="true"] .chip-farbe {
  display: block;
}

.chip-haken[aria-pressed="true"]::before {
  content: "\2713";
}

.wahl-titel {
  font-size: 0.9375rem;
  color: var(--pd-muted);
  margin-bottom: 0.5rem;
}

/* ---------- Zeichenfläche ---------- */

.grafik-flaeche {
  position: relative;
  height: 300px;
}

@media (min-width: 40rem) {
  .grafik-flaeche {
    height: 360px;
  }
}

.grafik-flaeche > svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.grafik-svg text,
.grafik-statisch text {
  font-family: var(--pd-font);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.achsentext {
  fill: var(--pd-muted);
}

.achsentext-klick {
  fill: var(--pd-text);
  text-decoration: underline;
}

.wert {
  fill: var(--pd-text);
  font-weight: 600;
}

.raster {
  stroke: var(--pd-border);
  stroke-width: 1;
}

.achse {
  stroke: var(--pd-muted);
  stroke-width: 1;
}

.balken {
  fill: var(--pd-primary);
}

.balken-ruhig {
  fill: var(--grafik-ruhig);
}

.reihe {
  fill: var(--farbe);
}

.linie {
  fill: none;
  stroke: var(--farbe);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.punkt {
  fill: var(--farbe);
  stroke: var(--pd-surface);
  stroke-width: 2;
}

.lot {
  stroke: var(--pd-muted);
  stroke-width: 1;
}

.treffer-flaeche {
  fill: transparent;
  pointer-events: all;
}

.saeule,
.treffer-flaeche {
  outline: none;
}

.saeule-klick {
  cursor: pointer;
}

.saeule-klick:hover .balken {
  fill: var(--pd-text);
}

.saeule:focus-visible > .treffer-flaeche,
.treffer-flaeche:focus-visible {
  stroke: var(--pd-primary);
  stroke-width: 2;
}

@media (prefers-reduced-motion: no-preference) {
  .wachsen {
    transform-box: fill-box;
    transform-origin: 50% 100%;
    animation: wachsen 0.32s ease-out both;
  }

  @keyframes wachsen {
    from {
      transform: scaleY(0.02);
    }
  }
}

/* ---------- Hinweisfeld, Legende, Tabellen ---------- */

.grafik-tipp {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  max-width: 15rem;
  background: var(--pd-surface);
  color: var(--pd-text);
  border: 1px solid var(--pd-muted);
  border-radius: var(--pd-radius);
  padding: 0.45rem 0.65rem 0.5rem;
  font-size: 0.875rem;
  line-height: 1.35;
}

.grafik-tipp[hidden] {
  display: none;
}

.grafik-tipp p {
  margin: 0;
}

.grafik-tipp-kopf {
  color: var(--pd-muted);
}

.grafik-tipp-zeile {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

.strich,
.feld {
  flex: none;
  display: inline-block;
  background: var(--farbe);
}

.strich {
  width: 0.9rem;
  height: 3px;
  border-radius: 2px;
}

.feld {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 2px;
}

.legende {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.1rem;
  min-height: 1.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.9375rem;
}

.legende li {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.grafik-meldung {
  min-height: 1.4rem;
  margin-top: 0.6rem;
  font-size: 0.9375rem;
  font-weight: 600;
}

.grafik-fuss {
  margin-top: 0.6rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--pd-muted);
}

.grafik-tabelle {
  margin-top: 0.9rem;
  border-top: 1px solid var(--pd-border);
}

.grafik-tabelle[hidden] {
  display: none;
}

.grafik-tabelle summary {
  cursor: pointer;
  padding-block: 0.7rem;
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--pd-primary);
}

.zahlentabelle {
  overflow-x: auto;
  max-height: 26rem;
  overflow-y: auto;
}

.zahlentabelle table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9375rem;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

.zahlentabelle th,
.zahlentabelle td {
  padding: 0.4rem 0.75rem 0.4rem 0;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--pd-border);
}

.zahlentabelle th:first-child {
  text-align: left;
  font-weight: 400;
}

.zahlentabelle thead th {
  font-weight: 600;
  position: sticky;
  top: 0;
  background: var(--pd-surface);
}

/* ---------- Vorbehalte, Ihre Systeme ---------- */

.vorbehalte {
  margin-top: 1.75rem;
  max-width: 46rem;
}

.vorbehalte h3 {
  margin-bottom: 0.6rem;
}

.vorbehalte ul {
  display: grid;
  gap: 0.6rem;
}

.vorbehalte li {
  position: relative;
  padding-left: 1.4rem;
}

.vorbehalte li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 2px;
  background: var(--site-akzent);
}

.systeme-satz {
  margin-block: 1.25rem 0.75rem;
  min-height: 4.5rem;
  max-width: 44rem;
  font-family: var(--site-display);
  font-weight: 650;
  font-size: clamp(1.375rem, 1.1rem + 1.2vw, 1.875rem);
  line-height: 1.25;
}

.systeme-leer {
  font-family: var(--pd-font);
  font-weight: 400;
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--pd-muted);
}

.systeme-knopf {
  margin-top: 1.25rem;
}

.kennzahlen {
  max-width: 46rem;
}

.seitenkopf {
  padding-block: 2rem 1rem;
}

.seitenkopf h1 {
  font-size: clamp(2.125rem, 1.4rem + 3.4vw, 3.25rem);
  max-width: 46rem;
}

.seitenkopf p {
  margin-top: 1.1rem;
  max-width: 42rem;
  font-size: 1.1875rem;
  line-height: 1.55;
}

.abschnitt-eng {
  padding-block: 2.25rem;
}

@media (min-width: 60rem) {
  .abschnitt-eng {
    padding-block: 3rem;
  }
}

/* Ohne JavaScript: Bedienteile ausblenden, die Tabellen bleiben. */
@media (scripting: none) {
  .braucht-js {
    display: none;
  }
}

.text-schmal {
  max-width: 44rem;
}
