/* Product gallery (modules/product-gallery). Classes are prefixed igg- and the
   root is deliberately not .images / .woocommerce-product-gallery, so neither
   WooCommerce's gallery JS nor the theme's legacy gallery CSS touches it. */

.igg {
	--igg-accent: #1e73e8;
	--igg-border: #dfe4ea;
	--igg-muted: #6b7280;
	--igg-gap: 12px;
	max-width: 620px;
	margin: 0 auto 24px;
	padding: 0 16px;
	box-sizing: border-box;
}

.igg *,
.igg *::before,
.igg *::after {
	box-sizing: border-box;
}

/* Main image: one square slide per image, swipeable via scroll-snap. The
   square is reserved before any image or script loads, so nothing shifts. */
.igg-stage {
	position: relative;
}

/* Sale badge (woocommerce/single-product/sale-flash.php), on the image's top
   left corner. The theme positions span.onsale absolutely with !important. */
.igg-sale {
	position: absolute;
	top: 12px;
	left: 12px;
	z-index: 2;
	pointer-events: none;
}

.woocommerce .igg .igg-sale span.onsale,
.igg .igg-sale span.onsale {
	position: static !important;
	display: inline-block;
	width: auto !important;
	height: auto !important;
	min-width: 0;
	min-height: 0;
	margin: 0 !important;
	padding: 6px 12px !important;
	border-radius: 999px;
	background: #b9dcb6;
	color: #1f4d1d;
	font-size: 13px;
	font-weight: 700;
	line-height: 1.2 !important;
	text-transform: uppercase;
	letter-spacing: .02em;
}

.igg-track {
	display: flex;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	overscroll-behavior-x: contain;
	scrollbar-width: none;
	outline: none;
}

.igg-track::-webkit-scrollbar {
	display: none;
}

.igg-track:focus-visible {
	box-shadow: 0 0 0 2px var(--igg-accent);
}

.igg-slide {
	flex: 0 0 100%;
	aspect-ratio: 1 / 1;
	margin: 0;
	scroll-snap-align: center;
	scroll-snap-stop: always;
}

.igg .igg-open {
	display: block;
	width: 100%;
	height: 100%;
	padding: 0;
	border: 0;
	background: none;
	cursor: zoom-in;
}

.igg .igg-slide img {
	display: block;
	width: 100% !important;
	height: 100% !important;
	max-width: none;
	object-fit: contain;
}

.igg-caption {
	margin: 8px 0 16px;
	color: var(--igg-muted);
	font-size: 14px;
	font-style: italic;
	text-align: center;
}

/* Thumbnails: four per row, the strip scrolls sideways when there are more. */
.igg-thumbs {
	position: relative;
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: calc((100% - 3 * var(--igg-gap)) / 4);
	gap: var(--igg-gap);
	overflow-x: auto;
	scroll-snap-type: x proximity;
	/* Snapping aligns to the padding edge, not the strip edge, so the first
	   thumbnail's border is never cut off. */
	scroll-padding-inline: 4px;
	scrollbar-width: none;
	padding: 4px;
}

.igg-thumbs::-webkit-scrollbar {
	display: none;
}

/* Mouse drag (JS): snapping and smooth scrolling off while the pointer moves. */
.igg-track.is-dragging,
.igg-thumbs.is-dragging {
	scroll-snap-type: none;
	scroll-behavior: auto;
	cursor: grabbing;
	user-select: none;
}

.igg-track.is-dragging .igg-open {
	cursor: grabbing;
}

.igg img {
	-webkit-user-drag: none;
	user-select: none;
}

.igg-thumbs[hidden] {
	display: none;
}

.igg .igg-thumb {
	aspect-ratio: 1 / 1;
	padding: 4px;
	border: 1px solid var(--igg-border);
	border-radius: 6px;
	background: #fff;
	cursor: pointer;
	scroll-snap-align: start;
	transition: border-color .15s, box-shadow .15s;
}

.igg .igg-thumb:hover {
	border-color: #b9c2cc;
}

.igg .igg-thumb.is-active {
	border-color: var(--igg-accent);
	/* Inside the border: nothing sticks out to be clipped by the strip. */
	box-shadow: inset 0 0 0 1px var(--igg-accent);
}

.igg .igg-thumb:focus-visible {
	outline: 2px solid var(--igg-accent);
	outline-offset: -4px;
}

.igg .igg-thumb img {
	display: block;
	width: 100% !important;
	height: 100% !important;
	object-fit: contain;
}

@media (max-width: 767px) {
	.igg {
		--igg-gap: 8px;
		padding: 0;
	}

	.igg-thumbs {
		grid-auto-columns: calc((100% - 3.5 * var(--igg-gap)) / 4.5);
	}
}

/* Lightbox (native <dialog>: focus trap, Esc and top layer for free). */
.igg-lightbox {
	width: 100vw;
	height: 100vh;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: rgba(17, 20, 24, .94);
	color: #fff;
	overflow: hidden;
}

.igg-lightbox::backdrop {
	background: rgba(17, 20, 24, .94);
}

.igg-lightbox[open] {
	display: flex;
	align-items: center;
	justify-content: center;
}

.igg-lb-img {
	max-width: 92vw;
	max-height: 86vh;
	width: auto;
	height: auto;
	object-fit: contain;
	user-select: none;
}

.igg-lightbox button {
	position: absolute;
	border: 0;
	background: rgba(255, 255, 255, .12);
	color: #fff;
	font-size: 32px;
	line-height: 1;
	cursor: pointer;
	border-radius: 50%;
	width: 48px;
	height: 48px;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background .15s;
}

.igg-lightbox button:hover,
.igg-lightbox button:focus-visible {
	background: rgba(255, 255, 255, .25);
	outline: none;
}

.igg-lb-close {
	top: 16px;
	right: 16px;
}

.igg-lb-prev {
	left: 16px;
	top: 50%;
	transform: translateY(-50%);
}

.igg-lb-next {
	right: 16px;
	top: 50%;
	transform: translateY(-50%);
}

.igg-lightbox[data-single] .igg-lb-nav,
.igg-lightbox[data-single] .igg-lb-count {
	display: none;
}

.igg-lb-count {
	position: absolute;
	bottom: 16px;
	left: 50%;
	transform: translateX(-50%);
	font-size: 14px;
	opacity: .8;
}

@media (max-width: 767px) {
	.igg-lb-nav {
		display: none !important; /* swipe instead */
	}
}

html.igg-lock {
	overflow: hidden;
}
