/* 
 * Accessibility Enhancements for Trivia Game
 * Provides high contrast themes, color-blind friendly indicators, and improved navigation
 */

:root {
    /* Default theme colors */
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    
    /* Text colors */
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-light: #ffffff;
    
    /* Background colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-dark: #343a40;
    
    /* Focus indicators */
    --focus-color: #0056b3;
    --focus-width: 2px;
    
    /* Contrast ratios - WCAG AA compliant */
    --contrast-ratio-normal: 4.5;
    --contrast-ratio-large: 3;
}

/* High Contrast Theme */
[data-theme="high-contrast"] {
    --primary-color: #0000ff;
    --secondary-color: #000000;
    --success-color: #008000;
    --danger-color: #ff0000;
    --warning-color: #ffff00;
    --info-color: #00ffff;
    --light-color: #ffffff;
    --dark-color: #000000;
    
    --text-primary: #000000;
    --text-secondary: #000000;
    --text-light: #ffffff;
    
    --bg-primary: #ffffff;
    --bg-secondary: #ffffff;
    --bg-dark: #000000;
    
    --focus-color: #ff0000;
    --focus-width: 3px;
}

/* Dark Theme */
[data-theme="dark"] {
    --primary-color: #4dabf7;
    --secondary-color: #adb5bd;
    --success-color: #51cf66;
    --danger-color: #ff6b6b;
    --warning-color: #ffd43b;
    --info-color: #74c0fc;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    
    --text-primary: #f8f9fa;
    --text-secondary: #adb5bd;
    --text-light: #212529;
    
    --bg-primary: #212529;
    --bg-secondary: #343a40;
    --bg-dark: #f8f9fa;
    
    --focus-color: #ffd43b;
}

/* Accessibility Theme Switcher */
.accessibility-controls {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 9999;
    background: var(--bg-primary);
    border: 2px solid var(--secondary-color);
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.theme-switcher {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
}

.theme-btn {
    padding: 8px 12px;
    border: 2px solid var(--secondary-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    transition: all 0.2s ease;
}

.theme-btn:hover,
.theme-btn:focus {
    outline: var(--focus-width) solid var(--focus-color);
    outline-offset: 2px;
    transform: scale(1.05);
}

.theme-btn.active {
    background: var(--primary-color);
    color: var(--text-light);
    border-color: var(--primary-color);
}

/* Enhanced Focus Indicators */
button:focus,
input:focus,
select:focus,
textarea:focus,
[tabindex]:focus {
    outline: var(--focus-width) solid var(--focus-color) !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.25) !important;
}

/* Skip to content link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-color);
    color: var(--text-light);
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 10000;
    font-weight: bold;
}

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

/* Accessible Answer States */
.answer-option {
    position: relative;
    transition: all 0.3s ease;
}

.answer-option.correct {
    background-color: var(--success-color) !important;
    color: var(--text-light) !important;
    border: 3px solid var(--success-color) !important;
}

.answer-option.incorrect {
    background-color: var(--danger-color) !important;
    color: var(--text-light) !important;
    border: 3px solid var(--danger-color) !important;
}

.answer-option.selected {
    background-color: var(--warning-color) !important;
    color: var(--text-primary) !important;
    border: 3px solid var(--warning-color) !important;
}

/* Add visual indicators beyond color */
.answer-option.correct::before {
    content: "✓ ";
    font-weight: bold;
    font-size: 1.2em;
    color: var(--text-light);
}

.answer-option.incorrect::before {
    content: "✗ ";
    font-weight: bold;
    font-size: 1.2em;
    color: var(--text-light);
}

.answer-option.selected::before {
    content: "► ";
    font-weight: bold;
    font-size: 1.2em;
    color: var(--text-primary);
}

/* Screen reader announcements */
.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;
}

.sr-announcement {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Enhanced button styles */
.btn-accessible {
    min-height: 44px; /* WCAG minimum touch target */
    min-width: 44px;
    font-size: 16px;
    font-weight: 600;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.btn-accessible:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-accessible:active {
    transform: translateY(0);
}

/* Loading states */
.loading {
    position: relative;
    color: transparent !important;
}

.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--primary-color);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* High contrast mode specific adjustments */
[data-theme="high-contrast"] .answer-option.correct {
    background-color: #008000 !important;
    border: 4px solid #000000 !important;
}

[data-theme="high-contrast"] .answer-option.incorrect {
    background-color: #ff0000 !important;
    border: 4px solid #000000 !important;
}

[data-theme="high-contrast"] .answer-option.selected {
    background-color: #ffff00 !important;
    color: #000000 !important;
    border: 4px solid #000000 !important;
}

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

/* Forced colors mode (Windows High Contrast) */
@media (forced-colors: active) {
    .answer-option.correct {
        forced-color-adjust: none;
        background: Highlight !important;
        color: HighlightText !important;
        border: 2px solid ButtonText !important;
    }
    
    .answer-option.incorrect {
        forced-color-adjust: none;
        background: ButtonFace !important;
        color: ButtonText !important;
        border: 2px solid ButtonText !important;
        text-decoration: line-through;
    }
    
    .theme-switcher {
        display: none; /* Hide in forced colors mode */
    }
}

/* Print styles */
@media print {
    .accessibility-controls,
    .theme-switcher {
        display: none;
    }
    
    .answer-option.correct {
        background: transparent !important;
        color: black !important;
        border: 2px solid black !important;
    }
    
    .answer-option.incorrect {
        background: transparent !important;
        color: black !important;
        border: 2px solid black !important;
        text-decoration: line-through;
    }
}

/* Mobile accessibility improvements */
@media (max-width: 768px) {
    .btn-accessible {
        min-height: 48px; /* Larger touch targets on mobile */
        min-width: 48px;
        font-size: 18px;
    }
    
    .accessibility-controls {
        position: relative;
        top: auto;
        right: auto;
        margin-bottom: 20px;
        width: 100%;
    }
    
    .theme-switcher {
        justify-content: center;
    }
}
