/* ============================================================
   BAZA · base
   Сброс, корневые элементы, типографика, фокус, поля ввода,
   проза редактора и мелкие утилиты.

   Всё — только через токены из tokens.css. Единственные
   исключения: толщина 1px у рамок и цвет внутри data-URI
   шеврона у select (в URL переменную подставить нельзя —
   поэтому вариантов два, по одному на тему).
   ============================================================ */

/* ── Сброс ────────────────────────────────────────────────── */

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

h1, h2, h3, h4, h5, h6,
p, figure, blockquote,
dl, dd, dt,
ul, ol, pre {
	margin: 0;
}

ul, ol {
	padding: 0;
	list-style: none;
}

fieldset {
	margin: 0;
	padding: 0;
	border: 0;
	min-width: 0;
}

legend {
	padding: 0;
}

table {
	border-collapse: collapse;
	border-spacing: 0;
}

/* Скрытие атрибутом hidden. Компоненты, которые сами задают display
   (оверлей поиска, панель фильтров), обязаны держать своё [hidden]. */
[hidden] {
	display: none;
}

button,
input,
select,
textarea,
optgroup {
	font: inherit;
	color: inherit;
	letter-spacing: inherit;
	margin: 0;
}

button {
	background: none;
	border: 0;
	padding: 0;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
	cursor: not-allowed;
	opacity: .6;
}

/* Ссылка-якорь не должна уезжать под липкую шапку. */
[id] {
	scroll-margin-top: calc(var(--header-h) + var(--s-6));
}

/* ── Корневые элементы ────────────────────────────────────── */

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	scroll-behavior: smooth;
	tab-size: 4;
	/* Место под скроллбар держим всегда: при блокировке прокрутки
	   (мобильное меню, оверлей поиска) страница не дёргается. */
	scrollbar-gutter: stable;
	overflow-x: hidden;
	scrollbar-width: thin;
	scrollbar-color: var(--c-border-strong) transparent;
}

body {
	min-height: 100%;
	background: var(--c-bg);
	color: var(--c-text);
	font-family: var(--ff-sans);
	font-size: var(--fs-base);
	line-height: 1.55;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-rendering: optimizeLegibility;
	overflow-wrap: break-word;
	/* Именно clip, а не hidden: hidden сделал бы body скролл-контейнером
	   и убил бы sticky-шапку. Горизонтальный вылет всё равно обрезается. */
	overflow-x: clip;
}

@supports not (overflow: clip) {
	body {
		overflow-x: hidden;
	}
}

::selection {
	background: color-mix(in srgb, var(--c-primary) 22%, transparent);
	color: var(--c-text);
}

/* Скроллбар WebKit — под тёплую палитру. */
::-webkit-scrollbar {
	width: 10px;
	height: 10px;
}
::-webkit-scrollbar-track {
	background: transparent;
}
::-webkit-scrollbar-thumb {
	background: var(--c-border-strong);
	border-radius: var(--r-pill);
	border: 2px solid var(--c-bg);
}
::-webkit-scrollbar-thumb:hover {
	background: var(--c-text-soft);
}

/* ── Типографика ──────────────────────────────────────────── */

/* h1-h3 — серифный Literata: главный опознавательный знак BAZA. */
h1, h2, h3 {
	font-family: var(--ff-display);
	line-height: 1.15;
	letter-spacing: -0.015em;
	text-wrap: balance;
	overflow-wrap: anywhere;
	color: var(--c-text);
}

h1 {
	font-size: var(--fs-h1);
	font-weight: 700;
}

h2 {
	font-size: var(--fs-h2);
	font-weight: 700;
}

h3 {
	font-size: var(--fs-h3);
	font-weight: 600;
}

/* h4-h6 — обычный Inter, без декора и без uppercase. */
h4, h5, h6 {
	font-family: var(--ff-sans);
	font-weight: 600;
	line-height: 1.3;
	letter-spacing: normal;
	text-wrap: pretty;
	overflow-wrap: anywhere;
	color: var(--c-text);
}

h4 { font-size: var(--fs-lead); }
h5 { font-size: var(--fs-base); }
h6 { font-size: var(--fs-md); }

p {
	overflow-wrap: anywhere;
}

strong, b {
	font-weight: 600;
	color: inherit;
}

em, i {
	font-style: italic;
}

small {
	font-size: var(--fs-sm);
	color: var(--c-text-muted);
}

mark {
	background: var(--c-accent-soft);
	color: var(--c-text);
	padding: 0 var(--s-1);
	border-radius: var(--r-sm);
}

code, samp, pre {
	font-family: var(--ff-mono);
	font-variant-numeric: normal;
}

pre {
	overflow-x: auto;
}

abbr[title] {
	text-decoration: underline dotted;
	cursor: help;
}

hr {
	border: 0;
	border-top: 1px solid var(--c-border);
	height: 0;
}

/* ── Ссылки ───────────────────────────────────────────────── */

a {
	color: inherit;
	text-decoration: none;
	overflow-wrap: anywhere;
	transition: color var(--t-fast) var(--ease);
}

/* Ссылка без класса = ссылка внутри текста: подчёркнута и в цвете бренда.
   :where() держит нулевую специфичность — любой компонент перебьёт. */
a:where(:not([class])) {
	color: var(--c-primary);
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 3px;
}
a:where(:not([class])):hover {
	color: var(--c-primary-hover);
	text-decoration-color: var(--c-primary-hover);
}

/* ── Медиа ────────────────────────────────────────────────── */

img, video {
	display: block;
	max-width: 100%;
	height: auto;
}

svg {
	vertical-align: middle;
	flex: none;
}

iframe, embed, object {
	max-width: 100%;
	border: 0;
}

figure > img {
	width: 100%;
}

/* ── Фокус ────────────────────────────────────────────────── */

:focus-visible {
	outline: 2px solid var(--c-primary);
	outline-offset: 2px;
	border-radius: var(--r-sm);
}

:focus:not(:focus-visible) {
	outline: none;
}

/* ── Служебное ────────────────────────────────────────────── */

.sr-only,
.screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* Ссылка «к содержимому»: видна только с клавиатуры. */
.skip-link {
	position: fixed;
	top: calc(var(--s-3) * -1 - 100%);
	left: var(--s-3);
	z-index: var(--z-search);
	padding: var(--s-3) var(--s-4);
	border-radius: var(--r-ctl);
	background: var(--c-primary);
	color: var(--c-on-primary);
	font-size: var(--fs-md);
	font-weight: 600;
	box-shadow: var(--sh-md);
	transition: top var(--t) var(--ease-out);
}
.skip-link:focus {
	top: var(--s-3);
}

/* ── Появление блоков при прокрутке ───────────────────────── */

/* Прячем ТОЛЬКО при живом JS (класс .js ставится в <head>): без него
   контент виден сразу. Состояние покоя — одноразовая анимация, а не
   transition: так собственные hover-переходы карточек не затираются. */
html.js .reveal:not(.is-in) {
	opacity: 0;
	transform: translateY(10px);
}
html.js .reveal.is-in {
	animation: baza-reveal 420ms var(--ease-out) 1;
}

@keyframes baza-reveal {
	from {
		opacity: 0;
		transform: translateY(10px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

/* ── Поля ввода ───────────────────────────────────────────── */

label {
	font-size: var(--fs-md);
	font-weight: 500;
	color: var(--c-text);
}

/* :where() у списка типов оставляет специфичность на уровне элемента —
   компоненты (.q__field, .sort-select, .field input) перебивают свободно. */
input:where(
	[type="text"], [type="search"], [type="email"], [type="url"],
	[type="tel"], [type="number"], [type="password"], [type="date"],
	[type="month"], [type="time"], [type="datetime-local"]
),
select,
textarea {
	display: block;
	max-width: 100%;
	padding: var(--s-3);
	border: 1px solid var(--c-border-strong);
	border-radius: var(--r-ctl);
	background-color: var(--c-surface);
	color: var(--c-text);
	font-size: var(--fs-base);
	line-height: 1.4;
	transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}

textarea {
	width: 100%;
	min-height: calc(var(--s-10) + var(--s-7));
	resize: vertical;
}

::placeholder {
	color: var(--c-text-soft);
	opacity: 1;
}

/* Ринг вместо outline: он и есть видимый фокус (см. §5.3). */
input:where(
	[type="text"], [type="search"], [type="email"], [type="url"],
	[type="tel"], [type="number"], [type="password"], [type="date"],
	[type="month"], [type="time"], [type="datetime-local"]
):focus,
select:focus,
textarea:focus {
	border-color: var(--c-primary);
	box-shadow: var(--sh-ring);
	outline: none;
}

/* Автозаполнение не должно приносить свой синий фон. */
input:-webkit-autofill,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
select:-webkit-autofill {
	-webkit-text-fill-color: var(--c-text);
	box-shadow: 0 0 0 100px var(--c-surface) inset;
}

input[type="search"] {
	-webkit-appearance: none;
	appearance: none;
}
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button {
	-webkit-appearance: none;
	appearance: none;
}

/* Кастомный шеврон select.
   ⚠️ padding-right: 36px — место под шеврон. Любое правило с padding
   для select в других файлах обязано его сохранять. */
select {
	-webkit-appearance: none;
	appearance: none;
	padding-right: 36px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%236a645b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6.5 8 10.5 12 6.5'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right var(--s-3) center;
	background-size: 16px 16px;
	cursor: pointer;
}

/* Тёмная тема: шеврон светлее, иначе теряется на тёмной поверхности. */
:root[data-theme="dark"] select {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%23a6a8af' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6.5 8 10.5 12 6.5'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) select {
		background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%23a6a8af' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6.5 8 10.5 12 6.5'/%3E%3C/svg%3E");
	}
}

select option {
	background: var(--c-surface);
	color: var(--c-text);
}

/* ── Проза (вывод редактора) ──────────────────────────────── */

.prose {
	max-width: 68ch;
	color: var(--c-text);
	font-size: var(--fs-base);
	line-height: 1.7;
	overflow-wrap: anywhere;
}

.prose > * + * {
	margin-top: var(--s-4);
}

.prose p {
	text-wrap: pretty;
}

.prose :is(h2, h3, h4, h5, h6) {
	margin-top: var(--s-7);
}

.prose > :first-child {
	margin-top: 0;
}

.prose :is(h2, h3) {
	font-family: var(--ff-display);
}

.prose h2 {
	font-size: var(--fs-h2);
	font-weight: 700;
}

.prose h3 {
	font-size: var(--fs-h3);
	font-weight: 600;
}

.prose h4 {
	font-size: var(--fs-lead);
}

.prose a {
	color: var(--c-primary);
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 3px;
}
.prose a:hover {
	color: var(--c-primary-hover);
}

.prose :is(ul, ol) {
	padding-left: var(--s-6);
}
.prose ul {
	list-style: disc;
}
.prose ol {
	list-style: decimal;
}
.prose li::marker {
	color: var(--c-accent);
}
.prose li + li {
	margin-top: var(--s-2);
}
.prose li > :is(ul, ol) {
	margin-top: var(--s-2);
}

.prose blockquote {
	padding: var(--s-2) 0 var(--s-2) var(--s-5);
	border-left: 1px solid var(--c-accent);
	color: var(--c-text-muted);
	font-family: var(--ff-display);
	font-size: var(--fs-lead);
	line-height: 1.5;
}

.prose :is(dt) {
	font-weight: 600;
}
.prose dd {
	color: var(--c-text-muted);
}

.prose code {
	padding: 0 var(--s-1);
	border-radius: var(--r-sm);
	background: var(--c-sunken);
	font-size: var(--fs-md);
}

.prose pre {
	padding: var(--s-4);
	border: 1px solid var(--c-border);
	border-radius: var(--r);
	background: var(--c-sunken);
	font-size: var(--fs-md);
	line-height: 1.5;
}
.prose pre code {
	padding: 0;
	background: none;
}

.prose hr {
	margin-block: var(--s-7);
}

.prose :is(img, video) {
	border-radius: var(--r);
}

.prose figure {
	margin-block: var(--s-6);
}

.prose figcaption,
.prose .wp-caption-text {
	margin-top: var(--s-2);
	color: var(--c-text-soft);
	font-size: var(--fs-sm);
	text-align: center;
}

.prose table {
	width: 100%;
	font-size: var(--fs-md);
}
.prose :is(th, td) {
	padding: var(--s-2) var(--s-3);
	border-bottom: 1px solid var(--c-border);
	text-align: left;
	vertical-align: top;
}
.prose th {
	font-weight: 600;
	color: var(--c-text);
	background: var(--c-surface-2);
}
.prose td {
	color: var(--c-text-muted);
}

/* Выравнивания редактора WordPress. */
.prose .aligncenter {
	margin-inline: auto;
}
.prose .alignleft {
	float: left;
	margin: 0 var(--s-5) var(--s-4) 0;
}
.prose .alignright {
	float: right;
	margin: 0 0 var(--s-4) var(--s-5);
}
.prose :is(.alignwide, .alignfull) {
	max-width: 100%;
}

/* ── Утилиты ──────────────────────────────────────────────── */

.lead {
	max-width: 62ch;
	color: var(--c-text-muted);
	font-size: var(--fs-lead);
	line-height: 1.55;
	text-wrap: pretty;
}

/* Единственное место, где допустим uppercase. Без «кодов» и линеек. */
.eyebrow {
	color: var(--c-text-soft);
	font-size: var(--fs-xs);
	font-weight: 600;
	letter-spacing: .1em;
	text-transform: uppercase;
}

/* Только для буквального адреса источника. */
.mono {
	font-family: var(--ff-mono);
	overflow-wrap: anywhere;
}

/* Числа в одну колонку: №, даты, счётчики. */
.num-t {
	font-variant-numeric: tabular-nums;
}

.arrow {
	display: inline-block;
	transition: transform var(--t-fast) var(--ease-out);
}
a:hover > .arrow,
a:focus-visible > .arrow,
button:hover > .arrow {
	transform: translateX(2px);
}

.u-muted { color: var(--c-text-muted); }
.u-soft { color: var(--c-text-soft); }
.u-accent { color: var(--c-accent); }
.u-center { text-align: center; }
.u-nowrap { white-space: nowrap; }

/* ── Изображение записи/страницы ──────────────────────────── */

.page-figure {
	margin-block: var(--s-6);
	border: 1px solid var(--c-border);
	border-radius: var(--r-lg);
	background: var(--c-surface-2);
	overflow: hidden;
}
.page-figure img {
	width: 100%;
	border-radius: 0;
}
.page-figure figcaption {
	padding: var(--s-3) var(--s-4);
	border-top: 1px solid var(--c-border);
	color: var(--c-text-soft);
	font-size: var(--fs-sm);
}

/* ── Крошки ───────────────────────────────────────────────── */

.crumbs {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--s-1) var(--s-2);
	min-width: 0;
	color: var(--c-text-muted);
	font-size: var(--fs-sm);
	font-weight: 500;
	overflow-wrap: anywhere;
}

.crumbs a,
.crumbs__link {
	color: var(--c-text-muted);
	text-decoration: none;
}
.crumbs a:hover,
.crumbs__link:hover {
	color: var(--c-text);
	text-decoration: underline;
	text-underline-offset: 3px;
}

.crumbs__sep {
	color: var(--c-text-soft);
}

.crumbs__now,
.crumbs [aria-current="page"] {
	color: var(--c-text);
	font-weight: 600;
}

/* ── ≤768: тач-цели и поля без iOS-зума ───────────────────── */

@media (max-width: 768px) {
	/* --fs-lead на этих ширинах = ровно 16px: iOS не зумит поле при фокусе. */
	input:where(
		[type="text"], [type="search"], [type="email"], [type="url"],
		[type="tel"], [type="number"], [type="password"], [type="date"],
		[type="month"], [type="time"], [type="datetime-local"]
	),
	select,
	textarea {
		font-size: var(--fs-lead);
		min-height: 44px;
	}

	textarea {
		min-height: calc(var(--s-10) + var(--s-8));
	}

	.skip-link {
		min-height: 44px;
		display: inline-flex;
		align-items: center;
	}
}

/* ── ≤600: узкие экраны ───────────────────────────────────── */

@media (max-width: 600px) {
	.prose {
		line-height: 1.65;
	}

	/* Широкая таблица прокручивается внутри себя, а не тянет страницу. */
	.prose table {
		display: block;
		overflow-x: auto;
		white-space: nowrap;
	}

	.prose :is(.alignleft, .alignright) {
		float: none;
		margin-inline: 0;
	}

	.prose blockquote {
		padding-left: var(--s-4);
	}
}

/* ── Меньше движения ──────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}

	a,
	.arrow,
	.skip-link,
	input,
	select,
	textarea {
		transition: none;
	}

	a:hover > .arrow,
	a:focus-visible > .arrow,
	button:hover > .arrow {
		transform: none;
	}

	html.js .reveal:not(.is-in) {
		opacity: 1;
		transform: none;
	}
	html.js .reveal.is-in {
		animation: none;
	}
}
