/* ===== ВЕРСИЯ ДЛЯ СЛАБОВИДЯЩИХ ===== */

.a11y-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 2px solid var(--primary);
    border-radius: 20px;
    background: var(--card-bg);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}

.a11y-toggle:hover,
.a11y-toggle[aria-pressed="true"] {
    background: var(--primary);
    color: var(--text-on-primary);
}

.header-utility .a11y-toggle {
    border-color: rgba(255, 255, 255, 0.45);
    background: transparent;
    color: var(--text-on-primary);
    font-size: 0.78rem;
    padding: 5px 12px;
}

.header-utility .a11y-toggle:hover,
.header-utility .a11y-toggle[aria-pressed="true"] {
    background: rgba(255, 255, 255, 0.15);
    border-color: #fff;
    color: var(--text-on-primary);
}

.header-utility .a11y-toggle-text {
    display: inline;
}

.a11y-toggle-icon {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1;
}

.a11y-panel {
    display: none;
    background: var(--card-bg);
    border-bottom: 3px solid var(--primary);
    box-shadow: var(--shadow);
    position: relative;
    z-index: 10000;
}

.a11y-panel.active {
    display: block;
}

.a11y-panel-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px 24px;
    padding: 14px 20px;
}

.a11y-panel-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    margin-right: 8px;
}

.a11y-panel-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    border: none;
    margin: 0;
    padding: 0;
}

.a11y-panel-group legend {
    font-size: 0.85rem;
    font-weight: 600;
    margin-right: 6px;
    padding: 0;
    float: left;
}

.a11y-panel-btn {
    min-width: 36px;
    min-height: 36px;
    padding: 6px 12px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: var(--body-bg);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.a11y-panel-btn:hover {
    border-color: var(--primary);
}

.a11y-panel-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--text-on-primary);
}

.a11y-panel-btn.a11y-panel-reset {
    margin-left: auto;
    border-color: var(--accent);
    color: var(--accent);
}

.a11y-panel-btn.a11y-panel-reset:hover {
    background: var(--accent);
    color: var(--text-on-primary);
}

.a11y-toggle-fixed {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 9999;
}

/* --- Режим для слабовидящих: базовые настройки --- */
html.a11y-mode body {
    font-weight: 400;
    letter-spacing: 0.02em;
}

html.a11y-mode a {
    text-decoration: underline !important;
    text-underline-offset: 3px;
}

html.a11y-mode :focus-visible {
    outline: 3px solid currentColor !important;
    outline-offset: 2px;
}

html.a11y-mode .site-title,
html.a11y-mode h1,
html.a11y-mode h2,
html.a11y-mode h3,
html.a11y-mode h4 {
    font-weight: 700;
}

/* Размер шрифта */
html.a11y-mode.a11y-fs-sm { font-size: 16px; }
html.a11y-mode.a11y-fs-md { font-size: 18px; }
html.a11y-mode.a11y-fs-lg { font-size: 22px; }
html.a11y-mode.a11y-fs-xl { font-size: 26px; }

html.a11y-mode.a11y-spacing body {
    letter-spacing: 0.08em;
    word-spacing: 0.12em;
}

/* Чёрным по белому */
html.a11y-mode.a11y-theme-bw {
    --body-bg: #ffffff;
    --card-bg: #ffffff;
    --text-primary: #000000;
    --text-on-primary: #ffffff;
    --primary: #000000;
    --primary-hover: #333333;
    --primary-active: #000000;
    --primary-rgb: 0, 0, 0;
    --accent: #000000;
    --accent-hover: #333333;
    --green-accent: #000000;
    --border-color: #000000;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --overlay-color: rgba(0, 0, 0, 0.85);
}

/* Белым по чёрному */
html.a11y-mode.a11y-theme-wb {
    --body-bg: #000000;
    --card-bg: #121212;
    --text-primary: #ffffff;
    --text-on-primary: #000000;
    --primary: #ffffff;
    --primary-hover: #e0e0e0;
    --primary-active: #ffffff;
    --primary-rgb: 255, 255, 255;
    --accent: #ffffff;
    --accent-hover: #e0e0e0;
    --green-accent: #ffffff;
    --border-color: #ffffff;
    --shadow-color: rgba(255, 255, 255, 0.2);
    --overlay-color: rgba(0, 0, 0, 0.9);
}

html.a11y-mode.a11y-theme-wb img {
    filter: brightness(0.85);
}

/* Синяя схема (ГОСТ) */
html.a11y-mode.a11y-theme-blue {
    --body-bg: #9dd1ff;
    --card-bg: #ccebff;
    --text-primary: #063462;
    --text-on-primary: #ffffff;
    --primary: #063462;
    --primary-hover: #0a4a8a;
    --primary-active: #063462;
    --primary-rgb: 6, 52, 98;
    --accent: #063462;
    --accent-hover: #0a4a8a;
    --green-accent: #063462;
    --border-color: #063462;
    --shadow-color: rgba(6, 52, 98, 0.25);
    --overlay-color: rgba(6, 52, 98, 0.85);
}

/* Скрытие изображений */
html.a11y-mode.a11y-images-off img:not(.a11y-keep) {
    visibility: hidden;
}

html.a11y-mode.a11y-images-off .slider,
html.a11y-mode.a11y-images-off .qr-card img,
html.a11y-mode.a11y-images-off .news-card img,
html.a11y-mode.a11y-images-off .book-cover {
    min-height: 48px;
    background: var(--border-color);
    border: 2px dashed var(--text-primary);
}

html.a11y-mode.a11y-images-off .logo-icon img {
    visibility: visible;
    filter: none;
}

@media (max-width: 767px) {
    .a11y-toggle-text {
        display: none;
    }

    .header-utility-label {
        display: none;
    }

    .a11y-panel-inner {
        flex-direction: column;
        align-items: stretch;
    }

    .a11y-panel-group {
        width: 100%;
    }

    .a11y-panel-btn.a11y-panel-reset {
        margin-left: 0;
        width: 100%;
    }
}
