/* =====================================================
   Globale Hilfsklassen (auf allen Seiten verfügbar)
===================================================== */

/* Visuell versteckter Text für Screenreader (WCAG 1.3.1) */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Skip-Link (WCAG 2.4.1) */
.skip-link {
    position: absolute;
    top: -9999px;
    left: 6px;
    z-index: 99998;
    background: #003a76;
    color: #fff;
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 0 0 4px 4px;
    text-decoration: none;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid #ffcc00;
    outline-offset: 3px;
}

/* =====================================================
   Accessibility Widget – Barrierefreiheits-Einstellungen
   WCAG 1.4.3 Kontrast (AA/AAA), 1.4.4 Textgröße (AA),
   1.4.6 Kontrast (Erweitert) (AAA)
===================================================== */

/* --- Widget Region --- */
/* !important verhindert, dass jQuery-Scroll-Plugins
   (nicescroll etc.) position:fixed überschreiben */
#a11y-widget {
    position: fixed !important;
    right: 0 !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 99999 !important;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;
    line-height: 1.4;
    /* Eigene Scroll- und Transform-Ebene → nie durch
       Parent-Transforms beeinflusst */
    will-change: transform;
    isolation: isolate;
}

/* --- Toggle-Button --- */
#a11y-toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #003a76;
    color: #fff;
    border: 3px solid #fff;
    border-right: none;
    padding: 12px 9px;
    cursor: pointer;
    border-radius: 8px 0 0 8px;
    box-shadow: -3px 3px 10px rgba(0,0,0,0.35);
    min-width: 44px;
    min-height: 88px;
    transition: background 0.2s;
}

#a11y-toggle:hover {
    background: #003a76;
}

#a11y-toggle:focus-visible {
    outline: 3px solid #ffcc00;
    outline-offset: 3px;
}

.a11y-toggle-icon {
    font-size: 1.375rem;
    font-weight: 900;
    line-height: 1;
    pointer-events: none;
}

.a11y-toggle-text {
    font-size: 0.5rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    pointer-events: none;
    writing-mode: vertical-lr;
    text-orientation: mixed;
    transform: rotate(180deg);
}

/* --- Panel --- */
#a11y-panel {
    position: absolute;
    top: 50%;
    right: calc(100% + 3px);
    transform: translateY(-50%);
    background: #fff;
    color: #1a1a1a;
    border: 2px solid #003a76;
    border-radius: 8px;
    padding: 1rem 1.125rem 1.125rem;
    min-width: 264px;
    box-shadow: -4px 4px 18px rgba(0,0,0,0.22);
}

#a11y-panel[hidden] {
    display: none;
}

/* Panel-Kopfzeile */
#a11y-panel-heading {
    font-size: 0.9375rem;
    font-weight: 700;
    color: #003a76;
    margin: 0 1.5rem 0.875rem 0;
    padding-bottom: 0.625rem;
    border-bottom: 2px solid #dde3ec;
}

/* Schließen-Button */
#a11y-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: transparent;
    border: 2px solid transparent;
    color: #555;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 4px;
    min-width: 32px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#a11y-close:hover {
    color: #1a1a1a;
    border-color: #999;
}

#a11y-close:focus-visible {
    outline: 3px solid #005fcc;
    outline-offset: 2px;
}

/* Gruppen */
.a11y-group {
    margin-bottom: 0.875rem;
}

.a11y-group:last-of-type {
    margin-bottom: 0;
}

.a11y-group-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: #555;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Button-Reihe */
.a11y-btn-row {
    display: flex;
    gap: 5px;
}

.a11y-btn {
    flex: 1;
    min-height: 44px;
    padding: 0.375rem 0.25rem;
    border: 2px solid #c0c8d8;
    background: #f4f6fa;
    color: #1a1a1a;
    cursor: pointer;
    border-radius: 5px;
    font-weight: 700;
    text-align: center;
    line-height: 1.2;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.a11y-btn:hover {
    border-color: #003a76;
    background: #e4edff;
}

.a11y-btn:focus-visible {
    outline: 3px solid #003a76;
    outline-offset: 2px;
}

.a11y-btn[aria-pressed="true"] {
    background: #003a76;
    color: #fff;
    border-color: #002a55;
}

/* Schriftgrößen-Buttons – optische Staffelung */
.a11y-sz-1 { font-size: 0.6875rem; }
.a11y-sz-2 { font-size: 0.875rem;  }
.a11y-sz-3 { font-size: 1.0625rem; }
.a11y-sz-4 { font-size: 1.25rem;   }
.a11y-sz-5 { font-size: 1.4375rem; }

/* Status-Anzeige Schriftgröße */
.a11y-size-status {
    text-align: center;
    font-size: 0.75rem;
    color: #666;
    margin-top: 0.3rem;
    min-height: 1.2em;
}

/* Trennlinie */
.a11y-divider {
    border: none;
    border-top: 1px solid #dde3ec;
    margin: 0.75rem 0;
}

/* Alles-zurücksetzen */
.a11y-reset {
    width: 100%;
    min-height: 40px;
    padding: 0.375rem 0.75rem;
    background: transparent;
    border: 2px solid #aaa;
    color: #444;
    cursor: pointer;
    border-radius: 5px;
    font-size: 0.8125rem;
    font-weight: 700;
    transition: all 0.15s;
    margin-top: 0.375rem;
}

.a11y-reset:hover {
    background: #f0f0f0;
    border-color: #555;
    color: #1a1a1a;
}

.a11y-reset:focus-visible {
    outline: 3px solid #005fcc;
    outline-offset: 2px;
}

/* Responsive: Panel nach unten öffnen auf kleinen Screens */
@media (max-height: 480px) {
    #a11y-widget {
        top: auto;
        bottom: 4rem;
        transform: none;
    }
    #a11y-panel {
        top: auto;
        bottom: 0;
        transform: none;
    }
}

@media (max-width: 360px) {
    #a11y-panel {
        right: auto;
        left: 0;
        min-width: 0;
        width: calc(100vw - 56px);
    }
}

/* =====================================================
   KONTRAST-MODUS: DUNKEL (invertiert)
   Zuverlässig für beliebige Seiten – Medien bleiben
   durch gegenläufigen Filter unverändert.
===================================================== */
html[data-a11y-contrast="dark"] body {
    filter: invert(1) hue-rotate(180deg);
    background-color: #000 !important;
}

/* Bilder, Videos und Canvas re-invertieren */
html[data-a11y-contrast="dark"] img,
html[data-a11y-contrast="dark"] video,
html[data-a11y-contrast="dark"] canvas:not(#raincanvas),
html[data-a11y-contrast="dark"] iframe,
html[data-a11y-contrast="dark"] svg:not(.a11y-svg) {
    filter: invert(1) hue-rotate(180deg);
}

/* Widget re-invertieren – bleibt visuell unverändert */
html[data-a11y-contrast="dark"] #a11y-widget {
    filter: invert(1) hue-rotate(180deg);
}

/* =====================================================
   KONTRAST-MODUS: HELL (Farben verstärkt)
   Erzwingt sehr hohen Kontrast auf hellem Hintergrund.
===================================================== */
html[data-a11y-contrast="light"] body,
html[data-a11y-contrast="light"] .wrapper,
html[data-a11y-contrast="light"] header,
html[data-a11y-contrast="light"] main,
html[data-a11y-contrast="light"] footer,
html[data-a11y-contrast="light"] section,
html[data-a11y-contrast="light"] nav,
html[data-a11y-contrast="light"] div,
html[data-a11y-contrast="light"] article,
html[data-a11y-contrast="light"] aside {
    background-color: #fff !important;
    background-image: none !important;
    color: #000 !important;
}

html[data-a11y-contrast="light"] p,
html[data-a11y-contrast="light"] h1,
html[data-a11y-contrast="light"] h2,
html[data-a11y-contrast="light"] h3,
html[data-a11y-contrast="light"] h4,
html[data-a11y-contrast="light"] h5,
html[data-a11y-contrast="light"] h6,
html[data-a11y-contrast="light"] li,
html[data-a11y-contrast="light"] span,
html[data-a11y-contrast="light"] address,
html[data-a11y-contrast="light"] time,
html[data-a11y-contrast="light"] label {
    color: #000 !important;
}

html[data-a11y-contrast="light"] a,
html[data-a11y-contrast="light"] a:visited {
    color: #00008b !important;
    text-decoration: underline !important;
    font-weight: 700 !important;
}

html[data-a11y-contrast="light"] a:hover,
html[data-a11y-contrast="light"] a:focus {
    color: #000066 !important;
    outline: 3px solid #000 !important;
    outline-offset: 2px !important;
}

/* Buttons im hellen Hochkontrast */
html[data-a11y-contrast="light"] .button,
html[data-a11y-contrast="light"] button:not(.a11y-btn):not(#a11y-toggle):not(#a11y-close):not(.a11y-reset):not(.acd-heading-btn) {
    background-color: #fff !important;
    color: #000 !important;
    border: 2px solid #000 !important;
}

/* Widget-eigene Elemente im hellen Hochkontrast */
html[data-a11y-contrast="light"] #a11y-toggle {
    background: #000 !important;
    color: #fff !important;
    border-color: #000 !important;
}

html[data-a11y-contrast="light"] #a11y-panel {
    background: #fff !important;
    border-color: #000 !important;
    color: #000 !important;
}

html[data-a11y-contrast="light"] #a11y-panel-heading {
    color: #000 !important;
    border-bottom-color: #000 !important;
}

html[data-a11y-contrast="light"] .a11y-group-label {
    color: #000 !important;
}

html[data-a11y-contrast="light"] .a11y-btn {
    background: #fff !important;
    color: #000 !important;
    border-color: #000 !important;
}

html[data-a11y-contrast="light"] .a11y-btn[aria-pressed="true"] {
    background: #000 !important;
    color: #fff !important;
    border-color: #000 !important;
}

html[data-a11y-contrast="light"] .a11y-reset {
    background: #fff !important;
    color: #000 !important;
    border-color: #000 !important;
}

html[data-a11y-contrast="light"] .a11y-divider {
    border-color: #000 !important;
}

html[data-a11y-contrast="light"] #a11y-close {
    color: #000 !important;
}

html[data-a11y-contrast="light"] .a11y-size-status {
    color: #000 !important;
}
