/* ==========================================================================
   CONTENT — текст из редактора: заголовки, абзацы, ссылки, списки, таблицы,
   картинки (увеличение по клику — assets/js/main.js).
   Обёртка на сайте — .content (секции), в редакторе — .editor-styles-wrapper.
   Без CSS-вложенности: файл подключается и как editor style.
   Figma 1440: H2 36/1.34 · текст 16/1.58 Medium · отступ между разделами 64.
   ========================================================================== */

:root {
	--content-section-gap: 64px; /* перед H2 — новый раздел */
	--content-gap: 22px;         /* между блоками */
}

@media (max-width: 1023px) {
	:root {
		--content-section-gap: 42px;
	}
}

@media (max-width: 767px) {
	:root {
		--content-section-gap: 34px;
		--content-gap: 16px;
	}
}

/* --------------------------------- Ритм ------------------------------------ */

.content > * + * {
	margin-block-start: var(--content-gap);
}

.content > p + p {
	margin-block-start: 14px;
}

.content > * + h2 {
	margin-block-start: var(--content-section-gap);
}

.content > * + :is(h3, h4, h5, h6) {
	margin-block-start: 32px;
}

.content > :is(h2, h3, h4, h5, h6) + * {
	margin-block-start: 16px;
}

/* -------------------------------- Текст ------------------------------------ */

:where(.content, .editor-styles-wrapper) p,
:where(.content, .editor-styles-wrapper) li {
	font-size: 16px;
	font-weight: 500;
	line-height: 1.58;
}

:where(.content, .editor-styles-wrapper) h2 {
	line-height: 1.34;
}

:where(.content, .editor-styles-wrapper) :is(h3, h4) {
	line-height: 1.2;
}

:where(.content, .editor-styles-wrapper) a:not([class]) {
	color: var(--c-red);
	text-decoration: underline;
	text-underline-offset: 0.15em;
}

:where(.content, .editor-styles-wrapper) a:not([class]):hover {
	text-decoration: none;
}

:where(.content, .editor-styles-wrapper) strong {
	font-weight: 700;
}

:where(.content, .editor-styles-wrapper) blockquote {
	padding: 16px 22px;
	background: var(--c-card);
	border-inline-start: 3px solid var(--c-red);
	border-radius: var(--radius);
}

/* -------------------------------- Списки ----------------------------------- */
/* Списки с классами BEM (меню, содержание) не трогаем. .wp-block-list — обычный список
   редактора: в редакторе у него служебный класс block-editor-block-list__layout. */

:where(.content, .editor-styles-wrapper) :is(ul, ol):is(:not([class*="__"]), .wp-block-list) {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding-inline-start: 26px;
}

:where(.content, .editor-styles-wrapper) ul:is(:not([class*="__"]), .wp-block-list) {
	list-style: none;
}

:where(.content, .editor-styles-wrapper) ul:is(:not([class*="__"]), .wp-block-list) > li {
	position: relative;
}

/* Маркер — красный ромб */
:where(.content, .editor-styles-wrapper) ul:is(:not([class*="__"]), .wp-block-list) > li::before {
	content: "";
	position: absolute;
	inset-inline-start: -20px;
	top: 0.62em;
	width: 7px;
	height: 7px;
	background: var(--c-red);
	border-radius: 1px;
	rotate: 45deg;
}

:where(.content, .editor-styles-wrapper) ol:is(:not([class*="__"]), .wp-block-list) {
	list-style: decimal;
}

:where(.content, .editor-styles-wrapper) ol:is(:not([class*="__"]), .wp-block-list) > li::marker {
	font-weight: 700;
	color: var(--c-red);
}

:where(.content, .editor-styles-wrapper) li > :is(ul, ol) {
	margin-block-start: 8px;
}

/* ------------------------------- Таблицы ----------------------------------- */
/* Обёртка .wp-block-table — по ширине таблицы (короткая таблица не растягивается
   на всю колонку), но не шире колонки: если не влезает — прокрутка по горизонтали. */

:where(.content, .editor-styles-wrapper) .wp-block-table {
	width: fit-content;
	max-width: 100%;
	overflow-x: auto;
	border: 1px solid var(--c-line);
	border-radius: 8px;
	-webkit-overflow-scrolling: touch;
	scrollbar-color: var(--c-red) var(--c-card);
	scrollbar-width: thin;
}

/* Выравнивание таблицы в редакторе (по центру / слева / справа): WordPress ставит
   display: table (и float), а у display: table не работает overflow — таблица вылезает
   за экран без прокрутки. Оставляем блоком, как у таблицы без выравнивания. */
.content .wp-block-table:is(.aligncenter, .alignleft, .alignright),
.editor-styles-wrapper .wp-block-table:is(.aligncenter, .alignleft, .alignright) {
	display: block;
	float: none;
}

/* table-layout и width: auto — иначе WordPress (has-fixed-layout, width: 100%) растягивает
   таблицу на всю колонку и сжимает колонки без прокрутки. */
.content .wp-block-table table,
.editor-styles-wrapper .wp-block-table table {
	width: auto;
	table-layout: auto;
}

:where(.content, .editor-styles-wrapper) .wp-block-table table {
	width: auto;
	border-collapse: collapse;
	font-size: 16px;
	line-height: 1.4;
}

:where(.content, .editor-styles-wrapper) .wp-block-table :is(th, td) {
	min-width: 110px;
	padding: 14px 18px;
	text-align: start;
	vertical-align: top;
	border: 0;
	border-block-end: 1px solid var(--c-line);
}

:where(.content, .editor-styles-wrapper) .wp-block-table tr:last-child > :is(th, td) {
	border-block-end: 0;
}

/* Мин. ширина по числу колонок: на узком экране таблица прокручивается, колонки не сжимаются. */
:where(.content, .editor-styles-wrapper) .wp-block-table table:has(tr > :nth-child(3)) {
	min-width: 640px;
}

:where(.content, .editor-styles-wrapper) .wp-block-table table:has(tr > :nth-child(4)) {
	min-width: 760px;
}

/* Убираем стандартные рамки WordPress (thead 3px и т.п.) — рамки свои. */
.content .wp-block-table :is(thead, tfoot),
.editor-styles-wrapper .wp-block-table :is(thead, tfoot) {
	border: 0;
}

:where(.content, .editor-styles-wrapper) .wp-block-table thead :is(th, td) {
	font-weight: 600;
	background: var(--c-dark);
	border-block-end-color: var(--c-red-dark);
}

:where(.content, .editor-styles-wrapper) .wp-block-table tbody tr:nth-child(odd) {
	background: var(--c-card);
}

:where(.content, .editor-styles-wrapper) .wp-block-table figcaption {
	padding: 10px 18px;
	font-size: 14px;
	color: var(--c-gray);
	border-block-start: 1px solid var(--c-line);
}

/* ------------------------------- Картинки ---------------------------------- */

:where(.content, .editor-styles-wrapper) .wp-block-image img {
	border: 1px solid var(--c-line);
	border-radius: 8px;
}

:where(.content, .editor-styles-wrapper) .wp-block-image figcaption {
	margin-block-start: 8px;
	font-size: 14px;
	color: var(--c-gray);
	text-align: center;
}

/* Увеличение по клику: значок лупы при наведении */
.content .gb-zoom {
	position: relative;
	display: inline-block;
	max-width: 100%;
	cursor: zoom-in;
}

.content .gb-zoom::after {
	content: "";
	position: absolute;
	inset-block-end: 12px;
	inset-inline-end: 12px;
	width: 36px;
	height: 36px;
	background: rgb(0 0 0 / 0.6) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%23f1f1f1' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='6'/%3E%3Cpath d='m16.5 16.5-4-4M8 5.5v5M5.5 8h5'/%3E%3C/svg%3E") center / 18px no-repeat;
	border: 1px solid var(--c-line);
	border-radius: 50%;
	opacity: 0;
	transition: opacity var(--transition);
}

.content .gb-zoom:hover::after {
	opacity: 1;
}

/* Окно просмотра */
.gb-lightbox {
	position: fixed;
	inset: 0;
	z-index: 1000;
	display: grid;
	place-items: center;
	padding: 48px 16px;
	background: rgb(0 0 0 / 0.9);
	cursor: zoom-out;
	opacity: 0;
	visibility: hidden;
	transition: opacity var(--transition), visibility var(--transition);
}

.gb-lightbox.is-open {
	opacity: 1;
	visibility: visible;
}

.gb-lightbox__img {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	border-radius: 8px;
}

.gb-lightbox__close {
	position: absolute;
	inset-block-start: 12px;
	inset-inline-end: 12px;
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	color: var(--c-light);
	background: var(--c-dark);
	border: 1px solid var(--c-line);
	border-radius: 50%;
}
