/**
 * TaskHero Accessibility Widget Styles
 * ============================================================ */

/* ===== Floating Toggle Button ===== */
.a11y-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #2563eb;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px -5px rgba(37, 99, 235, 0.5);
    cursor: pointer;
    z-index: 9998;
    border: none;
    transition: transform 0.2s, background 0.2s;
}
.a11y-toggle:hover { transform: scale(1.08); background: #1d4ed8; }
.a11y-toggle:focus-visible { outline: 3px solid #fbbf24; outline-offset: 3px; }
.a11y-toggle svg { width: 28px; height: 28px; }

/* When panel is open, toggle turns into close button */
.a11y-toggle.is-open { background: #dc2626; }
.a11y-toggle.is-open:hover { background: #b91c1c; }

/* ===== Panel ===== */
.a11y-panel {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 360px;
    max-width: calc(100vw - 48px);
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.25);
    z-index: 9999;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
    direction: rtl;
    text-align: right;
    font-family: 'Assistant', sans-serif;
}
.a11y-panel.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.a11y-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid #f3f4f6;
}
.a11y-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 800;
    color: #1e3a8a;
    margin: 0;
}
.a11y-title svg { width: 22px; height: 22px; }
.a11y-reset {
    background: none;
    border: none;
    color: #dc2626;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    font-family: inherit;
}
.a11y-reset:hover { background: #fef2f2; }

.a11y-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}
.a11y-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.a11y-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 6px;
    background: #f9fafb;
    border: 2px solid transparent;
    border-radius: 14px;
    color: #374151;
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
    min-height: 86px;
    line-height: 1.3;
}
.a11y-btn svg { width: 22px; height: 22px; color: #4b5563; }
.a11y-btn:hover { background: #eff6ff; color: #1e3a8a; }
.a11y-btn:hover svg { color: #2563eb; }
.a11y-btn.is-active {
    background: #dbeafe;
    border-color: #2563eb;
    color: #1e3a8a;
}
.a11y-btn.is-active svg { color: #2563eb; }
.a11y-btn:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }

/* ===== Big-apps toggle row ===== */
.a11y-footer {
    padding: 14px 20px;
    background: #eff6ff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.a11y-footer-label {
    font-size: 14px;
    font-weight: 800;
    color: #1e3a8a;
}
.a11y-switch {
    position: relative;
    width: 48px;
    height: 26px;
    background: #cbd5e1;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}
.a11y-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    right: 3px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}
.a11y-switch.is-on { background: #2563eb; }
.a11y-switch.is-on::after { transform: translateX(-22px); }

/* ============================================================
   GLOBAL EFFECTS — applied via classes on <html>
   ============================================================ */

/* ---- Text scaling ---- */
html.a11y-text-lg    { font-size: 112.5%; }
html.a11y-text-xl    { font-size: 125%; }
html.a11y-text-xxl   { font-size: 140%; }

/* ---- Readable typography (dyslexia-friendly) ---- */
html.a11y-readable body,
html.a11y-readable body * {
    font-family: Arial, Verdana, Tahoma, sans-serif !important;
    letter-spacing: 0.05em !important;
    word-spacing: 0.1em !important;
    line-height: 1.8 !important;
}

/* ---- Line height ---- */
html.a11y-line-height body,
html.a11y-line-height body * {
    line-height: 2 !important;
}

/* ---- Letter spacing ---- */
html.a11y-spacing body,
html.a11y-spacing body * {
    letter-spacing: 0.12em !important;
    word-spacing: 0.2em !important;
}

/* ---- Text alignment ---- */
html.a11y-align-right body * { text-align: right !important; }
html.a11y-align-center body * { text-align: center !important; }
html.a11y-align-left body * { text-align: left !important; }

/* ---- Big cursor ---- */
html.a11y-big-cursor,
html.a11y-big-cursor * {
    cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24' fill='%23000' stroke='%23fff' stroke-width='1.5'><path d='M3 2l7 18 2-8 8-2z'/></svg>") 0 0, auto !important;
}
html.a11y-big-cursor a,
html.a11y-big-cursor button,
html.a11y-big-cursor [role="button"],
html.a11y-big-cursor input,
html.a11y-big-cursor select,
html.a11y-big-cursor textarea {
    cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24' fill='%23dc2626' stroke='%23fff' stroke-width='1.5'><path d='M3 2l7 18 2-8 8-2z'/></svg>") 0 0, pointer !important;
}

/* ---- Highlight links ---- */
html.a11y-highlight-links a {
    background-color: #fef08a !important;
    color: #000 !important;
    text-decoration: underline !important;
    text-decoration-thickness: 2px !important;
    padding: 2px 4px !important;
    border-radius: 3px !important;
}

/* ---- Hide images ---- */
html.a11y-hide-images img,
html.a11y-hide-images picture,
html.a11y-hide-images video,
html.a11y-hide-images svg:not(.a11y-panel svg):not(.a11y-toggle svg) {
    visibility: hidden !important;
}
html.a11y-hide-images [style*="background-image"] {
    background-image: none !important;
}

/* ---- Stop animations ---- */
html.a11y-no-motion *,
html.a11y-no-motion *::before,
html.a11y-no-motion *::after {
    animation-duration: 0.001s !important;
    animation-delay: 0s !important;
    transition-duration: 0.001s !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
}

/* ---- Color profiles ---- */
html.a11y-high-contrast body {
    background: #000 !important;
    color: #fff !important;
}
html.a11y-high-contrast body *,
html.a11y-high-contrast body *::before,
html.a11y-high-contrast body *::after {
    background-color: transparent !important;
    color: #fff !important;
    border-color: #fff !important;
}
html.a11y-high-contrast body a,
html.a11y-high-contrast body a * {
    color: #fbbf24 !important;
}
html.a11y-high-contrast body button,
html.a11y-high-contrast body .btn-primary,
html.a11y-high-contrast body .btn-secondary,
html.a11y-high-contrast body .header-cta {
    background: #fff !important;
    color: #000 !important;
    border: 2px solid #fff !important;
}
html.a11y-high-contrast img,
html.a11y-high-contrast video {
    filter: grayscale(100%) contrast(1.2);
}

html.a11y-negative-contrast body {
    filter: invert(100%) hue-rotate(180deg);
}
html.a11y-negative-contrast img,
html.a11y-negative-contrast video,
html.a11y-negative-contrast iframe {
    filter: invert(100%) hue-rotate(180deg);
}

html.a11y-light-bg body,
html.a11y-light-bg body * {
    background-color: #fff !important;
    color: #000 !important;
}

/* ---- Reading guide (horizontal bar following cursor) ---- */
.a11y-reading-guide {
    position: fixed;
    left: 0;
    right: 0;
    height: 40px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 2px solid #fbbf24;
    border-bottom: 2px solid #fbbf24;
    pointer-events: none;
    z-index: 9997;
    display: none;
}
html.a11y-reading-guide-on .a11y-reading-guide { display: block; }

/* ---- Focus indicators (always improved when a11y is active) ---- */
html.a11y-focus-visible *:focus-visible {
    outline: 3px solid #2563eb !important;
    outline-offset: 3px !important;
}

/* ===== Mobile: force panel to safe position regardless of button position ===== */
@media (max-width: 480px) {
    .a11y-panel {
        right: 12px !important;
        left: 12px !important;
        bottom: 84px !important;
        top: auto !important;
        width: auto !important;
        max-width: none !important;
        max-height: calc(100vh - 120px);
        max-height: calc(100dvh - 120px);
    }
    .a11y-toggle {
        bottom: calc(16px + env(safe-area-inset-bottom)) !important;
        right: 16px !important;
        top: auto !important;
        left: auto !important;
        width: 52px !important;
        height: 52px !important;
        transform: none !important;
    }
    .a11y-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .a11y-btn { min-height: 78px; padding: 10px 4px; font-size: 11px; }
    .a11y-btn svg { width: 20px; height: 20px; }
}

/* ===== Very small screens (iPhone SE) ===== */
@media (max-width: 360px) {
    .a11y-grid { grid-template-columns: repeat(2, 1fr); }
    .a11y-btn { min-height: 80px; font-size: 12px; }
}

/* ===== Print: hide widget ===== */
@media print {
    .a11y-toggle, .a11y-panel, .a11y-reading-guide { display: none !important; }
}
