/* ==========================================================================
   ADA Handicap Accessibility Toolbar - Frontend Stylesheet
   ========================================================================== */

:root {
    --ada-btn-bg: #0f52ba;
    --ada-btn-color: #ffffff;
    --ada-primary: #0f52ba;
    --ada-focus-ring: #ffbf47;
    --ada-active-border: #0f52ba;
    --ada-active-bg: #eef5ff;
    --ada-text-main: #1f2937;
    --ada-text-muted: #6b7280;
    --ada-surface: #ffffff;
    --ada-surface-subtle: #f9fafb;
    --ada-border: #e5e7eb;
    --ada-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

/* Screen reader only utility */
.ada-sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Skip to Content Link (WCAG 2.4.1) */
.ada-skip-link {
    position: absolute;
    top: -999px;
    left: 10px;
    z-index: 9999999;
    padding: 12px 20px;
    background: #000000;
    color: #ffffff;
    font-weight: 700;
    text-decoration: underline;
    border-radius: 4px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    transition: top 0.2s ease-in-out;
}
.ada-skip-link:focus {
    top: 15px;
    outline: 4px solid var(--ada-focus-ring);
    color: #ffffff;
}

/* ==========================================================================
   Trigger Button
   ========================================================================== */
.ada-trigger-btn {
    position: fixed;
    z-index: 999990;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--ada-btn-bg);
    color: var(--ada-btn-color);
    border: 2px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s;
    user-select: none;
    padding: 0;
}
.ada-trigger-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}
.ada-trigger-btn:focus-visible {
    outline: 4px solid var(--ada-focus-ring) !important;
    outline-offset: 3px;
}

/* Sizes */
.ada-size-small { width: 44px; height: 44px; }
.ada-size-small svg { width: 22px; height: 22px; }

.ada-size-medium { width: 54px; height: 54px; }
.ada-size-medium svg { width: 28px; height: 28px; }

.ada-size-large { width: 62px; height: 62px; }
.ada-size-large svg { width: 34px; height: 34px; }

/* Shapes */
.ada-shape-circle { border-radius: 50%; }
.ada-shape-rounded { border-radius: 12px; }
.ada-shape-square { border-radius: 4px; }

/* Positions */
.ada-pos-bottom-right { bottom: 24px; right: 24px; }
.ada-pos-bottom-left { bottom: 24px; left: 24px; }
.ada-pos-top-right { top: 24px; right: 24px; }
.ada-pos-top-left { top: 24px; left: 24px; }

/* Pulse animation */
@keyframes adaPulseAnimation {
    0% { box-shadow: 0 0 0 0 rgba(15, 82, 186, 0.6); }
    70% { box-shadow: 0 0 0 14px rgba(15, 82, 186, 0); }
    100% { box-shadow: 0 0 0 0 rgba(15, 82, 186, 0); }
}
.ada-pulse {
    animation: adaPulseAnimation 2.5s infinite;
}

/* ==========================================================================
   Main Accessibility Modal Dialog
   ========================================================================== */
.ada-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999995;
    display: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}
.ada-modal.is-open {
    display: block;
    opacity: 1;
    visibility: visible;
}

.ada-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
}

.ada-modal-window {
    position: fixed;
    z-index: 999996;
    width: 92%;
    max-width: 440px;
    height: 90vh;
    max-height: 720px;
    background: var(--ada-surface);
    border-radius: 16px;
    box-shadow: var(--ada-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--ada-border);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--ada-text-main);
    box-sizing: border-box;
}

/* Alignment with launcher */
.ada-modal-pos-bottom-right .ada-modal-window {
    bottom: 24px;
    right: 24px;
}
.ada-modal-pos-bottom-left .ada-modal-window {
    bottom: 24px;
    left: 24px;
}
.ada-modal-pos-top-right .ada-modal-window {
    top: 24px;
    right: 24px;
}
.ada-modal-pos-top-left .ada-modal-window {
    top: 24px;
    left: 24px;
}

/* Modal Header */
.ada-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--ada-surface-subtle);
    border-bottom: 1px solid var(--ada-border);
}
.ada-modal-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
}
.ada-badge-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--ada-primary);
    color: #ffffff;
    border-radius: 8px;
}
.ada-modal-header h2 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ada-text-main);
}
.ada-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.ada-btn-reset-top {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    font-size: 0.8rem;
    font-weight: 600;
    background: transparent;
    border: 1px solid var(--ada-border);
    border-radius: 6px;
    color: var(--ada-text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}
.ada-btn-reset-top:hover {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fca5a5;
}
.ada-btn-close {
    background: transparent;
    border: none;
    color: var(--ada-text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}
.ada-btn-close:hover {
    background: #e5e7eb;
    color: var(--ada-text-main);
}

/* Modal Body */
.ada-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.ada-modal-body::-webkit-scrollbar {
    width: 6px;
}
.ada-modal-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

/* Section */
.ada-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.ada-sec-title {
    margin: 0;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ada-text-muted);
    font-weight: 700;
}

/* Grid & Tiles */
.ada-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}
.ada-grid-profiles {
    grid-template-columns: repeat(2, 1fr);
}

.ada-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 6px;
    padding: 14px 10px;
    background: var(--ada-surface-subtle);
    border: 2px solid var(--ada-border);
    border-radius: 10px;
    cursor: pointer;
    color: var(--ada-text-main);
    transition: all 0.15s ease-in-out;
    user-select: none;
}
.ada-tile:hover {
    border-color: #cbd5e1;
    background: #f1f5f9;
}
.ada-tile:focus-visible,
.ada-btn-reset-top:focus-visible,
.ada-btn-close:focus-visible,
.ada-stepper button:focus-visible {
    outline: 3px solid var(--ada-focus-ring) !important;
    outline-offset: 2px;
}
.ada-tile-icon {
    font-size: 1.35rem;
    line-height: 1;
}
.ada-tile-label {
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.25;
}

/* Active State for Tiles */
.ada-tile.is-active {
    background-color: var(--ada-active-bg);
    border-color: var(--ada-active-border);
    color: var(--ada-primary);
}
.ada-tile.is-active .ada-tile-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--ada-primary);
    box-shadow: 0 0 0 2px #ffffff;
}

/* Font Size Stepper Tile */
.ada-stepper-tile {
    cursor: default;
}
.ada-stepper-tile:hover {
    background: var(--ada-surface-subtle);
    border-color: var(--ada-border);
}
.ada-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 4px;
}
.ada-stepper button {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--ada-border);
    background: var(--ada-surface);
    color: var(--ada-text-main);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}
.ada-stepper button:hover {
    background: #e2e8f0;
}
.ada-stepper span {
    font-size: 0.85rem;
    font-weight: 700;
    min-width: 44px;
    text-align: center;
}

/* Text to Speech Panel */
.ada-tts-panel {
    background: var(--ada-surface-subtle);
    border: 1px solid var(--ada-border);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ada-tts-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}
.ada-btn-tts {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 10px;
    background: var(--ada-primary);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s ease;
}
.ada-btn-tts:hover {
    opacity: 0.9;
}
.ada-btn-tts-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--ada-surface);
    border: 1px solid var(--ada-border);
    border-radius: 6px;
    cursor: pointer;
    color: var(--ada-text-main);
    transition: background 0.15s ease;
}
.ada-btn-tts-action:hover {
    background: #e2e8f0;
}
.ada-tts-status {
    font-size: 0.75rem;
    color: var(--ada-text-muted);
    font-style: italic;
    min-height: 18px;
}

/* Modal Footer */
.ada-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--ada-surface-subtle);
    border-top: 1px solid var(--ada-border);
}
.ada-btn-reset-all {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}
.ada-btn-reset-all:hover {
    background: #fecaca;
}
.ada-link-statement {
    background: transparent;
    border: none;
    color: var(--ada-primary);
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
}
.ada-link-statement:hover {
    color: #0c4a6e;
}

/* ==========================================================================
   Statement Dialog
   ========================================================================== */
.ada-statement-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999998;
    display: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}
.ada-statement-modal.is-open {
    display: block;
    opacity: 1;
    visibility: visible;
}
.ada-statement-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.55);
}
.ada-statement-window {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 540px;
    max-height: 80vh;
    background: #ffffff;
    border-radius: 14px;
    overflow-y: auto;
    box-shadow: var(--ada-shadow);
    padding: 24px;
    box-sizing: border-box;
    font-family: inherit;
    color: #1f2937;
    z-index: 999999;
}
.ada-statement-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 12px;
    margin-bottom: 16px;
}
.ada-statement-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
}
.ada-statement-body p {
    line-height: 1.6;
    margin-bottom: 12px;
}
.ada-stmt-contact {
    margin-top: 20px;
    padding: 14px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}
.ada-stmt-contact h4 {
    margin: 0 0 6px 0;
    font-size: 0.95rem;
}
.ada-contact-link {
    display: inline-block;
    color: var(--ada-primary);
    font-weight: 600;
    text-decoration: underline;
}

/* ==========================================================================
   Accessibility Feature Effects (Applied to HTML / BODY)
   ========================================================================== */

/* Reading Guide Bar */
.ada-reading-guide {
    display: none;
    position: fixed;
    left: 0;
    width: 100%;
    height: 4px;
    background: #0f52ba;
    box-shadow: 0 0 8px rgba(15, 82, 186, 0.6);
    z-index: 999980;
    pointer-events: none;
    transition: top 0.04s ease-out;
}
body.ada-active-reading-guide .ada-reading-guide {
    display: block;
}

/* Reading Mask */
.ada-reading-mask {
    display: none;
    position: fixed;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.65);
    z-index: 999975;
    pointer-events: none;
}
body.ada-active-reading-mask .ada-reading-mask {
    display: block;
}

/* Large Mouse Cursors */
body.ada-cursor-black,
body.ada-cursor-black * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 24 24'%3E%3Cpath fill='%23000000' stroke='%23ffffff' stroke-width='1.5' d='M3 3l7.5 18 3-6 6.5 3-1.5-3.5 6-3L3 3z'/%3E%3C/svg%3E"), auto !important;
}

body.ada-cursor-white,
body.ada-cursor-white * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 24 24'%3E%3Cpath fill='%23ffffff' stroke='%23000000' stroke-width='1.5' d='M3 3l7.5 18 3-6 6.5 3-1.5-3.5 6-3L3 3z'/%3E%3C/svg%3E"), auto !important;
}

/* Dyslexia-Friendly Typography */
body.ada-mode-dyslexic-font,
body.ada-mode-dyslexic-font * {
    font-family: "OpenDyslexic", "Comic Sans MS", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    letter-spacing: 0.05em !important;
    word-spacing: 0.1em !important;
    line-height: 1.8 !important;
}

/* High Contrast: Dark */
body.ada-mode-contrast-dark {
    background-color: #121212 !important;
    color: #ffffff !important;
}
body.ada-mode-contrast-dark *:not(#ada-accessibility-root):not(#ada-accessibility-root *) {
    background-color: #121212 !important;
    color: #ffffff !important;
    border-color: #444444 !important;
}
body.ada-mode-contrast-dark a:not(#ada-accessibility-root a) {
    color: #ffff00 !important;
    text-decoration: underline !important;
}

/* High Contrast: Light */
body.ada-mode-contrast-light {
    background-color: #ffffff !important;
    color: #000000 !important;
}
body.ada-mode-contrast-light *:not(#ada-accessibility-root):not(#ada-accessibility-root *) {
    background-color: #ffffff !important;
    color: #000000 !important;
    border-color: #000000 !important;
}
body.ada-mode-contrast-light a:not(#ada-accessibility-root a) {
    color: #0000ee !important;
    text-decoration: underline !important;
}

/* Invert Colors */
body.ada-mode-contrast-invert {
    filter: invert(100%) hue-rotate(180deg) !important;
}
body.ada-mode-contrast-invert img,
body.ada-mode-contrast-invert video,
body.ada-mode-contrast-invert iframe,
body.ada-mode-contrast-invert #ada-accessibility-root {
    filter: invert(100%) hue-rotate(180deg) !important;
}

/* Monochrome / Grayscale */
body.ada-mode-contrast-mono {
    filter: grayscale(100%) !important;
}

/* High Saturation */
body.ada-mode-contrast-saturate {
    filter: saturate(200%) !important;
}

/* Highlight Links */
body.ada-mode-highlight-links a:not(#ada-accessibility-root a) {
    background-color: #ffff00 !important;
    color: #000000 !important;
    text-decoration: underline !important;
    outline: 2px solid #000000 !important;
    font-weight: 700 !important;
}

/* Highlight Headings */
body.ada-mode-highlight-headings h1:not(#ada-accessibility-root *),
body.ada-mode-highlight-headings h2:not(#ada-accessibility-root *),
body.ada-mode-highlight-headings h3:not(#ada-accessibility-root *),
body.ada-mode-highlight-headings h4:not(#ada-accessibility-root *),
body.ada-mode-highlight-headings h5:not(#ada-accessibility-root *),
body.ada-mode-highlight-headings h6:not(#ada-accessibility-root *) {
    outline: 2px dashed #0f52ba !important;
    background-color: rgba(15, 82, 186, 0.08) !important;
    padding: 2px 6px !important;
    border-radius: 4px;
}

/* Line Height */
body.ada-mode-line-height *:not(#ada-accessibility-root):not(#ada-accessibility-root *) {
    line-height: 2 !important;
}

/* Letter Spacing */
body.ada-mode-letter-spacing *:not(#ada-accessibility-root):not(#ada-accessibility-root *) {
    letter-spacing: 0.15em !important;
}

/* Align Left */
body.ada-mode-align-left *:not(#ada-accessibility-root):not(#ada-accessibility-root *) {
    text-align: left !important;
}

/* Stop Animations & Flashing (Vestibular & Seizure Safe) */
body.ada-mode-stop-animations *:not(#ada-accessibility-root):not(#ada-accessibility-root *) {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
}

/* Font Sizing Scales */
html.ada-scale-1 { font-size: 110% !important; }
html.ada-scale-2 { font-size: 120% !important; }
html.ada-scale-3 { font-size: 130% !important; }
html.ada-scale-4 { font-size: 140% !important; }
html.ada-scale-neg-1 { font-size: 90% !important; }
html.ada-scale-neg-2 { font-size: 80% !important; }

/* Responsive Media Queries */
@media (max-width: 480px) {
    .ada-modal-window {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: 0 !important;
    }
    .ada-grid {
        grid-template-columns: 1fr;
    }
    .ada-pos-bottom-right,
    .ada-pos-bottom-left {
        bottom: 16px;
    }
}
