/**
 * Accessibility Enhancements (WCAG 2.1 AA)
 * Verbesserte Barrierefreiheit für KDV-Website
 */

/* ================================
   Screen Reader Only Content
   ================================ */
.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;
}

/* Fokussierbar für Tastaturnutzer */
.sr-only-focusable:focus,
.sr-only-focusable:active {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* ================================
   Skip Links
   ================================ */
.skip-link {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    padding: var(--spacing-md, 1rem) var(--spacing-lg, 1.5rem);
    background: var(--color-primary, #C41E68);
    color: white;
    font-weight: 600;
    border-radius: var(--radius-md, 0.5rem);
    z-index: 10000;
    text-decoration: none;
    transition: top 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.skip-link:focus {
    top: var(--spacing-md, 1rem);
    outline: 3px solid var(--color-accent, #F5A623);
    outline-offset: 2px;
}

/* Mehrere Skip-Links untereinander */
.skip-link:nth-of-type(2):focus {
    top: calc(var(--spacing-md, 1rem) + 50px);
}

.skip-link:nth-of-type(3):focus {
    top: calc(var(--spacing-md, 1rem) + 100px);
}

/* ================================
   Focus Management
   ================================ */

/* Verbesserte Fokus-Sichtbarkeit */
*:focus-visible {
    outline: 3px solid var(--color-primary, #C41E68);
    outline-offset: 2px;
}

/* Fokus für Maus-User ausblenden */
*:focus:not(:focus-visible) {
    outline: none;
}

/* Interaktive Elemente */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--color-accent, #F5A623);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(245, 166, 35, 0.3);
}

/* Buttons mit Hintergrund */
.btn:focus-visible,
.btn-primary:focus-visible,
.btn-gradient:focus-visible {
    outline-color: white;
    box-shadow:
        0 0 0 3px var(--color-primary, #C41E68),
        0 0 0 6px rgba(245, 166, 35, 0.5);
}

/* Fokus auf dunklem Hintergrund */
.dark-bg *:focus-visible,
.hero *:focus-visible,
footer *:focus-visible {
    outline-color: var(--color-accent, #F5A623);
}

/* ================================
   Keyboard Navigation Indicators
   ================================ */

/* Zeigt an, dass Element keyboard-fokussiert werden kann */
[tabindex="0"],
[role="button"],
[role="link"],
[role="tab"],
[role="checkbox"],
[role="menuitem"] {
    cursor: pointer;
}

/* Deaktivierte Elemente */
[aria-disabled="true"],
[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ================================
   Color Contrast Improvements
   ================================ */

/* Mindestkontrast für Text */
.text-muted,
.text-light {
    color: #595959; /* Minimum 4.5:1 auf weiß */
}

/* Links mit besserer Sichtbarkeit - Navigation ausgenommen */
a:not(.btn):not(.nav-link):not(.logo):not(.skip-link) {
    text-decoration: underline;
    text-decoration-color: currentColor;
    text-underline-offset: 2px;
}

a:not(.btn):not(.nav-link):not(.logo):not(.skip-link):hover {
    text-decoration-thickness: 2px;
}

/* Navigation Links - keine Unterstreichung */
.nav-link {
    text-decoration: none !important;
}

/* Placeholder Kontrast verbessern */
::placeholder {
    color: #6B7280; /* WCAG AA konform */
    opacity: 1;
}

/* ================================
   Touch Target Sizes
   ================================ */

/* Mindestens 44x44px für Touch (Apple HIG, WCAG) */
button,
a.btn,
input[type="checkbox"],
input[type="radio"],
.clickable,
[role="button"] {
    min-width: 44px;
    min-height: 44px;
}

/* Checkbox/Radio visuell größer */
input[type="checkbox"],
input[type="radio"] {
    width: 20px;
    height: 20px;
}

/* Ausreichender Abstand zwischen Touch-Targets */
.tab-actions .btn + .btn,
.tab-actions button + button {
    margin-left: 0.5rem;
}

@media (max-width: 768px) {
    button,
    a.btn,
    .clickable {
        min-height: 48px;
        padding: 0.75rem 1rem;
    }
}

/* ================================
   Text Sizing & Readability
   ================================ */

/* Unterstützt Browser-Zoom bis 400% */
html {
    font-size: 100%; /* Respektiert User-Einstellungen */
}

/* Fluid Typography für bessere Lesbarkeit */
body {
    font-size: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
    line-height: 1.6;
}

/* Absatzabstände für bessere Lesbarkeit */
p {
    max-width: 75ch; /* Optimale Lesebreite */
}

/* Überschriften-Hierarchie */
h1, h2, h3, h4, h5, h6 {
    line-height: 1.3;
}

/* ================================
   Motion & Animation Control
   ================================ */

/* Respektiert Präferenz für reduzierte Bewegung */
@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;
    }

    /* Entferne Parallax-Effekte */
    .parallax,
    [data-parallax] {
        transform: none !important;
    }

    /* Entferne Auto-Scroll */
    .auto-scroll,
    .marquee {
        animation: none !important;
    }
}

/* ================================
   High Contrast Mode
   ================================ */

@media (prefers-contrast: high) {
    :root {
        --color-text: #000000;
        --color-background: #FFFFFF;
        --color-border: #000000;
    }

    /* Verstärkte Ränder */
    button,
    input,
    textarea,
    select {
        border-width: 2px;
        border-color: #000000;
    }

    /* Fokus noch sichtbarer */
    *:focus-visible {
        outline-width: 4px;
        outline-color: #000000;
    }

    /* Links unterstrichen */
    a {
        text-decoration: underline;
        text-decoration-thickness: 2px;
    }

    /* Buttons mit starkem Kontrast */
    .btn-primary,
    .btn-gradient {
        background: #000000;
        border-color: #000000;
        color: #FFFFFF;
    }

    .btn-secondary {
        background: #FFFFFF;
        border-width: 3px;
        border-color: #000000;
        color: #000000;
    }
}

/* ================================
   Color Blindness Support
   ================================ */

/* Nicht nur auf Farbe verlassen - zusätzliche Indikatoren */
.success-indicator::before {
    content: '✓ ';
}

.error-indicator::before {
    content: '✗ ';
}

.warning-indicator::before {
    content: '⚠ ';
}

.info-indicator::before {
    content: 'ℹ ';
}

/* Required Felder mit Icon */
.required-indicator::after {
    content: ' *';
    color: inherit;
}

/* ================================
   ARIA Live Regions
   ================================ */

/* Visuelle Hinweise für Live-Regions */
[aria-live="polite"],
[aria-live="assertive"],
[role="status"],
[role="alert"] {
    /* Sicherstellen, dass sie nicht versteckt sind */
    visibility: visible;
}

[role="alert"] {
    /* Wichtige Meldungen hervorheben */
    padding: 1rem;
    border-left: 4px solid var(--color-danger, #DC2626);
    background: rgba(220, 38, 38, 0.1);
    margin: 1rem 0;
}

/* ================================
   Form Accessibility
   ================================ */

/* Labels immer sichtbar */
label {
    display: block;
    margin-bottom: 0.5rem;
}

/* Pflichtfeld-Kennzeichnung */
label[data-required]::after,
.required::after {
    content: ' (Pflichtfeld)';
    color: var(--color-danger, #DC2626);
    font-size: 0.875em;
}

/* Fehlertext mit Icon */
.error-message,
[role="alert"] {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.error-message::before {
    content: '⚠';
    flex-shrink: 0;
}

/* Fieldset und Legend für Gruppen */
fieldset {
    border: 1px solid var(--color-border, #E5E7EB);
    border-radius: var(--radius-md, 0.5rem);
    padding: 1rem;
    margin-bottom: 1.5rem;
}

legend {
    font-weight: 600;
    padding: 0 0.5rem;
}

/* ================================
   Table Accessibility
   ================================ */

table {
    border-collapse: collapse;
    width: 100%;
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border, #E5E7EB);
}

th {
    background: var(--color-background, #F9F9F9);
    font-weight: 600;
}

/* Zebrastreifen für bessere Lesbarkeit */
tbody tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.02);
}

/* Hover-State für Zeilen */
tbody tr:hover {
    background: rgba(196, 30, 104, 0.05);
}

/* Caption für Screen Reader */
caption {
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-align: left;
}

/* ================================
   Media Accessibility
   ================================ */

/* Bilder mit Alt-Text-Indikator (Development) */
img:not([alt]) {
    outline: 3px dashed var(--color-danger, #DC2626);
}

/* Video/Audio Controls immer sichtbar */
video,
audio {
    width: 100%;
}

video:focus,
audio:focus {
    outline: 3px solid var(--color-primary, #C41E68);
    outline-offset: 2px;
}

/* ================================
   Print Styles für Accessibility
   ================================ */

@media print {
    /* Links mit URL anzeigen */
    a[href]::after {
        content: ' (' attr(href) ')';
        font-size: 0.8em;
        color: #666;
    }

    /* Keine dekorativen Elemente drucken */
    .decorative,
    [role="presentation"],
    [aria-hidden="true"] {
        display: none !important;
    }

    /* Kontrast für Druck optimieren */
    body {
        color: #000;
        background: #fff;
    }
}
