/*
 * _usluga-gallery.css ? gallery and lightbox styles for service pages.
 *
 * Split from _usluga.css by ADR-023 file-size guard.
 * Enqueue: after _usluga.css, before service-specific overrides.
 */

/* ─── Галерея работ ─── */
.mh__gallery-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
	gap: 16px;
}
.mh__gallery-grid--cases {
	grid-template-columns: repeat(auto-fill, minmax(260px, 320px));
	align-items: start;
}
.mh__gallery-item {
	display: block;
	position: relative;
	aspect-ratio: 4/3;
	overflow: hidden;
	background: var(--bg-deep);
	border: 1px solid var(--line);
	color: inherit;
	text-decoration: none;
}
.mh__gallery-item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 320ms ease;
}
.mh__gallery-item:hover img { transform: scale(1.04); }

.mh__gallery-item--case {
	aspect-ratio: auto;
	overflow: visible;
	background: transparent;
	border: 0;
}
.mh__gallery-item--case img {
	display: block;
	width: 100%;
	height: clamp(220px, 18vw, 280px);
	aspect-ratio: 4/3;
	object-fit: cover;
	background: var(--bg-deep);
	border: 1px solid var(--line);
}

.mh__gallery--mobile-stands .mh__gallery-grid--cases {
	grid-template-columns: repeat(auto-fill, minmax(180px, 220px));
	gap: 20px 18px;
}
.mh__gallery--interior-print .mh__gallery-grid--cases {
	grid-template-columns: repeat(auto-fill, minmax(220px, 280px));
	gap: 20px 18px;
}
.mh__gallery--tablichki .mh__gallery-grid--cases {
	grid-template-columns: repeat(auto-fill, minmax(200px, 260px));
	gap: 20px 18px;
}
.mh__gallery--mobile-stands [data-gallery-subservice],
.mh__gallery--interior-print [data-gallery-subservice],
.mh__gallery--tablichki [data-gallery-subservice] {
	display: none;
}
.mh__gallery--mobile-stands [data-gallery-subservice].is-active,
.mh__gallery--interior-print [data-gallery-subservice].is-active,
.mh__gallery--tablichki [data-gallery-subservice].is-active {
	display: block;
}
.mh__gallery--mobile-stands .mh__gallery-item--case img {
	height: auto;
	aspect-ratio: 3/4;
	object-fit: contain;
	padding: 8px;
	background: var(--paper);
}
.mh__gallery--interior-print .mh__gallery-item--case img {
	height: clamp(220px, 20vw, 300px);
	object-fit: contain;
	padding: 8px;
	background: var(--paper);
}
.mh__gallery--tablichki .mh__gallery-item--case img {
	height: clamp(220px, 20vw, 300px);
	object-fit: contain;
	padding: 8px;
	background: var(--paper);
}

.mh__gallery-caption {
	display: grid;
	gap: 3px;
	padding-top: 10px;
	color: var(--ink);
}
.mh__gallery-caption strong {
	display: -webkit-box;
	overflow: hidden;
	font-size: var(--text-body-sm);
	line-height: 1.25;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}

.mh-gallery-lightbox {
	width: min(1120px, calc(100vw - 32px));
	max-width: none;
	max-height: calc(100vh - 32px);
	padding: 0;
	background: var(--paper);
	border: 1px solid var(--ink);
	box-shadow: 0 24px 80px rgba(var(--rgb-black), 0.42);
	color: var(--fg);
}

.mh-gallery-lightbox::backdrop {
	background: rgba(var(--rgb-black), 0.72);
}

.mh-gallery-lightbox__figure {
	display: grid;
	gap: 0;
	margin: 0;
}

.mh-gallery-lightbox__img {
	display: block;
	width: 100%;
	max-height: calc(100vh - 120px);
	object-fit: contain;
	background: var(--bg-deep);
}

.mh-gallery-lightbox__caption {
	padding: 12px 18px;
	border-top: 1px solid var(--line);
	font-family: var(--font-mh-display);
	font-size: var(--text-body-sm);
	font-weight: 700;
	color: var(--ink);
}

.mh-gallery-lightbox__caption[hidden] {
	display: none;
}

.mh-gallery-lightbox__close {
	position: absolute;
	top: 10px;
	right: 10px;
	z-index: 2;
	display: grid;
	place-items: center;
	width: 42px;
	height: 42px;
	padding: 0;
	background-color: var(--color-yellow-500);
	border: 2px solid var(--color-graphite-900);
	color: var(--color-graphite-900);
	font-family: var(--font-mh-display);
	font-size: var(--text-h3-sm);
	line-height: 1;
	cursor: pointer;
	box-shadow: 0 8px 28px rgba(var(--rgb-black), 0.28);
}

.mh-gallery-lightbox__close:hover,
.mh-gallery-lightbox__close:focus-visible {
	background-color: var(--color-paper);
	color: var(--color-graphite-900);
	outline: none;
}

.mh-gallery-lightbox__nav {
	position: absolute;
	top: 50%;
	z-index: 2;
	display: grid;
	place-items: center;
	width: 48px;
	height: 64px;
	padding: 0;
	background: rgba(var(--rgb-graphite-900), 0.84);
	border: 1px solid rgba(var(--rgb-white), 0.8);
	color: var(--color-white);
	font-family: var(--font-mh-display);
	font-size: var(--text-h1-md);
	line-height: 1;
	transform: translateY(-50%);
	cursor: pointer;
}

.mh-gallery-lightbox__nav[hidden] {
	display: none;
}

.mh-gallery-lightbox__nav--prev {
	left: 12px;
}

.mh-gallery-lightbox__nav--next {
	right: 12px;
}

.mh-gallery-lightbox__nav:hover,
.mh-gallery-lightbox__nav:focus-visible {
	background: var(--color-yellow-500);
	border-color: var(--color-graphite-900);
	color: var(--color-graphite-900);
	outline: none;
}

@media (max-width: 640px) {
	.mh-gallery-lightbox {
		width: calc(100vw - 16px);
		max-height: calc(100vh - 16px);
	}
	.mh-gallery-lightbox__img {
		max-height: calc(100vh - 96px);
	}
	.mh-gallery-lightbox__nav {
		width: 40px;
		height: 56px;
		font-size: var(--text-h2-md);
	}
}

/* Mobile/tablet: горизонтальная карусель со scroll-snap */
@media (max-width: 1024px) {
	.mh__gallery-grid {
		display: flex;
		grid-template-columns: none;
		overflow-x: auto;
		overflow-y: hidden;
		scroll-snap-type: x mandatory;
		-webkit-overflow-scrolling: touch;
		gap: 12px;
		padding: 0 24px 8px;
		margin: 0 -24px;  /* edge-to-edge на mobile */
		scroll-padding-inline: 24px;
		scrollbar-width: none;
	}
	.mh__gallery-grid::-webkit-scrollbar { display: none; }
	.mh__gallery-grid > .mh__gallery-item {
		flex: 0 0 78%;
		scroll-snap-align: start;
		max-width: 360px;
	}
	.mh__gallery-grid--cases > .mh__gallery-item {
		flex-basis: 74%;
	}
	.mh__gallery--mobile-stands .mh__gallery-grid--cases > .mh__gallery-item {
		flex-basis: min(68vw, 260px);
		max-width: 260px;
	}
	.mh__gallery--plenka .mh__gallery-grid--cases {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		overflow: visible;
		gap: 14px 10px;
		padding: 0;
		margin: 0;
		scroll-snap-type: none;
	}
	.mh__gallery--plenka .mh__gallery-grid--cases > .mh__gallery-item {
		flex: initial;
		max-width: none;
		scroll-snap-align: none;
	}
	.mh__gallery--plenka .mh__gallery-item--case img {
		height: 150px;
	}
}
@media (max-width: 640px) {
	.mh__gallery-grid {
		padding: 0 16px 8px;
		margin: 0 -16px;
		scroll-padding-inline: 16px;
	}
	.mh__gallery-grid > .mh__gallery-item {
		flex: 0 0 85%;
	}
	.mh__gallery--plenka .mh__gallery-grid--cases {
		padding: 0;
		margin: 0;
	}
}
