/* ---------------------------------------------------------------
   Sherwoods Pfahl — Ergänzungen zu Pico.
   Pico macht die Grundarbeit. Hier steht nur, was Pico nicht kennt.
   Alle Farben über Pico-Variablen, damit Hell/Dunkel automatisch trägt.

   Vollfassung. Nicht anhängen, sondern ersetzen.
   --------------------------------------------------------------- */

:root {
  --sp-rule: var(--pico-muted-border-color);
  --sp-meta: var(--pico-muted-color);

  /* Lesbare Zeilenlänge im Fließtext. Der zentrale Wert dieser Datei.
     36em sind rund 70 Zeichen. Enger: 33em. Weiter: 40em.
     Der Container ist 52rem breit – die Differenz ist der Rand,
     in den Kopf, Bilder und Tabellen ausbrechen. */
  --sp-mass: 36em;
}

html {
  scroll-behavior: smooth;
}

/* Inhaltsbreite ---------------------------------------------------
   Pico lässt den Container auf großen Bildschirmen weit laufen.
   Schmaler und mittig liest sich ruhiger. */

body > main,
body > header > nav,
body > footer > nav {
  max-width: 52rem;
  margin-inline: auto;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* Nur für Screenreader ------------------------------------------- */

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

/* Kopfzeile ------------------------------------------------------ */

.wortmarke {
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
}

body > header nav ul {
  flex-wrap: wrap;
}

@media (max-width: 480px) {
  body > header nav {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
  body > header nav ul {
    padding: 0;
  }
}

/* Hell/Dunkel-Schalter -------------------------------------------
   Soll wie ein Navigationspunkt wirken, nicht wie ein Knopf.
   Pico gibt Buttons sonst Hintergrund und volle Breite. */

.themenschalter {
  width: auto;
  margin: 0;
  padding: var(--pico-nav-link-spacing-vertical) var(--pico-nav-link-spacing-horizontal);
  background: none;
  border: none;
  color: var(--pico-secondary);
  font-family: inherit;
  font-size: 0.875rem;
  line-height: inherit;
  cursor: pointer;
}

.themenschalter:hover,
.themenschalter:focus-visible {
  background: none;
  color: var(--pico-primary);
}

.themenschalter svg {
  width: 1.15em;
  height: 1.15em;
  vertical-align: -0.18em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[data-theme="dark"] .nur-hell { display: none; }
[data-theme="light"] .nur-dunkel { display: none; }

/* Kopfgrafik der Startseite --------------------------------------
   Das Band läuft über die Containerränder hinaus, damit der
   mitgelieferte dunkle Hintergrund der Grafik nicht als Kasten
   auf hellem Grund steht. */

.kopfgrafik {
  background: #0f1a0a;
  margin-block: -1rem 2.5rem;
  margin-inline: calc(50% - 50vw);
  padding-inline: calc(50vw - 50%);
}

.kopfgrafik img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 60rem;
  margin-inline: auto;
}

/* Suchfeld in der Kopfzeile -------------------------------------- */

.suchfeld {
  margin: 0;
}

.suchfeld input[type="search"] {
  width: 11rem;
  height: auto;
  margin: 0;
  padding-block: 0.3rem;
  padding-inline-end: 0.6rem;
  font-size: 0.875rem;
}

@media (max-width: 480px) {
  .suchfeld,
  .suchfeld input[type="search"] {
    width: 100%;
  }
}

/* Suchseite ------------------------------------------------------ */

.suchseite {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  margin: 1.5rem auto 2rem;
  max-width: var(--sp-mass);
}

.suchseite input[type="search"] {
  flex: 1 1 auto;
  margin: 0;
}

.suchseite button {
  flex: 0 0 auto;
  width: auto;
  margin: 0;
}

/* ================================================================
   TEXTSPALTE
   ================================================================
   Fließtext steht als mittige Spalte im Maß --sp-mass.
   Artikelkopf, Bilder und Tabellen laufen bewusst über die volle
   Containerbreite. Dadurch rahmt der Kopf den Text, statt ihn
   schmal danebenstehen zu lassen.

   Templates brauchen dafür einen Container mit class="text";
   Artikel zusätzlich class="artikel" am <article>.
   ================================================================ */

.artikel > *,
.text > * {
  max-width: var(--sp-mass);
  margin-inline: auto;
}

/* Was bewusst über die volle Breite läuft */
.artikel > header,
.artikel > h1,
.artikel > .serie,
.artikel > .untertitel,
.artikel > .anriss,
.artikel > .beitragszeile,
.artikel > .herkunft,
.artikel > .titelbild,
.artikel > .kopfgrafik,
.artikel > figure,
.text > figure,
.text > .titelbild,
.text > table,
.text > pre,
.text > .breit {
  max-width: none;
}

/* Innerhalb eines <header> gilt dasselbe: alles auf volle Breite,
   damit Titel und Herkunftsstreifen an derselben Kante beginnen. */
.artikel > header > * {
  max-width: none;
}

/* Tabellen bleiben Tabellen; lange Inhalte brechen um statt zu scrollen.
   Siehe die Regeln zu .artikel table weiter unten. */

/* Bildunterschriften folgen wieder dem Textmaß */
.titelbild figcaption,
.text > figure figcaption {
  max-width: var(--sp-mass);
  margin-inline: auto;
}

/* Artikelkopf ---------------------------------------------------- */

.artikel .serie {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sp-meta);
  margin-bottom: 0.4rem;
}

.artikel .untertitel {
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--sp-meta);
  margin-top: -0.5rem;
  margin-bottom: 1rem;
}

.artikel .anriss {
  font-size: 1.125rem;
  color: var(--sp-meta);
}

.artikel .beitragszeile {
  margin-top: -0.5rem;
  margin-bottom: 1.25rem;
}

/* Herkunftsstreifen — das Kernstück ------------------------------
   Macht sichtbar, dass jeder Beitrag aus einem dokumentierten
   Vorgang stammt: wann freigegeben, wie viele Belege, ob bearbeitet. */

.herkunft {
  border-left: 3px solid var(--sp-rule);
  padding-left: 1rem;
  margin: 1.5rem 0 2.5rem;
}

.herkunft dl {
  display: flex;
  flex-wrap: wrap;
  gap: 0 2rem;
  margin: 0;
  max-width: none;
}

.herkunft dl > div {
  min-width: 8rem;
}

.herkunft dt {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sp-meta);
  margin: 0;
}

.herkunft dd {
  margin: 0.15rem 0 0;
  font-size: 0.9375rem;
}

@media (max-width: 480px) {
  .herkunft dl {
    gap: 0.75rem 1.5rem;
  }
}

/* Bilder --------------------------------------------------------- */

.titelbild {
  margin: 2rem 0 2.5rem;
}

.titelbild img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 2px;
}

.titelbild figcaption {
  font-size: 0.8125rem;
  color: var(--sp-meta);
  margin-top: 0.5rem;
  line-height: 1.5;
}

.bildnachweis {
  display: block;
  font-size: 0.75rem;
  opacity: 0.8;
}

.bildnachweis a {
  color: inherit;
}

/* Quellenapparat als Akkordeon -----------------------------------
   Pico gestaltet details/summary bereits als Akkordeon. Hier nur
   die Anpassung an den Quellenapparat. */

details.quellen {
  margin: 3rem auto 2rem;
  border-top: 1px solid var(--sp-rule);
  border-bottom: 1px solid var(--sp-rule);
}

details.quellen > summary {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sp-meta);
  padding-block: 0.85rem;
}

details.quellen > summary:hover {
  color: var(--pico-primary);
}

details.quellen > summary + * {
  margin-top: 0;
}

details.quellen ol {
  font-size: 0.9375rem;
  padding-inline-start: 1.25rem;
}

details.quellen li {
  margin-bottom: 0.6rem;
}

.quellenart {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.05rem 0.4rem;
  margin-inline-start: 0.4rem;
  border: 1px solid var(--sp-rule);
  border-radius: 2px;
  color: var(--sp-meta);
  vertical-align: 0.05em;
}

details.quellen li .meta {
  display: inline-block;
  margin-inline-start: 0.5rem;
}

/* Korrekturen — bewusst offen, nicht im Akkordeon ---------------- */

.korrekturen {
  margin: 2rem auto;
  padding-top: 1.25rem;
  border-top: 1px solid var(--sp-rule);
}

.korrekturen h2 {
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sp-meta);
}

.korrekturen ul {
  list-style: none;
  padding: 0;
  font-size: 0.9375rem;
  max-width: none;
}

.korrekturen li {
  padding-left: 1rem;
  border-left: 2px solid var(--sp-rule);
  margin-bottom: 0.75rem;
}

.korrekturen li.wesentlich {
  border-left-color: var(--pico-primary);
}

.korrekturen time {
  display: block;
  font-size: 0.75rem;
  color: var(--sp-meta);
}

/* Hinweiskasten --------------------------------------------------
   Zusammengeführt: In der Vorfassung war .hinweis zweimal definiert,
   einmal als Zitatstrich, einmal als Kasten. Der Kasten hat gewonnen,
   also steht jetzt nur noch der. */

.hinweis {
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--sp-rule);
  border-radius: 0.4rem;
  margin: 1.5rem auto;
  font-size: 0.9375rem;
}

.hinweis p {
  margin-bottom: 0.5rem;
  max-width: none;
}

.hinweis p:last-child,
.hinweis ul:last-child {
  margin-bottom: 0;
}

.hinweis-gut {
  border-color: var(--pico-primary);
}

.hinweis-fehler {
  border-color: var(--pico-del-color, #b3454a);
}

.hinweis-fehler ul {
  margin-bottom: 0;
}

/* Artikelliste --------------------------------------------------- */

.artikelliste,
.artikelliste > li {
  list-style: none;
  padding-left: 0;
}

.artikelliste {
  max-width: var(--sp-mass);
  margin-inline: auto;
}

.artikelliste > li::marker {
  content: none;
}

.artikelliste > li {
  padding-block: 1.25rem;
  border-bottom: 1px solid var(--sp-rule);
  max-width: none;
}

.artikelliste > li:last-child {
  border-bottom: none;
}

.artikelliste h2 {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
  max-width: none;
}

.artikelliste h2 a {
  text-decoration: none;
}

.artikelliste h2 a:hover {
  text-decoration: underline;
}

.artikelliste p {
  margin-bottom: 0;
  max-width: none;
}

/* Mit Vorschaubild darf die Liste breiter laufen als das Textmaß,
   sonst bleibt neben dem 160px-Bild zu wenig für den Anriss. */
.artikelliste:has(.vorschau) {
  max-width: none;
}

.artikelliste:has(.vorschau) > li {
  display: grid;
  grid-template-columns: 160px 1fr;
  column-gap: 1.25rem;
  align-items: start;
}

.artikelliste:has(.vorschau) > li > * {
  grid-column: 2;
}

.artikelliste:has(.vorschau) > li > a:has(> .vorschau) {
  grid-column: 1;
  grid-row: 1 / span 5;
}

.artikelliste .vorschau {
  width: 160px;
  height: auto;
  border-radius: 2px;
}

@media (max-width: 480px) {
  .artikelliste:has(.vorschau) > li {
    display: block;
  }
  .artikelliste .vorschau {
    float: none;
    width: 100%;
    margin: 0 0 0.75rem 0;
  }
}

/* Weiterlesen-Zeile unter der Startseitenliste -------------------- */

.weiterlesen {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin: 1.5rem auto 0;
  font-size: 0.9375rem;
}

/* Metazeilen und Schlagworte ------------------------------------- */

.meta {
  font-size: 0.8125rem;
  color: var(--sp-meta);
}

.tag {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  margin-right: 0.25rem;
  border: 1px solid var(--sp-rule);
  border-radius: 2px;
  color: var(--sp-meta);
  text-decoration: none;
}

a.tag:hover,
a.tag:focus-visible {
  border-color: var(--pico-primary);
  color: var(--pico-primary);
}

/* Schlagwortwolke ------------------------------------------------
   Der Schriftgrad wird im Template nach Häufigkeit gesetzt. Damit die
   Wolke lesbar bleibt, ist die Spanne bewusst eng gehalten.
   Die Wolke läuft über die volle Containerbreite, nicht im Textmaß –
   sie ist Navigation, kein Fließtext. */

.wortwolke {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 0.9rem;
  margin: 1.5rem 0 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--sp-rule);
  line-height: 1.6;
  justify-content: flex-start;
  max-width: none;
}

.wortwolke a {
  text-decoration: none;
  color: var(--sp-text, var(--pico-contrast)) !important;
}

.wortwolke a:hover {
  color: var(--pico-primary);
  text-decoration: underline;
}

.wortwolke a[aria-current="page"] {
  color: var(--pico-primary);
  font-weight: 600;
}

.wortwolke .anzahl {
  font-size: 0.7rem;
  vertical-align: super;
  margin-inline-start: 0.15rem;
  color: var(--sp-meta);
}

/* Blättern zwischen Beiträgen ------------------------------------ */

.blaettern {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  margin: 2.5rem auto 1rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--sp-rule);
}

.blaettern a {
  flex: 1 1 0;
  min-width: 0;
  text-decoration: none;
}

.blaettern a:last-child {
  text-align: right;
}

.blaettern a:only-child:first-child {
  text-align: left;
}

.blaettern .richtung {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sp-meta);
  margin-bottom: 0.2rem;
}

.blaettern .beitragstitel {
  font-size: 0.9375rem;
  line-height: 1.4;
}

.blaettern a:hover .beitragstitel {
  text-decoration: underline;
}

@media (max-width: 480px) {
  .blaettern {
    flex-direction: column;
    gap: 1rem;
  }
  .blaettern a:last-child {
    text-align: left;
  }
}
/* Teilen-Leiste unter Beiträgen ---------------------------------- */
.teilen {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 2.5rem auto;
  padding: 1rem 1.25rem;
  border: 1px solid var(--sp-rule);
  border-radius: 12px;
}
.teilen-label {
  color: var(--sp-meta);
  font-size: 0.875rem;
}
.teilen a,
.teilen button {
  width: auto;
  margin: 0;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--sp-rule);
  border-radius: var(--pico-border-radius);
  background: none;
  color: var(--pico-h1-color) !important;
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.4;
  text-decoration: none;
  cursor: pointer;
}
.teilen a:hover,
.teilen button:hover {
  border-color: var(--pico-primary);
  background: none;
  color: var(--pico-primary) !important;
}

/* Kontaktformular ------------------------------------------------
   Stand in der Vorfassung zweimal wortgleich. Einmal reicht. */

.kontaktformular {
  margin: 2rem auto 0;
  max-width: var(--sp-mass);
}

.kontaktformular label {
  font-weight: 500;
}

.kontaktformular .pflicht {
  color: var(--pico-primary);
  font-weight: 400;
}

.kontaktformular button {
  width: auto;
}

.formhinweis {
  font-size: 0.85rem;
  color: var(--sp-meta);
  margin: 0.5rem auto 1.5rem;
  max-width: var(--sp-mass);
}

/* Honigtopf: fuer Menschen unsichtbar, fuer Bots im Quelltext sichtbar.
   Bewusst kein display:none - manche Bots ueberspringen versteckte Felder. */
.honigtopf {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Fußzeile ------------------------------------------------------- */

body > footer {
  border-top: 1px solid var(--sp-rule);
  margin-top: 4rem;
  font-size: 0.875rem;
}

body > footer nav ul {
  padding: 0;
  justify-content: center;
}

/* Nach oben ------------------------------------------------------
   Erscheint erst, wenn wirklich gescrollt wurde. Sitzt rechts unten
   am Rand, damit nichts vom Text verdeckt wird. */

.nachoben {
  position: fixed;
  inset-inline-end: 1.25rem;
  inset-block-end: 1.25rem;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--sp-rule);
  border-radius: 50%;
  background: var(--pico-background-color);
  color: var(--sp-meta);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(0.5rem);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.nachoben.sichtbar {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.nachoben:hover,
.nachoben:focus-visible {
  background: var(--pico-background-color);
  color: var(--pico-primary);
  border-color: var(--pico-primary);
}

.nachoben svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (prefers-reduced-motion: reduce) {
  .nachoben { transition: none; }
}

/* Drucken -------------------------------------------------------- */

@media print {
  .nachoben,
  .themenschalter,
  .teilen,
  body > header nav,
  body > footer nav { display: none; }

  .artikel > *,
  .text > * { max-width: none; }

  details.quellen { border: none; }
  details.quellen > summary { list-style: none; }
  details.quellen > *:not(summary) { display: block !important; }
}

/* Tabellen: lange Inhalte umbrechen statt scrollen */

.artikel table {
  width: 100%;
  table-layout: fixed;
}

.artikel table td,
.artikel table th {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.artikel table td code {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.8125rem;
}

.artikel table th:first-child,
.artikel table td:first-child {
  width: 12rem;
}

/* Tabellen auf schmalen Bildschirmen */

@media (max-width: 600px) {
  .artikel table th:first-child,
  .artikel table td:first-child {
    width: 7rem;
  }

  .artikel table td,
  .artikel table th {
    padding-left: 0.4rem;
    padding-right: 0.4rem;
    font-size: 0.9rem;
  }

  .artikel table td code {
    font-size: 0.75rem;
  }
}

/* Kein waagerechtes Verschieben der Seite */

html, body {
  overflow-x: hidden;
  max-width: 100%;
}

/* Wortmarke nicht umbrechen lassen: Seit "Über uns" dazugekommen ist,
   wird die Navigation breiter als der Kopfbereich und Pico staucht
   zuerst den Seitennamen. */
header nav .wortmarke {
  white-space: nowrap;
}

/* Kopfzeile: ab Tablet-Breite einzeilig, darunter darf umbrochen werden. */
@media (min-width: 768px) {
  header nav {
    flex-wrap: nowrap;
  }
  header nav .wortmarke {
    white-space: nowrap;
  }
  header nav .suchfeld input[type="search"] {
    max-width: 9rem;
  }
}

/* Schmale Bildschirme: Wortmarke als eigene Zeile oben, Menü darunter. */
@media (max-width: 767px) {
  header nav {
    flex-wrap: wrap;
  }
  header nav > ul:first-child {
    flex-basis: 100%;
  }
  header nav .wortmarke {
    white-space: nowrap;
  }
}

/* Kopfzeile ab Tablet-Breite einzeilig halten: Seit "Über uns" dazugekommen
   ist, wird die Navigation sonst zu breit und die Wortmarke rutscht nach
   unten. Auf schmalen Bildschirmen bleibt der Umbruch erwünscht. */
@media (min-width: 768px) {
  header nav {
    flex-wrap: nowrap;
  }
  header nav .wortmarke {
    white-space: nowrap;
  }
  header nav .suchfeld input[type="search"] {
    max-width: 9rem;
  }
}
