/* =====================================================================
   Product image gallery
   ===================================================================== */
.wpi {
	--wpi-cols: 5;
	--wpi-gap: 10px;
	--wpi-radius: 20px;
	--wpi-thumb-radius: 12px;
	position: relative;
	width: 100%;
	max-width: 100%;
}
.wpi *, .wpi *::before, .wpi *::after { box-sizing: border-box; }

/* ---------- Main image card ---------- */
.wpi-main {
	position: relative;
	overflow: hidden;
	background: #fff;
	border-radius: var(--wpi-radius);
	box-shadow: 0 10px 30px rgba(0, 0, 0, .12);
}
.wpi-stage {
	position: relative;
	line-height: 0;
	touch-action: pan-y;
	-webkit-tap-highlight-color: transparent;
}
.wpi-stage.is-zoomable { cursor: zoom-in; }

.wpi .wpi-main-img {
	display: block;
	width: 100%;
	height: auto;
	max-width: 100%;
	margin: 0;
	object-fit: contain;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	transition: opacity .22s ease;
	-webkit-user-drag: none;
	user-select: none;
}
.wpi .wpi-main-img.is-fading { opacity: 0; }

/* ---------- Thumbnails ---------- */
.wpi-thumbs {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-top: 12px;
}
.wpi-thumbs[hidden] { display: none !important; }

.wpi-track {
	display: flex;
	flex: 1 1 auto;
	gap: var(--wpi-gap);
	min-width: 0;
	padding: 8px 8px 16px; /* room so the thumbnail shadows are not clipped */
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x proximity;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior-x: contain;
}
.wpi-track::-webkit-scrollbar { display: none; }

.wpi .wpi-thumb {
	flex: 0 0 calc((100% - var(--wpi-gap) * (var(--wpi-cols) - 1)) / var(--wpi-cols));
	aspect-ratio: 1 / 1;
	margin: 0;
	padding: 0;
	overflow: hidden;
	background: #fff;
	border: 2px solid transparent;
	border-radius: var(--wpi-thumb-radius);
	box-shadow: 0 3px 10px rgba(0, 0, 0, .14);
	line-height: 0;
	opacity: .85;
	cursor: pointer;
	scroll-snap-align: start;
	transition: border-color .2s, opacity .2s;
	-webkit-tap-highlight-color: transparent;
}
.wpi .wpi-thumb img {
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	border: 0;
	border-radius: 0;
	object-fit: cover;
	pointer-events: none;
}
.wpi .wpi-thumb:hover { opacity: 1; }
.wpi .wpi-thumb.is-active { border-color: #1f2937; opacity: 1; }
.wpi .wpi-thumb:focus-visible,
.wpi .wpi-nav:focus-visible,
.wpi .wpi-arrow:focus-visible,
.wpi .wpi-expand:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }

/* ---------- Thumbnail arrows ---------- */
.wpi .wpi-nav {
	display: none;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	color: #9ca3af;
	box-shadow: none;
	cursor: pointer;
	transition: color .2s, opacity .2s;
}
.wpi .wpi-nav:hover { color: #374151; }
.wpi .wpi-nav:disabled { opacity: .3; cursor: default; }
.wpi-thumbs.has-overflow .wpi-nav { display: inline-flex; }
[dir="rtl"] .wpi .wpi-nav svg { transform: scaleX(-1); }

/* ---------- Arrows + expand icon on the main image ---------- */
.wpi .wpi-arrow,
.wpi .wpi-expand {
	position: absolute;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .9);
	color: #111827;
	box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
	cursor: pointer;
	transition: background-color .2s, opacity .2s;
}
.wpi .wpi-arrow { top: 50%; width: 40px; height: 40px; transform: translateY(-50%); opacity: 0; }
.wpi .wpi-arrow--prev { inset-inline-start: 12px; }
.wpi .wpi-arrow--next { inset-inline-end: 12px; }
.wpi .wpi-main:hover .wpi-arrow { opacity: 1; }
.wpi .wpi-arrow:hover, .wpi .wpi-expand:hover { background: #fff; }
.wpi .wpi-expand { top: 12px; inset-inline-start: 12px; width: 38px; height: 38px; }
[dir="rtl"] .wpi .wpi-arrow svg { transform: scaleX(-1); }

/* ---------- Phones / tablets ---------- */
@media (hover: none), (pointer: coarse) {
	.wpi .wpi-nav { display: none !important; }
	.wpi .wpi-arrow { opacity: 1; }
	.wpi .wpi-thumb { opacity: 1; }
}
@media (max-width: 767px) {
	.wpi-thumbs { margin-top: 8px; }
	.wpi .wpi-arrow { width: 36px; height: 36px; }
}

/* =====================================================================
   Lightbox
   ===================================================================== */
.wpi-lb {
	position: fixed;
	inset: 0;
	z-index: 2147483000;
	display: none;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, .9);
	touch-action: pan-y;
}
.wpi-lb.is-open { display: flex; }
body.wpi-lock { overflow: hidden; }

.wpi-lb__img {
	max-width: 94vw;
	max-height: 86vh;
	object-fit: contain;
	border-radius: 8px;
	user-select: none;
	-webkit-user-drag: none;
}
.wpi-lb button {
	position: absolute;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .14);
	color: #fff;
	cursor: pointer;
	transition: background-color .2s;
}
.wpi-lb button:hover { background: rgba(255, 255, 255, .28); }
.wpi-lb__close { top: 16px; inset-inline-end: 16px; }
.wpi-lb__prev { top: 50%; inset-inline-start: 16px; transform: translateY(-50%); }
.wpi-lb__next { top: 50%; inset-inline-end: 16px; transform: translateY(-50%); }
.wpi-lb__count {
	position: absolute;
	bottom: 18px;
	left: 50%;
	transform: translateX(-50%);
	color: #fff;
	font-size: 14px;
	opacity: .85;
}
[dir="rtl"] .wpi-lb__prev svg, [dir="rtl"] .wpi-lb__next svg { transform: scaleX(-1); }
.wpi-lb.is-single .wpi-lb__prev, .wpi-lb.is-single .wpi-lb__next, .wpi-lb.is-single .wpi-lb__count { display: none; }

@media (prefers-reduced-motion: reduce) {
	.wpi .wpi-main-img, .wpi .wpi-thumb { transition: none; }
}
