/* Галерея фото товара (тег [item_gallery]) и полноэкранный просмотр. Стили модуля, не относятся к теме сайта.
   Цвета и формы меняются переменными: задайте их в css темы на .itg или :root. */
.itg {
	--itg-ratio: 1 / 1;
	--itg-radius: 12px;
	--itg-gap: 12px;
	--itg-thumb: 72px;
	--itg-accent: #1d2130;
	--itg-bg: #fff;
	--itg-border: #e3e5ec;
	--itg-ui: rgba(255, 255, 255, .92);
	--itg-ui-text: #1d2130;
	position: relative;
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	grid-template-areas: "main" "thumbs";
	gap: var(--itg-gap);
	width: 100%;
	min-width: 0;
}
.itg-main { grid-area: main; min-width: 0; }
.itg-thumbs { grid-area: thumbs; }

.itg-stage {
	position: relative;
	aspect-ratio: var(--itg-ratio);
	max-height: min(78vh, 720px);
	overflow: hidden;
	border-radius: var(--itg-radius);
	background: var(--itg-bg);
	border: 1px solid var(--itg-border);
}
.itg-track {
	display: flex;
	width: 100%;
	height: 100%;
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	overscroll-behavior-x: contain;
	-webkit-overflow-scrolling: touch;
}
.itg-track::-webkit-scrollbar { display: none; }
.itg-track:focus-visible { outline: 2px solid var(--itg-accent); outline-offset: -2px; }
.itg-slide {
	flex: 0 0 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 0;
	scroll-snap-align: center;
	scroll-snap-stop: always;
	cursor: zoom-in;
	overflow: hidden;
	-webkit-tap-highlight-color: transparent;
}
.itg-slide picture { display: block; width: 100%; height: 100%; }
.itg-img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
	user-select: none;
	-webkit-user-drag: none;
	transition: transform .15s ease-out;
}
.itg.is-hovering .itg-img {
	transform: scale(2.1);
	transform-origin: var(--itg-zx, 50%) var(--itg-zy, 50%);
}

.itg-expand,
.itg-arrow {
	position: absolute;
	display: none;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--itg-ui);
	color: var(--itg-ui-text);
	cursor: pointer;
	box-shadow: 0 2px 10px rgba(20, 24, 40, .2);
	opacity: 0;
	transition: opacity .15s ease;
}
.itg-expand { top: 10px; right: 10px; }
.itg-arrow { top: 50%; margin-top: -20px; }
.itg-prev { left: 10px; }
.itg-next { right: 10px; }
.itg-stage:hover .itg-expand,
.itg-stage:hover .itg-arrow,
.itg-expand:focus-visible,
.itg-arrow:focus-visible { opacity: 1; }
.itg-expand:focus-visible,
.itg-arrow:focus-visible { outline: 2px solid var(--itg-accent); outline-offset: 2px; }

.itg-counter {
	position: absolute;
	left: 50%;
	bottom: 10px;
	transform: translateX(-50%);
	padding: 4px 12px;
	border-radius: 999px;
	background: rgba(20, 24, 40, .62);
	color: #fff;
	font: 600 12.5px/1.4 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
	pointer-events: none;
}

.itg-thumbs {
	display: flex;
	gap: 8px;
	overflow-x: auto;
	scrollbar-width: none;
	padding: 2px;
	-webkit-overflow-scrolling: touch;
}
.itg-thumbs::-webkit-scrollbar { display: none; }
.itg-thumb {
	flex: 0 0 auto;
	width: 56px;
	height: 56px;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 10px;
	background: var(--itg-bg);
	box-shadow: 0 0 0 1px var(--itg-border);
	overflow: hidden;
	cursor: pointer;
	opacity: .75;
	transition: opacity .12s ease, border-color .12s ease;
}
.itg-thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}
.itg-thumb:hover { opacity: 1; }
.itg-thumb.is-active { opacity: 1; border-color: var(--itg-accent); }
.itg-thumb:focus-visible { outline: 2px solid var(--itg-accent); outline-offset: 2px; }

@media (hover: hover) and (pointer: fine) {
	.itg-expand { display: inline-flex; }
	.itg:not(.itg--single) .itg-arrow { display: inline-flex; }
	.itg-counter { display: none; }
}

/* Планшет и компьютер: миниатюры слева столбцом, высота столбца равна высоте большого фото */
@media (min-width: 992px) {
	.itg:not(.itg--single) {
		grid-template-columns: var(--itg-thumb) minmax(0, 1fr);
		grid-template-areas: "thumbs main";
		align-items: start;
	}
	.itg:not(.itg--single) .itg-thumbs {
		flex-direction: column;
		overflow-x: hidden;
		overflow-y: auto;
		max-height: var(--itg-stage-h, 520px);
		padding: 2px;
	}
	.itg-thumb { width: calc(var(--itg-thumb) - 4px); height: calc(var(--itg-thumb) - 4px); }
	.itg-counter { display: none; }
}

@media (max-width: 575.98px) {
	.itg { --itg-gap: 8px; }
	.itg-stage { border-radius: 8px; }
	.itg-thumb { width: 52px; height: 52px; border-radius: 8px; }
}

/* ============================ Полноэкранный просмотр ============================ */

.itgl {
	position: fixed;
	inset: 0;
	z-index: 2147483000;
	display: flex;
	flex-direction: column;
	background: rgba(10, 12, 18, var(--itgl-fade, 1));
	color: #fff;
	font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
	opacity: 0;
	transition: opacity .18s ease;
	overscroll-behavior: none;
	-webkit-tap-highlight-color: transparent;
}
.itgl[hidden] { display: none; }
.itgl.is-open { opacity: 1; }
.itgl.is-closing { opacity: 0; }

html.itgl-lock,
html.itgl-lock body { overflow: hidden; }

.itgl-bar {
	position: relative;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left));
}
.itgl-counter {
	font-size: 14px;
	font-weight: 600;
	letter-spacing: .02em;
	color: rgba(255, 255, 255, .85);
}
.itgl-tools { display: flex; gap: 6px; }
.itgl-btn,
.itgl-arrow {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .12);
	color: #fff;
	cursor: pointer;
	transition: background .12s ease, opacity .12s ease;
}
.itgl-btn:hover,
.itgl-arrow:hover { background: rgba(255, 255, 255, .24); }
.itgl-btn:disabled,
.itgl-arrow:disabled { opacity: .3; cursor: default; }
.itgl-btn:focus-visible,
.itgl-arrow:focus-visible,
.itgl-thumb:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.itgl-viewport {
	position: relative;
	z-index: 1;
	flex: 1 1 auto;
	min-height: 0;
	overflow: hidden;
	touch-action: none;
	cursor: zoom-in;
}
.itgl.is-zoomed .itgl-viewport { cursor: grab; }
.itgl.is-grabbing .itgl-viewport { cursor: grabbing; }
.itgl-strip {
	display: flex;
	width: 100%;
	height: 100%;
	will-change: transform;
}
.itgl-cell {
	flex: 0 0 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 0;
	overflow: hidden;
}
.itgl-img {
	display: block;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	user-select: none;
	-webkit-user-drag: none;
	will-change: transform;
	transform-origin: 50% 50%;
}

.itgl-arrow {
	position: absolute;
	z-index: 3;
	top: 50%;
	margin-top: -22px;
	display: none;
}
.itgl-prev { left: 14px; }
.itgl-next { right: 14px; }
.itgl-arrow[hidden] { display: none; }

.itgl-thumbs {
	position: relative;
	z-index: 2;
	display: flex;
	gap: 8px;
	justify-content: center;
	overflow-x: auto;
	scrollbar-width: none;
	padding: 8px max(14px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}
.itgl-thumbs::-webkit-scrollbar { display: none; }
.itgl-thumbs[hidden] { display: none; }
.itgl-thumb {
	flex: 0 0 auto;
	width: 54px;
	height: 54px;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 8px;
	background: rgba(255, 255, 255, .06);
	overflow: hidden;
	cursor: pointer;
	opacity: .55;
	transition: opacity .12s ease, border-color .12s ease;
}
.itgl-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.itgl-thumb:hover { opacity: .9; }
.itgl-thumb.is-active { opacity: 1; border-color: #fff; }

@media (hover: hover) and (pointer: fine) {
	.itgl-arrow:not([hidden]) { display: inline-flex; }
}
@media (max-height: 520px) {
	.itgl-thumbs { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	.itg-img,
	.itgl,
	.itgl-btn,
	.itgl-thumb { transition: none; }
}
