/**
 * IFE - Product Image Thumbnails
 * Frontend gallery styles. All selectors are namespaced with .ife-pit-.
 */

.ife-pit-gallery {
	--ife-pit-gap: 14px;
	--ife-pit-thumb-size: 104px;
	--ife-pit-main-ratio: 1 / 1;
	--ife-pit-zoom-scale: 200%;
	--ife-pit-accent: #1a73e8;
	--ife-pit-border: #e2e2e2;
	width: 100%;
	max-width: 100%;
}

.ife-pit-gallery *,
.ife-pit-gallery *::before,
.ife-pit-gallery *::after {
	box-sizing: border-box;
}

/* -------------------------------------------------------------------------
 * Main image
 * ---------------------------------------------------------------------- */

.ife-pit-main {
	position: relative;
	width: 100%;
}

/*
 * The main image sits in a fixed-aspect frame (default 1:1) and is contained
 * inside it, so every image renders at the same size regardless of its own
 * dimensions. Set the gallery's --ife-pit-main-ratio (or pass aspect="auto"
 * to the shortcode) to change this.
 */
.ife-pit-main__btn {
	position: relative;
	display: block;
	width: 100%;
	aspect-ratio: var(--ife-pit-main-ratio, 1 / 1);
	margin: 0;
	padding: 0;
	border: 1px solid var(--ife-pit-border);
	border-radius: 6px;
	background: #fff;
	cursor: zoom-in;
	overflow: hidden;
	line-height: 0;
	touch-action: manipulation;
}

.ife-pit-main__btn[disabled] {
	cursor: default;
}

.ife-pit-main__btn:focus-visible {
	outline: 2px solid var(--ife-pit-accent);
	outline-offset: 2px;
}

.ife-pit-main__zoom {
	position: absolute;
	inset: 0;
	display: block;
	background-repeat: no-repeat;
	background-position: center;
	background-size: 0 0; /* hidden at rest; revealed only while zooming */
}

.ife-pit-main__img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: contain;
	display: block;
	transition: opacity 0.15s ease;
}

/* When zooming, reveal the magnified background and fade the base image. */
.ife-pit-main__zoom.is-zooming {
	background-size: var(--ife-pit-zoom-scale, 200%);
}

.ife-pit-main__zoom.is-zooming .ife-pit-main__img {
	opacity: 0;
}

/* Natural-aspect mode (aspect="auto"): let the image define its own height. */
.ife-pit-gallery--natural .ife-pit-main__btn {
	aspect-ratio: auto;
}

.ife-pit-gallery--natural .ife-pit-main__zoom {
	position: relative;
}

.ife-pit-gallery--natural .ife-pit-main__img {
	position: relative;
	width: 100%;
	height: auto;
}

/* -------------------------------------------------------------------------
 * Thumbnail strip
 * ---------------------------------------------------------------------- */

.ife-pit-thumbs {
	display: flex;
	align-items: center;
	gap: var(--ife-pit-gap);
	margin-top: var(--ife-pit-gap);
}

.ife-pit-thumbs__track {
	display: flex;
	flex: 1 1 auto;
	gap: var(--ife-pit-gap);
	overflow-x: auto;
	scroll-behavior: smooth;
	scroll-snap-type: x proximity;
	-ms-overflow-style: none; /* IE/Edge */
	scrollbar-width: none;     /* Firefox */
}

.ife-pit-thumbs__track::-webkit-scrollbar {
	display: none; /* WebKit */
}

.ife-pit-thumbs__item {
	flex: 0 0 auto;
	width: var(--ife-pit-thumb-size);
	height: var(--ife-pit-thumb-size);
	margin: 0;
	padding: 6px;
	border: 2px solid var(--ife-pit-border);
	border-radius: 6px;
	background: #fff;
	cursor: pointer;
	overflow: hidden;
	scroll-snap-align: start;
	line-height: 0;
	touch-action: manipulation;
	transition: border-color 0.15s ease;
}

.ife-pit-thumbs__item:hover {
	border-color: #b5b5b5;
}

.ife-pit-thumbs__item.is-active {
	border-color: var(--ife-pit-accent);
}

.ife-pit-thumbs__item:focus-visible {
	outline: 2px solid var(--ife-pit-accent);
	outline-offset: 2px;
}

.ife-pit-thumbs__img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.ife-pit-thumbs__arrow {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 1px solid var(--ife-pit-border);
	border-radius: 50%;
	background: #fff;
	color: #333;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	transition: opacity 0.15s ease, background 0.15s ease;
}

.ife-pit-thumbs__arrow:hover:not([disabled]) {
	background: #f3f3f3;
}

.ife-pit-thumbs__arrow:focus-visible {
	outline: 2px solid var(--ife-pit-accent);
	outline-offset: 2px;
}

.ife-pit-thumbs__arrow[disabled] {
	opacity: 0.35;
	cursor: default;
}

/* Arrows collapse out of the layout when the strip does not overflow. */
.ife-pit-thumbs.ife-pit-thumbs--no-overflow .ife-pit-thumbs__arrow {
	display: none;
}

/* -------------------------------------------------------------------------
 * Lightbox
 * ---------------------------------------------------------------------- */

.ife-pit-lightbox {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.9);
	padding: 24px;
}

.ife-pit-lightbox[hidden] {
	display: none;
}

.ife-pit-lightbox__img {
	max-width: 94vw;
	max-height: 92vh;
	width: auto;
	height: auto;
	object-fit: contain;
	user-select: none;
}

.ife-pit-lightbox__close,
.ife-pit-lightbox__nav {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	padding: 0;
	border: 1px solid rgba(255, 255, 255, 0.22);
	border-radius: 50%;
	background: rgba(24, 24, 27, 0.5);
	-webkit-backdrop-filter: blur(8px);
	backdrop-filter: blur(8px);
	color: #fff;
	cursor: pointer;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
	touch-action: manipulation;
	transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.ife-pit-lightbox .ife-pit-icon {
	width: 24px;
	height: 24px;
	display: block;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
	pointer-events: none;
}

.ife-pit-lightbox__close:hover,
.ife-pit-lightbox__nav:hover {
	background: rgba(39, 39, 42, 0.82);
	border-color: rgba(255, 255, 255, 0.45);
}

.ife-pit-lightbox__close:focus-visible,
.ife-pit-lightbox__nav:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

.ife-pit-lightbox__close {
	top: max(16px, env(safe-area-inset-top, 16px));
	right: 16px;
}

.ife-pit-lightbox__close:hover {
	transform: scale(1.06);
}

.ife-pit-lightbox__close:active {
	transform: scale(0.94);
}

.ife-pit-lightbox__nav {
	top: 50%;
	transform: translateY(-50%);
}

.ife-pit-lightbox__nav:hover {
	transform: translateY(-50%) scale(1.06);
}

.ife-pit-lightbox__nav:active {
	transform: translateY(-50%) scale(0.94);
}

.ife-pit-lightbox__nav--prev {
	left: 16px;
}

.ife-pit-lightbox__nav--next {
	right: 16px;
}

.ife-pit-lightbox__counter {
	position: absolute;
	bottom: max(16px, env(safe-area-inset-bottom, 16px));
	left: 50%;
	transform: translateX(-50%);
	padding: 5px 13px;
	border-radius: 999px;
	background: rgba(24, 24, 27, 0.5);
	-webkit-backdrop-filter: blur(8px);
	backdrop-filter: blur(8px);
	color: #fff;
	font-size: 13px;
	letter-spacing: 0.04em;
}

/* Body scroll lock while the lightbox is open. */
body.ife-pit-lightbox-open {
	overflow: hidden;
}

/* Hide single-image lightbox nav. */
.ife-pit-lightbox.ife-pit-lightbox--single .ife-pit-lightbox__nav {
	display: none;
}

/* -------------------------------------------------------------------------
 * Mobile / small screens
 * ---------------------------------------------------------------------- */

@media (max-width: 600px) {
	.ife-pit-gallery {
		--ife-pit-thumb-size: 72px;
		--ife-pit-gap: 10px;
	}

	.ife-pit-lightbox {
		padding: 12px;
	}

	.ife-pit-lightbox__close,
	.ife-pit-lightbox__nav {
		width: 44px;
		height: 44px;
	}

	.ife-pit-lightbox .ife-pit-icon {
		width: 22px;
		height: 22px;
	}

	.ife-pit-lightbox__close {
		right: 10px;
	}

	.ife-pit-lightbox__nav--prev {
		left: 8px;
	}

	.ife-pit-lightbox__nav--next {
		right: 8px;
	}

	.ife-pit-lightbox__img {
		max-width: 96vw;
		max-height: 88vh;
	}
}

/* -------------------------------------------------------------------------
 * Reduced motion
 * ---------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.ife-pit-thumbs__track {
		scroll-behavior: auto;
	}

	.ife-pit-main__img,
	.ife-pit-thumbs__item,
	.ife-pit-thumbs__arrow,
	.ife-pit-lightbox__close,
	.ife-pit-lightbox__nav {
		transition: none;
	}

	.ife-pit-lightbox__close:hover,
	.ife-pit-lightbox__close:active {
		transform: none;
	}

	.ife-pit-lightbox__nav:hover,
	.ife-pit-lightbox__nav:active {
		transform: translateY(-50%);
	}
}
