/**
 * statistik.css — Statistik: Kennzahlen, Verlauf, Anteilsbalken, Tooltip.
 *
 * Copyright (c) 2026 Rico Pinzke. Alle Rechte vorbehalten.
 * Stand: 2026-12-04 10:50
 */

:root {
  --f-nicht: #b5223f;
  --f-teils: #e5640f;
  --f-gewusst: #d8b400;
  --f-ohne: #a8a29a;
  --f-lernend: #e0601f;
  --f-sicher: #00a888;
  --f-neu-rand: #c9c3bb;
  --saeule-hoehe: 160px;
}

:root[data-theme="dunkel"] {
  --f-nicht: #d6344e;
  --f-teils: #ec7a2c;
  --f-gewusst: #e9c835;
  --f-ohne: #5c5f67;
  --f-lernend: #e76624;
  --f-sicher: #00a888;
  --f-neu-rand: #50545e;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --f-nicht: #d6344e;
    --f-teils: #ec7a2c;
    --f-gewusst: #e9c835;
    --f-ohne: #5c5f67;
    --f-lernend: #e76624;
    --f-sicher: #00a888;
    --f-neu-rand: #50545e;
  }
}

.statistik {
  position: relative;
}

.kennzahlen {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.kennzahl {
  display: grid;
  align-content: start;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--rand);
  border-radius: 10px;
  background: var(--karte);
  box-shadow: var(--innenkante);
}

.kennzahl-wert {
  font-size: 28px;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.kennzahl-text {
  font-size: 14px;
  line-height: 1.35;
  color: var(--text-leise);
}

.kennzahl-leiste {
  display: block;
  height: 6px;
  margin-top: 8px;
  border-radius: 3px;
  background: var(--flaeche-leise);
  box-shadow: inset 0 0 0 1px var(--rand);
  overflow: hidden;
}

.kennzahl-leiste span {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--f-sicher);
}

.statistik-raster {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.tafel {
  margin: 0;
  padding: 14px 16px 16px;
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  background: var(--karte);
  box-shadow: var(--innenkante);
}

.tafel-breit {
  grid-column: 1 / -1;
}

.tafel-titel {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
}

.legende {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  font-size: 13px;
  color: var(--text-leise);
}

.legende li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legende-farbe {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.teil-nicht {
  background: var(--f-nicht);
}

.teil-teils {
  background: var(--f-teils);
}

.teil-gewusst {
  background: var(--f-gewusst);
}

.teil-ohne {
  background: var(--f-ohne);
}

.teil-lernend {
  background: var(--f-lernend);
}

.teil-sicher {
  background: var(--f-sicher);
}

.teil-neu {
  background: var(--flaeche-leise);
  box-shadow: inset 0 0 0 1px var(--f-neu-rand);
}

.verlauf-flaeche {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
}

.verlauf-achse {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: var(--saeule-hoehe);
  margin: -7px 0;
  padding: 0;
  font-size: 12px;
  line-height: 14px;
  color: var(--text-leise);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.verlauf-spalten {
  position: relative;
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
}

.verlauf-spalten::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: var(--saeule-hoehe);
  border-top: 1px solid var(--rand);
  border-bottom: 1px solid var(--text-leise);
  background: linear-gradient(var(--rand), var(--rand)) center / 100% 1px no-repeat;
  pointer-events: none;
}

.spalte {
  position: relative;
  padding: 0 2px 4px;
  border-radius: 6px;
  outline: none;
}

.spalte:hover,
.spalte:focus-visible {
  background: color-mix(in srgb, var(--flaeche-leise) 70%, transparent);
}

.spalte:focus-visible {
  box-shadow: inset 0 0 0 2px var(--kopflinie);
}

.saeule-raum {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: var(--saeule-hoehe);
}

.saeule {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  max-width: 26px;
}

.saeule .teil {
  flex-basis: 0;
  min-height: 2px;
}

.saeule .teil:first-child {
  border-radius: 4px 4px 0 0;
}

.spalte-tag {
  display: grid;
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.25;
  color: var(--text-leise);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.spalte-heute .spalte-tag {
  color: var(--text);
  font-weight: 700;
}

.tabelle {
  margin-top: 10px;
  font-size: 14px;
}

.tabelle summary {
  color: var(--text-leise);
  cursor: pointer;
}

.tabelle table {
  margin-top: 8px;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.tabelle th,
.tabelle td {
  padding: 3px 10px;
  border-bottom: 1px solid var(--rand);
  text-align: right;
}

.tabelle th[scope="row"] {
  text-align: left;
  font-weight: 400;
}

.anteil-liste {
  display: grid;
  grid-template-columns: fit-content(14em) minmax(0, 1fr) auto;
  gap: 2px 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.anteil {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
  border-radius: 6px;
  outline: none;
}

.anteil:hover,
.anteil:focus-visible {
  background: var(--flaeche-leise);
}

.anteil:focus-visible {
  box-shadow: inset 0 0 0 2px var(--kopflinie);
}

.anteil-name {
  overflow: hidden;
  font-size: 14px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.anteil-balken {
  display: flex;
  gap: 2px;
  height: 12px;
  border-radius: 4px;
  overflow: hidden;
}

.anteil-balken .teil {
  flex-basis: 0;
  min-width: 2px;
}

.anteil-zahl {
  font-size: 13px;
  color: var(--text-leise);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.schwierig {
  display: grid;
  margin: 0;
  padding-left: 1.6em;
}

.schwierig li {
  padding: 7px 0;
  border-bottom: 1px solid var(--rand);
}

.schwierig li:last-child {
  border-bottom: 0;
}

.schwierig-frage {
  display: block;
  font-weight: 600;
  text-decoration: none;
}

.schwierig-frage:hover {
  text-decoration: underline;
}

.schwierig-zahlen {
  font-size: 13px;
  color: var(--text-leise);
}

.schwierig-leer {
  margin-left: -1.6em;
  list-style: none;
  color: var(--text-leise);
}

.tipp {
  position: absolute;
  top: var(--tipp-oben, 0);
  left: var(--tipp-links, 0);
  z-index: 10;
  max-width: 300px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--text);
  color: var(--flaeche);
  font-size: 13px;
  line-height: 1.35;
  pointer-events: none;
}

.tipp[hidden] {
  display: none;
}

@media (max-width: 760px) {
  .kennzahlen {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .kennzahl {
    padding: 10px 12px;
  }

  .kennzahl:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .kennzahl-wert {
    font-size: 24px;
  }

  .kennzahl-text {
    font-size: 13px;
  }

  .statistik-raster {
    grid-template-columns: minmax(0, 1fr);
  }

  .anteil-liste {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 0;
  }

  .anteil {
    gap: 2px 10px;
  }

  .anteil-name {
    grid-column: 1 / -1;
    white-space: normal;
  }

  .spalte {
    padding: 0 1px 4px;
  }

  .spalte-tag {
    font-size: 11px;
  }
}
