/* 4Schools Accessibility Stylesheet */
/* Dyslexia-friendly features and WCAG 2.1 AA compliance */

/* ========================================
   DYSLEXIA-FRIENDLY FONTS
   ======================================== */

/* Import OpenDyslexic from CDN */
@import url('https://fonts.cdnfonts.com/css/opendyslexic');

/* Import Lexend from Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@300;400;500;600;700&display=swap');

/* Font family classes */
.font-opendyslexic * {
    font-family: 'OpenDyslexic', Arial, sans-serif !important;
}

.font-lexend * {
    font-family: 'Lexend', Arial, sans-serif !important;
}

.font-comic * {
    font-family: 'Comic Sans MS', 'Comic Sans', cursive !important;
}

.font-arial * {
    font-family: Arial, Helvetica, sans-serif !important;
}

.font-verdana * {
    font-family: Verdana, Geneva, sans-serif !important;
}

/* ========================================
   IMPROVED LINE SPACING FOR DYSLEXIA
   ======================================== */

.dyslexia-spacing p,
.dyslexia-spacing li,
.dyslexia-spacing span,
.dyslexia-spacing div {
    line-height: 1.8 !important;
    letter-spacing: 0.08em !important;
    word-spacing: 0.16em !important;
}

.dyslexia-spacing h1,
.dyslexia-spacing h2,
.dyslexia-spacing h3 {
    line-height: 1.5 !important;
    margin-bottom: 1em !important;
}

/* ========================================
   FONT SIZE CONTROLS
   ======================================== */

.font-size-small {
    font-size: 14px !important;
}

.font-size-normal {
    font-size: 16px !important;
}

.font-size-large * {
    font-size: 18px !important;
}

.font-size-xlarge * {
    font-size: 20px !important;
}

.font-size-xxlarge * {
    font-size: 24px !important;
}

/* ========================================
   HIGH CONTRAST MODES
   ======================================== */

/* High Contrast - Black on White */
.high-contrast-bw {
    background: #ffffff !important;
    color: #000000 !important;
}

.high-contrast-bw * {
    background: transparent !important;
    color: #000000 !important;
    border-color: #000000 !important;
}

.high-contrast-bw button,
.high-contrast-bw .btn {
    background: #000000 !important;
    color: #ffffff !important;
    border: 2px solid #000000 !important;
}

/* High Contrast - Yellow on Black */
.high-contrast-yb {
    background: #000000 !important;
    color: #ffff00 !important;
}

.high-contrast-yb * {
    background: transparent !important;
    color: #ffff00 !important;
    border-color: #ffff00 !important;
}

.high-contrast-yb button,
.high-contrast-yb .btn {
    background: #ffff00 !important;
    color: #000000 !important;
    border: 2px solid #ffff00 !important;
}

/* Dyslexia-Friendly Cream Theme */
.theme-cream {
    background: #faf8f1 !important;
    color: #3e2723 !important;
}

.theme-cream * {
    background: transparent !important;
    color: #3e2723 !important;
}

.theme-cream button,
.theme-cream .btn {
    background: #8d6e63 !important;
    color: #faf8f1 !important;
}

/* Dyslexia-Friendly Blue Theme */
.theme-blue {
    background: #e3f2fd !important;
    color: #01579b !important;
}

.theme-blue * {
    background: transparent !important;
    color: #01579b !important;
}

.theme-blue button,
.theme-blue .btn {
    background: #0277bd !important;
    color: #ffffff !important;
}

/* ========================================
   REDUCE MOTION
   ======================================== */

.reduce-motion *,
.reduce-motion *::before,
.reduce-motion *::after {
    animation: none !important;
    transition: none !important;
}

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

/* ========================================
   READING RULER
   ======================================== */

.reading-ruler {
    position: fixed;
    left: 0;
    right: 0;
    height: 40px;
    background: rgba(255, 255, 0, 0.2);
    border-top: 2px solid #ffeb3b;
    border-bottom: 2px solid #ffeb3b;
    pointer-events: none;
    z-index: 9998;
    display: none;
}

.reading-ruler.active {
    display: block;
}

/* ========================================
   ACCESSIBILITY TOOLBAR
   ======================================== */

.accessibility-toolbar {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #ffffff;
    border: 2px solid #667eea;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    max-width: 300px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    overflow-x: hidden;
    font-family: Arial, sans-serif;
    scrollbar-width: thin;
    scrollbar-color: #667eea #f1f5f9;
}

.accessibility-toolbar::-webkit-scrollbar {
    width: 8px;
}

.accessibility-toolbar::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

.accessibility-toolbar::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

.accessibility-toolbar::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

.accessibility-toolbar.collapsed {
    width: 50px;
    height: 50px;
    padding: 0;
    overflow: hidden;
}

.accessibility-toolbar h3 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    color: #667eea;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.accessibility-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.accessibility-toggle:hover {
    background: #764ba2;
    transform: scale(1.1);
}

.accessibility-toolbar.collapsed .accessibility-toggle {
    display: flex;
}

.accessibility-toolbar:not(.collapsed) .accessibility-toggle {
    display: none;
}

.accessibility-section {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.accessibility-section:last-child {
    border-bottom: none;
}

.accessibility-section h4 {
    font-size: 0.85rem;
    color: #64748b;
    margin: 0 0 0.5rem 0;
    font-weight: 600;
}

.accessibility-btn {
    width: 100%;
    padding: 0.6rem;
    margin-bottom: 0.5rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    text-align: left;
    color: #2d3748;
}

.accessibility-btn:hover {
    background: #e2e8f0;
    border-color: #cbd5e0;
}

.accessibility-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.accessibility-btn-group {
    display: flex;
    gap: 0.5rem;
}

.accessibility-btn-group .accessibility-btn {
    flex: 1;
}

.close-toolbar {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #64748b;
    padding: 0;
    width: 24px;
    height: 24px;
}

.close-toolbar:hover {
    color: #ef4444;
}

/* ========================================
   TEXT WIDTH CONSTRAINTS
   ======================================== */

.max-width-text p,
.max-width-text li {
    max-width: 70ch;
}

/* ========================================
   FOCUS INDICATORS
   ======================================== */

*:focus-visible {
    outline: 3px solid #667eea !important;
    outline-offset: 2px !important;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid #667eea !important;
    outline-offset: 2px !important;
}

/* ========================================
   SKIP TO MAIN CONTENT
   ======================================== */

.skip-to-main {
    position: absolute;
    top: -100px;
    left: 0;
    background: #667eea;
    color: white;
    padding: 1rem 2rem;
    text-decoration: none;
    font-weight: bold;
    z-index: 10002;
}

.skip-to-main:focus {
    top: 0;
}

/* ========================================
   STATUS BADGES (for locked/owned modules)
   ======================================== */

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

.status-badge.locked {
    background: #cbd5e0;
    color: #1a202c;
}

.status-badge.owned {
    background: #10b981;
    color: white;
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */

@media (max-width: 768px) {
    .accessibility-toolbar {
        top: 10px;
        right: 10px;
        max-width: 280px;
    }

    .accessibility-toggle {
        top: 10px;
        right: 10px;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .accessibility-toolbar,
    .accessibility-toggle,
    .reading-ruler {
        display: none !important;
    }
}
