/* =============================================================================
   misery-child - база: токены, типографика, каркас секций
   -----------------------------------------------------------------------------
   Порядок загрузки: critical.css -> app.css -> ЭТОТ файл -> assets/css/blocks/*.css
   -> инлайновый <style> темы с :root-переменными (theme-parts/header-styles.php,
   печатается уже ПОСЛЕ wp_head).

   Отсюда правила работы:

   1) Переопределять переменные темы через `:root` бесполезно - инлайн темы идёт
      позже и выигрывает. Используем `html:root { --x: ... }` (специфичность выше).
   2) У <body> цвета фона и текста в инлайн-атрибуте style (BODY_COLOR_STRING),
      их правим либо в ACF Options (Site settings -> цвета), либо через !important.
   3) Наши файлы грузятся после app.css, поэтому при равной специфичности выигрываем
      мы. Но у темы много селекторов вида `.a.b .c:not(:first-of-type)` - такие
      правила надо перебивать селектором той же формы, а не более коротким.

   Разметка и классы блоков: wp-content/themes/misery-theme/acf-blocks/**
   Правки конкретного блока - в assets/css/blocks/<блок>.css (подключаются сами).
   ========================================================================== */

html:root {
	/* поверхности: база #1d1d1d приходит из ACF Options (global_colors) */
	--ms-surface: #242628;
	--ms-surface-2: #2a2d30;
	--ms-surface-3: #33373b;
	--ms-surface-top: #26292c;

	--ms-border: rgba(255, 255, 255, .09);
	--ms-border-2: rgba(255, 255, 255, .18);

	--ms-text: #f2f4f7;
	--ms-muted: #b3bac4;

	/* акценты берём из настроек темы, чтобы палитра оставалась одна */
	--ms-accent: var(--main-accent-bg-color, #5691ff);
	--ms-accent-2: var(--table-second-color, #7368e3);
	--ms-accent-3: var(--table-third-color, #e71e6a);
	--ms-accent-soft: rgba(86, 145, 255, .13);
	--ms-accent-line: rgba(86, 145, 255, .35);

	/* CTA темнее ссылочного синего: белый текст на #5691ff даёт 2.8:1 (провал AA),
	   на #2f6fe0 - 4.7:1. Вернуть брендовый оттенок: --ms-cta: var(--ms-accent). */
	--ms-cta: #2f6fe0;
	--ms-cta-hover: #1f5cc7;
	--ms-cta-text: #fff;

	--ms-radius-sm: 10px;
	--ms-radius: 14px;
	--ms-radius-lg: 20px;

	--ms-shadow: 0 18px 40px -26px rgba(0, 0, 0, .9);
	--ms-shadow-hover: 0 22px 44px -24px rgba(0, 0, 0, .95);
	--ms-ring: 0 0 0 3px rgba(86, 145, 255, .45);

	--ms-ease: cubic-bezier(.16, 1, .3, 1);
	--ms-dur: .2s;

	--ms-gap: clamp(1rem, 2.5vw, 1.75rem);
	--ms-pad: clamp(1.15rem, 3vw, 2.25rem);
}

/* -----------------------------------------------------------------------------
   Типографика
   Тема ставит main{font-weight:300}, при системном шрифте это выглядит хилым.
   -------------------------------------------------------------------------- */
body {
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

main {
	font-size: 1.0625rem;
	font-weight: 400;
	line-height: 1.7;
	color: var(--ms-text);
}

main h1,
main h2,
main h3,
main h4,
main h5,
main h6 {
	color: #fff;
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: -.015em;
	text-wrap: balance;
}

main h1 { font-size: clamp(1.8rem, 4.2vw, 2.85rem); }
main h2 { font-size: clamp(1.4rem, 2.8vw, 1.95rem); }
main h3 { font-size: clamp(1.15rem, 2vw, 1.35rem); font-weight: 600; }
main h4 { font-size: 1.1rem; font-weight: 600; }

main p { margin: 0 0 1rem; }
main p:last-child { margin-bottom: 0; }

main strong,
main b { color: #fff; font-weight: 600; }

/* Ссылки в тексте: подчёркивание тонкое, на ховере плотное.
   Селекторы намеренно привязаны к контентным контейнерам - глобальное
   `main a` перебивало бы крошки, оглавление и кнопки. */
.text-image__content a:not([class*="button"]),
.faq__item_answer a:not([class*="button"]),
.how-to__step_description a:not([class*="button"]),
.header-breadcrumbs-left__text p a:not([class*="button"]),
main table a:not([class*="button"]) {
	color: var(--ms-accent);
	text-decoration: underline;
	text-decoration-color: var(--ms-accent-line);
	text-underline-offset: .18em;
	text-decoration-thickness: 1px;
	transition: color var(--ms-dur) var(--ms-ease), text-decoration-color var(--ms-dur) var(--ms-ease);
}

.text-image__content a:not([class*="button"]):hover,
.faq__item_answer a:not([class*="button"]):hover,
.how-to__step_description a:not([class*="button"]):hover,
.header-breadcrumbs-left__text p a:not([class*="button"]):hover,
main table a:not([class*="button"]):hover {
	color: #86b0ff;
	text-decoration-color: currentColor;
}

/* Списки в контенте (в toc/меню/faq-навигацию не лезем) */
.text-image__content ul.wp-block-list,
.faq__item_answer ul,
.how-to__step_description ul {
	list-style: none;
	margin: 0 0 1rem;
	padding-left: 0;
}

.text-image__content ul.wp-block-list li,
.faq__item_answer ul li,
.how-to__step_description ul li {
	position: relative;
	padding-left: 1.6rem;
	margin-bottom: .5rem;
}

.text-image__content ul.wp-block-list li::before,
.faq__item_answer ul li::before,
.how-to__step_description ul li::before {
	content: "";
	position: absolute;
	left: .3rem;
	top: .62em;
	width: 7px;
	height: 7px;
	border-radius: 2px;
	background: var(--ms-accent);
	transform: rotate(45deg);
}

.text-image__content ol.wp-block-list,
.faq__item_answer ol,
.how-to__step_description ol {
	list-style: none;
	counter-reset: ms-ol;
	margin: 0 0 1rem;
	padding-left: 0;
}

.text-image__content ol.wp-block-list > li,
.faq__item_answer ol > li,
.how-to__step_description ol > li {
	counter-increment: ms-ol;
	position: relative;
	padding-left: 2.4rem;
	margin-bottom: .65rem;
}

.text-image__content ol.wp-block-list > li::before,
.faq__item_answer ol > li::before,
.how-to__step_description ol > li::before {
	content: counter(ms-ol);
	position: absolute;
	left: 0;
	top: .1em;
	width: 1.65rem;
	height: 1.65rem;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 8px;
	background: var(--ms-accent-soft);
	border: 1px solid var(--ms-accent-line);
	color: var(--ms-accent);
	font-size: .82rem;
	font-weight: 700;
	line-height: 1;
}

/* -----------------------------------------------------------------------------
   Каркас страницы: каждая H2-секция (обёртка latter/misery `tag-wrapper`)
   становится карточкой-поверхностью. Вложенные обёртки остаются плоскими.
   -------------------------------------------------------------------------- */
/* 1440px под сплошной текст - слишком широко: строки уезжают за комфортные
   65-90 знаков. Сужаем колонку контента, шапка остаётся full-bleed. */
main.page-content > .container,
.header-breadcrumbs-left > .container {
	max-width: 1240px;
}

main.page-content > .container > .tag-wrapper {
	background: linear-gradient(180deg, var(--ms-surface-top), var(--ms-surface));
	border: 1px solid var(--ms-border);
	border-radius: var(--ms-radius-lg);
	box-shadow: var(--ms-shadow);
	padding: var(--ms-pad);
	margin-bottom: var(--ms-gap);
}

main.page-content > .container > .tag-wrapper > *:last-child { margin-bottom: 0; }

.tag-wrapper .tag-wrapper {
	background: none;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	padding: 0;
	margin: 1.25rem 0;
}

/* Заголовок секции с акцентной чертой */
main.page-content > .container > .tag-wrapper > .text-image .text-image__heading .title,
main.page-content > .container > .tag-wrapper > .text-image > .text-image__content > h2.wp-block-heading {
	position: relative;
	padding-bottom: .6rem;
	margin-bottom: 1.1rem;
}

main.page-content > .container > .tag-wrapper > .text-image .text-image__heading .title::after,
main.page-content > .container > .tag-wrapper > .text-image > .text-image__content > h2.wp-block-heading::after {
	content: "";
	position: absolute;
	left: 0;
	bottom: 0;
	width: 56px;
	height: 3px;
	border-radius: 3px;
	background: linear-gradient(90deg, var(--ms-accent), var(--ms-accent-2));
}

/* Картинки в контенте */
main .get-image img {
	border-radius: var(--ms-radius);
	height: auto;
}

/* Дата обновления внизу страницы */
.page-update {
	color: var(--ms-muted);
	font-size: .9rem;
	margin-top: var(--ms-gap);
}

/* -----------------------------------------------------------------------------
   Доступность и состояния
   -------------------------------------------------------------------------- */
a:focus-visible,
button:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
	outline: 2px solid var(--ms-accent);
	outline-offset: 3px;
	border-radius: 6px;
}

::selection {
	background: var(--ms-accent);
	color: #fff;
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: .01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: .01ms !important;
		scroll-behavior: auto !important;
	}
}

html { scroll-behavior: smooth; }

/* Якоря из оглавления не должны прятаться под липкой шапкой */
main.page-content > .container > .tag-wrapper[id] { scroll-margin-top: 90px; }
