/*
Theme Name: Робин — доступная база знаний
Description: Тема портала самообслуживания умного помощника «Робин». Семантическая вёрстка под WCAG 2.2 AA и ГОСТ Р 52872–2019: ссылка перехода к содержанию, ориентиры, видимый фокус, контраст не ниже 7:1, масштабирование до 400 %, настройки отображения для слабовидящих.
Version: 1.1.1
Requires at least: 6.5
Requires PHP: 8.1
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: robin
*/

/* ---------- Цветовые схемы ---------- */

:root {
	--bg: #ffffff;
	--text: #1b1b1b;
	--muted: #3d3d3d;
	--link: #0a4a94;
	--link-visited: #5a2a82;
	--accent: #0a4a94;
	--accent-text: #ffffff;
	--surface: #eef3f9;
	--surface-text: #1b1b1b;
	--border: #5c5c5c;
	--focus: #0a4a94;
	--focus-halo: #ffd84d;
	--max: 50rem;
	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-scheme]) {
		--bg: #121212;
		--text: #f2f2f2;
		--muted: #d0d0d0;
		--link: #9ccaff;
		--link-visited: #d7b8ff;
		--accent: #9ccaff;
		--accent-text: #0b0b0b;
		--surface: #1f2630;
		--surface-text: #f2f2f2;
		--border: #a8a8a8;
		--focus: #ffd84d;
		--focus-halo: #121212;
		color-scheme: dark;
	}
}

:root[data-scheme="bw"] {
	--bg: #ffffff;
	--text: #000000;
	--muted: #000000;
	--link: #000000;
	--link-visited: #000000;
	--accent: #000000;
	--accent-text: #ffffff;
	--surface: #ffffff;
	--surface-text: #000000;
	--border: #000000;
	--focus: #000000;
	--focus-halo: #ffd84d;
	color-scheme: light;
}

:root[data-scheme="wb"] {
	--bg: #000000;
	--text: #ffffff;
	--muted: #ffffff;
	--link: #ffff66;
	--link-visited: #ffff66;
	--accent: #ffff66;
	--accent-text: #000000;
	--surface: #000000;
	--surface-text: #ffffff;
	--border: #ffffff;
	--focus: #ffff66;
	--focus-halo: #000000;
	color-scheme: dark;
}

:root[data-scheme="blue"] {
	--bg: #9dd1ff;
	--text: #063462;
	--muted: #063462;
	--link: #063462;
	--link-visited: #063462;
	--accent: #063462;
	--accent-text: #9dd1ff;
	--surface: #c4e3ff;
	--surface-text: #063462;
	--border: #063462;
	--focus: #063462;
	--focus-halo: #ffffff;
	color-scheme: light;
}

:root[data-scheme="beige"] {
	--bg: #f7f3d6;
	--text: #4d4b43;
	--muted: #4d4b43;
	--link: #2f2d27;
	--link-visited: #2f2d27;
	--accent: #4d4b43;
	--accent-text: #f7f3d6;
	--surface: #ede6bd;
	--surface-text: #2f2d27;
	--border: #4d4b43;
	--focus: #2f2d27;
	--focus-halo: #ffffff;
	color-scheme: light;
}

/* ---------- Размер шрифта и интервалы ---------- */

html {
	font-size: 112.5%; /* 18 px при стандартной настройке браузера */
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}
html[data-font="l"] { font-size: 131.25%; }  /* 21 px */
html[data-font="xl"] { font-size: 156.25%; } /* 25 px */

html[data-spacing="wide"] body {
	letter-spacing: 0.12em;
	word-spacing: 0.16em;
	line-height: 1.9;
}
html[data-spacing="wide"] p,
html[data-spacing="wide"] li { margin-bottom: 1.2em; }

/* ---------- Основа ---------- */

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
	line-height: 1.6;
	overflow-wrap: anywhere;
	hyphens: auto;
	-webkit-hyphens: auto;
}

img { max-width: 100%; height: auto; }

h1, h2, h3 { line-height: 1.25; margin: 1.6em 0 0.6em; hyphens: auto; -webkit-hyphens: auto; overflow-wrap: anywhere; }
h1 { font-size: 2rem; margin-top: 0.8em; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.22rem; }
p, ul, ol, table { margin: 0 0 1em; }
ul, ol { padding-left: 1.6em; }
li { margin-bottom: 0.45em; }
li::marker { color: var(--text); }

a { color: var(--link); text-decoration: underline; text-decoration-thickness: 0.08em; text-underline-offset: 0.18em; }
a:visited { color: var(--link-visited); }
a:hover { text-decoration-thickness: 0.18em; }

/* Видимый фокус: двойная рамка заметна на любом фоне (WCAG 2.4.7, 2.4.13). */
:focus { outline: none; }
:focus-visible,
.kb-feedback__status:focus {
	outline: 3px solid var(--focus);
	outline-offset: 3px;
	box-shadow: 0 0 0 6px var(--focus-halo);
	border-radius: 2px;
}
main:focus-visible,
main:focus { outline: none; box-shadow: none; }

.screen-reader-text,
.visually-hidden {
	position: absolute !important;
	width: 1px; height: 1px;
	padding: 0; margin: -1px;
	overflow: hidden; clip: rect(0, 0, 0, 0);
	white-space: nowrap; border: 0;
}

.container {
	max-width: var(--max);
	margin: 0 auto;
	padding: 0 1rem;
}

@media (prefers-reduced-motion: no-preference) {
	html { scroll-behavior: smooth; }
}

/* ---------- Переход к содержанию ---------- */

.skip-link {
	position: absolute;
	left: 1rem;
	top: -10rem;
	z-index: 1000;
	padding: 0.75rem 1rem;
	background: var(--accent);
	color: var(--accent-text) !important;
	font-weight: 700;
}
.skip-link:focus { top: 0.5rem; }

/* ---------- Шапка ---------- */

.site-header {
	border-bottom: 2px solid var(--border);
	background: var(--surface);
	color: var(--surface-text);
}
.header-inner {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem 1.5rem;
	padding-top: 0.75rem;
	padding-bottom: 0.75rem;
}
.site-title {
	margin: 0;
	font-size: 1.3rem;
	font-weight: 700;
}
.site-title a { color: var(--surface-text); text-decoration: none; }
.site-title a:hover { text-decoration: underline; }

.site-nav ul {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 1.25rem;
	list-style: none;
	margin: 0;
	padding: 0 0 0.75rem;
}
.site-nav li { margin: 0; }
.site-nav a {
	display: inline-block;
	padding: 0.4rem 0;
	min-height: 2.75rem;
	line-height: 2rem;
	color: var(--surface-text);
	font-weight: 600;
}
.site-nav a[aria-current="page"] { text-decoration-thickness: 0.2em; }

/* ---------- Кнопки ---------- */

.kb-button,
.settings-toggle,
.kb-search button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 2.75rem;
	min-width: 2.75rem;
	padding: 0.5rem 1.1rem;
	border: 2px solid var(--accent);
	border-radius: 0.4rem;
	background: var(--accent);
	color: var(--accent-text);
	font: inherit;
	font-weight: 700;
	cursor: pointer;
	text-align: center;
}
.kb-button:hover,
.kb-search button:hover { text-decoration: underline; }
.kb-button--secondary,
.settings-toggle {
	background: var(--bg);
	color: var(--text);
	border-color: var(--border);
}
.no-js .settings-toggle { display: none; }

/* ---------- Настройки отображения ---------- */

.display-settings {
	border-top: 2px solid var(--border);
	background: var(--bg);
	color: var(--text);
	padding: 1rem 0 1.25rem;
}
.display-settings h2 { margin-top: 0; font-size: 1.3rem; }
.display-settings fieldset {
	border: 2px solid var(--border);
	border-radius: 0.4rem;
	margin: 0 0 1rem;
	padding: 0.5rem 1rem 0.75rem;
}
.display-settings legend { font-weight: 700; padding: 0 0.3rem; }
.ds-options { display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; }

.kb-radio {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	min-height: 2.75rem;
}
.kb-radio input {
	width: 1.5rem;
	height: 1.5rem;
	margin: 0;
	accent-color: var(--accent);
	flex: none;
}

/* ---------- Поиск ---------- */

.kb-search { margin: 1rem 0 1.25rem; }
.kb-search label { display: block; font-weight: 700; margin-bottom: 0.35rem; }
.kb-search__row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.kb-search input[type="search"] {
	flex: 1 1 12rem;
	min-width: 0;
	width: 100%;
	min-height: 2.75rem;
	padding: 0.45rem 0.75rem;
	border: 2px solid var(--border);
	border-radius: 0.4rem;
	background: var(--bg);
	color: var(--text);
	font: inherit;
}
.kb-search--hero input[type="search"] { font-size: 1.15em; min-height: 3.2rem; }
.kb-search--hero button { min-height: 3.2rem; padding: 0.5rem 1.6rem; }
.kb-search__hint { margin: 0.4rem 0 0; color: var(--muted); font-size: 0.95em; }

/* ---------- Хлебные крошки ---------- */

.kb-breadcrumbs ol {
	display: flex;
	flex-wrap: wrap;
	list-style: none;
	margin: 1rem 0 0;
	padding: 0;
	font-size: 0.95em;
}
.kb-breadcrumbs li { margin: 0; }
.kb-breadcrumbs li + li::before {
	content: "›";
	margin: 0 0.5rem;
	color: var(--muted);
}
@supports (content: "x" / "") {
	.kb-breadcrumbs li + li::before { content: "›" / ""; }
}

/* ---------- Главная ---------- */

.kb-intro { font-size: 1.15em; }

.kb-tiles {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
	gap: 0.85rem;
	list-style: none;
	padding: 0;
}
.kb-tiles li { margin: 0; display: flex; }
.kb-tiles a {
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
	width: 100%;
	padding: 1rem 1.1rem;
	border: 2px solid var(--border);
	border-radius: 0.5rem;
	background: var(--surface);
	color: var(--surface-text);
	text-decoration: none;
}
.kb-tiles a:hover { border-width: 3px; padding: calc(1rem - 1px) calc(1.1rem - 1px); }
.kb-tile__title { font-size: 1.2rem; font-weight: 700; text-decoration: underline; text-underline-offset: 0.18em; }
.kb-tile__desc { color: var(--surface-text); }

.kb-sections { list-style: none; padding: 0; }
.kb-sections li {
	padding: 0.6rem 0;
	border-bottom: 1px solid var(--border);
	margin: 0;
}
.kb-sections a { font-weight: 700; font-size: 1.1em; }
.kb-sections p { margin: 0.2rem 0 0; color: var(--muted); }

/* ---------- Списки статей ---------- */

.kb-list { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.kb-list > li {
	padding: 0.25rem 0 0.75rem;
	border-bottom: 1px solid var(--border);
	margin: 0 0 0.75rem;
}
.kb-list h2,
.kb-list h3 { font-size: 1.2rem; margin: 0.4rem 0 0.3rem; }
.kb-list p { margin: 0.2rem 0; }
.kb-type { font-size: 0.95em; color: var(--muted); }

/* ---------- Статья ---------- */

.kb-lead { font-size: 1.15em; }
.kb-meta { color: var(--muted); font-size: 0.95em; }
.kb-content ol > li { padding-left: 0.2em; margin-bottom: 0.7em; }
.kb-content figure { margin: 1.5rem 0; }
.kb-content table,
.wp-block-table table {
	width: 100%;
	border-collapse: collapse;
}
.wp-block-table { margin: 1.5rem 0; overflow-x: auto; }
.kb-content th,
.kb-content td {
	border: 1px solid var(--border);
	padding: 0.5rem 0.65rem;
	text-align: left;
	vertical-align: top;
}
.kb-content thead th { background: var(--surface); color: var(--surface-text); }

.kb-related,
.kb-feedback,
.kb-support,
.kb-faq-section {
	margin: 2rem 0;
	padding: 1rem 1.25rem 1.25rem;
	border: 2px solid var(--border);
	border-radius: 0.5rem;
}
.kb-related h2,
.kb-feedback h2,
.kb-support h2,
.kb-support h3 { margin-top: 0.3rem; }
.kb-feedback__buttons { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.kb-feedback fieldset { border: 0; padding: 0; margin: 0 0 1rem; }
.kb-feedback legend { font-weight: 700; margin-bottom: 0.3rem; }
.kb-feedback__status:empty { display: none; }
.kb-feedback__status { font-weight: 700; padding: 0.25rem 0; }
.kb-hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.kb-support { background: var(--surface); color: var(--surface-text); }
.kb-support a { color: var(--link); }
.kb-support__list { list-style: none; padding: 0; }
.kb-support__list li { margin: 0 0 0.6rem; }
.kb-support__link { font-weight: 700; display: inline-block; padding: 0.3rem 0; }
.kb-support__note { display: block; color: var(--surface-text); font-size: 0.95em; }

/* ---------- Частые вопросы ---------- */

.kb-toc ul { padding-left: 1.2em; }
.kb-faq h3 { scroll-margin-top: 1rem; }
.kb-faq h3:target { outline: 3px dashed var(--focus); outline-offset: 4px; }

/* ---------- Курс ---------- */

.lesson-listen,
.lesson-files {
	margin: 1.5rem 0;
	padding: 1rem 1.25rem 1.1rem;
	border: 2px solid var(--border);
	border-radius: 0.5rem;
	background: var(--surface);
	color: var(--surface-text);
}
.lesson-listen h2,
.lesson-files h2 { margin-top: 0.2rem; }
.lesson-files a { color: var(--link); }
.lesson-audio {
	display: block;
	width: 100%;
	min-height: 3rem;
	margin: 0.25rem 0 0.75rem;
}
.lesson-speed {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem;
	margin: 0 0 0.75rem;
}
.lesson-speed__label { font-weight: 700; margin-right: 0.25rem; }
.lesson-speed .kb-button { padding: 0.4rem 0.9rem; }
.lesson-speed .kb-button[aria-pressed="true"] {
	background: var(--accent);
	border-color: var(--accent);
	color: var(--accent-text);
	text-decoration: underline;
	text-underline-offset: 0.18em;
}
.lesson-hint { margin: 0; }
.lesson-text > .lesson-hint { color: var(--muted); margin-bottom: 1rem; }
.lesson-files__list { list-style: none; padding: 0; margin: 0; }
.lesson-files__list li { margin: 0 0 0.6rem; }
.lesson-files__list a { font-weight: 700; display: inline-block; padding: 0.3rem 0; }

.lesson-nav { margin: 2rem 0; }
.lesson-nav ul {
	display: grid;
	gap: 0.6rem;
	list-style: none;
	padding: 0;
	margin: 0;
}
.lesson-nav li { margin: 0; }
.lesson-nav a {
	display: block;
	padding: 0.75rem 1rem;
	border: 2px solid var(--border);
	border-radius: 0.5rem;
}
.lesson-nav a:hover { border-width: 3px; padding: calc(0.75rem - 1px) calc(1rem - 1px); }
.lesson-nav__dir { font-weight: 700; }

.kb-checklist { list-style: none; padding: 0; margin: 0 0 1rem; }
.kb-check {
	display: flex;
	align-items: flex-start;
	gap: 0.75rem;
	margin: 0;
	padding: 0.6rem 0;
	border-bottom: 1px solid var(--border);
}
.kb-check input {
	flex: none;
	width: 1.6rem;
	height: 1.6rem;
	margin: 0.1em 0 0;
	accent-color: var(--accent);
}
.kb-check label { cursor: pointer; }
.kb-check__hint { color: var(--muted); }
.kb-check__status { font-weight: 700; }
.kb-check__status:empty { display: none; }

.course-lessons { padding-left: 1.6em; }
.course-lessons li { margin-bottom: 0.9em; }
.course-lessons a { font-weight: 700; }
.course-lessons p { margin: 0.2rem 0 0; color: var(--muted); }
.course-lessons__item--checklist a { font-style: normal; }
.course-module {
	margin: 1.25rem 0;
	padding: 0.25rem 1.25rem 0.5rem;
	border: 2px solid var(--border);
	border-radius: 0.5rem;
}
.course-module h3 { margin-top: 0.8rem; }
.course-module__note { border-left: 4px solid var(--accent); padding-left: 0.75rem; }

/* ---------- Подвал ---------- */

.site-footer {
	margin-top: 3rem;
	border-top: 2px solid var(--border);
	background: var(--surface);
	color: var(--surface-text);
	padding: 1rem 0 1.5rem;
}
.site-footer a { color: var(--surface-text); }
.site-footer ul {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 1.5rem;
	list-style: none;
	padding: 0;
}
.site-footer li { margin: 0; }
.site-footer li a { display: inline-block; padding: 0.4rem 0; }

/* ---------- Высокая контрастность Windows ---------- */

@media (forced-colors: active) {
	.kb-tiles a,
	.kb-button,
	.kb-search button,
	.settings-toggle { border: 2px solid ButtonText; }
	.lesson-speed .kb-button[aria-pressed="true"] { outline: 3px solid Highlight; outline-offset: 2px; }
	:focus-visible { outline: 3px solid Highlight; }
}

/* ---------- Печать ---------- */

@media print {
	.site-header,
	.site-footer,
	.kb-breadcrumbs,
	.kb-feedback,
	.kb-search,
	.lesson-listen,
	.lesson-files,
	.lesson-nav,
	.kb-check__actions,
	.skip-link { display: none !important; }
	body { font-size: 14pt; color: #000; background: #fff; }
	a { color: #000; }
	.kb-content a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.85em; }
}

/* ---------- Размер целей для ссылок вне текста (WCAG 2.5.8) ---------- */
/* Общее правило для ссылок-пунктов списков обёрнуто в :where() — нулевая специфичность,
   чтобы не перекрывать оформление плиток, кнопок «Назад/Далее» и других компонентов. */

.kb-breadcrumbs a,
.kb-related li > a,
.kb-toc li > a,
.kb-sections li > a,
.site-footer li a,
.kb-list h2 a,
.kb-list h3 a,
.course-lessons a,
:where(main li > a:only-child) {
	display: inline-block;
	min-height: 1.5rem;
	padding: 0.15rem 0;
}
