/* ============================================
   NZUMBI FOUNDATION - ACCESSIBILITY STYLES
   ============================================ */

/* ============================================
   1. ACCESSIBILITY WIDGET
   ============================================ */
.accessibility-widget {
    position: fixed;
    /* NEW POSITIONING: Matching WhatsApp Float Button Style */
    bottom: 30px; 
    left: 30px; 
    z-index: 999;
}

.accessibility-widget.left-widget {
    left: 30px;
    right: auto;
}

.accessibility-btn {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #8806CE, #6A05A3);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1.8rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(136, 6, 206, 0.4);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.accessibility-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(136, 6, 206, 0.5);
}

.accessibility-btn:focus {
    outline: 3px solid #FFD23F;
    outline-offset: 2px;
}

/* ============================================
   2. ACCESSIBILITY PANEL
   ============================================ */
.accessibility-panel {
    position: absolute;
    /* Panel opens above the button. 
       bottom: 70px is correct for the base 100px button position (100 - 30 margin) 
       We will manage the new bottom position in the mobile query below. */
    bottom: 70px;
    left: 0;
    width: 300px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    
    /* FIX 1: Max Height and Scrolling */
    max-height: 80vh; 
    overflow-y: auto; 
}

.accessibility-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.accessibility-panel h4 {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.2rem;
    margin-bottom: 20px;
    color: #8806CE;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============================================
   3. ACCESSIBILITY OPTIONS
   ============================================ */
.accessibility-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #E0E0E0;
}

.accessibility-option:last-of-type {
    border-bottom: none;
}

.accessibility-option span {
    font-weight: 500;
    color: #2C3E50;
}

/* Text Size Controls */
.text-size-controls {
    display: flex;
    gap: 8px;
}

.text-size-controls button {
    width: 35px;
    height: 35px;
    border: 2px solid #8806CE;
    background: white;
    color: #8806CE;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.text-size-controls button:hover {
    background: #8806CE;
    color: white;
    transform: scale(1.05);
}

.text-size-controls button:focus {
    outline: 2px solid #FFD23F;
    outline-offset: 2px;
}

/* Toggle Buttons */
.contrast-toggle,
.speech-toggle {
    position: relative;
    width: 60px;
    height: 30px;
    background: #E0E0E0;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.contrast-toggle::before,
.speech-toggle::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.contrast-toggle.active,
.speech-toggle.active {
    background: #8806CE;
}

.contrast-toggle.active::before,
.speech-toggle.active::before {
    left: 33px;
}

.contrast-off,
.contrast-on,
.speech-off,
.speech-on {
    position: absolute;
    font-size: 0.75rem;
    font-weight: 600;
    top: 50%;
    transform: translateY(-50%);
    transition: all 0.3s ease;
}

.contrast-off,
.speech-off {
    left: 8px;
    color: #6C757D;
}

.contrast-on,
.speech-on {
    right: 8px;
    color: white;
    opacity: 0;
}

.contrast-toggle.active .contrast-off,
.speech-toggle.active .contrast-off {
    opacity: 0;
}

.contrast-toggle.active .contrast-on,
.speech-toggle.active .speech-on {
    opacity: 1;
}

/* Close Panel Button */
.close-panel {
    width: 100%;
    margin-top: 15px;
    padding: 12px;
    background: #F8F9FA;
    border: 1px solid #E0E0E0;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    color: #6C757D;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.close-panel:hover {
    background: #E0E0E0;
    color: #2C3E50;
}

.close-panel:focus {
    outline: 2px solid #8806CE;
    outline-offset: 2px;
}

/* ============================================
   4. HIGH CONTRAST MODE
   ============================================ */
body.high-contrast {
    background: #000000;
    color: #FFFFFF;
}

/* ... (rest of high-contrast styles omitted for brevity) ... */

/* ============================================
   5. TEXT SIZE ADJUSTMENTS
   ============================================ */
body.text-size-small {
    font-size: 14px;
}

body.text-size-normal {
    font-size: 16px;
}

body.text-size-large {
    font-size: 18px;
}

body.text-size-xlarge {
    font-size: 20px;
}

/* ============================================
   6. FOCUS INDICATORS
   ============================================ */
*:focus {
    outline: 3px solid #FFD23F;
    outline-offset: 2px;
}

a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 3px solid #FFD23F;
    outline-offset: 2px;
}

/* ============================================
   7. SCREEN READER ONLY
   ============================================ */
.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;
}

/* ============================================
   8. REDUCED MOTION
   ============================================ */
@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;
    }
}

/* ============================================
   9. SPEECH MODE INDICATOR
   ============================================ */
body.speech-mode .speaking {
    background: #FFD23F;
    color: #000000;
    box-shadow: 0 0 10px #FFD23F;
    transition: all 0.3s ease;
}

/* ============================================
   10. MOBILE & TABLET ACCESSIBILITY
   ============================================ */
@media (max-width: 1024px) { 
    .accessibility-widget {
        /* Align widget with new 30px bottom/left target */
        bottom: 30px;
        left: 30px;
    }
    
    .accessibility-btn {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
    
    .accessibility-panel {
        /* FIX 2: Fixed Positioning for Viewport */
        position: fixed; 
        /* Panel positioned 110px from the bottom (30px + 60px button + 20px margin) */
        bottom: 110px; 
        top: auto; 
        
        /* FINAL POSITIONING: Aligned Bottom-Left (30px) */
        left: 30px; 
        width: calc(100vw - 60px); /* Adjust width for 30px margin on both sides */
        transform: none; 
    }
    
    .accessibility-panel.active {
        opacity: 1;
        visibility: visible;
        transform: none; 
    }
    
    /* FIX 3: Align text inside small toggles */
    .contrast-off,
    .contrast-on,
    .speech-off,
    .speech-on {
        font-size: 0.65rem; 
    }

    .contrast-off,
    .speech-off {
        left: 3px; 
    }

    .contrast-on,
    .speech-on {
        right: 3px; 
    }
}

/* ============================================
   11. TOUCH TARGET SIZES
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    /* Ensure all interactive elements are at least 44x44px */
    button,
    a,
    input[type="button"],
    input[type="submit"] {
        min-width: 44px;
        min-height: 44px;
    }
    
    .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ============================================
   12. COLOR BLIND MODES (Optional Enhancement)
   ============================================ */
body.deuteranopia {
    filter: url('#deuteranopia-filter');
}

body.protanopia {
    filter: url('#protanopia-filter');
}

body.tritanopia {
    filter: url('#tritanopia-filter');
}

/* ============================================
   13. PRINT ACCESSIBILITY
   ============================================ */
@media print {
    .accessibility-widget,
    .whatsapp-float {
        display: none;
    }
    
    a::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #6C757D;
    }
    
    a[href^="#"]::after,
    a[href^="javascript:"]::after {
        content: "";
    }
}