/*
Theme Name: WCAG Accessible Pro
Theme URI: https://werbeagentur-ice.de
Author: Werbeagentur ICE
Author URI: https://werbeagentur-ice.de
Description: Ein vollständig WCAG 2.1 AAA-konformes, lightweight WordPress-Theme mit 100% Barrierefreiheit, optimiert für Google Crawler und Core Web Vitals. Kompatibel mit Elementor und Elementor Pro.
Version: 1.0.0
Requires at least: 5.0
Tested up to: 6.4
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: wcag-accessible-pro
Tags: accessibility-ready, translation-ready, custom-menu, featured-images, threaded-comments, rtl-language-support, block-styles, wide-blocks, full-site-editing

WCAG Accessible Pro WordPress Theme
Copyright (C) 2025 Werbeagentur ICE

This theme is designed with accessibility as the primary focus:
- WCAG 2.1 Level AAA compliance
- Semantic HTML5 structure
- ARIA landmarks and attributes
- Keyboard navigation support
- Screen reader optimized
- High contrast mode support
- Focus management
- Skip links
- Optimized for Google Crawler and Core Web Vitals
*/

/* ==========================================================================
   1. CSS RESET & BASE STYLES (Lightweight & Performance-Optimized)
   ========================================================================== */

/* CRITICAL: Exclude WordPress Admin elements from reset */
body:not(.wp-admin) *:not(#wpadminbar):not(#wpadminbar *),
body:not(.wp-admin) *::before:not(#wpadminbar *),
body:not(.wp-admin) *::after:not(#wpadminbar *) {
    box-sizing: border-box !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* WordPress Admin Bar: Preserve default styles */
#wpadminbar,
#wpadminbar * {
    box-sizing: content-box;
    /* Do NOT reset margin/padding - let WordPress handle it */
}

html {
    font-size: 100%; /* 16px base - WCAG requirement for readability - NO !important to allow WCAG toolbar override */
    -webkit-text-size-adjust: 100% !important;
    -ms-text-size-adjust: 100% !important;
    scroll-behavior: smooth !important;
}

/* Only apply body styles to frontend, not admin */
body:not(.wp-admin) {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif !important;
    font-size: 1rem !important; /* 16px */
    line-height: 1.6 !important; /* WCAG 2.1 SC 1.4.8 - minimum 1.5 */
    color: #1a1a1a !important; /* WCAG AAA contrast ratio */
    background-color: #ffffff !important;
    font-weight: 400 !important;
    overflow-x: hidden !important;
    word-wrap: break-word !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
}

/* ==========================================================================
   2. SKIP LINKS (WCAG 2.1 SC 2.4.1 - Bypass Blocks)
   ========================================================================== */

.skip-link {
    position: absolute !important;
    top: -999px !important;
    left: -999px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    z-index: 999999 !important;
}

.skip-link:focus {
    position: fixed !important;
    top: 10px !important;
    left: 10px !important;
    width: auto !important;
    height: auto !important;
    padding: 15px 25px !important;
    background-color: #000000 !important;
    color: #ffffff !important;
    font-size: 1.125rem !important; /* 18px */
    font-weight: 700 !important;
    text-decoration: none !important;
    border-radius: 4px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
    z-index: 999999 !important;
    outline: 3px solid #ffcc00 !important;
    outline-offset: 2px !important;
}

/* ==========================================================================
   3. FOCUS STYLES (WCAG 2.1 SC 2.4.7 - Focus Visible)
   ========================================================================== */

/* Remove default focus outline on mouse click (exclude WordPress Admin Bar) */
body:not(.wp-admin) a:not(#wpadminbar a):focus,
body:not(.wp-admin) button:not(#wpadminbar button):focus,
body:not(.wp-admin) input:not(#wpadminbar input):focus,
body:not(.wp-admin) textarea:not(#wpadminbar textarea):focus,
body:not(.wp-admin) select:not(#wpadminbar select):focus,
body:not(.wp-admin) [tabindex]:not(#wpadminbar [tabindex]):focus {
    outline: none !important;
}

/* Show focus outline ONLY for keyboard navigation (modern browsers) */
body:not(.wp-admin) a:not(#wpadminbar a):focus-visible,
body:not(.wp-admin) button:not(#wpadminbar button):focus-visible,
body:not(.wp-admin) input:not(#wpadminbar input):focus-visible,
body:not(.wp-admin) textarea:not(#wpadminbar textarea):focus-visible,
body:not(.wp-admin) select:not(#wpadminbar select):focus-visible,
body:not(.wp-admin) [tabindex]:not(#wpadminbar [tabindex]):focus-visible {
    outline: 3px solid #0066cc !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 4px rgba(0, 102, 204, 0.2) !important;
}

/* Fallback for older browsers: use .user-is-tabbing class from accessibility.js */
body.user-is-tabbing:not(.wp-admin) a:not(#wpadminbar a):focus,
body.user-is-tabbing:not(.wp-admin) button:not(#wpadminbar button):focus,
body.user-is-tabbing:not(.wp-admin) input:not(#wpadminbar input):focus,
body.user-is-tabbing:not(.wp-admin) textarea:not(#wpadminbar textarea):focus,
body.user-is-tabbing:not(.wp-admin) select:not(#wpadminbar select):focus,
body.user-is-tabbing:not(.wp-admin) [tabindex]:not(#wpadminbar [tabindex]):focus {
    outline: 3px solid #0066cc !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 4px rgba(0, 102, 204, 0.2) !important;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    body:not(.wp-admin) a:not(#wpadminbar a):focus-visible,
    body:not(.wp-admin) button:not(#wpadminbar button):focus-visible,
    body:not(.wp-admin) input:not(#wpadminbar input):focus-visible,
    body:not(.wp-admin) textarea:not(#wpadminbar textarea):focus-visible,
    body:not(.wp-admin) select:not(#wpadminbar select):focus-visible,
    body:not(.wp-admin) [tabindex]:not(#wpadminbar [tabindex]):focus-visible {
        outline: 4px solid #000000 !important;
        outline-offset: 3px !important;
    }

    body.user-is-tabbing:not(.wp-admin) a:not(#wpadminbar a):focus,
    body.user-is-tabbing:not(.wp-admin) button:not(#wpadminbar button):focus,
    body.user-is-tabbing:not(.wp-admin) input:not(#wpadminbar input):focus,
    body.user-is-tabbing:not(.wp-admin) textarea:not(#wpadminbar textarea):focus,
    body.user-is-tabbing:not(.wp-admin) select:not(#wpadminbar select):focus,
    body.user-is-tabbing:not(.wp-admin) [tabindex]:not(#wpadminbar [tabindex]):focus {
        outline: 4px solid #000000 !important;
        outline-offset: 3px !important;
    }
}

/* ==========================================================================
   4. TYPOGRAPHY (WCAG 2.1 SC 1.4.8 - Visual Presentation)
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
    font-weight: 700 !important;
    line-height: 1.3 !important;
    margin-top: 1.5em !important;
    margin-bottom: 0.75em !important;
    color: #1a1a1a !important;
}

h1 {
    font-size: 2.5rem !important; /* 40px */
    margin-top: 0 !important;
}

h2 {
    font-size: 2rem !important; /* 32px */
}

h3 {
    font-size: 1.75rem !important; /* 28px */
}

h4 {
    font-size: 1.5rem !important; /* 24px */
}

h5 {
    font-size: 1.25rem !important; /* 20px */
}

h6 {
    font-size: 1.125rem !important; /* 18px */
}

p {
    margin-bottom: 1.5em !important;
    max-width: 75ch !important; /* WCAG 2.1 SC 1.4.8 - optimal line length */
}

/* ==========================================================================
   5. LINKS (WCAG 2.1 SC 1.4.1 - Use of Color)
   ========================================================================== */

a {
    color: #0066cc !important;
    text-decoration: underline !important;
    background-color: transparent !important;
    transition: color 0.2s ease, background-color 0.2s ease !important;
}

a:hover,
a:active {
    color: #004499 !important;
    text-decoration: underline !important;
    background-color: rgba(0, 102, 204, 0.1) !important;
}

a:visited {
    color: #551a8b !important;
}

/* External links indicator */
a[href^="http"]:not([href*="yourdomain.com"])::after {
    content: " ↗" !important;
    font-size: 0.875em !important;
    vertical-align: super !important;
}

/* ==========================================================================
   6. IMAGES & MEDIA (WCAG 2.1 SC 1.1.1 - Non-text Content)
   ========================================================================== */

img {
    max-width: 100% !important;
    height: auto !important;
    display: block !important;
    border: 0 !important;
}

figure {
    margin: 1.5em 0 !important;
}

figcaption {
    font-size: 0.875rem !important;
    font-style: italic !important;
    color: #666666 !important;
    margin-top: 0.5em !important;
    padding: 0.5em !important;
}

/* ==========================================================================
   7. FORMS (WCAG 2.1 SC 3.3.2 - Labels or Instructions)
   ========================================================================== */

label {
    display: block !important;
    margin-bottom: 0.5em !important;
    font-weight: 600 !important;
    color: #1a1a1a !important;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="date"],
textarea,
select {
    width: 100% !important;
    padding: 12px 15px !important;
    font-size: 1rem !important;
    line-height: 1.5 !important;
    color: #1a1a1a !important;
    background-color: #ffffff !important;
    border: 2px solid #666666 !important;
    border-radius: 4px !important;
    margin-bottom: 1em !important;
    transition: border-color 0.2s ease !important;
}

/* Form inputs: border color change on focus (always visible for usability) */
input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
textarea:focus,
select:focus {
    border-color: #0066cc !important;
}

/* Error states */
input:invalid,
textarea:invalid,
select:invalid {
    border-color: #cc0000 !important;
}

fieldset {
    border: 2px solid #cccccc !important;
    padding: 1em !important;
    margin-bottom: 1.5em !important;
    border-radius: 4px !important;
}

legend {
    font-weight: 700 !important;
    padding: 0 0.5em !important;
    color: #1a1a1a !important;
}

/* ==========================================================================
   8. BUTTONS (WCAG 2.1 SC 2.5.5 - Target Size)
   ========================================================================== */

button,
input[type="submit"],
input[type="button"],
input[type="reset"],
.button,
.btn {
    display: inline-block !important;
    padding: 12px 24px !important; /* Minimum 44x44px touch target */
    min-height: 44px !important;
    min-width: 44px !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    line-height: 1.5 !important;
    text-align: center !important;
    text-decoration: none !important;
    color: #ffffff !important;
    background-color: #0066cc !important;
    border: 2px solid #0066cc !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}

button:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
.button:hover,
.btn:hover {
    background-color: #004499 !important;
    border-color: #004499 !important;
    color: #ffffff !important;
}

button:disabled,
input[type="submit"]:disabled,
input[type="button"]:disabled {
    opacity: 0.6 !important;
    cursor: not-allowed !important;
}

/* ==========================================================================
   9. LISTS (Semantic Structure)
   ========================================================================== */

ul, ol {
    margin-left: 2em !important;
    margin-bottom: 1.5em !important;
}

li {
    margin-bottom: 0.5em !important;
    line-height: 1.6 !important;
}

/* ==========================================================================
   10. TABLES (WCAG 2.1 SC 1.3.1 - Info and Relationships)
   ========================================================================== */

table {
    width: 100% !important;
    border-collapse: collapse !important;
    margin-bottom: 1.5em !important;
    background-color: #ffffff !important;
}

th, td {
    padding: 12px 15px !important;
    text-align: left !important;
    border: 1px solid #cccccc !important;
}

th {
    background-color: #f5f5f5 !important;
    font-weight: 700 !important;
    color: #1a1a1a !important;
}

caption {
    font-weight: 700 !important;
    text-align: left !important;
    padding: 10px 0 !important;
    caption-side: top !important;
}

/* ==========================================================================
   11. LAYOUT STRUCTURE (Semantic HTML5)
   ========================================================================== */

.site-container {
    max-width: 1200px !important;
    margin: 0 auto !important;
    padding: 0 20px !important;
}

.site-header {
    background-color: #ffffff !important;
    border-bottom: 1px solid #e0e0e0 !important;
    padding: 20px 0 !important;
}

.site-main {
    padding: 40px 0 !important;
    min-height: 60vh !important;
}

.site-footer {
    background-color: #f5f5f5 !important;
    border-top: 1px solid #e0e0e0 !important;
    padding: 40px 0 20px !important;
    margin-top: 60px !important;
}

/* ==========================================================================
   12. NAVIGATION (WCAG 2.1 SC 2.4.3 - Focus Order)
   ========================================================================== */

.main-navigation {
    display: block !important;
}

.main-navigation ul {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 10px !important;
}

.main-navigation li {
    margin: 0 !important;
}

.main-navigation a {
    display: block !important;
    padding: 12px 20px !important;
    min-height: 44px !important;
    text-decoration: none !important;
    color: #1a1a1a !important;
    font-weight: 600 !important;
    border-radius: 4px !important;
    transition: background-color 0.2s ease !important;
}

/* Navigation: hover always visible, focus only on keyboard */
.main-navigation a:hover {
    background-color: #f0f0f0 !important;
    color: #0066cc !important;
}

.main-navigation a:focus-visible,
body.user-is-tabbing .main-navigation a:focus {
    background-color: #f0f0f0 !important;
    color: #0066cc !important;
}

.main-navigation .current-menu-item > a,
.main-navigation .current_page_item > a {
    background-color: #0066cc !important;
    color: #ffffff !important;
}

/* ==========================================================================
   13. RESPONSIVE DESIGN (Mobile-First)
   ========================================================================== */

@media screen and (max-width: 768px) {
    /* Font size controlled by WCAG toolbar - no override on mobile */

    h1 {
        font-size: 2rem !important;
    }

    h2 {
        font-size: 1.75rem !important;
    }

    h3 {
        font-size: 1.5rem !important;
    }

    .site-container {
        padding: 0 15px !important;
    }

    .main-navigation ul {
        flex-direction: column !important;
    }

    .main-navigation a {
        width: 100% !important;
    }
}


/* ==========================================================================
   14. ACCESSIBILITY UTILITIES
   ========================================================================== */

.sr-only,
.screen-reader-text {
    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;
}

.sr-only:focus,
.screen-reader-text:focus {
    position: static !important;
    width: auto !important;
    height: auto !important;
    padding: 15px 25px !important;
    margin: 0 !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
    background-color: #000000 !important;
    color: #ffffff !important;
    font-size: 1.125rem !important;
    font-weight: 700 !important;
    text-decoration: none !important;
    border-radius: 4px !important;
    z-index: 999999 !important;
}

@media (prefers-contrast: high) {
    /* Only apply to frontend, not admin */
    body:not(.wp-admin) {
        background-color: #ffffff !important;
        color: #000000 !important;
    }

    body:not(.wp-admin) a {
        color: #0000ee !important;
        text-decoration: underline !important;
    }

    body:not(.wp-admin) button,
    body:not(.wp-admin) input[type="submit"],
    body:not(.wp-admin) .button {
        border: 3px solid #000000 !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    /* Exclude WordPress Admin Bar from animation reset */
    body:not(.wp-admin) *:not(#wpadminbar):not(#wpadminbar *),
    body:not(.wp-admin) *::before:not(#wpadminbar *),
    body:not(.wp-admin) *::after:not(#wpadminbar *) {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

@media (prefers-color-scheme: dark) {
    /* Only apply to frontend, not admin */
    body:not(.wp-admin) {
        background-color: #1a1a1a !important;
        color: #f0f0f0 !important;
    }

    body:not(.wp-admin) h1,
    body:not(.wp-admin) h2,
    body:not(.wp-admin) h3,
    body:not(.wp-admin) h4,
    body:not(.wp-admin) h5,
    body:not(.wp-admin) h6 {
        color: #ffffff !important;
    }

    body:not(.wp-admin) a {
        color: #66b3ff !important;
    }

    body:not(.wp-admin) a:visited {
        color: #b399ff !important;
    }

    body:not(.wp-admin) .site-header,
    body:not(.wp-admin) .site-footer {
        background-color: #2a2a2a !important;
        border-color: #404040 !important;
    }

    body:not(.wp-admin) input[type="text"],
    body:not(.wp-admin) input[type="email"],
    body:not(.wp-admin) input[type="tel"],
    body:not(.wp-admin) textarea,
    body:not(.wp-admin) select {
        background-color: #2a2a2a !important;
        color: #f0f0f0 !important;
        border-color: #666666 !important;
    }
}

@media print {
    *,
    *::before,
    *::after {
        background: transparent !important;
        color: #000000 !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }

    a,
    a:visited {
        text-decoration: underline !important;
    }

    a[href]::after {
        content: " (" attr(href) ")" !important;
    }

    abbr[title]::after {
        content: " (" attr(title) ")" !important;
    }

    img {
        page-break-inside: avoid !important;
    }

    h2, h3 {
        page-break-after: avoid !important;
    }
}

/* ==========================================================================
   15. ELEMENTOR COMPATIBILITY
   ========================================================================== */

.elementor-widget-container {
    max-width: 100% !important;
}

.elementor-heading-title {
    line-height: 1.3 !important;
}

/* Elementor touch targets */
.elementor-button {
    min-height: 44px !important;
    min-width: 44px !important;
}

/* Note: Elementor focus styles are handled in elementor-compatibility.php */
