/* ── A11y Widget — bottom-right floating toolbar ── */

#a11y-widget {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 9000;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* FAB button */
.a11y-fab {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--color-accent, #0a5f66);
    background: var(--color-surface, #fff);
    color: var(--color-accent, #0a5f66);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
    transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
    padding: 0;
}

.a11y-fab svg {
    width: 22px;
    height: 22px;
    pointer-events: none;
}

.a11y-fab:hover {
    background: var(--color-accent, #0a5f66);
    color: #fff;
    transform: scale(1.06);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.22);
}

.a11y-fab:focus-visible {
    outline: 3px solid var(--color-focus, #0b6efd);
    outline-offset: 3px;
}

/* Panel */
.a11y-panel {
    position: absolute;
    bottom: 60px;
    right: 0;
    width: 220px;
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border, #dde1e6);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14);
    overflow: hidden;
}

.a11y-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border, #dde1e6);
    background: var(--color-bg, #f6f7f8);
}

.a11y-panel__title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-text-muted, #4a5056);
}

.a11y-close {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--color-text-muted, #4a5056);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.1s ease, color 0.1s ease;
}

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

.a11y-close:hover {
    background: var(--color-border, #dde1e6);
    color: var(--color-text, #1b1d1f);
}

.a11y-close:focus-visible {
    outline: 2px solid var(--color-focus, #0b6efd);
    outline-offset: 1px;
}

.a11y-panel__body {
    padding: 0.875rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

/* Sections */
.a11y-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.a11y-section__label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-muted, #4a5056);
}

/* Font size row */
.a11y-row {
    display: flex;
    gap: 0.375rem;
}

.a11y-btn {
    flex: 1;
    min-height: 36px;
    border: 1px solid var(--color-border, #dde1e6);
    border-radius: 7px;
    background: var(--color-bg, #f6f7f8);
    color: var(--color-text, #1b1d1f);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.1s ease, border-color 0.1s ease;
    font-family: inherit;
}

.a11y-btn:hover {
    background: var(--color-accent, #0a5f66);
    border-color: var(--color-accent, #0a5f66);
    color: #fff;
}

.a11y-btn:focus-visible {
    outline: 2px solid var(--color-focus, #0b6efd);
    outline-offset: 1px;
}

/* Toggle switches */
.a11y-toggles {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.a11y-toggle {
    min-height: 40px;
    padding: 0 0.75rem;
    border: 1px solid var(--color-border, #dde1e6);
    border-radius: 7px;
    background: var(--color-bg, #f6f7f8);
    color: var(--color-text, #1b1d1f);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-align: left;
    transition: background 0.1s ease, border-color 0.1s ease, color 0.1s ease;
    font-family: inherit;
}

.a11y-toggle svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.65;
}

.a11y-toggle:hover {
    border-color: var(--color-accent, #0a5f66);
    color: var(--color-accent, #0a5f66);
}

.a11y-toggle[aria-checked="true"] {
    background: var(--color-accent, #0a5f66);
    border-color: var(--color-accent, #0a5f66);
    color: #fff;
}

.a11y-toggle[aria-checked="true"] svg {
    opacity: 1;
}

.a11y-toggle:focus-visible {
    outline: 2px solid var(--color-focus, #0b6efd);
    outline-offset: 1px;
}

/* Reset button */
.a11y-reset-btn {
    width: 100%;
    min-height: 34px;
    border: 1px solid var(--color-border, #dde1e6);
    border-radius: 7px;
    background: transparent;
    color: var(--color-text-muted, #4a5056);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.1s ease, color 0.1s ease;
}

.a11y-reset-btn:hover {
    background: var(--color-border, #dde1e6);
    color: var(--color-text, #1b1d1f);
}

.a11y-reset-btn:focus-visible {
    outline: 2px solid var(--color-focus, #0b6efd);
    outline-offset: 1px;
}

/* ── High contrast mode ── */
[data-contrast="high"] {
    --color-bg: #000 !important;
    --color-surface: #000 !important;
    --color-text: #fff !important;
    --color-text-muted: #ffe066 !important;
    --color-accent: #ffe066 !important;
    --color-accent-hover: #fff !important;
    --color-border: #fff !important;
    --color-focus: #ffe066 !important;
    --shadow-sm: none !important;
    --shadow-md: none !important;
}

/* ── Reduced motion override ── */
[data-reduced-motion="true"] *,
[data-reduced-motion="true"] *::before,
[data-reduced-motion="true"] *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
}

/* ── Windows High Contrast passthrough ── */
@media (forced-colors: active) {
    .a11y-fab {
        border: 2px solid ButtonText;
        background: ButtonFace;
        color: ButtonText;
        forced-color-adjust: none;
    }
    .a11y-panel {
        border: 2px solid ButtonText;
    }
    .a11y-toggle[aria-checked="true"],
    .a11y-btn:hover,
    .a11y-toggle:hover {
        forced-color-adjust: none;
        background: Highlight;
        color: HighlightText;
        border-color: Highlight;
    }
}
