/**
 * ISCO · инфографика в статьях журнала: блоки isco-ig-* (плитки с цифрами, карточки, шаги, таблицы, чек-листы, выноски, источники).
 * Работает и для готового HTML, и для узоров редактора (core/group, core/list, core/table с классами isco-ig-*).
 * Подключается на странице статьи и в редакторе блоков (ISCO_Patterns).
 */

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-stats {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
	gap: 14px;
	margin: 28px 0;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-stat {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 20px 18px;
	border-radius: 18px;
	background: var(--isco-green-100);
	color: var(--isco-text-primary);
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-stat:nth-child(4n+2) { background: var(--isco-sun-100); }
:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-stat:nth-child(4n+3) { background: var(--isco-sky-100); }
:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-stat:nth-child(4n+4) { background: var(--isco-violet-100); }

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-stat strong {
	font-size: 36px;
	line-height: 1.1;
	font-weight: 800;
	color: var(--isco-text-brand);
	unicode-bidi: isolate;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-stat span {
	font-size: 15px;
	line-height: 1.45;
	font-weight: 500;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-steps {
	counter-reset: isco-step;
	margin: 24px 0;
	padding: 0;
	list-style: none;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-steps > li {
	position: relative;
	margin: 0;
	padding: 0 64px 22px 0;
	counter-increment: isco-step;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-steps > li::before {
	content: counter(isco-step);
	position: absolute;
	inset-inline-start: 0;
	inset-block-start: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	inline-size: 44px;
	block-size: 44px;
	border-radius: 999px;
	background: var(--isco-action-secondary);
	font-weight: 700;
	color: #fff;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-steps > li::after {
	content: "";
	position: absolute;
	inset-inline-start: 21px;
	inset-block: 48px 4px;
	inline-size: 2px;
	background: var(--isco-border-default);
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-steps > li:last-child::after {
	display: none;
}

/* В редакторе текст пункта завёрнут в .block-editor-rich-text__editable — правило должно доставать и туда. */
:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-steps > li > strong:first-child,
.editor-styles-wrapper .isco-ig-steps > li > .block-editor-rich-text__editable > strong:first-child {
	display: block;
	margin-block-end: 2px;
	padding-block-start: 8px;
	font-size: 19px;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-cards {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
	gap: 16px;
	margin: 24px 0;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-card {
	padding: 20px 22px;
	border: 1px solid var(--isco-border-default);
	border-radius: 18px;
	background: var(--isco-bg-surface);
	box-shadow: 0 2px 6px rgba(16, 34, 26, 0.05);
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-card h3 {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0 0 10px;
	font-size: 20px;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-card h3 b {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: none;
	inline-size: 36px;
	block-size: 36px;
	border-radius: 10px;
	background: var(--isco-green-100);
	font-size: 18px;
	color: var(--isco-text-brand);
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-card ul {
	margin: 0;
	padding-inline-start: 20px;
	font-size: 16px;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-card p {
	margin: 0;
	font-size: 16px;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-check {
	margin: 20px 0;
	padding: 0;
	list-style: none;
	columns: 2;
	column-gap: 28px;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-check li {
	position: relative;
	break-inside: avoid;
	padding-inline-start: 34px;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-check li::before {
	content: "✓";
	position: absolute;
	inset-inline-start: 0;
	inset-block-start: 2px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	inline-size: 24px;
	block-size: 24px;
	border-radius: 7px;
	background: var(--isco-green-100);
	font-size: 15px;
	font-weight: 700;
	color: var(--isco-text-brand);
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-table {
	margin: 20px 0 28px;
	overflow-x: auto;
	border: 1px solid var(--isco-border-default);
	border-radius: 16px;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-table table {
	inline-size: 100%;
	border-collapse: collapse;
	font-size: 16px;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-table caption {
	padding: 14px 16px;
	background: var(--isco-bg-brand-soft);
	font-weight: 700;
	text-align: start;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-table th,
:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-table td {
	padding: 12px 16px;
	border-block-start: 1px solid var(--isco-border-default);
	text-align: start;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-table thead th {
	background: var(--isco-bg-subtle);
	font-weight: 600;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-callout {
	display: flex;
	gap: 14px;
	margin: 24px 0;
	padding: 18px 20px;
	border-radius: 16px;
	background: var(--isco-sun-100);
	border-inline-start: 5px solid var(--isco-sun-600);
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-callout--alert {
	background: var(--isco-coral-100);
	border-inline-start-color: var(--isco-coral-500);
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-callout b {
	flex: none;
	font-size: 22px;
	line-height: 1.4;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-callout p {
	margin: 0;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-sources {
	margin: 32px 0 0;
	padding: 18px 22px;
	border-radius: 16px;
	background: var(--isco-bg-subtle);
	font-size: 15px;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-sources h2 {
	margin: 0 0 8px;
	font-size: 18px;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-sources ul {
	margin: 0;
}

@media (max-width: 640px) {
	:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-check {
		columns: 1;
	}

	:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-stat strong {
		font-size: 30px;
	}
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-card .isco-ig-check {
	columns: 1;
	margin: 0;
	font-size: 16px;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-stat strong[dir="ltr"] {
	text-align: right;
}

/* Число не должно вылезать из узкой плитки: длинное значение («9:00–16:00») переносится после тире. */
:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-stat strong {
	white-space: normal;
	overflow-wrap: anywhere;
	font-size: clamp(26px, 2.6vw, 36px);
}


/* ---------- Разметка узоров редактора (core-блоки) ---------- */

/* Групповые блоки без внутренней обёртки ведут себя как раньше; если обёртка есть — она прозрачна для сетки. */
:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-stats > .wp-block-group__inner-container,
:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-cards > .wp-block-group__inner-container,
:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-stat > .wp-block-group__inner-container,
:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-callout > .wp-block-group__inner-container {
	display: contents;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-stats,
:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-cards {
	gap: 14px;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-stat > * {
	margin: 0;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-stat .isco-ig-num {
	font-size: clamp(26px, 2.6vw, 36px);
	line-height: 1.1;
	font-weight: 800;
	white-space: normal;
	overflow-wrap: anywhere;
	color: var(--isco-text-brand);
	unicode-bidi: plaintext;
	text-align: right;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-stat p:not(.isco-ig-num) {
	font-size: 15px;
	line-height: 1.45;
	font-weight: 500;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-card > *:last-child {
	margin-block-end: 0;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-card h3 .isco-ig-badge,
:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-card h3 mark {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: none;
	inline-size: 36px;
	block-size: 36px;
	border-radius: 10px;
	background: var(--isco-green-100);
	font-size: 18px;
	color: var(--isco-text-brand);
}

:is(.isco-post__content, .editor-styles-wrapper) figure.isco-ig-table,
:is(.isco-post__content, .editor-styles-wrapper) .wp-block-table.isco-ig-table {
	margin: 20px 0 28px;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-table figcaption {
	order: -1;
	margin: 0;
	padding: 14px 16px;
	background: var(--isco-bg-brand-soft);
	font-size: 16px;
	font-weight: 700;
	text-align: start;
	color: var(--isco-text-primary);
}

:is(.isco-post__content, .editor-styles-wrapper) .wp-block-table.isco-ig-table {
	display: flex;
	flex-direction: column;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-table td,
:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-table th {
	border-inline: 0;
	border-block-end: 0;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-callout > p:first-child {
	flex: none;
	margin: 0;
	font-size: 22px;
	line-height: 1.4;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-callout > p + p {
	margin: 0;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-sources > *:last-child {
	margin-block-end: 0;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-sources p {
	margin: 8px 0 0;
	font-size: 14px;
	color: var(--isco-text-secondary);
}

/* Отступы «потока» WordPress между детьми группы ломают сетку плиток и карточек. */
:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-stats > *,
:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-cards > *,
:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-callout > * {
	margin: 0;
}

:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-card > * + *,
:is(.isco-post__content, .editor-styles-wrapper) .isco-ig-sources > * + * {
	margin-block-start: 8px;
}

/* ---------- «כרטיס קייטנה»: рамка лагеря в статье-подборке (как на kayt.co.il, просьба Шломо 06.11, docs/62) ---------- */

:is(.isco-post__content, .isco-page__body, .editor-styles-wrapper) .isco-campbox {
	margin: 28px 0;
	padding: 22px 24px;
	border: 2px solid var(--isco-border-strong);
	border-radius: 18px;
	background: var(--isco-bg-surface);
	color: var(--isco-text-primary);
}

:is(.isco-post__content, .isco-page__body, .editor-styles-wrapper) .isco-campbox > h3 {
	margin: 0 0 10px;
	color: var(--isco-text-brand);
	font-size: 24px;
	line-height: 1.3;
}

:is(.isco-post__content, .isco-page__body, .editor-styles-wrapper) .isco-campbox > p {
	margin: 0 0 12px;
}

:is(.isco-post__content, .isco-page__body, .editor-styles-wrapper) .isco-campbox__row {
	gap: 20px;
	align-items: stretch;
	margin: 16px 0;
}

:is(.isco-post__content, .isco-page__body, .editor-styles-wrapper) .isco-campbox__info {
	block-size: 100%;
	box-sizing: border-box;
	padding: 14px 18px;
	border: 1.5px solid var(--isco-border-default);
	border-radius: 14px;
	background: var(--isco-bg-subtle);
}

:is(.isco-post__content, .isco-page__body, .editor-styles-wrapper) .isco-campbox__info ul {
	margin: 0;
	padding: 0;
	list-style: none;
}

:is(.isco-post__content, .isco-page__body, .editor-styles-wrapper) .isco-campbox__info li {
	margin: 0;
	padding: 6px 0;
	border-block-end: 1px solid var(--isco-border-default);
}

:is(.isco-post__content, .isco-page__body, .editor-styles-wrapper) .isco-campbox__info li:last-child {
	border-block-end: 0;
}

:is(.isco-post__content, .isco-page__body, .editor-styles-wrapper) .isco-campbox__img {
	margin: 0;
}

:is(.isco-post__content, .isco-page__body, .editor-styles-wrapper) .isco-campbox__img img {
	display: block;
	inline-size: 100%;
	max-block-size: 360px;
	border-radius: 14px;
	object-fit: contain;
}

/* Картинку не выбрали — WordPress не выводит пустой блок картинки; пустую колонку прячем, сроки — на всю ширину */
:is(.isco-post__content, .isco-page__body) .isco-campbox__row > .wp-block-column:not(:has(*)) {
	display: none;
}

:is(.isco-post__content, .isco-page__body, .editor-styles-wrapper) .isco-campbox__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	margin-block-start: 8px;
}

:is(.isco-post__content, .isco-page__body, .editor-styles-wrapper) .isco-campbox__actions .wp-block-button {
	flex: 1 1 200px;
	margin: 0;
}

:is(.isco-post__content, .isco-page__body, .editor-styles-wrapper) .isco-campbox__actions .wp-block-button__link {
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	inline-size: 100%;
	min-block-size: 48px;
	padding: 10px 20px;
	border: 0;
	border-radius: var(--isco-radius-pill);
	font: 500 16px/1.2 Rubik, sans-serif;
	text-decoration: none;
}

:is(.isco-post__content, .isco-page__body, .editor-styles-wrapper) .isco-campbox__more .wp-block-button__link {
	background: var(--isco-header-bg);
	color: var(--isco-header-ink);
}

/* Тёмный текст на зелёном WhatsApp: белый на #25d366 даёт контраст ниже 4,5:1 */
:is(.isco-post__content, .isco-page__body, .editor-styles-wrapper) .isco-campbox__wa .wp-block-button__link {
	background: var(--isco-action-whatsapp);
	color: #0c1a12;
}

:is(.isco-post__content, .isco-page__body) .isco-campbox__actions .wp-block-button__link:hover {
	text-decoration: underline;
	text-underline-offset: 3px;
}

@media (max-width: 599px) {
	:is(.isco-post__content, .isco-page__body) .isco-campbox {
		padding: 18px 16px;
	}
}
