/*
===============================================================================
RENT ASSISTENZ - ACCESSIBILITY & PERFORMANCE SYSTEM - CLEAN VERSION
===============================================================================
Complete accessibility and performance optimizations with reduced Nuclear CSS
WCAG 2.1 AA compliance with senior-friendly UX and performance optimizations
Version: 1.1.0 - Nuclear CSS Cleanup (88 → 31 !important = 65% reduction)

CLEANUP RESULTS:
- KEPT: Critical accessibility !important (skip-links, sr-only, focus states)
- REMOVED: Unnecessary !important for transitions, colors, and styling
- PERFORMANCE: Maintained all accessibility functionality
===============================================================================
*/

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */

/* Focus-Styles für Tastatur-Navigation */
a:focus,
button:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 2px solid var(--rent-primary-blue) !important;
    outline-offset: 2px;
    border-radius: 3px;
    transition: outline-color var(--transition-fast);
}

/* Enhanced focus for better visibility */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 3px solid var(--rent-primary-blue) !important;
    outline-offset: 3px;
    box-shadow: 0 0 0 1px var(--rent-bg-white), 0 0 0 4px var(--rent-primary-blue) !important;
}

/* ===== SKIP LINK FOR SCREEN READERS ===== */

/* Skip-Link für Screen-Reader - CRITICAL: Must override theme positioning */
.skip-link {
    position: absolute !important;
    left: -9999px !important;
    z-index: var(--z-modal) !important;
    padding: var(--space-sm) var(--space-md);
    background: var(--rent-primary-blue);
    color: var(--rent-bg-white);
    text-decoration: none;
    font-weight: 600;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-base);
}

.skip-link:focus {
    left: var(--space-sm) !important;
    top: var(--space-sm) !important;
}

/* Multiple skip links for better navigation */
.skip-links {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    z-index: var(--z-modal) !important;
}

.skip-links a {
    position: absolute !important;
    left: -9999px !important;
    padding: var(--space-sm) var(--space-md);
    background: var(--rent-primary-blue);
    color: var(--rent-bg-white);
    text-decoration: none;
    font-weight: 600;
}

.skip-links a:focus {
    left: var(--space-sm) !important;
    top: var(--space-sm) !important;
}

/* ===== IMPROVED LINK ACCESSIBILITY ===== */

/* Verbesserte Link-Erkennbarkeit - CRITICAL: Override theme link styling */
a:not(.site-button):not(.navbar-brand) {
    text-decoration: underline !important;
    text-decoration-color: rgba(0, 124, 186, 0.3);
    text-underline-offset: 3px;
    transition: text-decoration-color var(--transition-base);
}

a:not(.site-button):not(.navbar-brand):hover {
    text-decoration-color: var(--rent-primary-blue);
}

/* Link context for screen readers - CRITICAL: Screen reader positioning */
.sr-context {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden;
    clip: rect(0,0,0,0) !important;
    white-space: nowrap;
    border: 0;
}

/* ===== SCREEN READER UTILITIES ===== */

/* Screen Reader Only Text - CRITICAL: Must override theme visibility */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden;
    clip: rect(0,0,0,0) !important;
    white-space: nowrap;
    border: 0;
}

.sr-only-focusable:active,
.sr-only-focusable:focus {
    position: static !important;
    width: auto !important;
    height: auto !important;
    padding: var(--space-sm) var(--space-md);
    margin: 0 !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal;
    background: var(--rent-bg-white);
    color: var(--rent-text-primary);
    border: 2px solid var(--rent-primary-blue);
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */

/* Hardware-Beschleunigung für Animationen */
.contact-teaser-content,
.mobile-call-button,
.mobile-contact-button {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Scroll-Performance */
.page-content,
.section-full {
    transform: translateZ(0);
    contain: layout style;
}

/* Performance-optimierte Animationen */
.featured-bx.style3,
.featured-bx.style3 .featured-media img,
.owl-location-carousel .owl-nav button {
    will-change: transform;
    backface-visibility: hidden;
    transform: translateZ(0);
}

/* Smooth Scrolling mit Performance-Optimierung */
.owl-location-carousel {
    scroll-behavior: smooth;
    transform: translateZ(0);
}

/* Layout-Shift Prevention */
.owl-location-carousel .owl-stage-outer {
    overflow: hidden;
    contain: layout;
}

.owl-location-carousel .owl-stage {
    display: flex;
    will-change: transform;
}

/* ===== REDUCED MOTION SUPPORT ===== */

/* Reduzierte Animationen für Nutzer-Präferenzen */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms;
        animation-iteration-count: 1;
        transition-duration: 0.01ms;
        scroll-behavior: auto;
    }
    
    .contact-teaser-content {
        animation: none;
    }
    
    .featured-bx.style3:hover {
        transform: none;
    }
    
    .featured-bx.style3:hover .featured-media img {
        transform: none;
    }
    
    /* Maintain will-change for performance even without animations */
    .contact-teaser-content,
    .mobile-call-button,
    .mobile-contact-button,
    .featured-bx.style3 {
        will-change: auto;
    }
}

/* ===== LOADING STATES ===== */

/* Skeleton-Loading für Bilder */
.image-loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Disable loading animation for reduced motion */
@media (prefers-reduced-motion: reduce) {
    .image-loading {
        animation: none;
        background: #f0f0f0;
    }
}

/* Content-Loading States */
.content-loading {
    opacity: 0.6;
    pointer-events: none;
    cursor: wait;
}

.content-loaded {
    opacity: 1;
    pointer-events: auto;
    transition: opacity var(--transition-base);
}

/* Progressive Enhancement Loading */
.no-js .content-loading {
    opacity: 1;
    pointer-events: auto;
}

/* ===== HIGH CONTRAST SUPPORT ===== */

/* High Contrast Mode Support - CRITICAL: Override theme in high contrast */
@media (prefers-contrast: high) {
    a:focus,
    button:focus,
    input:focus,
    textarea:focus,
    select:focus {
        outline: 4px solid var(--rent-primary-blue) !important;
        outline-offset: 2px;
        background: var(--rent-bg-white) !important;
    }
    
    .skip-link,
    .skip-links a {
        background: #000000 !important;
        color: #ffffff !important;
        border: 2px solid #ffffff;
    }
    
    a:not(.site-button):not(.navbar-brand) {
        text-decoration-thickness: 2px;
        text-underline-offset: 2px;
    }
}

/* ===== SENIOR-FRIENDLY ACCESSIBILITY ===== */

/* Larger target areas for seniors - CRITICAL: Override theme button sizes */
.accessible-target {
    min-width: 48px !important;
    min-height: 48px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Enhanced focus for senior users */
@media (prefers-contrast: high), (min-width: 1200px) {
    a:focus,
    button:focus {
        outline-width: 4px;
        outline-offset: 4px;
    }
}

/* ===== KEYBOARD NAVIGATION ENHANCEMENTS ===== */

/* Enhanced keyboard navigation */
.keyboard-focus-only:focus:not(:focus-visible) {
    outline: none;
}

/* Tab navigation improvements */
[tabindex="-1"]:focus {
    outline: none;
}

/* Custom focus indicators for complex components */
.carousel-focus:focus-within {
    outline: 3px solid var(--rent-primary-blue) !important;
    outline-offset: 2px;
}

/* ===== PERFORMANCE MONITORING ===== */

/* Performance hints for critical resources */
.performance-critical {
    contain: layout style;
    will-change: transform;
}

/* Lazy loading support */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity var(--transition-base);
}

img[loading="lazy"].loaded,
img:not([loading="lazy"]) {
    opacity: 1;
}

/* ===== ACCESSIBILITY TESTING SUPPORT ===== */

/* Development mode accessibility indicators - CRITICAL: Debug outlines must override */
.a11y-debug [role]:not([role=""]) {
    outline: 2px dashed #ff6b6b !important;
    outline-offset: 2px;
}

.a11y-debug [aria-label]:not([aria-label=""]) {
    box-shadow: inset 0 0 0 2px #4ecdc4 !important;
}

/* Only show in development */
@media (max-width: 0px) {
    .a11y-debug * {
        outline: none;
        box-shadow: none;
    }
}