/*
 * IVA Courses — раздел "Галерея" (page-gallery.php + single-product WooCommerce).
 *
 * :root-переменные (--iva-*), .container, .btn/.btn--fill/.btn--outline,
 * .block.img-placeholder — переиспользуются из course.css, здесь НЕ
 * дублируются. Брейкпоинты — 1024/768/480, как в course.css/blog.css
 * (см. docs/gallery-environment.md).
 */

/* ─── HERO-СЛАЙДЕР ─── */
.gallery-hero { position: relative; width: 100%; height: 520px; overflow: hidden; background: #e7e5e1; }
.gallery-hero--empty { height: auto; padding: 56px 0 32px; background: none; }
.gallery-hero--empty h1 { font-family: 'Bebas Neue', sans-serif; font-size: 42px; letter-spacing: 1px; }

.gallery-hero-track { display: flex; width: 100%; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.gallery-hero-track::-webkit-scrollbar { display: none; }
.gallery-hero-slide { flex: 0 0 100%; height: 100%; scroll-snap-align: start; }
.gallery-hero-slide a,
.gallery-hero-slide .block { display: block; width: 100%; height: 100%; }
.gallery-hero-slide img,
.gallery-hero-slide .block { width: 100%; height: 100%; object-fit: cover; }

.gallery-hero-title {
	position: absolute; top: 28px; left: 40px; z-index: 2;
	font-family: 'Bebas Neue', sans-serif; font-size: 34px; letter-spacing: 1px;
	text-transform: uppercase; color: #111;
	padding: 6px 14px; border-radius: 6px;
	background: rgba(255,255,255,0.55);
	pointer-events: none;
}

.gallery-hero-arrow {
	position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
	width: 44px; height: 44px; border-radius: 50%; border: none; cursor: pointer;
	background: rgba(255,255,255,0.85); display: flex; align-items: center; justify-content: center;
	font-size: 16px; transition: background .15s;
}
.gallery-hero-arrow:hover { background: #fff; }
.gallery-hero-arrow--prev { left: 24px; }
.gallery-hero-arrow--next { right: 24px; }

/* ─── ФИЛЬТРЫ + СЕТКА ─── */
.gallery-layout-wrap { padding: 56px 0 96px; }
.gallery-layout { display: flex; align-items: flex-start; gap: 40px; }

.gallery-filters { flex: 0 0 220px; display: flex; flex-direction: column; gap: 16px; position: sticky; top: 88px; }
.gallery-filter {
	font-family: 'IBM Plex Mono', monospace; font-size: 13px; font-weight: 700;
	letter-spacing: 0.5px; text-transform: uppercase; color: rgba(0,0,0,0.5);
	transition: color .15s;
}
.gallery-filter:hover { color: rgba(0,0,0,0.85); }
.gallery-filter.active { color: var(--iva-black); text-decoration: underline; text-underline-offset: 4px; }

.gallery-filters-toggle { display: none; }
.gallery-filters-close { display: none; }

.gallery-grid-wrap { flex: 1 1 auto; min-width: 0; }
.gallery-grid { display: flex; flex-wrap: wrap; gap: 12px; }

.gallery-card {
	position: relative; display: block; overflow: hidden;
	background: #ececea; flex: 0 0 auto;
}
.gallery-card img { width: 100%; height: 100%; object-fit: cover; display: block; }

.gallery-card__title {
	position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
	padding: 22px 12px 8px; font-family: 'IBM Plex Mono', monospace; font-size: 12px; font-weight: 600;
	color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
	background: linear-gradient(to top, rgba(0,0,0,0.6), rgba(0,0,0,0));
}

.gallery-empty-message { font-family: 'IBM Plex Mono', monospace; font-size: 13px; color: rgba(0,0,0,0.5); }
.gallery-loading-indicator {
	text-align: center; margin-top: 32px; font-family: 'IBM Plex Mono', monospace;
	font-size: 13px; color: rgba(0,0,0,0.5);
}
.gallery-infinite-sentinel { height: 1px; }

/* ─── МОДАЛКА "ОСТАВИТЬ ЗАЯВКУ" (single-product) ─── */
.gallery-lead-modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.gallery-lead-modal[hidden] { display: none; }
.gallery-lead-modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.55); }
.gallery-lead-modal__box { position: relative; width: 100%; max-width: 420px; margin: 20px; padding: 36px 32px; border-radius: 14px; background: #fff; }
.gallery-lead-modal__close { position: absolute; top: 10px; right: 14px; border: none; background: none; font-size: 24px; line-height: 1; color: rgba(0,0,0,0.4); cursor: pointer; }
.gallery-lead-modal__close:hover { color: rgba(0,0,0,0.8); }
.gallery-lead-modal__title { font-family: 'Bebas Neue', sans-serif; font-size: 26px; letter-spacing: 1px; }
.gallery-lead-modal__product { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: rgba(0,0,0,0.5); margin: 6px 0 22px; }

.gallery-lead-form { display: flex; flex-direction: column; gap: 14px; }
.gallery-lead-form__field { display: flex; flex-direction: column; gap: 6px; }
.gallery-lead-form__field span {
	font-family: 'IBM Plex Mono', monospace; font-size: 11px; font-weight: 700;
	text-transform: uppercase; letter-spacing: 0.5px; color: rgba(0,0,0,0.5);
}
.gallery-lead-form__field input {
	height: 44px; padding: 0 14px; border-radius: 8px; border: 1.5px solid rgba(0,0,0,0.14);
	font-family: 'IBM Plex Mono', monospace; font-size: 14px; color: #000;
}
.gallery-lead-form__field input:focus { outline: none; border-color: rgba(0,0,0,0.45); }
.gallery-lead-form__submit { margin-top: 4px; }
.gallery-lead-form__submit:disabled { opacity: 0.55; cursor: default; }
.gallery-lead-form__message { font-family: 'IBM Plex Mono', monospace; font-size: 12px; }
.gallery-lead-form__message.is-error { color: var(--iva-red); }
.gallery-lead-form__message.is-success { color: #0a7a34; }

/* ─── БРЕЙКПОИНТЫ ─── */
@media (max-width: 1024px) {
	.gallery-hero { height: 400px; }
	.gallery-layout { gap: 24px; }
	.gallery-filters { flex-basis: 160px; top: 76px; }
	/* Держим в шаге с iva_gallery_layout_config() (inc/woocommerce-gallery.php,
	   layoutCfg.gap в gallery.js) — иначе PHP/JS считают ширины карточек под
	   ОДИН gap, а браузер физически рисует ДРУГОЙ, из-за чего сумма ширин
	   ряда + реальный gap может на пару px превысить контейнер, и flex-wrap
	   переносит последнюю карточку ряда не туда (найдено визуальной проверкой). */
	.gallery-grid { gap: 10px; }
}

@media (max-width: 768px) {
	.gallery-hero { height: 280px; }
	.gallery-hero-title { font-size: 26px; top: 20px; left: 24px; }
	/* align-items: flex-start (базовое правило, .gallery-layout выше) в
	   строчном layout'е (десктоп/планшет) означает "прижать сайдбар и
	   сетку к верху" — безобидно. Но при flex-direction: column ось
	   align-items меняется на ГОРИЗОНТАЛЬНУЮ, и flex-start вместо
	   растягивания .gallery-grid-wrap на всю ширину даёт ему сжаться по
	   контенту (min/max-content карточек) — сетка считает свою ширину не
	   от реального доступного места, а от текущих (uже выставленных JS)
	   размеров карточек, замкнутый круг. Итог на практике: .gallery-grid
	   на телефоне физически выходит за правый край экрана на 10-40px
	   (подтверждено автотестом в реальном браузере на 375/344/412px —
	   documentScrollWidth > window.innerWidth), карточки без отступа
	   справа. stretch возвращает нормальное поведение колонки — сайдбар
	   и сетка растягиваются на всю ширину. */
	.gallery-layout { flex-direction: column; align-items: stretch; }
	.gallery-grid { gap: 8px; }

	/* Список категорий на мобильном прячем под кнопку "Фильтры" — сам
	   список (.gallery-filters) переиспользуется 1:1 (та же разметка, что
	   на десктопном сайдбаре), просто становится полноэкранным оверлеем с
	   белой подложкой поверх контента вместо статичной колонки слева. */
	.gallery-filters-toggle {
		display: inline-flex; align-items: center; gap: 8px; align-self: flex-start;
		margin-bottom: 20px; padding: 10px 20px; border: 1.5px solid rgba(0,0,0,0.16);
		border-radius: 999px; background: #fff; cursor: pointer;
		font-family: 'IBM Plex Mono', monospace; font-size: 13px; font-weight: 700;
		text-transform: uppercase; letter-spacing: 0.5px; color: rgba(0,0,0,0.8);
	}

	.gallery-filters {
		position: fixed; inset: 0; top: 0; z-index: 1100;
		flex-direction: column; align-items: flex-start; gap: 18px;
		width: 100%; height: 100%; margin: 0; padding: 76px 24px 24px;
		background: #fff; overflow-y: auto;
		visibility: hidden; opacity: 0; transition: opacity .2s ease;
	}
	.gallery-filters.is-open { visibility: visible; opacity: 1; }
	.gallery-filter { font-size: 15px; }

	.gallery-filters-close {
		display: block; position: fixed; top: 20px; right: 20px; z-index: 1101;
		border: none; background: none; font-size: 30px; line-height: 1;
		color: rgba(0,0,0,0.6); cursor: pointer;
	}
}

@media (max-width: 480px) {
	.gallery-hero { height: 220px; }
	.gallery-hero-title { font-size: 20px; top: 14px; left: 16px; padding: 4px 10px; }
	.gallery-hero-arrow { width: 36px; height: 36px; }
	.gallery-card__title { font-size: 11px; padding: 16px 10px 6px; }
}
