/* Bedienhilfen – Barrierefreiheit (tn-bedienhilfen) */

/* ---------- Theme-Stile im Menü neutralisieren ---------- */
.tnbh-root *:not(svg):not(svg *),
.tnbh-skip, .tnbh-open {
  all: revert;
  box-sizing: border-box;
}
.tnbh-root {
  --tnbh-bg: #ffffff;
  --tnbh-fg: #16181d;
  --tnbh-muted: #5a606c;
  --tnbh-line: #d9dce3;
  --tnbh-soft: #f1f3f7;
  font: 400 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif !important;
  color: var(--tnbh-fg);
  letter-spacing: normal !important;
  word-spacing: normal !important;
}
.tnbh-root [hidden] { display: none !important; }

/* ---------- Schwebender Knopf ---------- */
.tnbh-root .tnbh-fab {
  position: fixed; z-index: 2147483000;
  width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center; padding: 0; margin: 0;
  background: var(--tnbh-accent); color: var(--tnbh-on-accent);
  border: 3px solid var(--tnbh-on-accent);
  box-shadow: 0 6px 22px rgba(0, 0, 0, .28);
  cursor: pointer;
  transition: transform .2s ease;
}
.tnbh-root .tnbh-fab:hover { transform: scale(1.06); }
.tnbh-root .tnbh-fab:focus-visible,
.tnbh-root button:focus-visible,
.tnbh-root input:focus-visible + label,
.tnbh-root .tnbh-switch input:focus-visible + .tnbh-track {
  outline: 3px solid var(--tnbh-accent) !important;
  outline-offset: 3px !important;
}
.tnbh-root .tnbh-fab svg { width: 30px; height: 30px; display: block; }

.tnbh-root[data-pos="bottom-right"] .tnbh-fab { right: calc(var(--tnbh-off) + env(safe-area-inset-right, 0px)); bottom: calc(var(--tnbh-off) + env(safe-area-inset-bottom, 0px)); }
.tnbh-root[data-pos="bottom-left"]  .tnbh-fab { left:  calc(var(--tnbh-off) + env(safe-area-inset-left, 0px));  bottom: calc(var(--tnbh-off) + env(safe-area-inset-bottom, 0px)); }
.tnbh-root[data-pos="middle-right"] .tnbh-fab { right: calc(var(--tnbh-off) + env(safe-area-inset-right, 0px)); top: 50%; margin-top: -28px; }
.tnbh-root[data-pos="middle-left"]  .tnbh-fab { left:  calc(var(--tnbh-off) + env(safe-area-inset-left, 0px));  top: 50%; margin-top: -28px; }

/* ---------- Menü ---------- */
.tnbh-root .tnbh-panel {
  position: fixed; z-index: 2147483001;
  width: min(380px, calc(100vw - 24px));
  max-height: calc(100vh - 120px); overflow: auto;
  background: var(--tnbh-bg); color: var(--tnbh-fg);
  border: 1px solid var(--tnbh-line); border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
  padding: 18px; margin: 0;
  display: flex; flex-direction: column; gap: 16px;
  text-align: left;
}
.tnbh-root[data-pos="bottom-right"] .tnbh-panel { right: calc(var(--tnbh-off) + 4px); bottom: calc(var(--tnbh-off) + 70px); }
.tnbh-root[data-pos="bottom-left"]  .tnbh-panel { left:  calc(var(--tnbh-off) + 4px); bottom: calc(var(--tnbh-off) + 70px); }
.tnbh-root[data-pos="middle-right"] .tnbh-panel { right: calc(var(--tnbh-off) + 70px); top: 50%; transform: translateY(-50%); }
.tnbh-root[data-pos="middle-left"]  .tnbh-panel { left:  calc(var(--tnbh-off) + 70px); top: 50%; transform: translateY(-50%); }

.tnbh-root .tnbh-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tnbh-root .tnbh-title { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.2; color: var(--tnbh-fg); }
.tnbh-root .tnbh-x {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--tnbh-line);
  background: var(--tnbh-bg); color: var(--tnbh-fg); font-size: 22px; line-height: 1; cursor: pointer; padding: 0; margin: 0;
}
.tnbh-root .tnbh-x:hover { background: var(--tnbh-soft); }

.tnbh-root .tnbh-group { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; min-width: 0; }
.tnbh-root .tnbh-group legend {
  padding: 0; margin: 0 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .08em !important;
  text-transform: uppercase; color: var(--tnbh-muted);
}

/* Segmentierte Auswahl */
.tnbh-root .tnbh-seg { position: relative;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px;
  background: var(--tnbh-soft); border-radius: 12px; padding: 4px; margin: 0;
}
.tnbh-root .tnbh-seg input { position: absolute !important; opacity: 0 !important; width: 1px !important; height: 1px !important; margin: 0 !important; padding: 0 !important; border: 0 !important; clip-path: inset(50%) !important; appearance: none !important; -webkit-appearance: none !important; }
.tnbh-root .tnbh-seg input::before, .tnbh-root .tnbh-seg input::after { content: none !important; display: none !important; }
.tnbh-root .tnbh-seg label {
  display: flex; align-items: center; justify-content: center; min-height: 38px; margin: 0; padding: 4px 6px;
  border-radius: 9px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--tnbh-fg); text-align: center;
}
.tnbh-root .tnbh-seg input:checked + label { background: var(--tnbh-accent); color: var(--tnbh-on-accent); }
.tnbh-root .tnbh-sz label:nth-of-type(1) span:first-child { font-size: 13px; }
.tnbh-root .tnbh-sz label:nth-of-type(2) span:first-child { font-size: 16px; }
.tnbh-root .tnbh-sz label:nth-of-type(3) span:first-child { font-size: 19px; }
.tnbh-root .tnbh-sz label:nth-of-type(4) span:first-child { font-size: 23px; }
.tnbh-root .tnbh-sr {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* Schalter */
.tnbh-root .tnbh-switches { display: grid; margin: 0; }
.tnbh-root .tnbh-switch {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 0; margin: 0; border-top: 1px solid var(--tnbh-line); cursor: pointer; font-size: 15px; color: var(--tnbh-fg);
}
.tnbh-root .tnbh-switch:first-child { border-top: 0; }
.tnbh-root .tnbh-switch .tnbh-lbl { flex: 1 1 auto; }
/* Das echte Kontrollkästchen bleibt für Screenreader und Tastatur da, ist aber unsichtbar.
   Sichtbar ist nur die Schiene (span). So können Theme-Stile für Checkboxen nichts verbiegen. */
.tnbh-root .tnbh-switch input[type="checkbox"] {
  position: absolute !important; width: 1px !important; height: 1px !important; margin: -1px !important; padding: 0 !important;
  overflow: hidden !important; clip: rect(0 0 0 0) !important; clip-path: inset(50%) !important; border: 0 !important;
  opacity: 0 !important; appearance: none !important; -webkit-appearance: none !important;
}
.tnbh-root .tnbh-switch input[type="checkbox"]::before,
.tnbh-root .tnbh-switch input[type="checkbox"]::after { content: none !important; display: none !important; }
.tnbh-root .tnbh-switch .tnbh-track {
  display: block !important; flex: 0 0 44px !important; position: relative !important;
  width: 44px !important; min-width: 44px !important; height: 26px !important; margin: 0 !important; padding: 0 !important;
  border-radius: 999px !important; background: #c9cdd6 !important; transition: background .2s;
}
.tnbh-root .tnbh-switch .tnbh-track::after {
  content: "" !important; position: absolute !important; top: 3px !important; left: 3px !important;
  width: 20px !important; height: 20px !important; border-radius: 50% !important;
  background: #fff !important; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s;
}
.tnbh-root .tnbh-switch input:checked + .tnbh-track { background: var(--tnbh-accent) !important; }
.tnbh-root .tnbh-switch input:checked + .tnbh-track::after { transform: translateX(18px); }

/* Knöpfe */
.tnbh-root .tnbh-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tnbh-root .tnbh-btn {
  display: inline-flex; align-items: center; justify-content: center; margin: 0;
  min-height: 38px; padding: 6px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--tnbh-line); background: var(--tnbh-bg); color: var(--tnbh-fg);
  font: 600 14px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
.tnbh-root .tnbh-btn:hover { background: var(--tnbh-soft); }
.tnbh-root .tnbh-btn[disabled] { opacity: .45; cursor: default; }
.tnbh-root .tnbh-primary { background: var(--tnbh-accent); color: var(--tnbh-on-accent); border-color: var(--tnbh-accent); }
.tnbh-root .tnbh-primary:hover { background: var(--tnbh-accent); filter: brightness(1.08); }
.tnbh-root .tnbh-note { margin: 0; font-size: 13px; color: var(--tnbh-muted); }
.tnbh-root .tnbh-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 12.5px; color: var(--tnbh-muted); border-top: 1px solid var(--tnbh-line); padding-top: 12px;
}

/* Profile, Unterüberschriften, Auswahlfeld, Seitenübersicht */
.tnbh-root .tnbh-sub { margin: 4px 0 0; font-size: 13px; font-weight: 600; color: var(--tnbh-fg); }
.tnbh-root .tnbh-profiles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tnbh-root .tnbh-profiles .tnbh-btn { border-radius: 10px; justify-content: flex-start; text-align: left; }
.tnbh-root .tnbh-profiles .tnbh-btn[aria-pressed="true"] { background: var(--tnbh-accent); color: var(--tnbh-on-accent); border-color: var(--tnbh-accent); }
.tnbh-root .tnbh-selectrow {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0;
  padding: 9px 0 0; border-top: 1px solid var(--tnbh-line); font-size: 15px; color: var(--tnbh-fg);
}
.tnbh-root .tnbh-selectrow select {
  max-width: 60%; min-height: 36px; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--tnbh-line);
  background: var(--tnbh-bg); color: var(--tnbh-fg); font: 500 14px system-ui, sans-serif;
}
.tnbh-root .tnbh-wide { width: 100%; margin-top: 6px; }
.tnbh-root .tnbh-outline { list-style: none; margin: 6px 0 0; padding: 6px; max-height: 240px; overflow: auto; border: 1px solid var(--tnbh-line); border-radius: 10px; }
.tnbh-root .tnbh-outline li { margin: 0; padding: 0; }
.tnbh-root .tnbh-outline button {
  display: block; width: 100%; text-align: left; padding: 6px 8px; margin: 0; border: 0; border-radius: 6px;
  background: none; color: var(--tnbh-fg); font: 500 14px/1.3 system-ui, sans-serif; cursor: pointer;
}
.tnbh-root .tnbh-outline button:hover { background: var(--tnbh-soft); }
.tnbh-root .tnbh-outline small { color: var(--tnbh-muted); font-weight: 700; margin-right: 6px; }
.tnbh-root .tnbh-outline .tnbh-lm { color: var(--tnbh-accent); }

/* Ebenen: Blaufilter, Leselinie, Lesemaske */
.tnbh-root .tnbh-bluelayer, .tnbh-root .tnbh-guide, .tnbh-root .tnbh-mask { display: none; position: fixed; pointer-events: none; margin: 0; padding: 0; }
html.tnbh-blue .tnbh-root .tnbh-bluelayer {
  display: block; inset: 0; z-index: 2147482990; background: rgba(255, 150, 40, .22); mix-blend-mode: multiply;
}
html.tnbh-guide .tnbh-root .tnbh-guide {
  display: block; left: 0; right: 0; top: 50%; height: 10px; margin-top: -5px; z-index: 2147482995;
  background: var(--tnbh-accent); opacity: .55; border-top: 2px solid #000; border-bottom: 2px solid #000;
}
html.tnbh-mask .tnbh-root .tnbh-mask { display: block; left: 0; right: 0; z-index: 2147482994; background: rgba(0, 0, 0, .62); }
.tnbh-root .tnbh-mask-top { top: 0; height: calc(50% - 60px); }
.tnbh-root .tnbh-mask-bottom { bottom: 0; top: calc(50% + 60px); }

/* Vorlese-Leiste */
.tnbh-root .tnbh-player {
  position: fixed; z-index: 2147483002; left: 50%; transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 8px; max-width: calc(100vw - 24px);
  padding: 8px 8px 8px 16px; border-radius: 999px;
  background: var(--tnbh-bg); color: var(--tnbh-fg); border: 1px solid var(--tnbh-line);
  box-shadow: 0 12px 34px rgba(0, 0, 0, .3); font-size: 14px;
}
.tnbh-root .tnbh-player span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Shortcode-Knopf */
.tnbh-open {
  cursor: pointer; font: inherit; color: inherit; background: none; border: 0; padding: 0;
  text-decoration: underline; text-underline-offset: .2em;
}

/* Sprunglink */
.tnbh-skip {
  position: fixed !important; left: 12px; top: -80px; z-index: 2147483003;
  padding: 12px 18px; border-radius: 10px; font: 700 16px/1.2 system-ui, sans-serif;
  background: var(--tnbh-accent); color: var(--tnbh-on-accent); text-decoration: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
}
.tnbh-skip:focus { top: 12px; outline: 3px solid var(--tnbh-on-accent); outline-offset: -6px; }

/* Smartphones */
@media (max-width: 600px) {
  .tnbh-root[data-mobile="0"] { display: none !important; }
  .tnbh-root .tnbh-panel {
    left: 8px !important; right: 8px !important; top: auto !important; bottom: 8px !important;
    transform: none !important; width: auto; max-height: 78vh; border-radius: 18px;
  }
}

/* ---------- Wirkung auf die Website ---------- */

/* Hoher Kontrast */
html.tnbh-contrast body,
html.tnbh-contrast body *:not(.tnbh-root):not(.tnbh-root *):not(.tnbh-skip):not(img):not(video):not(svg):not(svg *):not(picture) {
  background-color: #000 !important; color: #fff !important; border-color: #fff !important;
  text-shadow: none !important; box-shadow: none !important;
}
html.tnbh-contrast body *:not(.tnbh-root):not(.tnbh-root *):not(img):not(video):not(picture) { background-image: none !important; }
/* :not(#tnbh-x) erhöht nur die Spezifität, damit Links gelb bleiben */
html.tnbh-contrast body a:not(.tnbh-root a):not(.tnbh-skip):not(#tnbh-x),
html.tnbh-contrast body a:not(.tnbh-root a):not(#tnbh-x) * { color: #ffe100 !important; }
html.tnbh-contrast body button:not(.tnbh-root button),
html.tnbh-contrast body input:not(.tnbh-root input),
html.tnbh-contrast body select, html.tnbh-contrast body textarea { border: 2px solid #fff !important; }
html.tnbh-contrast body svg:not(.tnbh-root svg) { filter: invert(1) grayscale(1) contrast(2); }
html.tnbh-contrast body svg:not(.tnbh-root svg) svg { filter: none; }

/* Filter (Graustufen, Nachtmodus, Farbkorrektur) – zusammengesetzt per JavaScript */
/* Filter auf <html>: Nur dort bleiben fest positionierte Elemente (Menü, Kopfzeilen des Themes) am Bildschirm verankert. */
html.tnbh-filtered { filter: var(--tnbh-filter) !important; }
html.tnbh-night { background-color: #fff; }
/* Bedienhilfen selbst im Nachtmodus zurückdrehen, damit das Menü normal aussieht */
html.tnbh-night .tnbh-root > * { filter: invert(1) hue-rotate(180deg) !important; }
/* Nachtmodus: Bilder und Videos zurückdrehen, damit sie echt aussehen */
html.tnbh-night body img:not(.tnbh-root img),
html.tnbh-night body picture, html.tnbh-night body video,
html.tnbh-night body iframe, html.tnbh-night body canvas:not(.tnbh-root canvas) { filter: invert(1) hue-rotate(180deg) !important; }
html.tnbh-night body picture img { filter: none !important; }

/* Seitenzoom */
html.tnbh-zoomed body > *:not(.tnbh-root):not(.tnbh-skip) { zoom: var(--tnbh-zoom) !important; }

/* Bilder ausblenden */
html.tnbh-noimg body img:not(.tnbh-root img),
html.tnbh-noimg body picture, html.tnbh-noimg body video,
html.tnbh-noimg body svg[role="img"]:not(.tnbh-root svg) { visibility: hidden !important; }
html.tnbh-noimg body *:not(.tnbh-root):not(.tnbh-root *) { background-image: none !important; }

/* Tastaturfokus hervorheben */
html.tnbh-focus body *:focus-visible,
html.tnbh-focus body *:focus:not(.tnbh-root *) {
  outline: 4px solid var(--tnbh-accent) !important; outline-offset: 3px !important;
  box-shadow: 0 0 0 7px #fff, 0 0 0 9px #000 !important;
}

/* Gut lesbare Schrift */
html.tnbh-font body *:not(.tnbh-root):not(.tnbh-root *):not(i):not(code):not(pre):not(kbd):not([class*="icon"]):not([class*="Icon"]):not([class^="fa"]):not([class*=" fa"]):not(.dashicons):not([aria-hidden="true"]) {
  font-family: "TNBH Lesbar", Verdana, Tahoma, sans-serif !important;
}

/* Mehr Abstand (Werte nach WCAG 1.4.12) */
html.tnbh-spacing body *:not(.tnbh-root):not(.tnbh-root *) {
  line-height: 1.6 !important; letter-spacing: .12em !important; word-spacing: .16em !important;
}
html.tnbh-spacing body p:not(.tnbh-root p) { margin-bottom: 2em !important; }

/* Links hervorheben */
html.tnbh-links body a:not(.tnbh-root a):not(.tnbh-skip) {
  text-decoration: underline !important; text-decoration-thickness: 2px !important; text-underline-offset: .2em !important;
}
html.tnbh-links body a:not(.tnbh-root a):hover,
html.tnbh-links body a:not(.tnbh-root a):focus {
  outline: 3px solid var(--tnbh-accent) !important; outline-offset: 2px !important;
}

/* Animationen anhalten */
html.tnbh-motion *, html.tnbh-motion *::before, html.tnbh-motion *::after {
  animation-duration: 0s !important; animation-iteration-count: 1 !important;
  transition: none !important; scroll-behavior: auto !important;
}

/* Großer Mauszeiger */
html.tnbh-cursor, html.tnbh-cursor * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cpath d='M6 4l0 34 9-8 6 14 7-3-6-14 12 0z' fill='%23000' stroke='%23fff' stroke-width='3' stroke-linejoin='round'/%3E%3C/svg%3E") 6 4, auto !important;
}
html.tnbh-cursor a, html.tnbh-cursor a *, html.tnbh-cursor button, html.tnbh-cursor button *, html.tnbh-cursor label, html.tnbh-cursor [role="button"] {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cpath d='M18 22V8a3 3 0 016 0v12l1-1a3 3 0 015 0 3 3 0 015 1 3 3 0 015 2v10c0 7-5 12-12 12h-3c-4 0-7-2-9-5l-7-10a3 3 0 015-4l4 4z' fill='%23fff' stroke='%23000' stroke-width='2.5' stroke-linejoin='round'/%3E%3C/svg%3E") 18 6, pointer !important;
}

/* Vorlesen: aktueller Absatz */
.tnbh-reading {
  outline: 3px solid var(--tnbh-accent) !important; outline-offset: 4px !important;
  border-radius: 4px; scroll-margin: 30vh;
}

@media (prefers-reduced-motion: reduce) {
  .tnbh-root .tnbh-fab, .tnbh-root .tnbh-switch .tnbh-track, .tnbh-root .tnbh-switch .tnbh-track::after { transition: none; }
}
