/* ==========================================================================
   Accessibility Design System & Toolbar - ULD Universitas Ma Chung
   Compliant with WCAG 2.1 AA/AAA Guidelines
   ========================================================================== */

/* Accessibility Bar Top Header */
.a11y-toolbar {
    background: #061c3d;
    color: #f1f5f9;
    font-size: 0.78rem;
    padding: 3px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    position: relative;
    z-index: 1040;
}

.a11y-toolbar .a11y-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 2px 7px;
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.a11y-toolbar .a11y-btn:hover,
.a11y-toolbar .a11y-btn:focus-visible {
    background: #d97706;
    color: #000000;
    border-color: #f59e0b;
    outline: 2px solid #ffffff;
}

.a11y-toolbar .a11y-btn.active {
    background: #f59e0b;
    color: #0b2f64;
    border-color: #ffffff;
}

/* Font Size Scaling Classes (Applied to <html> or <body>) */
html.font-size-sm { font-size: 14px; }
html.font-size-md { font-size: 16px; }
html.font-size-lg { font-size: 18px; }
html.font-size-xl { font-size: 20px; }

/* Focus Indicators for Keyboard Navigation */
html.a11y-highlight-focus a:focus-visible,
html.a11y-highlight-focus button:focus-visible,
html.a11y-highlight-focus input:focus-visible,
html.a11y-highlight-focus select:focus-visible,
html.a11y-highlight-focus textarea:focus-visible {
    outline: 3px solid #f59e0b !important;
    outline-offset: 3px !important;
    box-shadow: 0 0 0 5px rgba(11, 47, 100, 0.5) !important;
}

/* High Contrast Mode (Dark Background + Yellow Text) */
html.high-contrast-dark {
    filter: none !important;
}
html.high-contrast-dark body {
    background-color: #000000 !important;
    color: #ffff00 !important;
}
html.high-contrast-dark .card,
html.high-contrast-dark .navbar,
html.high-contrast-dark .footer,
html.high-contrast-dark .bg-white,
html.high-contrast-dark .bg-light,
html.high-contrast-dark section {
    background-color: #121212 !important;
    color: #ffff00 !important;
    border-color: #ffff00 !important;
}
html.high-contrast-dark a,
html.high-contrast-dark h1,
html.high-contrast-dark h2,
html.high-contrast-dark h3,
html.high-contrast-dark h4,
html.high-contrast-dark h5,
html.high-contrast-dark h6,
html.high-contrast-dark .nav-link {
    color: #ffff00 !important;
}
html.high-contrast-dark .btn-primary,
html.high-contrast-dark .btn-danger,
html.high-contrast-dark .btn-success {
    background-color: #ffff00 !important;
    color: #000000 !important;
    border-color: #ffff00 !important;
    font-weight: bold !important;
}

/* Grayscale Mode */
html.mode-grayscale {
    filter: grayscale(100%) !important;
}

/* Invert Mode */
html.mode-invert {
    filter: invert(100%) hue-rotate(180deg) !important;
}
html.mode-invert img,
html.mode-invert video {
    filter: invert(100%) hue-rotate(180deg) !important;
}

/* Dyslexic Friendly Font */
@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@300;400;500;600;700&display=swap');
html.font-dyslexic body,
html.font-dyslexic p,
html.font-dyslexic a,
html.font-dyslexic h1,
html.font-dyslexic h2,
html.font-dyslexic h3,
html.font-dyslexic h4,
html.font-dyslexic h5,
html.font-dyslexic h6,
html.font-dyslexic span,
html.font-dyslexic button,
html.font-dyslexic input {
    font-family: 'Lexend', 'Comic Sans MS', sans-serif !important;
    letter-spacing: 0.05em !important;
    word-spacing: 0.1em !important;
    line-height: 1.8 !important;
}

/* Reading Ruler Guide */
#reading-ruler {
    display: none;
    position: fixed;
    left: 0;
    width: 100%;
    height: 38px;
    background: rgba(245, 158, 11, 0.25);
    border-top: 2px solid #f59e0b;
    border-bottom: 2px solid #f59e0b;
    pointer-events: none;
    z-index: 999999;
}
html.reading-ruler-active #reading-ruler {
    display: block;
}

/* Text-to-Speech Sticky Player */
.tts-player-bar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #0b2f64;
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 50px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    z-index: 1050;
    display: none;
    align-items: center;
    gap: 12px;
    border: 2px solid #f59e0b;
}
.tts-player-bar.active {
    display: flex;
}
.tts-speaking-pulse {
    display: inline-block;
    width: 12px;
    height: 12px;
    background-color: #10b981;
    border-radius: 50%;
    animation: ttsPulse 1.2s infinite ease-in-out;
}
@keyframes ttsPulse {
    0% { transform: scale(0.9); opacity: 0.7; }
    50% { transform: scale(1.4); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.7; }
}

/* ==========================================================================
   Voice Typing / Speech-to-Text (Suara ke Teks)
   ========================================================================== */
.btn-voice-input {
    background-color: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #0b2f64;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.25s ease;
}

.btn-voice-input:hover {
    background-color: #0b2f64;
    color: #ffffff;
    border-color: #0b2f64;
}

.btn-voice-input.listening {
    background-color: #dc2626 !important;
    color: #ffffff !important;
    border-color: #b91c1c !important;
    animation: voiceButtonPulse 1.2s infinite ease-in-out;
}

/* Glowing outline on the active listening input field */
.voice-field-active {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 0.25rem rgba(220, 38, 38, 0.25) !important;
    background-color: #fffaf0 !important;
}

/* Success green highlight when voice successfully selects an option */
.voice-field-success {
    border-color: #16a34a !important;
    box-shadow: 0 0 0 0.25rem rgba(22, 163, 74, 0.25) !important;
    background-color: #f0fdf4 !important;
    animation: voiceSelectSuccess 1.5s ease-out;
}

@keyframes voiceSelectSuccess {
    0% { transform: scale(0.99); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.btn-voice-select {
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    color: #3730a3;
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 0.78rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-voice-select:hover {
    background: #4338ca;
    color: #ffffff;
    border-color: #4338ca;
}

.btn-voice-select.listening {
    background: #dc2626 !important;
    color: #ffffff !important;
    border-color: #b91c1c !important;
    animation: voiceButtonPulse 1.2s infinite ease-in-out;
}

.voice-helper-banner {
    background: linear-gradient(135deg, #fef2f2 0%, #fff7ed 100%);
    border: 1px solid #fecaca;
    border-left: 5px solid #dc2626;
    border-radius: 12px;
    padding: 14px 18px;
    margin-bottom: 24px;
}

@keyframes voiceButtonPulse {
    0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(220, 38, 38, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

/* Floating Voice Typing Toast Banner */
#voice-typing-toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    max-width: 420px;
    background: #0f172a;
    color: #ffffff;
    border-radius: 14px;
    padding: 16px 20px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.35);
    z-index: 1060;
    display: none;
    align-items: center;
    gap: 14px;
    border: 2px solid #ef4444;
}

#voice-typing-toast.active {
    display: flex;
}

.voice-wave-indicator {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #ef4444;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    animation: voiceWavePulse 1.1s infinite alternate;
}

@keyframes voiceWavePulse {
    from { transform: scale(0.9); opacity: 0.8; }
    to { transform: scale(1.15); opacity: 1; }
}

.voice-toast-text {
    flex-grow: 1;
    overflow: hidden;
}

.voice-toast-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #fca5a5;
    margin-bottom: 2px;
}

.voice-toast-interim {
    font-size: 0.8rem;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
}

