/* ========================================
   ACCESSIBILITY & NAVIGATION ENHANCEMENTS
   ======================================== */

/* Skip Links */
.skip-links {
    position: absolute;
    top: -40px;
    left: 6px;
    z-index: 1000;
}

.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    z-index: 1000;
    color: white;
    background: #000;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
}

.skip-link:focus {
    top: 6px;
}

/* 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;
}

/* Focus Indicators */
*:focus {
    outline: 3px solid #3b82f6;
    outline-offset: 2px;
}

button:focus,
a:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 3px solid #3b82f6;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .card {
        border: 2px solid currentColor;
    }
    
    .filter-btn {
        border: 2px solid currentColor;
    }
    
    .filter-btn.active {
        background: currentColor;
        color: white;
    }
}

/* 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;
    }
    
    .fade-in {
        opacity: 1 !important;
        transform: none !important;
    }
}

/* Breadcrumb Navigation */
.breadcrumb-nav {
    background: var(--card-bg);
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.breadcrumb {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    font-size: 0.9rem;
}

.breadcrumb li:not(:last-child)::after {
    content: ">";
    margin-left: 0.5rem;
    color: var(--text-muted);
}

.breadcrumb a {
    color: var(--primary-color);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.breadcrumb li[aria-current="page"] {
    color: var(--text-color);
    font-weight: 500;
}

/* Mobile Navigation Improvements */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    position: relative;
    z-index: 1001;
}

.hamburger {
    display: block;
    width: 24px;
    height: 2px;
    background: currentColor;
    position: relative;
    transition: background 0.3s ease;
}

.hamburger::before,
.hamburger::after {
    content: '';
    display: block;
    width: 24px;
    height: 2px;
    background: currentColor;
    position: absolute;
    transition: all 0.3s ease;
}

.hamburger::before {
    top: -8px;
}

.hamburger::after {
    bottom: -8px;
}

/* Hamburger animation */
.nav-toggle[aria-expanded="true"] .hamburger {
    background: transparent;
}

.nav-toggle[aria-expanded="true"] .hamburger::before {
    transform: rotate(45deg);
    top: 0;
}

.nav-toggle[aria-expanded="true"] .hamburger::after {
    transform: rotate(-45deg);
    bottom: 0;
}

/* Enhanced Filter Buttons */
.filter-btn {
    position: relative;
    transition: all 0.3s ease;
}

.filter-btn[aria-selected="true"] {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.filter-btn:not([aria-selected="true"]):hover {
    background: var(--hover-bg);
    transform: translateY(-1px);
}

/* Keyboard Navigation Indicators */
.keyboard-user *:focus {
    outline: 3px solid #3b82f6;
    outline-offset: 2px;
}

/* High Contrast Theme */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #000080;
        --text-color: #000000;
        --bg-color: #ffffff;
        --border-color: #000000;
    }
    
    [data-theme="dark"] {
        --primary-color: #66b3ff;
        --text-color: #ffffff;
        --bg-color: #000000;
        --border-color: #ffffff;
    }
}

/* Large Text Support */
@media (min-resolution: 192dpi) {
    body {
        font-size: 1.1rem;
    }
    
    .card-links a {
        font-size: 1rem;
        padding: 0.75rem 0;
    }
    
    .filter-btn {
        padding: 0.75rem 1.25rem;
        font-size: 1rem;
    }
}

/* Mobile Navigation */
@media (max-width: 768px) {
    .nav-toggle {
        display: block;
    }
    
    .main-nav ul {
        position: fixed;
        top: 0;
        right: -100%;
        width: 100%;
        height: 100vh;
        background: var(--bg-color);
        flex-direction: column;
        justify-content: center;
        align-items: center;
        transition: right 0.3s ease;
        z-index: 1000;
    }
    
    .main-nav ul.open {
        right: 0;
    }
    
    .main-nav li {
        margin: 1rem 0;
    }
    
    .main-nav a {
        font-size: 1.5rem;
        padding: 1rem;
        display: block;
    }
    
    /* Mobile filter buttons */
    .filter-container {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .filter-btn {
        min-width: auto;
        flex: 1 1 auto;
        font-size: 0.9rem;
        padding: 0.5rem 0.75rem;
    }
}

/* Touch Target Improvements */
@media (hover: none) and (pointer: coarse) {
    .card-links a,
    .filter-btn,
    button {
        min-height: 44px;
        min-width: 44px;
        padding: 0.75rem 1rem;
    }
    
    .theme-toggle {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Print Styles */
@media print {
    .skip-links,
    .nav-toggle,
    .theme-toggle,
    .filter-container,
    .search-container {
        display: none;
    }
    
    .card {
        break-inside: avoid;
        border: 1px solid #000;
        margin-bottom: 1rem;
    }
    
    a[href^="http"]:after {
        content: " (" attr(href) ")";
        font-size: 0.8rem;
        color: #666;
    }
}

/* Keyboard Help Modal */
.keyboard-help {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    max-width: 400px;
    z-index: 2000;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.keyboard-help.hidden {
    display: none;
}

.keyboard-help h3 {
    margin-top: 0;
    color: var(--primary-color);
}

.keyboard-help ul {
    list-style: none;
    padding: 0;
}

.keyboard-help li {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.keyboard-help kbd {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-family: monospace;
    font-size: 0.9rem;
}