/* ==========================================================================
   Barrierefreiheit Widget – Haas Digitalagentur

   Farben und die konfigurierbaren Maße kommen aus --bfw-* Variablen, die das
   Plugin aus den Einstellungen als Inline-CSS ausgibt. Die Fallback-Werte
   hinter jedem var() entsprechen den Standardeinstellungen, damit das
   Stylesheet auch ohne Inline-CSS vollständig funktioniert.

   Sämtliche Maße im Widget stehen in absoluten Pixeln – weder rem noch em.
   Das Bedienelement soll in jedem Theme gleich aussehen: rem hinge an der
   Basisschriftgröße der Seite (die dieses Plugin selbst verändert), em an
   einer geerbten Schriftgröße, die jedes Theme anders setzt.
   ========================================================================== */

/* ---------- Schriftgröße der Seite ----------
   Wirkt auf alle rem-basierten Angaben des Themes. Themes mit festen
   px-Größen zieht das Skript im Modus „Automatisch“ zusätzlich nach. */
html {
  font-size: calc(100% * var(--bfw-scale, 1));
}

/* --------------------------------------------------------------------------
   1. Container und Position
   -------------------------------------------------------------------------- */
.bfw {
  position: fixed;
  z-index: var(--bfw-z, 99990);
  font-size: 14px;
  font-family: var(--bfw-font, inherit);
  font-weight: 400;
  font-style: normal;
  line-height: 1.4;
  text-align: start;
  direction: inherit;
}

.bfw--bottom-left {
  inset-block-end: var(--bfw-offset-block, 20px);
  inset-inline-start: var(--bfw-offset-inline, 20px);
}
.bfw--bottom-right {
  inset-block-end: var(--bfw-offset-block, 20px);
  inset-inline-end: var(--bfw-offset-inline, 20px);
}
.bfw--top-left {
  inset-block-start: var(--bfw-offset-block, 20px);
  inset-inline-start: var(--bfw-offset-inline, 20px);
}
.bfw--top-right {
  inset-block-start: var(--bfw-offset-block, 20px);
  inset-inline-end: var(--bfw-offset-inline, 20px);
}
.bfw--middle-left {
  inset-block-start: 50%;
  inset-inline-start: var(--bfw-offset-inline, 20px);
  transform: translateY(-50%);
}
.bfw--middle-right {
  inset-block-start: 50%;
  inset-inline-end: var(--bfw-offset-inline, 20px);
  transform: translateY(-50%);
}

/* --------------------------------------------------------------------------
   2. Schutz vor Theme-Stilen
   Themes formatieren Buttons, Fieldsets und Labels sehr unterschiedlich.
   Alles im Widget wird deshalb auf einen bekannten Stand zurückgesetzt.
   -------------------------------------------------------------------------- */
.bfw,
.bfw *,
.bfw *::before,
.bfw *::after {
  box-sizing: border-box;
}

/* Achtung: hier keine Größen zurücksetzen. Dieser Selektor ist spezifischer
   (0,1,1) als die Klassen der einzelnen Schaltflächen (0,1,0) – ein „width:
   auto“ an dieser Stelle würde jede spätere Größenangabe aushebeln. Die
   Abmessungen setzt deshalb jedes Element selbst, mit „.bfw“ davor. */
.bfw button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-family: inherit;
  font-weight: 400;
  font-style: normal;
  letter-spacing: normal;
  text-transform: none;
  text-decoration: none;
  text-shadow: none;
  text-align: center;
  box-shadow: none;
  line-height: 1.3;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.bfw fieldset {
  min-width: 0;
  max-width: none;
}

.bfw p,
.bfw h2,
.bfw legend,
.bfw label,
.bfw span {
  margin: 0;
  padding: 0;
  font-family: inherit;
  letter-spacing: normal;
  text-transform: none;
  float: none;
}

/* --------------------------------------------------------------------------
   3. Schaltfläche
   Mindestens 44 × 44 px – WCAG 2.5.8 („Target Size“).
   -------------------------------------------------------------------------- */
.bfw .bfw__toggle {
  width: var(--bfw-button-size, 48px);
  height: var(--bfw-button-size, 48px);
  min-width: 44px;
  min-height: 44px;
  max-width: none;
  max-height: none;
  padding: 0;
  border-radius: var(--bfw-button-radius, 50%);
  display: grid;
  place-items: center;
  background: var(--bfw-button-bg, #111111);
  color: var(--bfw-button-fg, #ffffff);
  box-shadow: var(--bfw-shadow, 0 10px 30px rgba(0, 0, 0, 0.18));
  transition: background-color 0.25s ease, transform 0.25s ease;
}
.bfw .bfw__toggle:hover {
  background: var(--bfw-button-bg-hover, #333333);
  transform: translateY(-2px);
}
.bfw .bfw__toggle:focus-visible {
  outline: 3px solid var(--bfw-focus-ring, #000000);
  outline-offset: 3px;
}
.bfw .bfw__toggle svg,
.bfw .bfw__toggle img {
  width: var(--bfw-icon-size, 22px);
  height: var(--bfw-icon-size, 22px);
  max-width: none;
  max-height: none;
  display: block;
}

/* --------------------------------------------------------------------------
   4. Einstellungsfenster
   -------------------------------------------------------------------------- */
.bfw .bfw__panel {
  position: absolute;
  width: var(--bfw-panel-width, 320px);
  max-width: calc(100vw - 40px);
  max-height: calc(100dvh - 120px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px;
  background: var(--bfw-panel-bg, #ffffff);
  color: var(--bfw-panel-fg, #1a1a1a);
  border: 1px solid var(--bfw-line, #cccccc);
  border-radius: var(--bfw-panel-radius, 14px);
  box-shadow: var(--bfw-shadow, 0 10px 30px rgba(0, 0, 0, 0.18));
}

/* Das Fenster klappt zur Seite auf, auf der Platz ist. */
.bfw--bottom-left .bfw__panel,
.bfw--bottom-right .bfw__panel {
  inset-block-end: calc(100% + 10px);
}
.bfw--top-left .bfw__panel,
.bfw--top-right .bfw__panel {
  inset-block-start: calc(100% + 10px);
}
.bfw--middle-left .bfw__panel,
.bfw--middle-right .bfw__panel {
  inset-block-start: 50%;
  transform: translateY(-50%);
}
.bfw--bottom-left .bfw__panel,
.bfw--top-left .bfw__panel {
  inset-inline-start: 0;
}
.bfw--bottom-right .bfw__panel,
.bfw--top-right .bfw__panel {
  inset-inline-end: 0;
}
.bfw--middle-left .bfw__panel {
  inset-inline-start: calc(100% + 10px);
}
.bfw--middle-right .bfw__panel {
  inset-inline-end: calc(100% + 10px);
}

.bfw__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 18px;
}
.bfw__title {
  font-size: 17px;
  line-height: 1.3;
  font-weight: 700;
  color: var(--bfw-title, #000000);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.bfw .bfw__close {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  max-width: none;
  max-height: none;
  flex: none;
  padding: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--bfw-panel-fg, #1a1a1a);
  transition: background-color 0.25s ease, color 0.25s ease;
}
.bfw .bfw__close svg {
  width: 14px;
  height: 14px;
  display: block;
}
.bfw .bfw__close:hover {
  background: var(--bfw-option-hover, #f0f0f0);
  color: var(--bfw-title, #000000);
}

.bfw__group {
  border: 0;
  padding: 0;
  margin: 0 0 18px;
}
.bfw__group legend {
  display: block;
  width: 100%;
  padding: 0;
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--bfw-muted, #595959);
}

/* Festes Raster statt Flex: die Knöpfe behalten ihre Breite, unabhängig
   davon, wie lang die Beschriftungen sind und wie viele es gibt. */
.bfw__options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.bfw__options--cols-2 {
  grid-template-columns: repeat(2, 1fr);
}
.bfw .bfw__options button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: auto;
  min-width: 0;
  min-height: 44px;
  max-width: none;
  max-height: none;
  padding: 6px 4px;
  border: 1px solid var(--bfw-line, #cccccc);
  border-radius: 999px;
  background: var(--bfw-option-bg, #ffffff);
  color: var(--bfw-option-fg, #1a1a1a);
  font-size: 14px;
  font-weight: 600;
  white-space: normal;
  overflow-wrap: break-word;
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}
.bfw .bfw__options button:hover {
  background: var(--bfw-option-hover, #f0f0f0);
  border-color: var(--bfw-active-bg, #111111);
}
.bfw .bfw__options button[aria-checked='true'] {
  background: var(--bfw-active-bg, #111111);
  border-color: var(--bfw-active-bg, #111111);
  color: var(--bfw-active-fg, #ffffff);
}
.bfw__options button:focus-visible,
.bfw__reset:focus-visible,
.bfw__close:focus-visible,
.bfw__statement a:focus-visible {
  outline: 3px solid var(--bfw-focus-ring, #000000);
  outline-offset: 2px;
}

.bfw__check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 2px 0;
  cursor: pointer;
  font-size: 16px;
  line-height: 1.3;
  color: var(--bfw-option-fg, #1a1a1a);
}
.bfw .bfw__check input {
  width: 20px;
  height: 20px;
  min-width: 20px;
  min-height: 20px;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  accent-color: var(--bfw-active-bg, #111111);
  cursor: pointer;
  flex: none;
}

.bfw .bfw__reset {
  width: 100%;
  height: auto;
  min-width: 0;
  min-height: 44px;
  max-width: none;
  max-height: none;
  padding: 8px 12px;
  margin: 4px 0 0;
  border: 1px solid var(--bfw-line, #cccccc);
  border-radius: 999px;
  background: var(--bfw-option-bg, #ffffff);
  color: var(--bfw-panel-fg, #1a1a1a);
  font-size: 15px;
  font-weight: 600;
  transition: background-color 0.25s ease, color 0.25s ease;
}
.bfw .bfw__reset:hover {
  background: var(--bfw-option-hover, #f0f0f0);
  color: var(--bfw-title, #000000);
}

.bfw__statement {
  margin: 8px 0 0;
  font-size: 15px;
  line-height: 1.4;
  text-align: center;
}
.bfw__statement a {
  /* Zielfläche 44 px hoch (WCAG 2.5.8 verlangt mind. 24 px) */
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--bfw-title, #000000);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/* --------------------------------------------------------------------------
   5. Kleine Bildschirme
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .bfw .bfw__panel {
    width: calc(100vw - 40px);
  }
  /* Seitlich angedockte Fenster passen auf schmalen Geräten nicht daneben. */
  .bfw--middle-left .bfw__panel {
    inset-inline-start: 0;
  }
  .bfw--middle-right .bfw__panel {
    inset-inline-end: 0;
  }
}

@media print {
  .bfw {
    display: none !important;
  }
}

/* --------------------------------------------------------------------------
   6. Modus: Animationen reduzieren
   -------------------------------------------------------------------------- */
html.bfw-motion *,
html.bfw-motion *::before,
html.bfw-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}
/* Verbreitete Animationsbibliotheken und Reveal-Effekte sichtbar schalten. */
html.bfw-motion [data-reveal],
html.bfw-motion [data-aos],
html.bfw-motion .aos-init,
html.bfw-motion .wow,
html.bfw-motion .elementor-invisible,
html.bfw-motion .animated {
  opacity: 1 !important;
  transform: none !important;
  visibility: visible !important;
  animation: none !important;
}

/* --------------------------------------------------------------------------
   7. Modus: Fokus verstärken
   -------------------------------------------------------------------------- */
html.bfw-focus *:focus-visible {
  outline: 4px solid var(--bfw-focus-ring, #000000) !important;
  outline-offset: 3px !important;
}
/* Browser ohne :focus-visible-Unterstützung fallen auf :focus zurück. */
html.bfw-focus a:focus,
html.bfw-focus button:focus,
html.bfw-focus input:focus,
html.bfw-focus select:focus,
html.bfw-focus textarea:focus,
html.bfw-focus [tabindex]:focus {
  outline: 4px solid var(--bfw-focus-ring, #000000) !important;
  outline-offset: 3px !important;
}

/* --------------------------------------------------------------------------
   8. Modus: Links unterstreichen
   -------------------------------------------------------------------------- */
html.bfw-underline a[href] {
  text-decoration: underline !important;
  text-decoration-thickness: 1px !important;
  text-underline-offset: 0.18em !important;
  text-decoration-color: currentColor !important;
}
/* Schaltflächen-Links und Bildlinks bleiben ohne Unterstrich. */
html.bfw-underline a.btn,
html.bfw-underline a.button,
html.bfw-underline a.wp-block-button__link,
html.bfw-underline a.elementor-button,
html.bfw-underline .bfw a {
  text-decoration: none !important;
}
/* Eigene Regel: ein Browser ohne :has() würde sonst den ganzen Block verwerfen. */
html.bfw-underline a:has(> img:only-child) {
  text-decoration: none !important;
}
html.bfw-underline .bfw__statement a {
  text-decoration: underline !important;
}

/* --------------------------------------------------------------------------
   9. Modus: Kontrast hoch

   Grundsatz: so wenig wie möglich umfärben. Verlässlich kontrastarm ist immer
   nur die Kombination aus Text und seiner Fläche – deshalb wird der Text auf
   die dunkle Farbe gezwungen, während Flächen weitgehend bleiben, wie sie sind.

   Das Skript markiert vorher in data-bfw-surface, was ein Element selbst
   mitbringt. Umgefärbt werden nur zwei Fälle:
   – dunkle, deckende Flächen (sie brauchen hellen Text)
   – Flächen mit Hintergrundbild (sie bekommen einen aufhellenden Schleier,
     damit dunkler Text darauf lesbar wird – auch Text, der technisch außerhalb
     des Bildelements liegt und nur darüber positioniert ist)

   Helle Flächen behalten ihre Farbe: ein farbiger Störer oder eine getönte
   Sektion bleibt erkennbar, der Text darauf wird trotzdem maximal kontrastreich.

   Teiltransparente Hintergründe bleiben unangetastet (siehe surfaceOf() im
   Skript): ein halbdurchsichtiges Overlay deckend zu färben würde das Bild
   darunter verdecken. Aus demselben Grund werden Pseudo-Elemente hier nicht
   eingefärbt.
   -------------------------------------------------------------------------- */
html.bfw-contrast-high body {
  background-color: var(--bfw-high-bg, #ffffff) !important;
  color: var(--bfw-high-fg, #000000) !important;
}
html.bfw-contrast-high body * {
  color: inherit !important;
  text-shadow: none !important;
}
/* Flächen werden auch im Hover-Zustand festgehalten. Sonst färbt das Theme
   beim Überfahren um, während die erzwungene Textfarbe stehen bleibt – und der
   Text verschwindet auf dem neuen Untergrund. --bfw-own-bg ist die vom Skript
   gemessene Originalfarbe der Fläche. */
html.bfw-contrast-high [data-bfw-surface='light'],
html.bfw-contrast-high [data-bfw-surface='light']:hover,
html.bfw-contrast-high [data-bfw-surface='light']:focus {
  background-color: var(--bfw-own-bg) !important;
  color: var(--bfw-high-fg, #000000) !important;
}
html.bfw-contrast-high [data-bfw-surface='dark'],
html.bfw-contrast-high [data-bfw-surface='dark']:hover,
html.bfw-contrast-high [data-bfw-surface='dark']:focus {
  background-color: var(--bfw-high-fg, #000000) !important;
  color: var(--bfw-high-bg, #ffffff) !important;
}
/* Der Schleier liegt als Innenschatten über dem Bild, aber unter dem Inhalt. */
html.bfw-contrast-high [data-bfw-surface='image'] {
  box-shadow: inset 0 0 0 100vmax var(--bfw-high-veil, rgba(255, 255, 255, 0.7)) !important;
  color: var(--bfw-high-fg, #000000) !important;
}

html.bfw-contrast-high body a[href] {
  color: var(--bfw-high-link, #0000ee) !important;
  text-decoration: underline !important;
}
/* Das Skript markiert Links, die auf einer dunklen Fläche liegen. */
html.bfw-contrast-high body a[href][data-bfw-on='dark'] {
  color: var(--bfw-high-link-dark, #ffff00) !important;
}

/* Umrandet werden nur Bedienelemente, die weder eine eigene Fläche noch einen
   eigenen Rand oder Schatten mitbringen – das Skript markiert sie. Alle anderen
   behalten das Aussehen, das ihnen das Theme gibt. */
html.bfw-contrast-high [data-bfw-outline] {
  border: 2px solid currentColor !important;
}

/* Bedienelemente ohne eigene Fläche bekommen ein eindeutiges Hover-Bild.
   Was das Theme dort vorsieht, ist im Hochkontrast nicht vorhersagbar. */
html.bfw-contrast-high body button:not([data-bfw-surface]):hover,
html.bfw-contrast-high body [role='button']:not([data-bfw-surface]):hover,
html.bfw-contrast-high body input[type='submit']:not([data-bfw-surface]):hover,
html.bfw-contrast-high body input[type='button']:not([data-bfw-surface]):hover {
  background-color: var(--bfw-high-fg, #000000) !important;
  color: var(--bfw-high-bg, #ffffff) !important;
}

/* Harte Variante: eine einzige Farbkombination für die gesamte Seite. */
html.bfw-high-simple body,
html.bfw-high-simple body * {
  background-color: var(--bfw-high-bg, #ffffff) !important;
  color: var(--bfw-high-fg, #000000) !important;
  border-color: var(--bfw-high-fg, #000000) !important;
  box-shadow: none !important;
}
/* Overlays durchsichtig statt deckend – sonst verdecken sie den Inhalt. */
html.bfw-high-simple body *::before,
html.bfw-high-simple body *::after {
  background-color: transparent !important;
  background-image: none !important;
}
/* Nur hier nötig: in der harten Variante ginge einfarbige Grafik sonst unter. */
html.bfw-high-simple body svg {
  fill: currentColor !important;
  stroke: currentColor !important;
}
html.bfw-high-simple .bfw .bfw__toggle svg {
  fill: none !important;
  stroke: none !important;
}

/* Das Widget behält in beiden Varianten seine eigenen Farben. */
html.bfw-contrast-high .bfw,
html.bfw-contrast-high .bfw * {
  background-color: transparent !important;
  background-image: none !important;
  color: inherit !important;
  border-color: var(--bfw-line, #cccccc) !important;
  box-shadow: none !important;
}
html.bfw-contrast-high .bfw .bfw__panel {
  background-color: var(--bfw-panel-bg, #ffffff) !important;
  color: var(--bfw-panel-fg, #1a1a1a) !important;
  border: 1px solid var(--bfw-line, #cccccc) !important;
}
html.bfw-contrast-high .bfw .bfw__toggle {
  background-color: var(--bfw-button-bg, #111111) !important;
  color: var(--bfw-button-fg, #ffffff) !important;
  border: 0 !important;
}
html.bfw-contrast-high .bfw .bfw__title {
  color: var(--bfw-title, #000000) !important;
}
html.bfw-contrast-high .bfw .bfw__group legend {
  color: var(--bfw-muted, #595959) !important;
}
html.bfw-contrast-high .bfw .bfw__options button {
  background-color: var(--bfw-option-bg, #ffffff) !important;
  color: var(--bfw-option-fg, #1a1a1a) !important;
  border: 1px solid var(--bfw-line, #cccccc) !important;
}
html.bfw-contrast-high .bfw .bfw__options button:hover {
  background-color: var(--bfw-option-hover, #f0f0f0) !important;
  color: var(--bfw-option-fg, #1a1a1a) !important;
}
html.bfw-contrast-high .bfw .bfw__options button[aria-checked='true'] {
  background-color: var(--bfw-active-bg, #111111) !important;
  color: var(--bfw-active-fg, #ffffff) !important;
  border-color: var(--bfw-active-bg, #111111) !important;
}
html.bfw-contrast-high .bfw .bfw__reset,
html.bfw-contrast-high .bfw .bfw__close {
  background-color: var(--bfw-option-bg, #ffffff) !important;
  color: var(--bfw-panel-fg, #1a1a1a) !important;
}
html.bfw-contrast-high .bfw .bfw__reset {
  border: 1px solid var(--bfw-line, #cccccc) !important;
}
html.bfw-contrast-high .bfw .bfw__statement a {
  color: var(--bfw-title, #000000) !important;
}

/* --------------------------------------------------------------------------
   10. Modus: Schwarz-Weiß und Invertiert
   Gefiltert werden die direkten Kinder von <body>, nicht <html> oder <body>
   selbst: so bleiben Sticky-Header und Overlays der Themes funktionsfähig,
   und das Widget lässt sich vom Filter ausnehmen.
   -------------------------------------------------------------------------- */
html.bfw-contrast-bw body > * {
  filter: var(--bfw-bw-filter, grayscale(100%) contrast(1.05));
}
html.bfw-contrast-bw body > .bfw,
html.bfw-contrast-bw .bfw {
  filter: none !important;
}

html.bfw-contrast-invert body {
  background-color: #000 !important;
}
html.bfw-contrast-invert body > * {
  filter: var(--bfw-invert-filter, invert(100%) hue-rotate(180deg));
}
html.bfw-contrast-invert body > .bfw,
html.bfw-contrast-invert .bfw {
  filter: none !important;
}
/* Bilder, Videos und Einbettungen zurückdrehen, damit sie normal aussehen. */
html.bfw-contrast-invert img,
html.bfw-contrast-invert video,
html.bfw-contrast-invert iframe,
html.bfw-contrast-invert canvas,
html.bfw-contrast-invert [style*='background-image'] {
  filter: var(--bfw-invert-filter, invert(100%) hue-rotate(180deg)) brightness(var(--bfw-invert-dim, 0.85));
}
html.bfw-contrast-invert .bfw img,
html.bfw-contrast-invert .bfw svg {
  filter: none !important;
}
