/* Панель доступності + базові правки доступності. Логіка — inc/npc-a11y.php, js/npc-a11y.js. */

/* ---------- Базові правки (для всіх) ---------- */

/* Посилання «Перейти до основного вмісту»: невидиме, з'являється при навігації з клавіатури. */
.npc-skip {
	position: fixed; top: 8px; left: 8px; z-index: 100000;
	padding: 12px 18px; border-radius: 8px;
	background: #fff; color: #00573b; font-size: 16px; font-weight: 600;
	box-shadow: 0 4px 16px rgba(0,0,0,.2);
	transform: translateY(-200%); transition: transform .15s;
}
.npc-skip:focus, .npc-skip:focus-visible { transform: none; text-decoration: none !important; }
#main:focus { outline: none; }

/* Видимий фокус для навігації з клавіатури (тема глобально прибирала outline у a:focus).
   Чорне кільце + біла облямівка — видно на будь-якому фоні. Мишею фокус не показується. */
html body :focus-visible {
	outline: 3px solid #111 !important;
	outline-offset: 2px !important;
	box-shadow: 0 0 0 5px #fff !important;
}

/* ---------- Кнопки відкриття панелі ---------- */
.npc-a11y-btn { display: none; }
html.npc-a11y-on .npc-a11y-btn { display: inline-flex; }
/* Десктоп: кнопка стоїть у пункті з пошуком, праворуч від поля. */
@media (min-width: 992px) {
	html.npc-a11y-on .header .top_info > li:nth-child(2) { display: flex; align-items: center; gap: 22px; }
}

.npc-a11y-btn {
	align-items: center; gap: 6px;
	margin: 0; padding: 4px 2px; border: 0; background: none;
	font: inherit; font-size: 14px; font-weight: 500; color: inherit; line-height: 1.2;
	cursor: pointer;
}
.npc-a11y-btn svg { flex: 0 0 auto; color: #007a53; }
.npc-a11y-btn:hover, .npc-a11y-btn[aria-expanded="true"] { color: #007a53; }

/* Мобільна кнопка — у зеленій смузі з логотипом, ліворуч від перемикача мови. */
.npc-a11y-btn--m {
	position: absolute; top: 6px; right: 64px; z-index: 2; /* центр на одній лінії з перемикачем мови (центр ~26px) */
	width: 40px; height: 40px; margin: 0; padding: 0;
	justify-content: center; border-radius: 50%; color: #fff;
}
.npc-a11y-btn--m svg { color: #fff; }
.npc-a11y-btn--m:hover, .npc-a11y-btn--m[aria-expanded="true"] { color: #fff; background: rgba(255,255,255,.15); }
@media (min-width: 992px) { .npc-a11y-btn--m { display: none !important; } }

/* ---------- Панель ---------- */
.npc-a11y {
	position: fixed; top: 16px; right: 16px; z-index: 99990;
	width: 380px; max-width: calc(100vw - 32px); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px);
	overflow-y: auto; overscroll-behavior: contain;
	padding: 20px; border-radius: 16px;
	background: #fff; color: #1a1a1a;
	box-shadow: 0 12px 40px rgba(0,0,0,.25);
	font-size: 16px; line-height: 1.35; letter-spacing: normal !important;
	zoom: 1 !important;
}
.npc-a11y[hidden] { display: none; }
.npc-a11y * { letter-spacing: normal !important; line-height: 1.35 !important; }
.npc-a11y__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.npc-a11y__title { margin: 0; font-size: 20px; font-weight: 700; color: #1a1a1a; }
.npc-a11y__title:focus { outline: none; }
.npc-a11y__close {
	flex: 0 0 auto; width: 40px; height: 40px; border: 0; border-radius: 50%;
	background: #f1f4f2; color: #1a1a1a; font-size: 18px; cursor: pointer;
}
.npc-a11y__close:hover { background: #e3ebe6; }
.npc-a11y__list { display: flex; flex-direction: column; }
.npc-a11y__row {
	display: flex; align-items: center; gap: 12px;
	min-height: 52px; margin: 0; padding: 6px 0;
	border-bottom: 1px solid #eceeed;
	font-weight: 400; cursor: pointer;
}
.npc-a11y__row[role="group"] { cursor: default; }
.npc-a11y__ico { flex: 0 0 auto; display: inline-flex; color: #007a53; }
.npc-a11y__lbl { flex: 1 1 auto; font-size: 15px; color: #1a1a1a; }

/* Перемикач: справжній чекбокс поверх намальованого повзунка (працює з клавіатурою і скрінрідерами). */
.npc-a11y__row { position: relative; }
.npc-a11y__chk { position: absolute; right: 0; width: 46px; height: 26px; margin: 0; opacity: 0; cursor: pointer; }
.npc-a11y__sw { position: relative; flex: 0 0 auto; width: 46px; height: 26px; border-radius: 13px; background: #c9cfcc; transition: background .15s; }
.npc-a11y__sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .15s; }
.npc-a11y__chk:checked + .npc-a11y__sw { background: #007a53; }
.npc-a11y__chk:checked + .npc-a11y__sw::after { transform: translateX(20px); }
.npc-a11y__chk:focus-visible + .npc-a11y__sw { outline: 3px solid #111; outline-offset: 2px; box-shadow: 0 0 0 5px #fff; }

.npc-a11y__rng { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; }
.npc-a11y__step {
	width: 36px; height: 36px; border: 1px solid #cfd6d2; border-radius: 50%;
	background: #fff; color: #1a1a1a; font-size: 20px; line-height: 1 !important; cursor: pointer;
}
.npc-a11y__step:hover:not(:disabled) { border-color: #007a53; color: #007a53; }
.npc-a11y__step:disabled { opacity: .4; cursor: default; }
.npc-a11y__val { min-width: 52px; text-align: center; font-size: 15px; font-weight: 600; }

.npc-a11y__reset {
	display: block; width: 100%; margin-top: 16px; padding: 12px 16px;
	border: 0; border-radius: 999px; background: #007a53; color: #fff;
	font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
}
.npc-a11y__reset:hover { background: #00573b; }
.npc-a11y__note { margin: 10px 0 0; font-size: 13px; color: #555; text-align: center; }

/* Мобайл: панель випадає під зеленою смугою хедера (знизу її перекривала панель інструментів Safari). */
@media (max-width: 991px) {
	.npc-a11y {
		top: 68px; right: 8px; left: 8px; bottom: auto;
		width: auto; max-width: none;
		max-height: calc(100vh - 84px); max-height: calc(100dvh - 84px);
		padding: 16px 16px 20px; border-radius: 16px;
	}
}

/* ---------- Режими ---------- */

/* Чорно-білий / контраст — фільтр на корені (на <html> він не ламає фіксовані елементи). */
html.a11y-grey { filter: grayscale(1); }
html.a11y-contrast { filter: contrast(1.45); }
html.a11y-grey.a11y-contrast { filter: grayscale(1) contrast(1.45); }

/* Розмір тексту: шрифти в темі в px, тому масштабуємо вміст сторінки (хедер не чіпаємо). */
html.a11y-fs #main,
html.a11y-fs .npc-footer { zoom: var(--a11y-zoom, 1); overflow-x: clip; }
/* Попапи: запис на консультацію, відгук, підписка (magnific inline) і вікно cookie.
   Масштабуємо вміст, а не фіксовані контейнери — щоб не зсунути позиціонування. */
html.a11y-fs .mfp-inline-holder .mfp-content,
html.a11y-fs .npc-cc-box,
html.a11y-fs .npc-cc-bar > * { zoom: var(--a11y-zoom, 1); }
/* Bootstrap-контейнери мають фіксовану ширину (970/1170 px): у збільшеному вмісті обмежуємо її шириною екрана. */
html.a11y-fs :is(#main, .npc-footer, .mfp-content) .container { max-width: 100% !important; }
/* Заголовок секції з посиланням «Всі новини / відгуки» — переносимо посилання, якщо не вміщується. */
html.a11y-fs :is(.npc-hn__head, .npc-rev__head) { flex-wrap: wrap; row-gap: 8px; }
/* Заголовок блоку новин на головній: при збільшенні «Всі новини →» переноситься, а не обрізається. */
html.a11y-fs .npc-hn__head { flex-wrap: wrap; row-gap: 8px; }

/* Відступ між літерами. */
/* Хедер не чіпаємо: його верхній рядок розрахований під фіксовану ширину тексту. */
html.a11y-ls :is(#main, .npc-footer, .mfp-content, .npc-cc-box, .npc-cc-bar) * { letter-spacing: var(--a11y-ls, 0) !important; }

/* Міжрядковий інтервал. */
html.a11y-lh #main :is(p, li, td, th, dd, dt, blockquote, figcaption),
html.a11y-lh .npc-footer :is(p, li),
html.a11y-lh .mfp-content :is(p, li, label),
html.a11y-lh :is(.npc-cc-box, .npc-cc-bar) p { line-height: 1.9 !important; }
html.a11y-lh #main p { margin-bottom: 1em; }

/* Підкреслення посилань. */
html.a11y-links body a:not(.npc-skip) { text-decoration: underline !important; text-underline-offset: 3px; }

/* Великий курсор. */
html.a11y-cursor, html.a11y-cursor * {
	cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24'%3E%3Cpath d='M4.04 4.69a.5.5 0 0 1 .65-.65l16 6.5a.5.5 0 0 1-.06.95l-6.12 1.58a2 2 0 0 0-1.44 1.43l-1.58 6.13a.5.5 0 0 1-.95.06z' fill='%23000' stroke='%23fff' stroke-width='1.4' stroke-linejoin='round'/%3E%3C/svg%3E") 8 8, auto !important;
}

/* Лінія для читання. */
.npc-a11y-guide { display: none; }
html.a11y-line .npc-a11y-guide {
	display: block; position: fixed; left: 0; right: 0; top: 0; z-index: 99980;
	height: 44px; margin-top: -22px; pointer-events: none;
	background: rgba(255, 214, 0, .18);
	border-top: 3px solid #007a53; border-bottom: 3px solid #007a53;
	transform: translateY(-100px);
}

/* Зупинка анімації. */
html.a11y-motion *, html.a11y-motion *::before, html.a11y-motion *::after {
	animation-duration: .001ms !important; animation-iteration-count: 1 !important;
	transition-duration: .001ms !important; transition-delay: 0s !important;
	scroll-behavior: auto !important;
}
