/**
 * Accessibility (A11y) Styles
 * Focus indicators, skip links, screen reader only content
 */

/* Skip Link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #000;
    color: #fff;
    padding: 12px 16px;
    text-decoration: none;
    z-index: 10000;
    font-weight: 600;
    border-radius: 0 0 4px 0;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid #fff;
    outline-offset: 2px;
}

/* Focus Indicators */
*:focus-visible {
    outline: 3px solid #4A90E2;
    outline-offset: 2px;
    border-radius: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid #4A90E2;
    outline-offset: 2px;
}

/* Remove default outline for mouse users, keep for keyboard */
*:focus:not(:focus-visible) {
    outline: none;
}

/* Enhanced Focus for Interactive Elements */
button:focus-visible,
a:focus-visible {
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.3);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    border-color: #4A90E2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

/* 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-width: 0;
}

.sr-only-focusable:focus {
    position: static;
    width: auto;
    height: auto;
    padding: inherit;
    margin: inherit;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    *:focus-visible {
        outline: 3px solid;
        outline-offset: 3px;
    }
    
    button,
    a,
    input,
    select,
    textarea {
        border: 2px solid;
    }
}

/* Reduced Motion Support */
@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;
    }
    
    .skip-link {
        transition: none;
    }
}

/* Focus Visible for Custom Components */
.dropdown:focus-within,
.modal:focus-within {
    outline: 2px solid #4A90E2;
    outline-offset: 2px;
}

/* ARIA Live Region */
#a11y-live-region {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Keyboard Navigation Indicators */
[tabindex="0"]:focus-visible,
[tabindex="-1"]:focus-visible {
    outline: 3px solid #4A90E2;
    outline-offset: 2px;
}

/* Disabled State */
button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

button:disabled:focus-visible,
input:disabled:focus-visible,
select:disabled:focus-visible,
textarea:disabled:focus-visible {
    outline: 2px solid #999;
    outline-offset: 2px;
}

/* Loading State Accessibility */
.loading[aria-busy="true"] {
    position: relative;
}

.loading[aria-busy="true"]::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #4A90E2;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Error State Accessibility */
[aria-invalid="true"] {
    border-color: #f44336;
}

[aria-invalid="true"]:focus-visible {
    outline-color: #f44336;
    box-shadow: 0 0 0 3px rgba(244, 67, 54, 0.2);
}

/* Success State Accessibility */
[aria-invalid="false"] {
    border-color: #4caf50;
}

/* Required Field Indicator */
[aria-required="true"]::after {
    content: " *";
    color: #f44336;
    font-weight: bold;
}

/* Responsive Accessibility */
@media (max-width: 768px) {
    .skip-link {
        font-size: 14px;
        padding: 10px 14px;
    }
    
    *:focus-visible {
        outline-width: 2px;
    }
}

