/* Gebietsseiten (#23): Abstände und Layout. Die Farb-Tokens, hell und dunkel, und die Linkfarbe
   bringt /gebietsseiten.css aus der App mit dem Deploy (#615); gepflegt werden sie nur dort. */
:root {
  --radius-sm: 4px;
  --radius: 8px;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1.5rem;
  --tap: 44px;
}

html {
  font-family: system-ui, sans-serif;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface);
}

body {
  max-width: 44rem;
  margin: 0 auto;
  padding: 0 1rem;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

header.site {
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}

header.site a,
.crumbs a,
footer.site a,
.map {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
}

header.site a {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.crumbs,
footer.site ul {
  display: flex;
  flex-wrap: wrap;
  margin: var(--space-2) 0 0;
  padding: 0;
  list-style: none;
}

.crumbs li:not(:last-child)::after {
  content: '›';
  padding: 0 var(--space-2);
  color: var(--text-muted);
}

h1 {
  margin: var(--space-2) 0 0;
  font-size: 1.75rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

h2 {
  margin: 0 0 var(--space-2);
  font-size: 1.25rem;
  line-height: 1.3;
}

h3 {
  margin: 0 0 var(--space-1);
  font-size: 1rem;
}

p {
  margin: 0 0 var(--space-2);
}

.kind,
.muted,
.caption,
.source,
.note,
.parents {
  color: var(--text-muted);
}

.caption,
.source,
.note {
  font-size: 0.875rem;
}

/* Vorläufiges Wahlergebnis (#702): gleiche Größe wie der Wahltag, aber nicht gedämpft. */
.provisional {
  font-size: 0.875rem;
  font-weight: 600;
}

section {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.block {
  margin: var(--space-3) 0;
}

.value strong {
  display: block;
  font-size: 1.125rem;
}

.value .note {
  display: block;
}

.group {
  margin-bottom: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

dl {
  margin: 0 0 var(--space-2);
}

dl div {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 var(--space-3);
  padding: var(--space-1) 0;
  border-bottom: 1px solid var(--surface-2);
}

dd {
  margin: 0 0 0 auto;
  text-align: right;
  overflow-wrap: anywhere;
}

/* Einordnung oder Erklärung unter der Zeile, über die ganze Breite. */
dd.note {
  flex-basis: 100%;
  margin: 0;
  text-align: left;
}

table {
  width: 100%;
  margin: 0 0 var(--space-2);
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: var(--space-1) var(--space-2) var(--space-1) 0;
  border-bottom: 1px solid var(--surface-2);
  text-align: left;
  vertical-align: top;
}

thead th {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 600;
}

th[scope='row'] {
  font-weight: normal;
}

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

.total th,
.total td {
  font-weight: 600;
}

.votes td.num:first-of-type {
  width: 60%;
}

/* Schmal (#57): Der Kopf „Veränderung zu 2019“ darf umbrechen, damit die Tabelle mit langen
   Parteinamen wie „Tierschutzpartei“ auch mit breiteren Schriften in 360 px passt. Die Namen
   selbst bleiben ganz. */
.votes thead th {
  white-space: normal;
}

/* Bevölkerungsbewegung (#631): Jahre als Zahlenspalten, „davon“-Zeilen eingerückt. Schmal
   wie die Strukturdaten je Kennzahl ein Block mit den Jahren darunter, damit drei
   siebenstellige Bundeswerte auch mit breiteren Schriften (DejaVu unter Linux) passen. */
.movement thead th.num,
.movement td.state {
  text-align: right;
}

.movement .sub th {
  padding-left: var(--space-3);
  color: var(--text-muted);
}

.movement td.state {
  color: var(--text-muted);
}

.movement td.state[colspan] {
  text-align: center;
}

/* Strukturdaten (#60): gleiche Spalten in allen Gruppen, Köpfe über den Zahlen. Einheit unter
   dem Namen, Zustände dürfen umbrechen. */
.structure {
  table-layout: fixed;
}

.structure thead th:first-child {
  width: 40%;
}

.structure thead th:not(:first-child) {
  text-align: right;
}

.structure td.num:last-child,
.structure td.state:last-child,
.structure thead th:last-child {
  padding-right: 0;
}

.structure .unit {
  display: block;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.structure td.state {
  text-align: right;
}

/* Drei Wahlen (#629): vier Spalten auch in 360 px. Parteinamen brechen um, Zahlen nicht; Köpfe
   und Zustände („nicht angetreten“) dürfen umbrechen. Der Wahltag steht unter dem Parlament. */
.compare {
  table-layout: fixed;
}

.compare thead th:first-child {
  width: 32%;
}

.compare thead th {
  white-space: normal;
}

.compare .day {
  display: block;
  font-weight: normal;
}

.compare td.state {
  color: var(--text-muted);
  font-size: 0.875rem;
  white-space: normal;
}

.compare .others th,
.compare .others td {
  color: var(--text-muted);
}

.compare th:first-child {
  overflow-wrap: anywhere;
}

.notes,
.elections {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.elections li + li,
.notes li + li {
  margin-top: var(--space-1);
}

/* Schmal: je Kennzahl ein Block, Name über die ganze Breite, darunter drei beschriftete Werte. */
@media (max-width: 40rem) {
  .structure thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .structure tr {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: var(--space-2);
    padding-block: var(--space-1);
    border-bottom: 1px solid var(--surface-2);
  }

  .structure th,
  .structure td {
    padding: 0;
    border: 0;
  }

  .structure th[scope='row'] {
    grid-column: 1 / -1;
    margin-bottom: var(--space-1);
  }

  .structure td,
  .structure td.state {
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .structure td::before {
    content: attr(data-label);
    display: block;
    color: var(--text-muted);
    font-size: 0.875rem;
  }

  .movement thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .movement tr {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: var(--space-2);
    padding-block: var(--space-1);
    border-bottom: 1px solid var(--surface-2);
  }

  .movement th,
  .movement td {
    padding: 0;
    border: 0;
  }

  .movement th[scope='row'] {
    grid-column: 1 / -1;
  }

  .movement .sub th {
    padding-left: var(--space-3);
  }

  .movement td,
  .movement td.state {
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .movement td[colspan] {
    grid-column: 1 / -1;
  }

  .movement td::before {
    content: attr(data-label);
    display: block;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: normal;
  }
}

.bar {
  display: inline-block;
  width: calc(100% - 4.5rem);
  max-width: 14rem;
  height: 0.75rem;
  margin-right: var(--space-2);
  vertical-align: middle;
}

/* Feste Breite, damit die Balken bei „4,1 %“ und „21,9 %“ an derselben Stelle beginnen. */
.n {
  display: inline-block;
  min-width: 3.75em;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--bar);
}

details {
  margin: var(--space-3) 0;
}

/* Natives Dreieck; die Zeile ist mindestens ein Tippziel hoch. */
summary {
  box-sizing: border-box;
  min-height: var(--tap);
  padding: 0.625rem 0;
  cursor: pointer;
  font-weight: 600;
}

.offences,
.groups,
.links,
.children {
  margin: 0;
  padding: 0;
  list-style: none;
}

.offence {
  margin: 0;
  border-bottom: 1px solid var(--surface-2);
}

.offence summary {
  font-weight: normal;
}

.offence .name {
  font-weight: 600;
}

.offence .figures,
.offence .parents,
.offence .few {
  display: block;
  font-size: 0.875rem;
}

/* Eingerückt bis hinter das Dreieck der aufklappbaren Zeile. Die feste Zeile ohne Dreieck
   (Stadtteile mit nur Fallzahlen) bleibt auf einer Linie mit Name und Schlüssel (#712). */
details.offence .figures,
details.offence .parents,
details.offence .few {
  padding-left: 1.1em;
}

.groups li {
  margin-bottom: var(--space-3);
}

.groups .name {
  font-weight: 600;
}

.links a,
.children a {
  display: flex;
  align-items: center;
  min-height: var(--tap);
}

.children {
  columns: 14rem;
  column-gap: var(--space-4);
}

.children li {
  break-inside: avoid;
}

.map {
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
}

.map:hover {
  background: var(--surface-2);
}

.sources ul {
  padding-left: 1.25rem;
  font-size: 0.875rem;
}

.sources li {
  margin-bottom: var(--space-1);
  overflow-wrap: anywhere;
}

/* Dateien je Berichtsjahr nebeneinander, jede ein Tippziel (#756). */
.sources .files {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.sources .files li {
  margin: 0;
}

.sources .files a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
}

.basis {
  margin-top: var(--space-4);
  /* Vermerke der Städte nennen lange Adressen (#653). */
  overflow-wrap: anywhere;
}

footer.site {
  margin: var(--space-4) 0;
  padding-top: var(--space-2);
  border-top: 1px solid var(--border);
}

footer.site li:not(:last-child) {
  margin-right: var(--space-4);
}

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

/* Altersgruppen von Tatverdächtigen und Opfern (#632): Unterteilungen eingerückt. */
.ages caption {
  padding: var(--space-1) 0;
  font-weight: 600;
  text-align: left;
}

.ages .depth-2 th {
  padding-left: var(--space-3);
}

.ages .depth-3 th {
  padding-left: calc(2 * var(--space-3));
}

/* Breite Tabellen scrollen in sich, nicht die Seite (#632). */
.table-scroll {
  overflow-x: auto;
}

.table-scroll:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* Drei Zahlenspalten mit siebenstelligen Werten: am Handy kleiner, damit die Tabelle meist
   ohne Scrollen passt (360 px, #632). Spaltenköpfe dürfen umbrechen. */
@media (max-width: 480px) {
  .ages {
    font-size: 0.875rem;
  }

  .ages th,
  .ages td {
    padding-right: var(--space-1);
  }

  .ages thead .num {
    white-space: normal;
    hyphens: auto;
  }
}
