/* ============================
   Accessibility toolbar + body modes
   ============================ */

/* ---------- Toolbar: floating panel, hidden by default ---------- */
.a11y-toolbar-wrap {
    position: fixed;
    top: 72px;
    left: 50%;
    transform: translateX(-50%) translateY(-12px);
    z-index: 110;
    display: flex;
    justify-content: center;
    padding: 0 var(--s-3);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--motion-fast), transform var(--motion-fast), visibility var(--motion-fast);
    max-width: calc(100vw - 32px);
}
.a11y-toolbar-wrap.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}
.a11y-toolbar {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: #fff;
    border: 1px solid var(--c-line);
    border-radius: var(--r-pill);
    padding: 4px;
    box-shadow: var(--sh-lg);
    font-family: var(--ff-sans);
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
}
.a11y-toolbar::-webkit-scrollbar { display: none; }

/* Trigger button (lives in top-bar) */
.a11y-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px 3px 3px;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.15);
    border-radius: var(--r-pill);
    color: inherit;
    font-size: var(--fs-xs);
    font-weight: var(--fw-semi);
    cursor: pointer;
    transition: background-color var(--motion-fast), color var(--motion-fast);
    font-family: inherit;
}
.a11y-trigger:hover,
.a11y-trigger.is-open {
    background: var(--c-gold);
    color: var(--c-brand-deep);
    border-color: var(--c-gold);
}
.a11y-trigger-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: var(--c-brand);
    color: #fff;
    border-radius: 50%;
    font-size: 0.72rem;
    flex-shrink: 0;
}
.a11y-trigger:hover .a11y-trigger-icon,
.a11y-trigger.is-open .a11y-trigger-icon {
    background: var(--c-brand-deep);
    color: var(--c-gold);
}
.a11y-trigger-label { white-space: nowrap; }

@media (max-width: 720px) {
    .a11y-trigger-label { display: none; }
    .a11y-trigger { padding: 3px; }
}

.a11y-label {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    padding: 6px 14px;
    background: transparent;
    border: none;
    color: var(--c-text);
    font-size: var(--fs-sm);
    font-weight: var(--fw-semi);
    white-space: nowrap;
    border-radius: var(--r-pill);
    cursor: default;
}
.a11y-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--c-brand);
    color: #fff;
    border-radius: 50%;
    font-size: 0.85rem;
}

.a11y-divider {
    width: 1px;
    height: 24px;
    background: var(--c-line);
    margin: 0 4px;
    flex-shrink: 0;
}

.a11y-group { display: inline-flex; align-items: center; gap: 2px; }

.a11y-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: transparent;
    border: none;
    border-radius: var(--r-pill);
    color: var(--c-text);
    font-family: inherit;
    font-size: var(--fs-sm);
    font-weight: var(--fw-semi);
    cursor: pointer;
    transition: background-color var(--motion-fast), color var(--motion-fast);
    white-space: nowrap;
}
.a11y-btn:hover { background: var(--c-bg-soft); }
.a11y-btn:focus-visible { outline: 2px solid var(--c-brand); outline-offset: 2px; }
.a11y-btn.active {
    background: var(--c-brand);
    color: #fff;
}
.a11y-btn i { font-size: 0.85rem; }

.a11y-fs {
    width: 34px;
    height: 34px;
    justify-content: center;
    padding: 0;
    font-family: var(--ff-serif);
    font-weight: var(--fw-bold);
}
.a11y-fs { font-size: 0.85rem; }
.a11y-fs.md { font-size: 1rem; }
.a11y-fs.lg { font-size: 1.2rem; }

/* FAB no longer needed — toolbar is always visible at top */
.a11y-fab { display: none !important; }

/* Mobile: hide labels, keep icons/dividers compact */
@media (max-width: 720px) {
    .a11y-label span,
    .a11y-btn span { display: none; }
    .a11y-btn { padding: 6px 8px; min-width: 32px; justify-content: center; }
    .a11y-fs { width: 30px; height: 30px; }
    .a11y-toolbar { gap: 0; }
    .a11y-divider { margin: 0 2px; }
}

/* ============================
   BODY MODE OVERRIDES (apply classes to <html>)
   ============================ */

/* ---------- Font size ---------- */
html.a11y-fs-large   { font-size: 112.5%; }  /* 18px base */
html.a11y-fs-xl      { font-size: 125%; }    /* 20px base */

/* ---------- High contrast ---------- */
html.a11y-contrast {
    --c-brand:        #000;
    --c-brand-light:  #003399;
    --c-brand-deep:   #000;
    --c-gold:         #ffd500;
    --c-text:         #000;
    --c-muted:        #000;
    --c-line:         #000;
    --c-bg:           #fff;
    --c-bg-soft:      #fff;
    --sh-sm: none;
    --sh-md: none;
    --sh-lg: none;
}
html.a11y-contrast * {
    text-shadow: none !important;
    font-weight: 600 !important;
}
html.a11y-contrast .btn,
html.a11y-contrast .chip-dark,
html.a11y-contrast .chip {
    border: 2px solid currentColor !important;
}

/* ---------- Grayscale ---------- */
html.a11y-grayscale body {
    filter: grayscale(1);
}

/* ---------- Dark mode ---------- */
html.a11y-dark {
    --c-brand:        #4a7bcc;
    --c-brand-light:  #6d99e5;
    --c-brand-deep:   #0f1a33;
    --c-gold:         #e0b83a;
    --c-gold-light:   #f0c84a;
    --c-text:         #e5e7eb;
    --c-muted:        #9ca3af;
    --c-line:         #2a3245;
    --c-bg:           #0f1724;
    --c-bg-soft:      #1a2435;
}
html.a11y-dark body { background: var(--c-bg); color: var(--c-text); }
html.a11y-dark .site-header,
html.a11y-dark .main-menu-bar,
html.a11y-dark .site-footer,
html.a11y-dark .top-bar,
html.a11y-dark .tn-card,
html.a11y-dark .media-card,
html.a11y-dark .lesson-card,
html.a11y-dark .fund-col,
html.a11y-dark .forum-panel,
html.a11y-dark .poll-panel,
html.a11y-dark .latest-news-card,
html.a11y-dark .chart-card,
html.a11y-dark .rank-card,
html.a11y-dark .geo-panel.floating {
    background: var(--c-bg-soft);
    color: var(--c-text);
}
html.a11y-dark .top-bar { background: #000; }
html.a11y-dark input[type="search"],
html.a11y-dark input[type="text"] { color: var(--c-text); }

/* ---------- Underline all links ---------- */
html.a11y-links a {
    text-decoration: underline !important;
    text-underline-offset: 2px;
    text-decoration-thickness: 2px;
    color: var(--c-brand) !important;
}
html.a11y-links a:hover { color: var(--c-gold) !important; }

/* ---------- Disable motion ---------- */
html.a11y-no-motion *,
html.a11y-no-motion *::before,
html.a11y-no-motion *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
}
