﻿/*
 * Версия для слабовидящих: кнопка «Глазок» в шапке открывает «Меню доступности» —
 * боковую панель с плитками настроек.
 * Логика — Content/js/custom/accessibility.js, разметка — Views/Shared/_AccessibilityMenu.cshtml.
 *
 * Выбранные настройки выставляются классами на <html>: a11y-<настройка>-<значение>,
 * например a11y-contrast-dark, a11y-textsize-140, a11y-cursor-guide.
 * Служебные классы: a11y-active — включена хотя бы одна настройка,
 * a11y-text-scaled — увеличен текст, a11y-filter — активен цветовой фильтр.
 *
 * Все переопределения содержимого страницы исключают собственные элементы режима (.a11y-ui),
 * чтобы меню оставалось читаемым при любых настройках.
 */

/* ======================= Кнопка «Глазок» ======================= */

.a11y-toggle {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 3em;
    height: 3em;
    margin: 0 1em;
    padding: 0;
    color: #0E3AA1;
    background: #fff;
    border: 1px solid #d3d4d8;
    border-radius: 0.25em;
    cursor: pointer;
}

.a11y-toggle:hover,
.a11y-toggle[aria-expanded="true"] {
    color: #fff;
    background: #0E3AA1;
    border-color: #0E3AA1;
}

.a11y-toggle__icon {
    width: 1.5em;
    height: 1.5em;
}

/* Отметка «настройки включены» */
.a11y-toggle__badge {
    position: absolute;
    top: -6px;
    right: -6px;
    display: none;
    width: 16px;
    height: 16px;
    background: #1bb35a url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px no-repeat;
    border: 2px solid #fff;
    border-radius: 50%;
}

html.a11y-active .a11y-toggle__badge {
    display: block;
}

/* ======================= Меню доступности ======================= */

/* Размеры меню в px: оно не должно масштабироваться вместе с текстом страницы */
.a11y-menu {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    width: 420px;
    max-width: 100vw;
    font-family: "Tahoma", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.35;
    color: #1d2226;
    text-align: left;
    background: #eef1f7;
    -webkit-box-shadow: -8px 0 24px rgba(0, 0, 0, 0.2);
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.2);
    animation: a11yMenuIn 200ms ease-out;
}

.a11y-menu[hidden] {
    display: none;
}

@keyframes a11yMenuIn {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}

.a11y-menu_big {
    width: 520px;
    font-size: 17px;
}

.a11y-menu__header {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    color: #fff;
    background: #0E3AA1;
}

.a11y-menu__title {
    margin: 0;
    font-size: 1.15em;
    font-weight: bold;
    color: inherit;
}

.a11y-menu__hotkey {
    font-weight: normal;
    opacity: 0.85;
}

.a11y-menu__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    color: #0E3AA1;
    background: #fff;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.a11y-menu__close svg {
    width: 16px;
    height: 16px;
}

.a11y-menu__body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px;
}

.a11y-menu__switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    cursor: pointer;
}

.a11y-menu__switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.a11y-menu__switch-track {
    position: relative;
    width: 40px;
    height: 22px;
    background: #9aa1ad;
    border-radius: 11px;
    transition: background 150ms;
}

.a11y-menu__switch-track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: left 150ms;
}

.a11y-menu__switch input:checked + .a11y-menu__switch-track {
    background: #0E3AA1;
}

.a11y-menu__switch input:checked + .a11y-menu__switch-track::after {
    left: 21px;
}

.a11y-menu__switch input:focus-visible + .a11y-menu__switch-track {
    outline: 3px solid #ffbf47;
    outline-offset: 2px;
}

.a11y-menu__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

/* Плитка настройки */
.a11y-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 118px;
    padding: 14px 8px 18px;
    font: inherit;
    line-height: 1.25;
    color: #1d2226;
    text-align: center;
    background: #fff;
    border: 2px solid transparent;
    border-radius: 10px;
    cursor: pointer;
}

.a11y-tile:hover {
    border-color: #9db1e6;
}

.a11y-tile[aria-pressed="true"] {
    border-color: #0E3AA1;
}

.a11y-tile__icon {
    width: 32px;
    height: 32px;
    color: #1d2226;
}

.a11y-tile__title {
    font-weight: bold;
}

.a11y-tile__step {
    display: none;
    font-size: 0.9em;
    color: #0E3AA1;
}

.a11y-tile[data-a11y-level="1"] .a11y-tile__step:nth-child(1),
.a11y-tile[data-a11y-level="2"] .a11y-tile__step:nth-child(2),
.a11y-tile[data-a11y-level="3"] .a11y-tile__step:nth-child(3),
.a11y-tile[data-a11y-level="4"] .a11y-tile__step:nth-child(4) {
    display: block;
}

.a11y-tile__check {
    position: absolute;
    top: 8px;
    right: 8px;
    display: none;
    width: 18px;
    height: 18px;
    background: #0E3AA1 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 14px no-repeat;
    border-radius: 50%;
}

.a11y-tile[aria-pressed="true"] .a11y-tile__check {
    display: block;
}

/* Индикатор шагов у настроек с несколькими режимами */
.a11y-tile__dots {
    position: absolute;
    right: 14px;
    bottom: 8px;
    left: 14px;
    display: flex;
    gap: 4px;
}

.a11y-tile__dots i {
    flex: 1;
    height: 4px;
    background: #d6dbe5;
    border-radius: 2px;
}

.a11y-tile[data-a11y-level="1"] .a11y-tile__dots i:nth-child(-n+1),
.a11y-tile[data-a11y-level="2"] .a11y-tile__dots i:nth-child(-n+2),
.a11y-tile[data-a11y-level="3"] .a11y-tile__dots i:nth-child(-n+3),
.a11y-tile[data-a11y-level="4"] .a11y-tile__dots i:nth-child(-n+4) {
    background: #0E3AA1;
}

.a11y-menu__reset {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    margin-top: 16px;
    padding: 12px 16px;
    font: inherit;
    font-weight: bold;
    color: #fff;
    background: #0E3AA1;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
}

.a11y-menu__reset svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.a11y-menu__reset:hover {
    background: #0a2d7e;
}

/* Заметный фокус клавиатуры в меню всегда, на странице — когда включена любая настройка */
.a11y-toggle:focus-visible,
.a11y-ui button:focus-visible,
html.a11y-active :focus-visible {
    outline: 3px solid #ffbf47 !important;
    outline-offset: 2px;
}

/* ======================= Контраст + ======================= */

/*
 * Цветовые фильтры (инверсия, насыщенность) висят на корневом элементе и складываются через переменные.
 * На <html>, в отличие от <body>, фильтр не ломает position: fixed у модальных окон и лоадера.
 */
html.a11y-contrast-invert {
    --a11y-invert: invert(1) hue-rotate(180deg);
}

html.a11y-saturation-low {
    --a11y-saturate: saturate(0.5);
}

html.a11y-saturation-high {
    --a11y-saturate: saturate(2);
}

html.a11y-saturation-none {
    --a11y-saturate: grayscale(1);
}

html.a11y-filter {
    filter: var(--a11y-invert, invert(0)) var(--a11y-saturate, saturate(1));
}

/* Фото, флаги, логотипы провайдеров и само меню инвертируем обратно, чтобы они выглядели как обычно.
   Логотип банка не трогаем: на тёмном фоне его светлый вариант читается лучше. */
html.a11y-contrast-invert img:not(.logo__image),
html.a11y-contrast-invert video,
html.a11y-contrast-invert canvas,
html.a11y-contrast-invert iframe,
html.a11y-contrast-invert .a11y-ui {
    filter: invert(1) hue-rotate(180deg);
}

/* Тёмный контраст: белый текст на чёрном, ссылки жёлтые */
html.a11y-contrast-dark body,
html.a11y-contrast-dark body :not(.a11y-ui, .a11y-ui *) {
    color: #fff !important;
    background-color: #000 !important;
    border-color: #fff !important;
    -webkit-box-shadow: none !important;
    box-shadow: none !important;
}

html.a11y-contrast-dark body a:not(.a11y-ui *),
html.a11y-contrast-dark body a:not(.a11y-ui *) * {
    color: #ffe600 !important;
}

html.a11y-contrast-dark body ::placeholder {
    color: #c8c8c8 !important;
}

/* Светлый контраст: чёрный текст на белом, ссылки тёмно-синие */
html.a11y-contrast-light body,
html.a11y-contrast-light body :not(.a11y-ui, .a11y-ui *) {
    color: #000 !important;
    background-color: #fff !important;
    border-color: #000 !important;
    -webkit-box-shadow: none !important;
    box-shadow: none !important;
}

html.a11y-contrast-light body a:not(.a11y-ui *),
html.a11y-contrast-light body a:not(.a11y-ui *) * {
    color: #0000b3 !important;
}

html.a11y-contrast-light body ::placeholder {
    color: #505050 !important;
}

/* ======================= Выделить ссылки ======================= */

html.a11y-links-on body a:not(.a11y-ui *) {
    color: #000 !important;
    text-decoration: underline !important;
    background-color: #ffe600 !important;
    outline: 2px solid #000 !important;
    outline-offset: 1px;
}

html.a11y-links-on body a:not(.a11y-ui *) * {
    color: #000 !important;
}

/* ======================= Больший текст ======================= */

/*
 * Базовые размеры заданы в em от html { font-size: 62.5% } (reset.css),
 * поэтому масштабируем корень, а редкие правила в px пересчитываем через --a11y-scale.
 */
html.a11y-textsize-120 {
    --a11y-scale: 1.2;
    font-size: 75%;
}

html.a11y-textsize-140 {
    --a11y-scale: 1.4;
    font-size: 87.5%;
}

html.a11y-textsize-160 {
    --a11y-scale: 1.6;
    font-size: 100%;
}

html.a11y-text-scaled .dropdown-menu-item,
html.a11y-text-scaled .form-hint,
html.a11y-text-scaled .sidebar-menu__item,
html.a11y-text-scaled .user-widget__name,
html.a11y-text-scaled .flatpickr-calendar,
html.a11y-text-scaled .flatpickr-time input {
    font-size: calc(14px * var(--a11y-scale));
}

html.a11y-text-scaled .form-item__error,
html.a11y-text-scaled .textarea_style_default .textarea__control,
html.a11y-text-scaled .pagination_style_default .pagination__item {
    font-size: calc(16px * var(--a11y-scale));
}

/* ---------- Совместимость вёрстки с крупным текстом ----------
 *
 * Вёрстка рассчитана на базовый размер шрифта: колонки таблиц заданы в процентах при
 * table-layout: fixed, подписи кнопок не переносятся, длинные значения обрезаются многоточием.
 * С крупным текстом или увеличенным интервалом это даёт наложение колонок и обрезку сумм,
 * поэтому в таких режимах разрешаем переносы и раскладку по содержимому.
 * Класс a11y-text-wide ставится, когда увеличен текст или интервал между буквами.
 */

/* Контейнер ограничен 1120px и с текстом не растёт — в крупном режиме отдаём всю ширину окна */
html.a11y-text-wide .container {
    max-width: none;
}

/* Боковая колонка задана в em и при крупном тексте занимает пол-экрана, не оставляя места таблицам.
   Переходим в одну колонку — так же, как вёрстка уже делает на узких экранах. */
html.a11y-text-wide .layout {
    -ms-flex-direction: column;
    flex-direction: column;
}

html.a11y-text-wide .layout__sidebar {
    -ms-flex: 0 0 auto;
    flex: 0 0 auto;
    max-width: none;
}

html.a11y-text-wide .layout__sidebar_left {
    margin-right: 0;
}

html.a11y-text-wide .layout__sidebar_right {
    margin-left: 0;
}

/* Подпись переносится по словам, а не выходит за пределы кнопки */
html.a11y-text-wide .button {
    white-space: normal;
    overflow-wrap: break-word;
}

/* Пара кнопок «Создать перевод» / «Список платежей» делит карточку пополам — в крупном режиме
   подписи в половину ширины не помещаются, поэтому ставим кнопки друг под другом (как на мобильных) */
html.a11y-text-wide .transfers-list-item__actions {
    display: block;
}

html.a11y-text-wide .transfers-list-item__action {
    width: auto;
}

html.a11y-text-wide .transfers-list-item__action + .transfers-list-item__action {
    margin-top: 1em;
    margin-left: 0;
}

/* Таблица операций: ширина колонок по содержимому вместо жёстких процентов.
   На узких экранах она и так превращается в карточки. */
html.a11y-text-wide .operations-table {
    table-layout: auto;
}

/*
 * Виджет курсов остаётся с фиксированными колонками: только так таблица гарантированно
 * не становится шире своей карточки независимо от того, в какой контейнер её поставили.
 * Место под сами курсы освобождаем за счёт отступов (они заданы в em и растут вместе с текстом)
 * и разрешаем значению перенестись, если оно всё же не помещается в колонку.
 */
html.a11y-text-wide .exchange-rates-widget__cell {
    padding-right: 0.25em;
    padding-left: 0.25em;
}

html.a11y-text-wide .exchange-rates-widget__cell:first-child {
    padding-left: 0.75em;
}

html.a11y-text-wide .exchange-rates-widget__cell:last-child {
    padding-right: 0.75em;
}

html.a11y-text-wide .exchange-rates-widget__amount {
    overflow-wrap: anywhere;
}

/* Название счёта и его номер стоят в одной строке — разрешаем переносить номер */
html.a11y-text-wide .account-list-item__title-container,
html.a11y-text-wide .credit-deposit-list-item__title-container {
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
}

/* Только overflow-wrap: word-break: break-word ужимает колонку до одной буквы на узких экранах */
html.a11y-text-wide .operations-table__cell,
html.a11y-text-wide .exchange-rates-widget__cell {
    white-space: normal;
    overflow-wrap: break-word;
}

/* Отступы ячеек заданы в em: при 160% шесть колонок тратят на них почти 500px,
   из-за чего таблица перестаёт помещаться. Освобождаем место под сами значения. */
html.a11y-text-wide .operations-table_style_expanded .operations-table__cell {
    padding: 0.75em 0.5em;
}

html.a11y-text-wide .operations-table_style_expanded .operations-table__cell:first-child {
    padding-right: 0.75em;
    padding-left: 0.75em;
}

html.a11y-text-wide .operations-table_style_expanded .operations-table__cell:last-child {
    padding-right: 0.75em;
}

/* Значения, обрезаемые многоточием в обычном режиме, показываем целиком */
html.a11y-text-wide .operations-table__title,
html.a11y-text-wide .operations-table__category,
html.a11y-text-wide .operations-table__amount,
html.a11y-text-wide .account-list-item__title,
html.a11y-text-wide .account-list-item__balance,
html.a11y-text-wide .account-cards-list-item__label,
html.a11y-text-wide .account-cards-list-item__value,
html.a11y-text-wide .credit-deposit-list-item__title,
html.a11y-text-wide .money-widget {
    overflow: visible;
    white-space: normal;
    text-overflow: clip;
    overflow-wrap: break-word;
}

/* ======================= Интервал текста ======================= */

html.a11y-spacing-light body :not(.a11y-ui, .a11y-ui *) {
    letter-spacing: 0.05em !important;
    word-spacing: 0.1em !important;
}

html.a11y-spacing-medium body :not(.a11y-ui, .a11y-ui *) {
    letter-spacing: 0.1em !important;
    word-spacing: 0.2em !important;
}

html.a11y-spacing-heavy body :not(.a11y-ui, .a11y-ui *) {
    letter-spacing: 0.15em !important;
    word-spacing: 0.3em !important;
}

/* ======================= Остановить анимацию ======================= */

/*
 * Не animation: none — модальные окна (micromodal, awaitCloseAnimation) закрываются по событию animationend,
 * которое при отключённой анимации не придёт. Почти нулевая длительность событие сохраняет.
 */
html.a11y-animations-on,
html.a11y-animations-on *,
html.a11y-animations-on *::before,
html.a11y-animations-on *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001s !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
    transition-delay: 0s !important;
}

/* ======================= Скрыть изображения ======================= */

html.a11y-images-on body img:not(.a11y-ui *),
html.a11y-images-on body picture:not(.a11y-ui *),
html.a11y-images-on body video:not(.a11y-ui *) {
    visibility: hidden !important;
}

html.a11y-images-on body,
html.a11y-images-on body :not(.a11y-ui, .a11y-ui *) {
    background-image: none !important;
}

/* ======================= Читаемый шрифт ======================= */

html.a11y-font-on body :not(.a11y-ui, .a11y-ui *) {
    font-family: Verdana, Arial, Helvetica, sans-serif !important;
}

/* ======================= Курсор ======================= */

html.a11y-cursor-big,
html.a11y-cursor-big * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cpath d='M6 3l30 27H21l-8 15z' fill='%23000' stroke='%23fff' stroke-width='3' stroke-linejoin='round'/%3E%3C/svg%3E") 6 3, auto !important;
}

/* Линейка для чтения: полоса, следующая за курсором по вертикали */
.a11y-reading-guide {
    position: fixed;
    right: 0;
    left: 0;
    z-index: 9998;
    height: 12px;
    margin-top: -6px;
    pointer-events: none;
    background: #000;
    border-top: 3px solid #ffe600;
    border-bottom: 3px solid #ffe600;
}

/* Маска для чтения: затемнение выше и ниже окна вокруг курсора */
.a11y-reading-mask {
    position: fixed;
    right: 0;
    left: 0;
    z-index: 9998;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.6);
}

.a11y-reading-mask_top {
    top: 0;
}

.a11y-reading-mask_bottom {
    bottom: 0;
}

/* ======================= Подсказки ======================= */

.a11y-tooltip {
    position: fixed;
    z-index: 10001;
    max-width: 320px;
    padding: 8px 12px;
    font-family: "Tahoma", Arial, sans-serif;
    font-size: 18px;
    line-height: 1.3;
    color: #fff;
    pointer-events: none;
    background: #1d2226;
    border: 2px solid #ffe600;
    border-radius: 6px;
}

.a11y-tooltip[hidden] {
    display: none;
}

/* ======================= Высота строки ======================= */

html.a11y-lineheight-150 body :not(.a11y-ui, .a11y-ui *, .icon, .icon *) {
    line-height: 1.5 !important;
}

html.a11y-lineheight-175 body :not(.a11y-ui, .a11y-ui *, .icon, .icon *) {
    line-height: 1.75 !important;
}

html.a11y-lineheight-200 body :not(.a11y-ui, .a11y-ui *, .icon, .icon *) {
    line-height: 2 !important;
}

/* ======================= Выравнивание текста ======================= */

html.a11y-align-left body :not(.a11y-ui, .a11y-ui *) {
    text-align: left !important;
}

html.a11y-align-center body :not(.a11y-ui, .a11y-ui *) {
    text-align: center !important;
}

html.a11y-align-right body :not(.a11y-ui, .a11y-ui *) {
    text-align: right !important;
}

html.a11y-align-justify body :not(.a11y-ui, .a11y-ui *) {
    text-align: justify !important;
}

/* ======================= Печать ======================= */

@media print {
    .a11y-toggle,
    .a11y-ui {
        display: none !important;
    }

    html.a11y-filter,
    html.a11y-contrast-invert img:not(.logo__image),
    html.a11y-contrast-invert video,
    html.a11y-contrast-invert canvas,
    html.a11y-contrast-invert iframe {
        filter: none !important;
    }
}
