/* ============================================================
   Gutenberg-Bridge
   Dockt die WordPress-Core-Blöcke (group, columns, image, heading)
   an das bestehende .article-Design an. Nötig nur dort, wo WP-Default-
   Styles mit unseren .article__*-Regeln kollidieren.
   Wird sowohl im Frontend als auch (via add_editor_style) im Editor geladen.
   ============================================================ */

/* --- core/columns als unser Grid-Row --- */
.article__row.wp-block-columns {
  display: grid;
  gap: clamp(2rem, 4vw, 3.5rem);
  align-items: start;
}
.article__row .wp-block-column { min-width: 0; }
@media (max-width: 900px) {
  .article__row.wp-block-columns { grid-template-columns: 1fr; }
}

/* --- core/image: Figure + Caption-Overlay wie .article__caption --- */
.article__figure.wp-block-image { display: block; position: relative; }
.article__figure.wp-block-image > img { width: 100%; height: auto; border-radius: var(--radius-md); }
.article__figure--cutout.wp-block-image > img {
  width: auto; max-width: 100%;
  max-height: clamp(320px, 38vw, 460px);
  margin: 0 auto; border-radius: 0;
}
.article__figure figcaption,
.article__figure .wp-element-caption {
  position: absolute;
  bottom: -24px;
  right: -16px;
  max-width: min(90%, 500px);
  margin: 0;
  padding: 0.7rem 0.95rem;
  background: var(--swh-white);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.16);
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-style: italic;
  font-size: clamp(0.78rem, 0.95vw, 0.88rem);
  color: var(--chapter-color);
  line-height: 1.4;
  text-align: left;
}

/* Mobile: Caption IM FLUSS statt absolut — sie zählt zur Figure-Höhe und kann
   nie in den Folgeblock ragen. Kleiner negativer margin-top deutet das
   Overlay an (leichte Überlappung der Bildunterkante). */
@media (max-width: 720px) {
  .article__figure.wp-block-image:has(figcaption) {
    display: flex;
    flex-direction: column;
  }
  .article__figure figcaption,
  .article__figure .wp-element-caption {
    position: relative;
    bottom: auto;
    right: auto;
    transform: none;
    width: fit-content;
    max-width: 90%;
    margin: -20px 4% 0 auto;
  }
}

/* --- Zitat-Pfeil: .article__tag als core/group, innerer Absatz erbt --- */
.article__tag p {
  margin: 0;
  color: inherit;
  font-family: inherit;
  font-weight: inherit;
  font-style: inherit;
  font-size: inherit;
  line-height: inherit;
  text-align: inherit;
}

/* --- Heading-Block: Default-Top-Margin raus (Abstände regelt .article) --- */
.article .wp-block-heading { margin-top: 0; }

/* --- core/table: Klasse sitzt auf <figure>, unsere Tabellen-Styles greifen
       per Descendant; nur Tabelle selbst noch auf 100% + fixed setzen --- */
.wp-block-table.article__table { margin: var(--space-5) 0; }
.wp-block-table.article__table > table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

/* --- Werte-Kacheln (was-uns-treibt) als verschachtelte Block-Gruppen ---
   WP-Block-Layout-Margins auf den Grid-Items killen (Grid-Gap regelt Abstände),
   Marker-Figure ohne Default-Margin. */
.values__grid > * { margin-block: 0; }
.values .value > * { margin-block: 0; }
.value-marker.wp-block-image { margin: 0; }

/* --- Abstände & Einrückungen: WP-Block-Layout im Article neutralisieren ---
   .article__section ist flex + gap; WordPress gibt Block-Kindern zusätzlich
   margin-block (is-layout-flow) → doppelte/uneinheitliche Abstände. Hier kappen,
   unsere Heading-Margins aber bewusst beibehalten. */
.article__section > *,
.article__subsection > * { margin-block: 0; }
/* WICHTIG: WP-Block-Layout (is-layout-constrained/-flow) zwingt Block-Kindern
   margin-inline:auto + eine max-width auf → alles wird zentriert und Tabellen
   werden schmal gequetscht. Hier komplett aufheben → linksbündig & volle Breite. */
.article .wp-block-group > *,
.article .wp-block-column > * { margin-left: 0; margin-right: 0; max-width: none; }
/* Nachfahren-Selektor (nicht nur direkte Kinder!), damit der Heading-Abstand
   IMMER gegen `.article .wp-block-heading { margin-top:0 }` gewinnt — egal wie
   tief der Heading verschachtelt ist. Sonst blieb der Abstand teils auf 0. */
.article .article__section-title { margin: 0 0 var(--space-2); }
.article .article__subsection-title { margin: var(--space-5) 0 var(--space-1); }
/* Falls WP die Gruppe mit innerem Container rendert (ältere Block-Recovery):
   Flex-Layout durchreichen, keine Einrückung. */
.article__section > .wp-block-group__inner-container,
.article__subsection > .wp-block-group__inner-container {
  display: flex; flex-direction: column; gap: var(--space-3);
  margin: 0; padding: 0;
}

/* --- Editor-Vorschau: Kapitelfarbe setzen (im Backend fehlt der .article-Wrapper) --- */
.editor-styles-wrapper {
  --chapter-color: #0061A6;   /* Fallback; echte Kapitelfarbe wird pro Post injiziert (functions.php) */
  --chapter-tint: #DFF2FD;
  --chapter-tint-strong: #BEDCF0;
  max-width: 1000px;
  margin: 0 auto;
}
/* WICHTIG (Editor): WP zentriert & begrenzt jeden Block via `.wp-block { margin:auto; max-width }`.
   Im Editor fehlt der .article-Wrapper, daher hier direkt aufheben → linksbündig & volle Breite
   wie im Frontend. !important, weil die WP-Core-Editor-Regel gleiche Spezifität hat. */
.editor-styles-wrapper .wp-block {
  margin-left: 0 !important;
  margin-right: 0 !important;
  max-width: none !important;
}

/* ============================================================
   SWH-Farbpalette (Gutenberg) — Text- & Hintergrundklassen.
   Greifen im Frontend UND im Editor (gutenberg-bridge.css ist in beiden geladen).
   ============================================================ */
.has-swh-blau-color { color: #0061A6 !important; }
.has-swh-blau-background-color { background-color: #0061A6 !important; }
.has-swh-blau-dunkel-color { color: #003D6B !important; }
.has-swh-blau-dunkel-background-color { background-color: #003D6B !important; }
.has-swh-blau-hell-color { color: #003D6B !important; }   /* helles Blau nur als Fläche sinnvoll */
.has-swh-blau-hell-background-color { background-color: #DCEEF9 !important; }
.has-swh-tuerkis-color { color: #1F9AA6 !important; }
.has-swh-tuerkis-background-color { background-color: #1F9AA6 !important; }
.has-swh-orange-color { color: #EF7D00 !important; }
.has-swh-orange-background-color { background-color: #EF7D00 !important; }
.has-swh-magenta-color { color: #E6007E !important; }
.has-swh-magenta-background-color { background-color: #E6007E !important; }
.has-swh-gelb-color { color: #FFD500 !important; }
.has-swh-gelb-background-color { background-color: #FFD500 !important; }
.has-swh-rot-color { color: #C1121F !important; }
.has-swh-rot-background-color { background-color: #C1121F !important; }
.has-swh-gruen-color { color: #A2BC0C !important; }
.has-swh-gruen-background-color { background-color: #A2BC0C !important; }
.has-swh-schwarz-color { color: #1A1A1A !important; }
.has-swh-schwarz-background-color { background-color: #1A1A1A !important; }
.has-swh-grau-color { color: #5F5E5A !important; }
.has-swh-grau-background-color { background-color: #5F5E5A !important; }
.has-swh-weiss-color { color: #FFFFFF !important; }
.has-swh-weiss-background-color { background-color: #FFFFFF !important; }

/* ================================================================
   „>"-Chevron-Liste zum manuellen Eintragen: im Block-Editor unter
   „Erweitert → Zusätzliche CSS-Klasse(n)" der Liste  swh-arrow-list  eintragen.
   Ersetzt die Standard-Punkte durch ein „>"-Zeichen in Kapitelfarbe
   (Fallback SWH-Blau). Wirkt im Editor UND im Frontend, auch außerhalb .article
   (z. B. Seite „Leichte Sprache").
   ================================================================ */
.swh-arrow-list { list-style: none; padding-left: 0; }
.swh-arrow-list > li { position: relative; padding-left: 1.4rem; }
.swh-arrow-list > li::before {
  content: ">";
  position: absolute; left: 0; top: 0;
  color: var(--chapter-color, #0061A6);
  font-weight: 700;
  line-height: inherit;
}
.swh-arrow-list .swh-arrow-list { margin-top: 0.25rem; }
