/* ============================================
   DKSB Euskirchen - Accessibility Styles
   WCAG 2.1 AA Compliant
   ============================================ */

/* === Skip Links (WCAG 2.4.1) === */
.skip-links {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10000;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--primary-blue);
    color: white;
    padding: 12px 24px;
    text-decoration: none;
    font-weight: 700;
    font-size: 16px;
    border-radius: 0 0 8px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    transition: left 0.1s ease;
}

.skip-link:focus {
    left: 0;
    outline: 3px solid var(--primary-orange);
    outline-offset: 2px;
}

/* === Focus Styles (WCAG 2.4.7) === */
*:focus {
    outline: 3px solid var(--primary-orange);
    outline-offset: 2px;
}

*:focus:not(:focus-visible) {
    outline: none;
}

*:focus-visible {
    outline: 3px solid var(--primary-orange);
    outline-offset: 2px;
}

/* Button Focus */
.btn:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-outline:focus-visible,
.btn-donate:focus-visible {
    outline: 3px solid var(--primary-orange);
    outline-offset: 3px;
    box-shadow: 0 0 0 6px rgba(236, 124, 50, 0.3);
}

/* Link Focus */
a:focus-visible {
    outline: 3px solid var(--primary-orange);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Form Input Focus */
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 3px solid var(--primary-blue);
    outline-offset: 0;
    border-color: var(--primary-blue);
}

/* === Accessibility Widget === */
.a11y-widget {
    position: fixed;
    bottom: 100px;
    right: 30px;
    z-index: 9998;
}

/* Beim offenen Mobile-Menü ausblenden (sonst Überlappung mit Slide-In-Menu von rechts) */
body.menu-open .a11y-widget {
    display: none;
}

.a11y-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-blue);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(0, 100, 173, 0.4);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.a11y-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 100, 173, 0.5);
}

.a11y-toggle:focus-visible {
    outline: 3px solid var(--primary-orange);
    outline-offset: 3px;
}

.a11y-toggle svg {
    width: 28px;
    height: 28px;
}

/* Widget Panel */
.a11y-panel {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 320px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    padding: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: all 0.3s ease;
    overflow: hidden;
}

.a11y-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Panel Header */
.a11y-panel-header {
    background: var(--primary-blue);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.a11y-panel-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: white;
}

.a11y-close {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.a11y-close:hover {
    background: rgba(255,255,255,0.2);
}

.a11y-close:focus-visible {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* Panel Content */
.a11y-panel-content {
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
}

/* Option Group */
.a11y-option-group {
    margin-bottom: 20px;
}

.a11y-option-group:last-child {
    margin-bottom: 0;
}

.a11y-option-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 10px;
}

/* Font Size Control */
.a11y-font-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.a11y-font-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    background: white;
    cursor: pointer;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-dark);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.a11y-font-btn:hover {
    border-color: var(--primary-blue);
    color: var(--primary-blue);
}

.a11y-font-btn:focus-visible {
    outline: 3px solid var(--primary-orange);
    outline-offset: 2px;
}

.a11y-font-size {
    flex: 1;
    text-align: center;
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-blue);
}

/* Toggle Buttons */
.a11y-toggle-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.a11y-toggle-btn {
    flex: 1;
    min-width: 80px;
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: white;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-dark);
    transition: all 0.2s ease;
    text-align: center;
}

.a11y-toggle-btn:hover {
    border-color: var(--primary-blue);
}

.a11y-toggle-btn:focus-visible {
    outline: 3px solid var(--primary-orange);
    outline-offset: 2px;
}

.a11y-toggle-btn.active {
    background: var(--primary-blue);
    border-color: var(--primary-blue);
    color: white;
}

/* Reset Button */
.a11y-reset {
    width: 100%;
    padding: 12px;
    margin-top: 15px;
    border: none;
    border-radius: 8px;
    background: var(--bg-light);
    color: var(--text-dark);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.a11y-reset:hover {
    background: var(--primary-orange);
    color: white;
}

.a11y-reset:focus-visible {
    outline: 3px solid var(--primary-orange);
    outline-offset: 2px;
}

/* === Accessibility Modifications === */

/* Font Size Adjustments - zoom auf page-wrapper für konsistente Skalierung
   Funktioniert mit allen Einheiten (px, rem, em) */
body.a11y-font-110 .page-wrapper {
    zoom: 1.1;
    -moz-transform: scale(1.1);
    -moz-transform-origin: top left;
}

body.a11y-font-120 .page-wrapper {
    zoom: 1.2;
    -moz-transform: scale(1.2);
    -moz-transform-origin: top left;
}

body.a11y-font-130 .page-wrapper {
    zoom: 1.3;
    -moz-transform: scale(1.3);
    -moz-transform-origin: top left;
}

body.a11y-font-140 .page-wrapper {
    zoom: 1.4;
    -moz-transform: scale(1.4);
    -moz-transform-origin: top left;
}

body.a11y-font-150 .page-wrapper {
    zoom: 1.5;
    -moz-transform: scale(1.5);
    -moz-transform-origin: top left;
}

/* High Contrast Mode */
body.a11y-high-contrast {
    --text-dark: #000000;
    --text-medium: #000000;
    --text-light: #333333;
    --bg-white: #ffffff;
    --bg-light: #f0f0f0;
    --border-color: #000000;
}

body.a11y-high-contrast * {
    border-color: #000000 !important;
}

body.a11y-high-contrast a {
    text-decoration: underline !important;
}

body.a11y-high-contrast img {
    filter: contrast(1.2);
}

/* Inverted Colors - auf .page-wrapper anwenden, nicht body!
   Grund: filter auf body erstellt neuen Stacking Context,
   wodurch position:fixed Elemente verschoben werden */
body.a11y-inverted .page-wrapper {
    -webkit-filter: invert(1) hue-rotate(180deg) !important;
    filter: invert(1) hue-rotate(180deg) !important;
    background-color: #fff !important;
}

body.a11y-inverted .page-wrapper img,
body.a11y-inverted .page-wrapper video,
body.a11y-inverted .page-wrapper iframe {
    -webkit-filter: invert(1) hue-rotate(180deg);
    filter: invert(1) hue-rotate(180deg);
}

/* Widget und Sidebar bleiben außerhalb des page-wrapper,
   daher werden sie NICHT vom filter erfasst.
   Keine zusätzliche CSS-Regel nötig - sie sind im DOM außerhalb! */

/* Increased Line Height */
body.a11y-line-height {
    line-height: 2 !important;
}

body.a11y-line-height p,
body.a11y-line-height li,
body.a11y-line-height span,
body.a11y-line-height div {
    line-height: 2 !important;
}

/* Highlight Links */
body.a11y-highlight-links a {
    background: yellow !important;
    color: #000000 !important;
    padding: 2px 4px;
    text-decoration: underline !important;
}

body.a11y-highlight-links a:hover {
    background: var(--primary-orange) !important;
    color: white !important;
}

/* Big Cursor */
body.a11y-big-cursor,
body.a11y-big-cursor * {
    cursor: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24"><path fill="%23000" stroke="%23fff" stroke-width="1" d="M5.5 3.21V20.8l5.04-5.04h7.25L5.5 3.21z"/></svg>') 0 0, auto !important;
}

/* Stop Animations */
body.a11y-stop-animations *,
body.a11y-stop-animations *::before,
body.a11y-stop-animations *::after {
    animation: none !important;
    transition: none !important;
}

/* Reading Guide (requires JS) */
.a11y-reading-guide {
    position: fixed;
    left: 0;
    right: 0;
    height: 40px;
    background: rgba(255, 255, 0, 0.3);
    pointer-events: none;
    z-index: 9997;
    display: none;
}

body.a11y-reading-guide-active .a11y-reading-guide {
    display: block;
}

/* === Screen Reader Only (Visually Hidden) === */
.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;
}

/* === Scroll-Stabilisierung für Filter-Wechsel === */
body.a11y-inverted,
body.a11y-high-contrast {
    scroll-behavior: auto !important;
}

/* === Reduced Motion Preference === */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* === High Contrast Mode Preference === */
@media (prefers-contrast: more) {
    :root {
        --text-dark: #000000;
        --text-medium: #000000;
        --border-color: #000000;
    }

    * {
        border-color: #000000 !important;
    }
}

/* === Mobile Adjustments === */
@media (max-width: 768px) {
    .a11y-widget {
        bottom: 90px;
        right: 15px;
    }

    .a11y-toggle {
        width: 50px;
        height: 50px;
    }

    .a11y-toggle svg {
        width: 24px;
        height: 24px;
    }

    .a11y-panel {
        width: calc(100vw - 30px);
        right: 0;
        bottom: 65px;
        max-width: 320px;
    }

    .a11y-panel-content {
        max-height: 300px;
    }
}
