/* ==========================================================================
   Product gallery: [stbhh_gallery]

   The thumbnails and arrows are real <button>s, so the site's Elementor kit
   styles them (background, border, colours...) in every state. Each button
   state is therefore declared explicitly, on selectors that start with `body`
   and so outrank the kit's `.elementor-kit-N button:hover` rules, never by
   forcing priority.
   ========================================================================== */

/* Make the Elementor shortcode widget around the gallery span the full column. */
.elementor-widget-shortcode:has(.stbhh-gallery),
.elementor-widget-shortcode:has(.stbhh-gallery) .elementor-widget-container,
.elementor-shortcode:has(.stbhh-gallery) {
	width: 100%;
}

.stbhh-gallery {
	--stbhh-gal-ink: var(--stbhh-set-ink, #40415E);
	--stbhh-gal-accent: #6C8AE4;
	--stbhh-gal-line: rgba(64, 65, 94, .10);

	position: relative;
	display: grid;
	grid-template-columns: 1fr;
	gap: 12px;
	box-sizing: border-box;
	width: 100%;
	margin: 0;
	padding: 0;
}

/* Main image */
.stbhh-gallery .stbhh-main-img {
	position: relative;
	display: block;
	box-sizing: border-box;
	width: 100%;
	aspect-ratio: 1 / 1;
	margin: 0;
	padding: 0;
	border-radius: var(--stbhh-set-gal-main-radius, 24px);
	overflow: hidden;
}

.stbhh-gallery .stbhh-main-img img {
	position: absolute;
	inset: 0;
	z-index: 1;
	display: block;
	box-sizing: border-box;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	object-fit: cover;
}

/* Thumbnail strip */
.stbhh-gallery .stbhh-thumbs {
	display: flex;
	flex-direction: row;
	scroll-behavior: smooth;
	gap: var(--stbhh-set-gal-thumb-gap, 9px);
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	margin: 0;
	padding: 0;
	list-style: none;
	overflow-x: auto;
	overflow-y: hidden;
	scrollbar-width: none;
	-ms-overflow-style: none;
}

.stbhh-gallery .stbhh-thumbs::-webkit-scrollbar {
	display: none;
}

body .stbhh-gallery .stbhh-thumb {
	flex-shrink: 0;
	box-sizing: border-box;
	width: var(--stbhh-set-gal-thumb-size, 80px);
	height: var(--stbhh-set-gal-thumb-size, 80px);
	margin: 0;
	padding: 0;
	border: 2px solid transparent;
	border-radius: var(--stbhh-set-gal-thumb-radius, 18px);
	background: none;
	font: inherit;
	line-height: 1;
	opacity: var(--stbhh-set-gal-thumb-opacity, .6);
	overflow: hidden;
	cursor: pointer;
	transition: border-color .14s, opacity .14s;
}

.stbhh-gallery .stbhh-thumb img {
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	border-radius: 0;
	object-fit: cover;
}

/* Thumbnail states. Mouse :focus looks exactly like rest (no "stuck" highlight
   after a click); keyboard focus gets its own ring through :focus-visible. */
body .stbhh-gallery .stbhh-thumb:hover,
body .stbhh-gallery .stbhh-thumb:focus,
body .stbhh-gallery .stbhh-thumb:active {
	border-style: solid;
	border-color: transparent;
	background: none;
	color: inherit;
	box-shadow: none;
	outline: none;
}

body .stbhh-gallery .stbhh-thumb:hover,
body .stbhh-gallery .stbhh-thumb:active {
	border-color: var(--stbhh-set-gal-thumb-active, var(--stbhh-gal-accent));
	opacity: 1;
}

/* Drawn INSIDE the thumbnail: the strip is overflow:hidden and exactly as
   tall as a thumbnail, so an outside ring would be clipped. */
body .stbhh-gallery .stbhh-thumb:focus-visible {
	outline: 2px solid var(--stbhh-gal-accent);
	outline-offset: -6px;
}

body .stbhh-gallery .stbhh-thumb.stbhh-active,
body .stbhh-gallery .stbhh-thumb.stbhh-active:hover,
body .stbhh-gallery .stbhh-thumb.stbhh-active:focus,
body .stbhh-gallery .stbhh-thumb.stbhh-active:active {
	border-style: solid;
	border-color: var(--stbhh-set-gal-thumb-active, var(--stbhh-gal-accent));
	background: none;
	box-shadow: inset 0 0 0 1px var(--stbhh-set-gal-thumb-active, var(--stbhh-gal-accent));
	opacity: 1;
}

/* Previous / next arrows */
body .stbhh-gallery .stbhh-gnav {
	position: absolute;
	top: 50%;
	z-index: 2;
	display: grid;
	place-items: center;
	box-sizing: border-box;
	width: var(--stbhh-set-gal-arrow-size, 38px);
	height: var(--stbhh-set-gal-arrow-size, 38px);
	margin: 0;
	padding: 0;
	border: 1.5px solid var(--stbhh-set-gal-arrow-border, var(--stbhh-gal-line));
	border-radius: 999px;
	background: var(--stbhh-set-gal-arrow-bg, rgba(255, 255, 255, .9));
	color: var(--stbhh-set-gal-arrow-color, var(--stbhh-gal-ink));
	font: inherit;
	line-height: 1;
	transform: translateY(-50%);
	cursor: pointer;
	transition: border-color .14s, color .14s;
}

.stbhh-gallery .stbhh-gnav svg {
	width: 18px;
	height: 18px;
}

/* Every state re-declares the rest look first; hover / pressed / keyboard
   focus then add the accent colour. */
body .stbhh-gallery .stbhh-gnav:hover,
body .stbhh-gallery .stbhh-gnav:focus,
body .stbhh-gallery .stbhh-gnav:active {
	border-style: solid;
	border-width: 1.5px;
	border-color: var(--stbhh-set-gal-arrow-border, var(--stbhh-gal-line));
	background: var(--stbhh-set-gal-arrow-bg, rgba(255, 255, 255, .9));
	color: var(--stbhh-set-gal-arrow-color, var(--stbhh-gal-ink));
	box-shadow: none;
	outline: none;
}

body .stbhh-gallery .stbhh-gnav:hover:not(:disabled),
body .stbhh-gallery .stbhh-gnav:active:not(:disabled),
body .stbhh-gallery .stbhh-gnav:focus-visible:not(:disabled) {
	border-color: var(--stbhh-set-gal-arrow-hover, var(--stbhh-gal-accent));
	color: var(--stbhh-set-gal-arrow-hover, var(--stbhh-gal-accent));
}

body .stbhh-gallery .stbhh-gnav:focus-visible {
	outline: 2px solid var(--stbhh-gal-accent);
	outline-offset: 2px;
}

body .stbhh-gallery .stbhh-gnav:disabled {
	opacity: .35;
	cursor: not-allowed;
}

.stbhh-gallery .stbhh-gnav--prev {
	left: 12px;
}

.stbhh-gallery .stbhh-gnav--next {
	right: 12px;
}

/* Loading state. Only added if the next image takes more than ~150 ms to
   arrive (see showImage() in product-gallery.js), so fast or cached switches
   never flash it. ::before is a white veil over the whole image, so the
   spinner stays visible on busy product images; it always exists at opacity 0
   so it can fade in and out. z-index 2 keeps it above the image (1) but under
   the arrows (2, later in the DOM), which stay clickable (pointer-events:none). */
.stbhh-gallery .stbhh-main-img::before {
	content: '';
	position: absolute;
	inset: 0;
	z-index: 2;
	background: var(--stbhh-set-gal-veil, rgba(255, 255, 255, .72));
	opacity: 0;
	transition: opacity .2s ease;
	pointer-events: none;
}

.stbhh-gallery .stbhh-main-img.stbhh-loading::before {
	opacity: 1;
}

.stbhh-gallery .stbhh-main-img.stbhh-loading::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	z-index: 3;
	box-sizing: border-box;
	width: 28px;
	height: 28px;
	margin: -14px 0 0 -14px;
	border: 2.5px solid var(--stbhh-set-gal-spinner-track, rgba(64, 65, 94, .15));
	border-top-color: var(--stbhh-set-gal-spinner, var(--stbhh-gal-accent));
	border-radius: 50%;
	animation: stbhh-gallery-spin .7s linear infinite;
	pointer-events: none;
}

@keyframes stbhh-gallery-spin {
	to {
		transform: rotate(360deg);
	}
}

/* Mobile: the thumbnails become dots. They have no border in any state. */
@media (max-width: 767px) {
	.stbhh-gallery .stbhh-thumbs {
		justify-content: center;
		gap: var(--stbhh-set-gal-dot-gap, 8px);
	}

	body .stbhh-gallery .stbhh-thumb {
		width: var(--stbhh-set-gal-dot-size, 8px);
		height: var(--stbhh-set-gal-dot-size, 8px);
		border: 0;
		border-radius: 999px;
		background: var(--stbhh-set-gal-dot, rgba(64, 65, 94, .10));
		transition: background-color .14s;
	}

	.stbhh-gallery .stbhh-thumb img {
		display: none;
	}

	body .stbhh-gallery .stbhh-thumb:hover,
	body .stbhh-gallery .stbhh-thumb:focus,
	body .stbhh-gallery .stbhh-thumb:active {
		border: 0;
		background: var(--stbhh-set-gal-dot, rgba(64, 65, 94, .10));
		box-shadow: none;
	}

	body .stbhh-gallery .stbhh-thumb:hover,
	body .stbhh-gallery .stbhh-thumb:active {
		background: var(--stbhh-set-gal-dot-hover, rgba(108, 138, 228, .5));
	}

	body .stbhh-gallery .stbhh-thumb.stbhh-active,
	body .stbhh-gallery .stbhh-thumb.stbhh-active:hover,
	body .stbhh-gallery .stbhh-thumb.stbhh-active:focus,
	body .stbhh-gallery .stbhh-thumb.stbhh-active:active {
		border: 0;
		background: var(--stbhh-set-gal-dot-active, var(--stbhh-gal-accent));
		box-shadow: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.stbhh-gallery .stbhh-thumbs {
		scroll-behavior: auto;
	}
}
