/**
 * WCAG 2.2 AAA Accessibility Styles
 * This file contains accessibility-specific styles and enhancements
 */

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

/* Screen reader announcements */
#sr-announcements {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Focus management */
*:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    box-shadow: 0 0 0 1px #ffffff, 0 0 0 3px #3b82f6;
}

/* High contrast ratios for WCAG AAA (7:1 for normal text, 4.5:1 for large text) */
:root {
    /* AAA contrast ratios */
    --text-contrast-aaa: #000000; /* 21:1 ratio on white background */
    --text-contrast-large-aaa: #333333; /* 12.6:1 ratio on white background */
    --link-contrast-aaa: #0000EE; /* 7.7:1 ratio on white background */
    --focus-indicator: #005fcc; /* High contrast focus indicator */
}

/* Text contrast enhancements */
body {
    color: var(--text-contrast-aaa);
}

p, li, td, th {
    color: var(--text-contrast-aaa);
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-contrast-aaa);
}

/* Large text can use slightly lower contrast (4.5:1) */
h1, h2 {
    color: var(--text-contrast-large-aaa);
}

/* Link contrast */
a {
    color: var(--link-contrast-aaa);
}

a:hover, a:focus {
    color: #0000CC; /* Even higher contrast on interaction */
}

/* Focus indicators with enhanced visibility */
*:focus {
    outline: 2px solid var(--focus-indicator);
    outline-offset: 2px;
    box-shadow: 0 0 0 1px #ffffff, 0 0 0 3px var(--focus-indicator);
}

/* Skip links with enhanced styling */
.skip-link {
    background: #000000;
    color: #ffffff;
    border: 3px solid #ffffff;
    font-size: 1.125rem;
    font-weight: 700;
    padding: 12px 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.skip-link:focus {
    outline: 4px solid #ffffff;
    outline-offset: 4px;
}

/* Button focus indicators */
.btn-primary:focus,
.back-to-top:focus {
    outline: 2px solid var(--focus-indicator);
    outline-offset: 2px;
    box-shadow: 0 0 0 1px #ffffff, 0 0 0 3px var(--focus-indicator);
}

/* Thinner focus for hamburger menu button */
.hamburger-menu-button:focus {
    outline: 1px solid var(--focus-indicator);
    outline-offset: 1px;
    box-shadow: 0 0 0 1px #ffffff, 0 0 0 2px var(--focus-indicator);
}

/* Navigation focus indicators */
.nav-link:focus,
.mobile-nav-link:focus,
.desktop-nav-link:focus,
.breadcrumb-link:focus,
.footer-link:focus {
    outline: 2px solid var(--focus-indicator);
    outline-offset: 1px;
    background-color: #f0f8ff;
    box-shadow: 0 0 0 1px #ffffff, 0 0 0 3px var(--focus-indicator);
}

/* Improved mobile navigation focus */
.mobile-nav-link:focus {
    background-color: rgba(59, 130, 246, 0.1);
    border: none;
    outline: 2px solid var(--focus-indicator);
    outline-offset: 1px;
}

@media (prefers-color-scheme: dark) {
    .mobile-nav-link:focus {
        background-color: rgba(59, 130, 246, 0.2);
    }
}

/* Enhanced focus for form elements (if any are added) */
input:focus,
textarea:focus,
select:focus,
button:focus {
    outline: 2px solid var(--focus-indicator);
    outline-offset: 2px;
    box-shadow: 0 0 0 1px #ffffff, 0 0 0 3px var(--focus-indicator);
}

/* Target size requirements (WCAG 2.2 - 2.5.8 Target Size Minimum) */
.nav-link,
.mobile-nav-link,
.desktop-nav-link,
.btn-primary,
.hamburger-menu-button,
.back-to-top,
.skip-link {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nav-link,
.mobile-nav-link,
.desktop-nav-link {
    padding: 12px 16px;
}

/* Ensure focus is not obscured (WCAG 2.2 - 2.4.11 & 2.4.12) */
*:focus {
    position: relative;
    z-index: 1000;
}

/* Dragging movements alternative (WCAG 2.2 - 2.5.7) */
/* If any drag interactions are added, ensure pointer alternatives exist */

/* Consistent help positioning (WCAG 2.2 - 3.2.6) */
.help-text {
    position: relative;
    margin-top: 4px;
    font-size: 0.875rem;
    color: var(--text-contrast-aaa);
}

/* Redundant entry prevention (WCAG 2.2 - 3.3.7) */
/* This would be handled programmatically for forms */

/* Accessible authentication (WCAG 2.2 - 3.3.8 & 3.3.9) */
/* If authentication is added, ensure no cognitive function tests */

/* Motion and animation controls */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --primary: #000000;
        --primary-dark: #000000;
        --text-contrast-aaa: #000000;
        --text-contrast-large-aaa: #000000;
        --link-contrast-aaa: #000080;
        --focus-indicator: #ff0000;
    }

    body {
        background: #ffffff;
        color: #000000;
    }

    .content-wrapper {
        background: #ffffff;
        border: 3px solid #000000;
    }

    a {
        color: #000080;
        text-decoration: underline;
        font-weight: bold;
    }

    button,
    .btn-primary {
        background: #000000;
        color: #ffffff;
        border: 3px solid #000000;
    }

    *:focus {
        outline: 4px solid #ff0000;
        background: #ffff00;
        color: #000000;
    }
}

/* Color blindness support */
.color-blind-safe {
    /* Use patterns and shapes in addition to color */
}

/* Status indicators that don't rely on color alone */
.status-success::before {
    content: "✓ ";
    font-weight: bold;
}

.status-error::before {
    content: "✗ ";
    font-weight: bold;
}

.status-warning::before {
    content: "⚠ ";
    font-weight: bold;
}

/* Typography enhancements for readability */
body {
    line-height: 1.6; /* Enhanced line height for better readability */
    word-spacing: 0.1em;
    letter-spacing: 0.025em;
}

/* Paragraph spacing for better content separation */
.markdown-content p + p {
    margin-top: 1.5em;
}

/* List spacing improvements */
.markdown-content li {
    margin-bottom: 0.5em;
    line-height: 1.7;
}

/* Table accessibility (if tables are present) */
table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 1.5rem;
}

th,
td {
    border: 2px solid #000000;
    padding: 12px;
    text-align: left;
}

th {
    background-color: #f5f5f5;
    font-weight: 700;
    color: #000000;
}

/* Caption styling */
caption {
    font-weight: 700;
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
    text-align: left;
    color: #000000;
}

/* Form enhancements (if forms are added) */
label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #000000;
}

input,
textarea,
select {
    border: 3px solid #000000;
    padding: 12px;
    font-size: 1rem;
    line-height: 1.5;
}

/* Error message styling */
.error-message {
    color: #cc0000;
    font-weight: 600;
    font-size: 1rem;
    margin-top: 0.25rem;
}

.error-message::before {
    content: "Error: ";
    font-weight: 700;
}

/* Success message styling */
.success-message {
    color: #006600;
    font-weight: 600;
    font-size: 1rem;
    margin-top: 0.25rem;
}

.success-message::before {
    content: "Success: ";
    font-weight: 700;
}

/* Print accessibility */
@media print {
    * {
        color: #000000 !important;
        background: #ffffff !important;
    }

    a[href^="http"]:after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #000000;
    }

    .skip-links,
    .mobile-menu-button,
    .back-to-top-container {
        display: none !important;
    }
}

/* Language support */
[lang] {
    font-family: var(--font-family);
}

/* RTL language support */
[dir="rtl"] {
    text-align: right;
}

[dir="rtl"] .breadcrumb li:not(:last-child)::after {
    content: '\\';
}

/* Ensure minimum text size for mobile */
@media (max-width: 768px) {
    body {
        font-size: 18px; /* Minimum 16px, but 18px is better for accessibility */
    }

    .nav-link,
    .mobile-nav-link,
    .btn-primary {
        min-height: 48px; /* Larger touch targets on mobile */
        min-width: 48px;
        font-size: 1.125rem;
    }
}

/* Focus appearance (WCAG 2.2 - 2.4.13 Focus Appearance AAA) */
*:focus {
    outline: 2px solid var(--focus-indicator);
    outline-offset: 2px;
    /* Focus indicator must be at least 2px thick and high contrast */
}

/* Ensure focus indicators are visible on all backgrounds */
*:focus {
    box-shadow:
        0 0 0 1px #ffffff,
        0 0 0 3px var(--focus-indicator);
}

/* Mobile navigation improvements */
@media (max-width: 768px) {
    .mobile-nav {
        background-color: #ffffff;
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    }
    
    .mobile-nav-link {
        border-bottom: 1px solid #e5e7eb;
        margin: 0;
        border-radius: 0;
        padding: 0.75rem 1rem;
        display: block;
        width: 100%;
    }
    
    /* Keep border-bottom for all mobile nav items including last child */
    
    /* Remove auto-focus on first mobile nav item */
    .mobile-nav-link:first-child {
        outline: none;
    }
    
    /* Ensure mobile nav list has no spacing */
    .mobile-nav ul {
        margin: 0;
        padding: 0;
    }
    
    .mobile-nav li {
        margin: 0;
        padding: 0;
    }
}

@media (max-width: 768px) and (prefers-color-scheme: dark) {
    .mobile-nav {
        background-color: #1f2937;
        border-top: 1px solid #374151;
    }
    
    .mobile-nav-link {
        border-bottom: 1px solid #374151;
        color: #d1d5db;
        padding: 0.75rem 1rem;
        margin: 0;
        display: block;
        width: 100%;
    }
    
    .mobile-nav-link:last-child {
        border-bottom: 1px solid #374151; /* Keep border for last item too */
    }
    
    .mobile-nav-link:hover,
    .mobile-nav-link:focus {
        background-color: #374151;
        color: #f9fafb;
    }
    
    /* Ensure mobile nav list has no spacing in dark mode */
    .mobile-nav ul {
        margin: 0;
        padding: 0;
    }
    
    .mobile-nav li {
        margin: 0;
        padding: 0;
    }
}

