/*
 * Products Hub — single product gallery and full-screen image viewer (v1.9.0).
 *
 * Replaces the earlier stage/canvas overrides and inline !important rules.
 * The viewer is a native <dialog> shown with showModal(): it renders in the
 * browser top layer, so theme z-index, transforms and overflow cannot clip
 * or cover it.
 */

/* ---------------------------------------------------------------------------
 * Gallery
 * ------------------------------------------------------------------------ */
.sls-pm-gallery {
	display: flex;
	flex-direction: column;
	gap: 12px;
	width: 100%;
	min-width: 0;
	margin: 0;
}

/* Square, consistent stage. The image is contained (never cropped or
 * stretched) and centered, whatever its proportions. */
.sls-pm-gallery-stage {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	aspect-ratio: 1 / 1;
	margin: 0;
	padding: 0;
	background: var(--sls-pm-well, #f6f3ef);
	border-radius: var(--sls-pm-radius, 18px);
	overflow: hidden;
}

.sls-pm-gallery-stage .sls-pm-gallery-main {
	display: block;
	width: 100%;
	height: 100%;
	max-width: 100%;
	max-height: 100%;
	margin: 0;
	padding: 4%;
	border: 0;
	border-radius: 0;
	object-fit: contain;
	object-position: center;
	box-shadow: none;
	transition: transform 0.25s ease;
}

.sls-pm-gallery.is-zooming .sls-pm-gallery-main {
	transform: scale(1.8);
	cursor: zoom-in;
}

.sls-pm-gallery-stage .sls-pm-gallery-open {
	position: relative;
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	background: transparent;
	border: 0;
	border-radius: inherit;
	box-shadow: none;
	color: inherit;
	font: inherit;
	cursor: zoom-in;
}

.sls-pm-gallery-stage .sls-pm-gallery-open:focus-visible {
	outline: 2px solid var(--sls-pm-accent, #2563eb);
	outline-offset: -4px;
}

.sls-pm-gallery-expand {
	position: absolute;
	right: 14px;
	bottom: 14px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	background: rgba(255, 255, 255, 0.92);
	border-radius: 50%;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
	color: #222;
	opacity: 0.85;
	transition: opacity 0.2s ease, transform 0.2s ease;
	pointer-events: none;
}

.sls-pm-gallery-open:hover .sls-pm-gallery-expand {
	opacity: 1;
	transform: scale(1.05);
}

/* Thumbnails: equal square tiles, contained images, clear active state. */
.sls-pm-gallery-thumbs {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
	gap: 10px;
	max-width: 100%;
	margin: 0;
	padding: 0;
	list-style: none;
}

.sls-pm-gallery-thumbs li {
	min-width: 0;
	margin: 0;
	padding: 0;
	list-style: none;
}

.sls-pm-gallery-thumbs li::before,
.sls-pm-gallery-thumbs li::marker {
	content: none;
}

.sls-pm-gallery .sls-pm-gallery-thumb {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	aspect-ratio: 1 / 1;
	min-height: 0;
	margin: 0;
	padding: 6px;
	background: var(--sls-pm-well, #f6f3ef);
	border: 2px solid transparent;
	border-radius: 12px;
	box-shadow: none;
	cursor: pointer;
	opacity: 0.72;
	transition: opacity 0.2s ease, border-color 0.2s ease;
}

.sls-pm-gallery .sls-pm-gallery-thumb img {
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	object-fit: contain;
	border-radius: 6px;
	pointer-events: none;
}

.sls-pm-gallery .sls-pm-gallery-thumb:hover {
	opacity: 1;
}

.sls-pm-gallery .sls-pm-gallery-thumb.is-active {
	border-color: var(--sls-pm-accent, #2563eb);
	opacity: 1;
}

.sls-pm-gallery .sls-pm-gallery-thumb:focus-visible {
	outline: 2px solid var(--sls-pm-accent, #2563eb);
	outline-offset: 2px;
}

/* Thumbnails beside the image on wide layouts. */
@container sls-pm-single (min-width: 760px) {
	.sls-pm-gallery.is-thumbs-side.has-thumbs {
		display: grid;
		grid-template-columns: 76px minmax(0, 1fr);
		align-items: start;
	}

	.sls-pm-gallery.is-thumbs-side .sls-pm-gallery-thumbs {
		grid-column: 1;
		grid-row: 1;
		grid-template-columns: minmax(0, 1fr);
		max-height: 100%;
		overflow-y: auto;
		scrollbar-width: thin;
	}

	.sls-pm-gallery.is-thumbs-side .sls-pm-gallery-stage {
		grid-column: 2;
		grid-row: 1;
	}
}

/* ---------------------------------------------------------------------------
 * Full-screen viewer
 * ------------------------------------------------------------------------ */
.sls-pm-lightbox {
	position: fixed;
	inset: 0;
	box-sizing: border-box;
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: 0;
	background: transparent;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	color: #fff;
	overflow: hidden;
	overscroll-behavior: contain;
}

.sls-pm-lightbox:not([open]) {
	display: none;
}

.sls-pm-lightbox::backdrop {
	background: rgba(12, 13, 15, 0.94);
}

/* Fallback when showModal() is not supported. */
.sls-pm-lightbox.is-fallback-open {
	z-index: 2147483000;
	background: rgba(12, 13, 15, 0.94);
}

.sls-pm-lightbox-frame {
	position: relative;
	display: grid;
	place-items: center;
	width: 100%;
	height: 100%;
	padding: clamp(56px, 7vh, 72px) clamp(12px, 7vw, 96px);
}

.sls-pm-lightbox-figure {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
}

.sls-pm-lightbox .sls-pm-lightbox-image {
	display: block;
	width: 100%;
	height: 100%;
	max-width: 100%;
	max-height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	object-fit: contain;
	box-shadow: none;
	user-select: none;
	transition: opacity 0.18s ease;
}

.sls-pm-lightbox.is-loading .sls-pm-lightbox-image {
	opacity: 0.35;
}

.sls-pm-lightbox button {
	position: absolute;
	z-index: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	min-height: 0;
	margin: 0;
	padding: 0;
	background: rgba(255, 255, 255, 0.12);
	border: 1px solid rgba(255, 255, 255, 0.18);
	border-radius: 50%;
	box-shadow: none;
	color: #fff;
	font: inherit;
	line-height: 1;
	cursor: pointer;
	transition: background-color 0.2s ease;
}

.sls-pm-lightbox button:hover,
.sls-pm-lightbox button:focus-visible {
	background: rgba(255, 255, 255, 0.24);
	color: #fff;
}

.sls-pm-lightbox button:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

.sls-pm-lightbox button svg {
	display: block;
	pointer-events: none;
}

.sls-pm-lightbox .sls-pm-lightbox-close {
	top: max(14px, env(safe-area-inset-top));
	right: max(14px, env(safe-area-inset-right));
}

.sls-pm-lightbox .sls-pm-lightbox-prev,
.sls-pm-lightbox .sls-pm-lightbox-next {
	top: 50%;
	transform: translateY(-50%);
}

.sls-pm-lightbox .sls-pm-lightbox-prev {
	left: max(14px, env(safe-area-inset-left));
}

.sls-pm-lightbox .sls-pm-lightbox-next {
	right: max(14px, env(safe-area-inset-right));
}

.sls-pm-lightbox-counter {
	position: absolute;
	bottom: max(16px, env(safe-area-inset-bottom));
	left: 50%;
	margin: 0;
	padding: 5px 12px;
	background: rgba(255, 255, 255, 0.12);
	border-radius: 999px;
	color: rgba(255, 255, 255, 0.9);
	font-size: 0.85rem;
	font-variant-numeric: tabular-nums;
	line-height: 1.2;
	transform: translateX(-50%);
}

/* Phones: arrows move to the bottom edge so they never cover the image. */
@media (max-width: 600px) {
	.sls-pm-lightbox-frame {
		padding: 64px 8px 84px;
	}

	.sls-pm-lightbox .sls-pm-lightbox-prev,
	.sls-pm-lightbox .sls-pm-lightbox-next {
		top: auto;
		bottom: max(14px, env(safe-area-inset-bottom));
		transform: none;
	}

	.sls-pm-lightbox-counter {
		bottom: max(26px, calc(env(safe-area-inset-bottom) + 12px));
	}
}

@media (prefers-reduced-motion: reduce) {
	.sls-pm-gallery-main,
	.sls-pm-lightbox-image,
	.sls-pm-gallery-thumb {
		transition: none;
	}
}
