/**
 * Accessibility Enhancements (WCAG 2.1 AA Compliance)
 */

/* ====================
   FOCUS STYLES
   ==================== */

/* High-visibility focus indicators */
*:focus-visible {
    outline: 3px solid #8b5cf6;
    outline-offset: 3px;
    border-radius: 4px;
}

/* Remove default outline but keep custom one */
*:focus {
    outline: none;
}

*:focus:not(:focus-visible) {
    outline: none;
}

/* Specific focus styles for interactive elements */
.nav__link:focus-visible,
.btn:focus-visible,
.account-card:focus-visible,
.lang-selector__button:focus-visible,
.theme-toggle:focus-visible {
    outline: 3px solid #8b5cf6;
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(139, 92, 246, 0.15);
}

/* Focus visible on light theme */
[data-theme="light"] *:focus-visible {
    outline-color: #7c3aed;
    box-shadow: 0 0 0 6px rgba(124, 58, 237, 0.15);
}

/* ====================
   SKIP LINKS
   ==================== */

.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    background: #8b5cf6;
    color: #fff;
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    font-weight: 600;
    border-radius: 0 0 8px 0;
    z-index: 10000;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid #fff;
    outline-offset: -3px;
}

/* ====================
   SCREEN READER ONLY
   ==================== */

.sr-only,
.visually-hidden {
    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,
.visually-hidden:focus {
    position: static;
    width: auto;
    height: auto;
    padding: inherit;
    margin: inherit;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* ====================
   HIGH CONTRAST MODE
   ==================== */

@media (prefers-contrast: high) {
    .nav__link,
    .btn,
    .card {
        border: 2px solid currentColor;
    }
    
    .nav__link--active,
    .btn-primary {
        background: #000;
        color: #fff;
        border-color: #fff;
    }
    
    [data-theme="light"] .nav__link--active,
    [data-theme="light"] .btn-primary {
        background: #fff;
        color: #000;
        border-color: #000;
    }
}

/* ====================
   COLOR CONTRAST
   ==================== */

/* Ensure WCAG AA contrast ratios (4.5:1 for normal text, 3:1 for large text) */

/* Dark theme - already good contrast */
body {
    color: #f5f7ff; /* Against dark background: ~16:1 */
}

/* Light theme - ensure good contrast */
[data-theme="light"] {
    color: #1b1d30; /* Against light background: ~15:1 */
}

/* Muted text - still meets AA standard */
.card__meta,
.account-card__meta,
.footer__copyright {
    color: rgba(245, 247, 255, 0.72); /* Against dark: ~8:1 */
}

[data-theme="light"] .card__meta,
[data-theme="light"] .account-card__meta {
    color: rgba(27, 29, 48, 0.72); /* Against light: ~7:1 */
}

/* Link contrast */
a {
    color: #a78bfa; /* Against dark: ~8:1 */
}

[data-theme="light"] a {
    color: #7c3aed; /* Against light: ~8:1 */
}

/* ====================
   TOUCH TARGETS
   ==================== */

/* Minimum 44x44px touch targets (WCAG 2.1 AAA) */
.nav__link,
.btn,
.lang-selector__button,
.theme-toggle,
.mobile-toggle,
.account-card__details,
.footer__social-link {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Ensure adequate spacing between touch targets */
.topbar__controls > * {
    margin-inline: 0.25rem;
}

.nav__list > * {
    margin-inline: 0.125rem;
}

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

/* Visual indicator for keyboard focus */
.nav__link:focus-visible::after {
    content: '';
    position: absolute;
    inset: -4px;
    border: 3px solid #8b5cf6;
    border-radius: 10px;
    pointer-events: none;
}

/* Tab order optimization */
.topbar {
    /* Ensures logical tab order */
    display: flex;
    flex-wrap: wrap;
}

/* ====================
   MOTION PREFERENCES
   ==================== */

/* Respect user's motion preferences */
@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;
    }
    
    /* Keep essential transforms for layout */
    .nav,
    .lang-selector__dropdown {
        transition-property: visibility, opacity;
    }
}

/* ====================
   ARIA LIVE REGIONS
   ==================== */

/* Polite announcements for dynamic content */
[aria-live="polite"] {
    position: relative;
}

/* Assertive announcements for critical updates */
[aria-live="assertive"] {
    position: relative;
}

/* Status messages */
.accounts-status,
.loading-state,
.error-state {
    padding: 1rem;
    border-radius: 8px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
}

/* ====================
   FORM ACCESSIBILITY
   ==================== */

/* Clear labeling */
input:not([type="hidden"]),
select,
textarea {
    font-size: 16px; /* Prevents zoom on iOS */
}

/* Error states */
input:invalid,
select:invalid {
    border-color: #ef4444;
}

input:invalid:focus,
select:invalid:focus {
    outline-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

/* Required field indicators */
[required]::after {
    content: '*';
    color: #ef4444;
    margin-left: 0.25rem;
}

/* ====================
   MODAL/DIALOG ACCESSIBILITY
   ==================== */

/* Modal backdrop */
.accounts-modal[aria-modal="true"] {
    position: fixed;
    inset: 0;
    z-index: 9999;
}

/* Trap focus in modal */
.accounts-modal[aria-modal="true"] .accounts-modal__dialog {
    position: relative;
    z-index: 10000;
}

/* Close button */
.accounts-modal__close {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ====================
   LANGUAGE ATTRIBUTES
   ==================== */

/* Ensure proper language declaration */
:lang(uz) {
    font-family: 'Inter', sans-serif;
}

:lang(ru) {
    font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif;
}

:lang(en) {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ====================
   SEMANTIC HTML SUPPORT
   ==================== */

/* Enhance native semantic elements */
main {
    display: block;
    min-height: 60vh;
}

article,
section {
    display: block;
}

/* ====================
   COLOR BLINDNESS SUPPORT
   ==================== */

/* Don't rely solely on color to convey information */

/* Success states */
.success {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%2310b981' d='M13.5 2.5l-7 7-3-3'/%3E%3C/svg%3E");
}

/* Error states */
.error {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23ef4444' d='M2.5 2.5l11 11m0-11l-11 11'/%3E%3C/svg%3E");
}

/* Use patterns in addition to colors */
.account-card__badge {
    /* Verified badge */
    position: relative;
}

.account-card__badge::before {
    content: '✓';
    font-weight: bold;
}

/* ====================
   PRINT ACCESSIBILITY
   ==================== */

@media print {
    /* Ensure print-friendly styles */
    .topbar,
    .footer,
    .mobile-toggle,
    .theme-toggle {
        display: none;
    }
    
    a[href]::after {
        content: ' (' attr(href) ')';
    }
    
    body {
        background: #fff;
        color: #000;
    }
}

/* ====================
   TEXT SIZING
   ==================== */

/* Support text scaling up to 200% */
@media (min-resolution: 2dppx) {
    body {
        font-size: 100%; /* Relative units for scalability */
    }
}

/* Ensure text doesn't overflow at 200% zoom */
.nav__link,
.btn,
.card__meta {
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: auto;
}


