/* ===== Базовый движок режима доступности (универсальный). Подгонка под сайт — в templates/<tpl>/css/accessibility.css ===== */

/* Размер шрифта: масштаб корня */
html.a11y-size-1 { font-size: 125%; }
html.a11y-size-2 { font-size: 150%; }

/* Дефолтные переменные на случай, если схема ещё не выбрана */
html.a11y { --a11y-bg:#fff; --a11y-fg:#000; --a11y-link:#00f; }

/* Цветовые схемы (ГОСТ): фон/текст/ссылки */
html.a11y-scheme-0 { --a11y-bg:#fff; --a11y-fg:#000; --a11y-link:#00f; }
html.a11y-scheme-1 { --a11y-bg:#000; --a11y-fg:#fff; --a11y-link:#ffff00; }
html.a11y-scheme-2 { --a11y-bg:#f7f3d6; --a11y-fg:#4a3b1a; --a11y-link:#063e7a; }
html.a11y-scheme-3 { --a11y-bg:#9dd1ff; --a11y-fg:#063462; --a11y-link:#003; }

html.a11y body,
html.a11y body * {
    background-color: var(--a11y-bg) !important;
    color: var(--a11y-fg) !important;
    border-color: var(--a11y-fg) !important;
    box-shadow: none !important;
    text-shadow: none !important;
}
html.a11y a, html.a11y a * { color: var(--a11y-link) !important; text-decoration: underline; }
html.a11y svg { fill: var(--a11y-fg) !important; }

/* Шрифт */
html.a11y-font-0, html.a11y-font-0 * { font-family: Arial, "Helvetica Neue", sans-serif !important; }
html.a11y-font-1, html.a11y-font-1 * { font-family: Georgia, "Times New Roman", serif !important; }

/* Интервалы */
html.a11y-ls-1, html.a11y-ls-1 * { letter-spacing: 0.12em !important; }
html.a11y-lh-1, html.a11y-lh-1 * { line-height: 2 !important; }

/* Изображения: скрыть все, затем вернуть иконки панели (каскад, без сложного :not) */
html.a11y img { filter: grayscale(100%) contrast(1.1); }
html.a11y-noimg img { display: none !important; }
html.a11y-noimg svg { display: none !important; }
html.a11y-noimg .a11y-panel svg { display: inline !important; }

/* Универсальная починка кнопок (фон убран схемой -> возвращаем рамку и читаемость) */
html.a11y .btn,
html.a11y button,
html.a11y [type="submit"] {
    background-color: var(--a11y-bg) !important;
    color: var(--a11y-fg) !important;
    border: 2px solid var(--a11y-fg) !important;
    width: auto !important; min-width: 0 !important;
    white-space: normal !important; height: auto !important;
    box-shadow: none !important;
}

/* Псевдоэлементы-фоны (декор) гасим */
html.a11y *::before, html.a11y *::after { background-image: none !important; }

/* ===== Панель управления: layout ===== */
/* Скрыта по умолчанию — видна только при включённом режиме (html.a11y) */
.a11y-panel {
    display: none;
    position: fixed; left: 0; right: 0; z-index: 99999;
    flex-wrap: wrap; align-items: center; gap: .5rem;
    padding: .5rem 1rem; font: 16px/1.4 Arial, sans-serif;
}
html.a11y .a11y-panel { display: flex; }
.a11y-panel--bottom { bottom: 0; }
.a11y-panel--top { top: 0; }
.a11y-panel__group { display: flex; align-items: center; gap: .25rem; }
.a11y-panel button:focus-visible { outline: 3px solid #ffd400; outline-offset: 2px; }
.a11y-panel__sz-1 { font-size: 1.1rem; }
.a11y-panel__sz-2 { font-size: 1.35rem; }
.a11y-panel__sw { width: 2.2rem; }

/* Цвета панели — префикс html.a11y поднимает специфичность выше «бланкетных» правил схемы.
   Контейнер тёмный; группы/метки — прозрачный фон (иначе бланкетное правило схемы красит
   их фон в цвет страницы и белый текст становится невидим). */
html.a11y .a11y-panel { background: #1f1f1f !important; color: #fff !important; border-color: transparent !important; }
html.a11y .a11y-panel__group { background: transparent !important; color: #fff !important; }
html.a11y .a11y-panel__label { opacity: .8; margin-right: .25rem; background: transparent !important; color: #fff !important; }
html.a11y .a11y-panel button {
    cursor: pointer; border: 1px solid #fff !important; background: #2c2c2c !important; color: #fff !important;
    min-width: 2.2rem; min-height: 2.2rem; padding: .25rem .5rem; border-radius: .25rem;
}
html.a11y .a11y-panel button[aria-pressed="true"] { background: #fff !important; color: #000 !important; }
html.a11y .a11y-panel a, html.a11y .a11y-panel a * { color: #fff !important; }
html.a11y .a11y-panel svg { fill: #fff !important; }
/* Свотчи всегда показывают цвет своей схемы (button.КЛАСС = специфичнее общей кнопки и
   её pressed-состояния); активная схема отмечается обводкой, а не сменой фона. */
html.a11y .a11y-panel button.a11y-panel__sw-0 { background:#fff !important; color:#000 !important; }
html.a11y .a11y-panel button.a11y-panel__sw-1 { background:#000 !important; color:#fff !important; }
html.a11y .a11y-panel button.a11y-panel__sw-2 { background:#f7f3d6 !important; color:#4a3b1a !important; }
html.a11y .a11y-panel button.a11y-panel__sw-3 { background:#9dd1ff !important; color:#063462 !important; }
html.a11y .a11y-panel button.a11y-panel__sw[aria-pressed="true"] { outline: 3px solid #ffd400 !important; outline-offset: 1px; }

/* отступ под панель */
html.a11y body { scroll-padding-bottom: 4rem; }
