/**
 * LuckyTrials — версія для людей з порушенням зору.
 * Режими — атрибути на <html> (їх ставить assets/js/a11y.js і inline-скрипт у <head>):
 *   data-a11y-font="130|160" · data-a11y-color="bw|wb|yb" · data-a11y-spacing="wide"
 *   data-a11y-motion="off" · data-a11y-images="off" · data-a11y-links="on" · data-a11y-active (будь-який режим увімкнено)
 * Кольори й розміри сайту задані змінними, тому режими лише перевизначають змінні.
 * Фон і текст розділені (--bg-* для фонів, --color-* для тексту й рамок): у темних режимах кольорова поверхня стає чорною,
 * а текст — світлим. Панель налаштувань навмисно не залежить від режимів (свої кольори в px) — її завжди легко знайти.
 */

/* ============================================================
   Кнопка в шапці
   ============================================================ */

.a11y-toggle {
    order: 2;
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 6px;
    min-height: 36px;
    padding: 0 10px;
    border: 1px solid var(--on-dark-line);
    border-radius: 6px;
    background: transparent;
    color: var(--on-dark-2);
    font: 600 var(--fs-sm)/1.2 var(--font-body);
    white-space: nowrap;
    cursor: pointer;
}

.a11y-toggle:hover,
.a11y-toggle:focus,
.a11y-toggle[aria-expanded="true"],
html[data-a11y-active] .a11y-toggle {
    background: var(--on-dark-line);
    color: var(--on-dark-1);
}

.a11y-toggle:focus-visible,
.a11y-quick:focus-visible,
.a11y-menu-item:focus-visible {
    outline: 2px solid var(--on-dark-1);
    outline-offset: 2px;
}

.a11y-ico {
    flex: none;
}

/* «Звичайна версія»: видно в активному режимі, поки панель згорнута */
.a11y-quick {
    order: 2;
    display: none;
    flex: 0 0 auto;
    min-height: 36px;
    padding: 0 12px;
    border: 2px solid var(--on-dark-1);
    border-radius: 6px;
    background: transparent;
    color: var(--on-dark-1);
    font: 700 var(--fs-sm)/1.2 var(--font-body);
    white-space: nowrap;
    cursor: pointer;
}

.a11y-quick:hover,
.a11y-quick:focus {
    background: var(--on-dark-1);
    color: var(--bg-navy);
}

html[data-a11y-active]:not(.a11y-open) .a11y-quick {
    display: inline-flex;
    align-items: center;
}

.a11y-menu-item {
    display: none;
}

@media (max-width: 1199px) {
    .a11y-toggle {
        order: 1;
        justify-content: center;
        width: 44px;
        min-height: 44px;
        padding: 0;
    }

    .a11y-toggle__text {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .a11y-quick {
        display: none !important;
    }

    /* Пункт у меню, що виїжджає */
    .a11y-menu-item {
        display: flex;
        align-items: center;
        gap: 10px;
        width: 100%;
        min-height: 48px;
        padding: 12px 0;
        border: 0;
        border-bottom: 1px solid var(--on-dark-line);
        border-radius: 0;
        background: transparent;
        color: var(--on-dark-2);
        font: 400 var(--fs-base)/1.4 var(--font-body);
        text-align: left;
        cursor: pointer;
    }

    .a11y-menu-item:hover,
    .a11y-menu-item:focus {
        background: transparent;
        color: var(--on-dark-1);
    }
}

/* Шапка: з кнопкою «Для слабозорих» меню (особливо RU) потребує трохи більше ширини, ніж колонка контенту */
@media (min-width: 1200px) {
    .site-header > .container {
        max-width: calc(1240px + var(--gutter) * 2);
    }
}

/* Ще тісніше (1200–1279 px): лише іконка, підпис — у aria-label і в панелі */
@media (min-width: 1200px) and (max-width: 1279px) {
    .a11y-toggle {
        justify-content: center;
        width: 40px;
        padding: 0;
    }

    .a11y-toggle__text {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }
}

/* В активному режимі підпис кнопки згортається в іконку: поруч з'являється «Звичайна версія», місце в шапці обмежене */
html[data-a11y-active]:not(.a11y-open) .a11y-toggle {
    justify-content: center;
    width: 40px;
    padding: 0;
}

html[data-a11y-active]:not(.a11y-open) .a11y-toggle__text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ============================================================
   Панель налаштувань (кольори й розмір не залежать від режимів)
   ============================================================ */

html .a11y-panel {
    position: relative;
    background: #fff;
    color: #0F2036;
    border-bottom: 3px solid #185FA5;
    box-shadow: 0 8px 24px rgba(4, 44, 83, .18) !important;
    font: 400 16px/1.4 var(--font-body);
    letter-spacing: normal;
}

html .a11y-panel[hidden] {
    display: none;
}

html .a11y-panel__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 16px 28px;
    max-width: var(--container-max, 1120px);
    max-height: 70vh;
    margin: 0 auto;
    padding: 16px var(--gutter, 16px);
    overflow-y: auto;
}

html .a11y-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

html .a11y-group__label {
    color: #0F2036;
    font: 700 16px/1.3 var(--font-body);
}

html .a11y-group__opts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

html .a11y-opt {
    box-sizing: border-box;
    min-width: 44px;
    min-height: 44px;
    padding: 0 14px;
    border: 2px solid #185FA5;
    border-radius: 8px;
    background: #fff;
    color: #185FA5;
    font: 600 16px/1.2 var(--font-body);
    letter-spacing: normal;
    text-decoration: none;
    cursor: pointer;
}

html .a11y-opt:hover,
html .a11y-opt:focus {
    background: #E6F1FB;
    color: #0C447C;
}

html .a11y-opt[aria-pressed="true"],
html .a11y-opt[aria-pressed="true"]:hover,
html .a11y-opt[aria-pressed="true"]:focus {
    background: #185FA5;
    color: #fff;
}

html .a11y-opt:focus-visible {
    outline: 3px solid #0F2036;
    outline-offset: 2px;
}

html .a11y-opt--font-130 { font-size: 20px; }
html .a11y-opt--font-160 { font-size: 24px; }

html .a11y-panel__actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
    align-self: flex-end;
}

@media (max-width: 659px) {
    html .a11y-panel__inner {
        gap: 14px;
        max-height: 75vh;
    }

    html .a11y-group,
    html .a11y-panel__actions {
        width: 100%;
    }

    html .a11y-group__opts .a11y-opt,
    html .a11y-panel__actions .a11y-opt {
        flex: 1 1 calc(50% - 8px);
    }
}

/* ============================================================
   Розмір шрифту: усе масштабується через rem
   ============================================================ */

html[data-a11y-font="130"] { font-size: 130%; }
html[data-a11y-font="160"] { font-size: 160%; }

/* ============================================================
   Кольорові режими
   ============================================================ */

html[data-a11y-color="bw"] {
    color-scheme: light;
    --color-navy: #000; --color-navy-light: #000; --color-blue: #000; --color-blue-dark: #000;
    --bg-navy: #000; --bg-navy-light: #000; --bg-blue: #000; --bg-blue-dark: #000; --bg-green: #000; --bg-amber: #000;
    --color-accent: #fff; --color-blue-bg: #fff;
    --color-green: #000; --color-green-bg: #fff; --color-amber: #000; --color-amber-bg: #fff; --color-red: #000; --color-red-bg: #fff;
    --color-surface: #fff; --color-surface-2: #fff; --color-border: #000;
    --color-text: #000; --color-text-2: #000; --color-text-3: #000; --color-white: #fff;
    --on-dark-1: #fff; --on-dark-2: #fff; --on-dark-3: #fff; --on-dark-4: #fff; --on-dark-line: rgba(255, 255, 255, .4);
    --status-open: #000; --status-soon: #000; --status-closed: #000; --status-closed-fg: #000; --status-closed-bg: #fff;
    --color-ok-border: #000; --color-info-border: #000; --overlay: rgba(0, 0, 0, .85);
    --ref-a: #000; --ref-b: #000; --ref-accent: #fff;
}

html[data-a11y-color="wb"] {
    color-scheme: dark;
    --color-navy: #fff; --color-navy-light: #fff; --color-blue: #fff; --color-blue-dark: #fff;
    --bg-navy: #000; --bg-navy-light: #000; --bg-blue: #000; --bg-blue-dark: #000; --bg-green: #000; --bg-amber: #000;
    --color-accent: #fff; --color-blue-bg: #000;
    --color-green: #fff; --color-green-bg: #000; --color-amber: #fff; --color-amber-bg: #000; --color-red: #fff; --color-red-bg: #000;
    --color-surface: #000; --color-surface-2: #000; --color-border: #fff;
    --color-text: #fff; --color-text-2: #fff; --color-text-3: #fff; --color-white: #000;
    --on-dark-1: #fff; --on-dark-2: #fff; --on-dark-3: #fff; --on-dark-4: #fff; --on-dark-line: rgba(255, 255, 255, .4);
    --status-open: #fff; --status-soon: #fff; --status-closed: #fff; --status-closed-fg: #fff; --status-closed-bg: #000;
    --color-ok-border: #fff; --color-info-border: #fff; --overlay: rgba(0, 0, 0, .85);
    --ref-a: #000; --ref-b: #000; --ref-accent: #fff;
}

html[data-a11y-color="yb"] {
    color-scheme: dark;
    --color-navy: #FFE500; --color-navy-light: #FFE500; --color-blue: #FFE500; --color-blue-dark: #FFE500;
    --bg-navy: #000; --bg-navy-light: #000; --bg-blue: #000; --bg-blue-dark: #000; --bg-green: #000; --bg-amber: #000;
    --color-accent: #FFE500; --color-blue-bg: #000;
    --color-green: #FFE500; --color-green-bg: #000; --color-amber: #FFE500; --color-amber-bg: #000; --color-red: #FFE500; --color-red-bg: #000;
    --color-surface: #000; --color-surface-2: #000; --color-border: #FFE500;
    --color-text: #FFE500; --color-text-2: #FFE500; --color-text-3: #FFE500; --color-white: #000;
    --on-dark-1: #FFE500; --on-dark-2: #FFE500; --on-dark-3: #FFE500; --on-dark-4: #FFE500; --on-dark-line: rgba(255, 229, 0, .4);
    --status-open: #FFE500; --status-soon: #FFE500; --status-closed: #FFE500; --status-closed-fg: #FFE500; --status-closed-bg: #000;
    --color-ok-border: #FFE500; --color-info-border: #FFE500; --overlay: rgba(0, 0, 0, .85);
    --ref-a: #000; --ref-b: #000; --ref-accent: #FFE500;
}

/* Без градієнтів і тіней, товсті рамки, прозорі підсвітки замінені суцільним фоном */
html[data-a11y-color] *,
html[data-a11y-color] *::before,
html[data-a11y-color] *::after {
    box-shadow: none !important;
    text-shadow: none !important;
    background-image: none !important;
}

html[data-a11y-color] body {
    background: var(--color-surface);
    color: var(--color-text);
}

html[data-a11y-color] :is(.btn, button.btn, a.btn) {
    border: 2px solid currentColor;
}

html[data-a11y-color] :is(input, select, textarea) {
    border: 2px solid var(--color-border);
    background: var(--color-white);
    color: var(--color-text);
}

html[data-a11y-color] ::placeholder {
    color: var(--color-text-2);
    opacity: 1;
}

html[data-a11y-color] :is(.study-card, .clinic-card, .blog-card, .area-card, .home-step, .apply-card, .cabinet-card) {
    border: 2px solid var(--color-border);
}

html[data-a11y-color] a:focus-visible,
html[data-a11y-color] button:focus-visible,
html[data-a11y-color] input:focus-visible,
html[data-a11y-color] select:focus-visible,
html[data-a11y-color] textarea:focus-visible {
    outline: 3px solid var(--color-text);
    outline-offset: 2px;
}

/* ============================================================
   Інтервали, анімації, зображення, посилання
   ============================================================ */

html[data-a11y-spacing="wide"] body {
    letter-spacing: .05em;
    word-spacing: .1em;
}

html[data-a11y-spacing="wide"] :is(p, li, dd, dt, td, th, label, blockquote, figcaption, .btn, input, textarea, select) {
    line-height: 2 !important;
}

html[data-a11y-spacing="wide"] :is(h1, h2, h3, h4, h5, h6) {
    line-height: 1.5 !important;
}

html[data-a11y-motion="off"] *,
html[data-a11y-motion="off"] *::before,
html[data-a11y-motion="off"] *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}

.a11y-alt {
    display: none;
}

html[data-a11y-images="off"] img:not([data-keep]) {
    display: none !important;
}

html[data-a11y-images="off"] .a11y-alt {
    display: inline-block;
    padding: 2px 8px;
    border: 1px dashed currentColor;
    font-style: italic;
}

html[data-a11y-links="on"] a:not(.btn):not(.a11y-opt) {
    text-decoration: underline !important;
    font-weight: 700;
}

/* Збільшений шрифт: сітки й ряди не повинні розпирати екран у вузькому вікні */
html[data-a11y-font] body {
    overflow-wrap: break-word;
}

html[data-a11y-font] :where(.area-tiles) {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr));
}

html[data-a11y-font] :where(.area-tile, .area-tile__name) {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
}

html[data-a11y-font] .area-tile {
    aspect-ratio: auto;
    min-height: 96px;
}

html[data-a11y-font] .apply-steps__item {
    min-width: 0;
}

html[data-a11y-font] .apply-steps__item:not(.is-active) .apply-steps__label {
    display: none;
}

html[data-a11y-font] .apply-steps__label {
    overflow-wrap: anywhere;
}

/* Збільшений шрифт на вузьких екранах: шапка й пошук переносяться в другий рядок */
@media (max-width: 599px) {
    html[data-a11y-font] .site-header__inner {
        flex-wrap: wrap;
        row-gap: 6px;
    }

    html[data-a11y-font] .site-branding {
        flex: 1 1 auto;
        min-width: 0;
    }

    html[data-a11y-font] .site-logo__text {
        white-space: normal;
        overflow-wrap: anywhere;
    }

    html[data-a11y-font] .catalog-search {
        flex-wrap: wrap;
    }

    html[data-a11y-font] .catalog-search__input {
        flex: 1 1 100%;
    }
}

/* Збільшений шрифт: довгі кнопки, заголовки й картки не виходять за екран */
html[data-a11y-font] .btn {
    max-width: 100%;
    white-space: normal;
}

html[data-a11y-font] :where(.study-main, .study-title, .study-badges, .sub-how__card, .catalog-search, .catalog-search__input) {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
}

/* Збільшений шрифт: меню не вміщується в рядок і на широких екранах — мобільна шапка діє до 1919 px
   (дублює блок «МОБІЛЬНА ШАПКА» з components.css і мобільні правила цього файлу) */
@media (min-width: 1200px) and (max-width: 1919px) {
html[data-a11y-font] .site-header__inner {
        gap: var(--sp-3);
        min-height: 56px;
}

html[data-a11y-font] .site-branding {
        flex: 1 1 auto;
}

html[data-a11y-font] .lang-switcher {
        order: 1;
}

html[data-a11y-font] .header-burger {
        order: 2;
        display: inline-flex;
        flex-direction: column;
        justify-content: center;
        gap: 5px;
        width: 40px;
        height: 40px;
        margin-right: -8px;
        padding: 0 9px;
        border: 0;
        border-radius: 6px;
        background: transparent;
        cursor: pointer;
}

html[data-a11y-font] .header-burger span {
        display: block;
        height: 2px;
        border-radius: 1px;
        background: var(--on-dark-2);
}

html[data-a11y-font] .header-burger:hover span,
html[data-a11y-font] .header-burger:focus-visible span {
        background: var(--on-dark-1);
}

html[data-a11y-font] .header-burger:focus-visible {
        outline: 2px solid var(--on-dark-2);
        outline-offset: 0;
}

html[data-a11y-font] .header-panel {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        z-index: var(--z-drawer);
        display: flex;
        flex-direction: column;
        gap: var(--sp-4);
        width: min(86vw, 360px);
        padding: var(--sp-3) var(--sp-5) var(--sp-6);
        overflow-y: auto;
        overscroll-behavior: contain;
        background: var(--bg-navy);
        box-shadow: -12px 0 32px rgba(0, 0, 0, .25);
        transform: translateX(100%);
        visibility: hidden;
        transition: transform .25s ease, visibility 0s linear .25s;
}

html[data-a11y-font].is-menu-open .header-panel {
        transform: none;
        visibility: visible;
        transition: transform .25s ease;
}

html[data-a11y-font] .admin-bar .header-panel {
        top: 46px;
}

html[data-a11y-font] .header-panel__head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        min-height: 44px;
}

html[data-a11y-font] .header-panel__title {
        font-size: var(--fs-xs);
        font-weight: 700;
        letter-spacing: .06em;
        text-transform: uppercase;
        color: var(--on-dark-4);
}

html[data-a11y-font] .header-panel__close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        margin-right: -10px;
        padding: 0;
        border: 0;
        border-radius: 6px;
        background: transparent;
        color: var(--on-dark-2);
        cursor: pointer;
}

html[data-a11y-font] .header-panel__close svg {
        display: block;
        width: 20px;
        height: 20px;
        max-width: none;
        flex: 0 0 20px;
}

html[data-a11y-font] .header-panel__close:hover,
html[data-a11y-font] .header-panel__close:focus,
html[data-a11y-font] .header-burger:hover,
html[data-a11y-font] .header-burger:focus {
        background: var(--on-dark-line);
        color: var(--on-dark-1);
}

html[data-a11y-font] .header-panel__close:focus:not(:focus-visible),
html[data-a11y-font] .header-burger:focus:not(:focus-visible) {
        background: transparent;
}

html[data-a11y-font] .header-panel__close:focus-visible {
        outline: 2px solid var(--on-dark-2);
        outline-offset: 0;
}

html[data-a11y-font] .lucky-nav {
        flex: 0 0 auto;
}

html[data-a11y-font] .lucky-menu {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
}

html[data-a11y-font] .lucky-menu a {
        display: block;
        padding: 14px 0;
        border-bottom: 1px solid var(--on-dark-line);
        font-size: var(--fs-base);
        white-space: normal;
}

html[data-a11y-font] .header-account {
        padding: var(--sp-2) 0;
        font-size: var(--fs-base);
}

html[data-a11y-font] .site-header .header-cta {
        display: flex;
        justify-content: center;
        width: 100%;
        margin-top: auto;
        padding-block: 12px;
        font-size: var(--fs-base);
}

html[data-a11y-font] .header-overlay {
        position: fixed;
        inset: 0;
        z-index: calc(var(--z-drawer) - 1);
        display: block;
        background: var(--overlay);
        opacity: 0;
        visibility: hidden;
        transition: opacity .25s ease, visibility 0s linear .25s;
}

html[data-a11y-font].is-menu-open .header-overlay {
        opacity: 1;
        visibility: visible;
        transition: opacity .25s ease;
}

html[data-a11y-font] html.is-menu-open {
        overflow: hidden;
}

html[data-a11y-font] .a11y-toggle {
        order: 1;
        justify-content: center;
        width: 44px;
        min-height: 44px;
        padding: 0;
}

html[data-a11y-font] .a11y-toggle__text {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
}

html[data-a11y-font] .a11y-quick {
        display: none !important;
}

html[data-a11y-font] .a11y-menu-item {
        display: flex;
        align-items: center;
        gap: 10px;
        width: 100%;
        min-height: 48px;
        padding: 12px 0;
        border: 0;
        border-bottom: 1px solid var(--on-dark-line);
        border-radius: 0;
        background: transparent;
        color: var(--on-dark-2);
        font: 400 var(--fs-base)/1.4 var(--font-body);
        text-align: left;
        cursor: pointer;
}

html[data-a11y-font] .a11y-menu-item:hover,
html[data-a11y-font] .a11y-menu-item:focus {
        background: transparent;
        color: var(--on-dark-1);
}

html[data-a11y-font] .admin-bar .header-panel {
        top: 32px;
}
}
