/**
 * Accessibility Styles for Parents Corner Analytics
 * Provides screen reader support, focus indicators, and keyboard navigation
 */

/* Screen Reader Only - visually hidden but accessible to screen readers */
.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;
}

/* Skip to main content link - fixed so it doesn't scroll into view */
.skip-link {
    position: fixed;
    top: -100px;
    left: 0.5rem;
    background: #1E40AF;
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 10001;
    border-radius: 0 0 4px 0;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 0.5rem;
}

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

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

/* Focus visible for keyboard navigation only */
*:focus:not(:focus-visible) {
    outline: none;
}

*:focus-visible {
    outline: 3px solid #4ECDC4;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    *:focus,
    *:focus-visible {
        outline: 4px solid currentColor;
        outline-offset: 3px;
    }
}

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

/* Keyboard navigation indicators */
.keyboard-nav *:focus {
    outline: 3px solid #4ECDC4;
    outline-offset: 2px;
}

/* Interactive element minimum touch target size */
button,
a,
input,
select,
textarea,
.clickable {
    min-height: 44px;
    min-width: 44px;
}

/* Chart text alternatives - visible when charts fail or for screen readers */
.chart-text-alternative {
    margin-top: 1rem;
    padding: 1rem;
    background: #f5f5f5;
    border-radius: 8px;
    border-left: 4px solid #4ECDC4;
}

.chart-text-alternative table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
}

.chart-text-alternative th,
.chart-text-alternative td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.chart-text-alternative th {
    background: #e0e0e0;
    font-weight: bold;
}

/* ARIA live region styling */
[aria-live] {
    position: relative;
}

/* Loading spinner accessibility */
.loading-spinner {
    position: relative;
}

.loading-spinner::after {
    content: "Loading...";
    position: absolute;
    left: -9999px;
}

/* Modal accessibility */
.modal[aria-hidden="true"] {
    display: none !important;
}

.modal[aria-hidden="false"] {
    display: flex !important;
}

/* Focus trap for modals */
.modal-content:focus {
    outline: none;
}

/* Ensure icons don't interfere with screen readers */
[aria-hidden="true"] {
    speak: none;
}

/* Status messages */
[role="status"],
[role="alert"] {
    padding: 1rem;
    border-radius: 4px;
}

[role="alert"] {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
}

/* Improve color contrast for links */
a {
    color: #1565C0;
    text-decoration: underline;
}

a:hover,
a:focus {
    color: #0D47A1;
    text-decoration: underline;
}

/* Ensure sufficient color contrast for text */
.stat-value,
.chart-title,
.section-title {
    color: #1b5e20;
}

/* Keyboard shortcuts hint */
.keyboard-shortcuts {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: white;
    border: 2px solid #4ECDC4;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-width: 300px;
}

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

.keyboard-shortcuts h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    color: #1b5e20;
}

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

.keyboard-shortcuts li {
    margin: 0.25rem 0;
    font-size: 0.875rem;
}

.keyboard-shortcuts kbd {
    background: #f5f5f5;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 2px 6px;
    font-family: monospace;
    font-size: 0.875rem;
}

/* Print styles for accessibility */
@media print {
    .skip-link,
    .nav-toggle,
    .keyboard-shortcuts,
    .modal-overlay,
    button {
        display: none !important;
    }
    
    .chart-text-alternative {
        display: block !important;
    }
    
    * {
        color: black !important;
        background: white !important;
    }
}
