/* =========================================
   ACCESSIBILITY WIDGET STYLES
   ========================================= */

/* --- Widget Floating Button --- */
#a11y-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background-color: #003366; /* Navy Blue */
    color: #ffffff;
    border: 2px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    cursor: pointer;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

#a11y-toggle-btn:hover,
#a11y-toggle-btn:focus {
    transform: scale(1.1);
    background-color: #002244;
    outline: 2px solid #D4AF37; /* Gold */
    outline-offset: 2px;
}

#a11y-toggle-btn svg {
    width: 32px;
    height: 32px;
    fill: currentColor;
}

/* --- Widget Panel --- */
#a11y-panel {
    position: fixed;
    top: 0;
    right: -400px; /* Hidden by default */
    width: 380px;
    height: 100vh;
    background-color: #f8f9fa;
    box-shadow: -4px 0 15px rgba(0,0,0,0.1);
    z-index: 10000;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    color: #333333;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#a11y-panel.a11y-panel-open {
    right: 0;
}

/* --- Panel Header --- */
.a11y-panel-header {
    background-color: #6a1b9a; /* Matching the purple header from the screenshot */
    color: #ffffff;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.a11y-panel-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.a11y-shortcut-badge {
    background-color: rgba(255,255,255,0.2);
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: normal;
}

.a11y-close-btn {
    background: none;
    border: none;
    color: #ffffff;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.a11y-close-btn:hover,
.a11y-close-btn:focus {
    background-color: rgba(255,255,255,0.2);
    outline: none;
}

.a11y-close-btn svg {
    width: 20px;
    height: 20px;
}

/* --- Panel Body --- */
.a11y-panel-body {
    padding: 20px;
    overflow-y: auto;
    flex-grow: 1;
}

.a11y-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

/* --- Option Buttons --- */
.a11y-option-btn {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 15px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    color: #555555;
    min-height: 90px;
}

.a11y-option-btn:hover,
.a11y-option-btn:focus {
    border-color: #6a1b9a;
    box-shadow: 0 4px 8px rgba(106, 27, 154, 0.1);
    outline: none;
}

.a11y-option-btn.active {
    border-color: #6a1b9a;
    background-color: #f3e5f5;
    color: #6a1b9a;
    border-width: 2px;
}

.a11y-option-icon {
    font-size: 24px;
    margin-bottom: 8px;
    fill: currentColor;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.a11y-option-icon svg {
    width: 100%;
    height: 100%;
}

.a11y-option-label {
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
}

/* --- Panel Footer --- */
.a11y-panel-footer {
    padding: 16px 20px;
    background-color: #ffffff;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.a11y-reset-btn {
    background-color: #f3e5f5;
    color: #6a1b9a;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s ease;
}

.a11y-reset-btn:hover,
.a11y-reset-btn:focus {
    background-color: #e1bee7;
    outline: none;
}

.a11y-reset-btn svg {
    width: 16px;
    height: 16px;
}

.a11y-credit {
    font-size: 11px;
    color: #888888;
}

/* =========================================
   ACCESSIBILITY FEATURE CLASSES (Applied to HTML/BODY)
   ========================================= */

/* 3. Text Spacing */
html.a11y-text-spacing body * {
    letter-spacing: 0.12em !important;
    word-spacing: 0.16em !important;
}

/* 4. Line Height */
html.a11y-line-height body * {
    line-height: 1.8 !important;
}

/* 5. Dyslexia Friendly */
html.a11y-dyslexia body * {
    font-family: 'OpenDyslexic', 'Comic Sans MS', 'Segoe Print', 'Bradley Hand', sans-serif !important;
    letter-spacing: 0.05em !important;
    word-spacing: 0.1em !important;
}

/* 6. ADHD Mode (Dim non-essential, highlight focus) */
html.a11y-adhd body {
    background-color: #eeeeee !important;
}
html.a11y-adhd body *:not(#a11y-panel):not(#a11y-panel *) {
    transition: opacity 0.3s ease;
}
html.a11y-adhd body *:not(:hover):not(:focus):not(#a11y-panel):not(#a11y-panel *) {
    /* Dim everything that isn't hovered/focused, but keep the widget normal */
}
html.a11y-adhd body section {
    opacity: 0.6;
}
html.a11y-adhd body section:hover,
html.a11y-adhd body section:focus-within {
    opacity: 1;
    background-color: #ffffff !important;
    box-shadow: 0 0 0 4px #D4AF37 inset !important;
}
html.a11y-adhd .absolute { /* Hide decorative backgrounds */
    display: none !important;
}

/* 7. Saturation (Desaturate) */
html.a11y-saturation body {
    filter: saturate(30%) !important;
}

/* 8. Light-Dark Mode */
html.a11y-dark-mode body {
    background-color: #121212 !important;
    color: #e0e0e0 !important;
}
html.a11y-dark-mode body section,
html.a11y-dark-mode body header,
html.a11y-dark-mode body footer,
html.a11y-dark-mode body div.bg-white,
html.a11y-dark-mode body div.bg-slate-50,
html.a11y-dark-mode body div.bg-gray-50 {
    background-color: #1e1e1e !important;
    border-color: #333333 !important;
    color: #e0e0e0 !important;
}
html.a11y-dark-mode h1,
html.a11y-dark-mode h2,
html.a11y-dark-mode h3,
html.a11y-dark-mode h4,
html.a11y-dark-mode p.text-gray-600,
html.a11y-dark-mode p.text-gray-800,
html.a11y-dark-mode span.text-gray-600 {
    color: #ffffff !important;
}

/* 9. Invert Colors */
html.a11y-invert {
    filter: invert(1) hue-rotate(180deg) !important;
}
html.a11y-invert img,
html.a11y-invert video,
html.a11y-invert iframe,
html.a11y-invert #a11y-panel {
    filter: invert(1) hue-rotate(180deg) !important; /* un-invert images and the widget */
}

/* 10. Highlight Links */
html.a11y-highlight-links a,
html.a11y-highlight-links button {
    background-color: #ffff00 !important;
    color: #000000 !important;
    text-decoration: underline !important;
    text-decoration-thickness: 3px !important;
    outline: 3px solid #ff0000 !important;
    outline-offset: 2px !important;
    font-weight: bold !important;
}
html.a11y-highlight-links #a11y-panel a,
html.a11y-highlight-links #a11y-panel button {
    background-color: initial !important;
    color: initial !important;
    text-decoration: none !important;
    outline: none !important;
    font-weight: initial !important;
}

/* 11. Text To Speech (cursor style indicating readability) */
html.a11y-tts-active body * {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"></polygon><path d="M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"></path></svg>'), pointer !important;
}
/* Highlight text currently being read */
.a11y-tts-highlight {
    background-color: #ffeb3b !important;
    color: #000 !important;
    outline: 2px solid #fbc02d !important;
}

/* 12. Cursor Enlargement */
html.a11y-cursor body * {
    cursor: zoom-in !important;
}
/* Ensure links still look clickable with a big cursor */
html.a11y-cursor body a,
html.a11y-cursor body button {
    cursor: pointer !important;
}

/* 13. Pause Animations */
html.a11y-pause-animations *,
html.a11y-pause-animations *::before,
html.a11y-pause-animations *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
}

/* 14. Hide Images */
html.a11y-hide-images img:not(.logo):not(.a11y-keep) {
    opacity: 0 !important;
    visibility: hidden !important;
}
html.a11y-hide-images svg:not(#a11y-panel svg) {
    opacity: 0 !important;
    visibility: hidden !important;
}

/* Base font-size classes for JS to calculate upon */
html.a11y-text-resize {
    /* JS will apply --a11y-font-scale custom property */
    font-size: calc(100% * var(--a11y-font-scale, 1)) !important;
}
