/* ==========================================================================
   Globale Barrierefreiheits-Basis (WCAG 2.1 AA)
   --------------------------------------------------------------------------
   Wird von allen Theme-Layouts und vom Admin geladen — gilt also überall.
   Behandelt Themen, die nicht Theme-spezifisch sind: Skip-Link, Fokus-
   Sichtbarkeit, Reduced-Motion-Override, sr-only-Hilfsklasse, Forced-
   Colors-Mode.
   ========================================================================== */

/* --- Skip-Link --------------------------------------------------------------
   Standard: visuell versteckt (clip-path), aber für Screenreader/Tastatur
   verfügbar. Bei Fokus erscheint er oben links.
   ------------------------------------------------------------------------- */
.fw-skip-link {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 100000;
  padding: 0.75rem 1.25rem;
  background: #000;
  color: #fff;
  font: 600 1rem/1.2 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  text-decoration: none;
  border: 3px solid #fff;
  border-radius: 0 0 6px 0;
  transform: translateY(-150%);
  transition: transform 0.15s ease-out;
}
.fw-skip-link:focus,
.fw-skip-link:focus-visible {
  transform: translateY(0);
  outline: 3px solid #ffd400;
  outline-offset: 2px;
}

/* --- Screen-Reader-only -----------------------------------------------------
   Bewährtes Pattern: Element ist visuell unsichtbar, aber für AT verfügbar.
   ------------------------------------------------------------------------- */
.sr-only,
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* --- :focus-visible Sicherheitsnetz ----------------------------------------
   Falls eine Theme-Spezial-CSS Outlines unterdrückt, holen wir hier eine
   sichtbare Fokus-Markierung zurück. WCAG 2.4.7 Focus Visible.
   ------------------------------------------------------------------------- */
:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 2px;
}
/* Browser-Default-Fokus auf Buttons/Links wieder aktivieren, falls per
 * "outline: none" entfernt — :focus-visible greift hier dann normal. */
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible,
[role="link"]:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 2px;
  box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.25);
}

/* --- Hauptinhalt: bei Skip-Link-Sprung NICHT als „klickbar" markieren ------ */
main:focus,
[role="main"]:focus {
  outline: none;
}
main[tabindex="-1"]:focus-visible {
  outline: none;
  box-shadow: none;
}

/* --- Reduced-Motion-Override -----------------------------------------------
   WCAG 2.3.3 Animation from Interactions. Globaler Schutz.
   ------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto !important;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* --- Forced-Colors-Mode (Windows High Contrast) ---------------------------
   Erlaubt dem Betriebssystem, eigene Farben zu erzwingen. Wir ergänzen nur
   sicherheitsrelevante Korrekturen für Komponenten, die sonst unsichtbar
   wären (z. B. Icon-Buttons mit reinem CSS-Hintergrund).
   ------------------------------------------------------------------------- */
@media (forced-colors: active) {
  .fw-skip-link,
  .btn,
  .btn-primary,
  .btn-secondary,
  button {
    border: 1px solid ButtonBorder;
  }
  :focus-visible {
    outline: 3px solid Highlight;
  }
}

/* --- Touch-Targets: Mindestgröße 44×44 px (WCAG 2.5.5 / 2.5.8 AA) ---------
   Greift nur, wenn das Element keine eigene Mindestgröße hat. Themes können
   überschreiben.
   ------------------------------------------------------------------------- */
@media (pointer: coarse) {
  button,
  [role="button"],
  a.btn,
  .btn,
  input[type="button"],
  input[type="submit"],
  input[type="reset"] {
    min-height: 44px;
    min-width: 44px;
  }
}

/* --- Form-Validation: aria-invalid optisch verstärken ----------------------
   Damit Fehler nicht nur farblich (Rot) markiert sind — WCAG 1.4.1 Use of
   Color verbietet, Information ausschließlich über Farbe zu vermitteln.
   ------------------------------------------------------------------------- */
[aria-invalid="true"] {
  outline-offset: 0;
}
input[aria-invalid="true"],
textarea[aria-invalid="true"],
select[aria-invalid="true"] {
  border-color: #b91c1c !important;
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.15);
}
input[aria-invalid="true"]:focus-visible,
textarea[aria-invalid="true"]:focus-visible,
select[aria-invalid="true"]:focus-visible {
  outline: 3px solid #b91c1c;
  outline-offset: 2px;
}

/* --- Pflichtfeld-Markierung „*" auch für Screenreader hörbar -------------- */
.req {
  color: #b91c1c;
  font-weight: 700;
  margin-left: 0.15em;
}
.req::after {
  content: "";
}

/* --- Link-Erkennung im Fließtext: Unterstreichung ist Pflicht (1.4.1) -----
   Wenn ein Theme Links nur per Farbe markiert, ist das ein Verstoß. Diese
   Regel gilt aber NUR, wenn Theme nicht selbst entscheidet — daher relativ
   schwach (lowest specificity).
   ------------------------------------------------------------------------- */
.content a,
.prose a,
article a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.content a:hover,
.prose a:hover,
article a:hover {
  text-decoration-thickness: 2px;
}
