/**
 * ACB Product Gallery
 * Layout consumes CSS custom properties; the Elementor style controls set those
 * properties per instance (and responsively), so this file stays the single
 * source of truth for structure. Values below are the out-of-the-box defaults.
 *
 * Selectors are scoped under .acb-gallery (and a few use !important on resets)
 * specifically so theme / Elementor global *button* and *list* styling can't
 * leak into the thumbnail and navigation elements (that leak is what caused the
 * gold borders and the off-centre thumbnail row).
 */

.acb-gallery {
	/* Main image */
	--acb-main-aspect: 16 / 9;
	--acb-main-radius: 8px;
	--acb-main-fit: cover;
	--acb-main-bg: transparent;

	/* Thumbnails */
	--acb-thumb-cols: 4;
	--acb-thumb-gap: 14px;
	--acb-thumb-aspect: 4 / 3;
	--acb-thumb-radius: 8px;
	--acb-thumb-bg: #EDF0F6;
	--acb-inactive-opacity: 0.7;
	--acb-inactive-border-color: transparent;

	/* Sliding window: show up to N thumbnails (N = columns, capped at item count).
	   --acb-thumb-count is emitted per instance by PHP. */
	--acb-thumb-visible: min(var(--acb-thumb-cols), var(--acb-thumb-count, 4));
	--acb-thumb-itemw: calc((100% - (var(--acb-thumb-visible) - 1) * var(--acb-thumb-gap)) / var(--acb-thumb-visible));

	/* Active + focus */
	--acb-active-border-width: 2px;
	--acb-active-border-color: #4790CD;
	--acb-focus-color: #49678D;

	/* Video play button */
	--acb-play-bg: #4790CD;
	--acb-play-icon: #ffffff;
	--acb-play-size: 72px;

	/* Navigation (arrows + dots) */
	--acb-arrow-size: 44px;
	--acb-arrow-bg: rgba(73, 103, 141, 0.85);
	--acb-arrow-icon: #ffffff;
	--acb-dot-size: 10px;
	--acb-dot-color: #7E8CA3; /* ~3.4:1 on white — visible to low-vision users */
	--acb-dot-active: #4790CD;

	display: block;
}

/* Visually-hidden live region that announces the active item to screen readers. */
.acb-gallery .acb-gallery__live {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	border: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
}

/* ---- Main image ------------------------------------------------------- */
.acb-gallery .acb-gallery__main {
	position: relative;
	width: 100%;
	aspect-ratio: var(--acb-main-aspect);
	border-radius: var(--acb-main-radius);
	overflow: hidden;
	background: var(--acb-main-bg);
}

.acb-gallery .acb-gallery__main-img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: var(--acb-main-fit);
}

/* If an image optimiser wraps the main image in <picture>, the class above lands
   on the wrapper — keep the wrapper and its inner <img> filling the frame. */
.acb-gallery .acb-gallery__main picture {
	display: block;
	width: 100%;
	height: 100%;
}

.acb-gallery .acb-gallery__main img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: var(--acb-main-fit);
}

.acb-gallery.is-playing .acb-gallery__main-img {
	visibility: hidden;
}

/* Video player injected on play. */
.acb-gallery .acb-gallery__main iframe {
	position: absolute;
	inset: 0;
	z-index: 4;
	width: 100%;
	height: 100%;
	border: 0;
}

/* ---- Play button (overlays the whole main area = large, easy target) -- */
.acb-gallery .acb-gallery__play {
	position: absolute;
	inset: 0;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0 !important;
	border: 0 !important;
	background: transparent !important;
	box-shadow: none !important;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

/* Wins over the UA hidden { display:none } against our display:flex above. */
.acb-gallery .acb-gallery__play[hidden] {
	display: none;
}

.acb-gallery .acb-gallery__play-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: var(--acb-play-size);
	height: var(--acb-play-size);
	border-radius: 50%;
	background: var(--acb-play-bg);
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.acb-gallery .acb-gallery__play-icon::before {
	content: "";
	display: block;
	width: 0;
	height: 0;
	margin-left: 8%; /* optical centering of the triangle */
	border-style: solid;
	border-width: 0.18em 0 0.18em 0.3em;
	border-color: transparent transparent transparent var(--acb-play-icon);
	font-size: var(--acb-play-size); /* scales the triangle with the button */
}

.acb-gallery .acb-gallery__play:focus-visible {
	outline: 3px solid var(--acb-focus-color);
	outline-offset: -3px;
}

/* ---- Enlarge (lightbox) button ---------------------------------------- */
/* Sits in the top-right of the main image on image items; also a visual cue
   that the image can be enlarged. Hidden by JS on video items and where the
   lightbox can't open (e.g. "desktop only" mode on a phone). */
.acb-gallery .acb-gallery__expand {
	position: absolute;
	top: 10px;
	right: 10px;
	z-index: 3;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	margin: 0;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 50% !important;
	background: rgba(15, 23, 38, 0.5) !important;
	color: #ffffff;
	box-shadow: 0 1px 6px rgba(0, 0, 0, 0.25);
	cursor: zoom-in;
	-webkit-appearance: none;
	appearance: none;
}

.acb-gallery .acb-gallery__expand[hidden] {
	display: none;
}

.acb-gallery .acb-gallery__expand:hover {
	background: rgba(15, 23, 38, 0.7) !important;
}

.acb-gallery .acb-gallery__expand:focus-visible {
	outline: 3px solid var(--acb-focus-color);
	outline-offset: 2px;
}

.acb-gallery .acb-gallery__expand-icon {
	display: block;
	width: 22px;
	height: 22px;
	pointer-events: none;
}

/* Don't show the enlarge button over a playing video. */
.acb-gallery.is-playing .acb-gallery__expand {
	display: none;
}

/* Zoom cursor on the main image when it can be enlarged. */
.acb-gallery.is-zoomable .acb-gallery__main-img,
.acb-gallery.is-zoomable .acb-gallery__main img {
	cursor: zoom-in;
}

/* ---- Navigation arrows ------------------------------------------------ */
.acb-gallery .acb-gallery__arrow {
	position: absolute;
	top: 50%;
	z-index: 5;
	transform: translateY(-50%);
	display: flex;
	align-items: center;
	justify-content: center;
	width: var(--acb-arrow-size);
	height: var(--acb-arrow-size);
	margin: 0;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 50% !important;
	background: var(--acb-arrow-bg) !important;
	color: var(--acb-arrow-icon);
	box-shadow: 0 1px 6px rgba(0, 0, 0, 0.25);
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.acb-gallery .acb-gallery__arrow--prev {
	left: 10px;
}

.acb-gallery .acb-gallery__arrow--next {
	right: 10px;
}

.acb-gallery .acb-gallery__arrow:hover {
	opacity: 0.9;
}

.acb-gallery .acb-gallery__arrow:focus-visible {
	outline: 3px solid var(--acb-focus-color);
	outline-offset: 2px;
}

/* Don't overlay the arrows on top of a playing video. */
.acb-gallery.is-playing .acb-gallery__arrow {
	display: none;
}

.acb-gallery .acb-gallery__arrow-icon {
	display: block;
	width: 0.3em;
	height: 0.3em;
	border-right: 0.12em solid currentColor;
	border-bottom: 0.12em solid currentColor;
	font-size: var(--acb-arrow-size);
}

.acb-gallery .acb-gallery__arrow--prev .acb-gallery__arrow-icon {
	margin-left: 0.07em;
	transform: rotate(135deg);
}

.acb-gallery .acb-gallery__arrow--next .acb-gallery__arrow-icon {
	margin-right: 0.07em;
	transform: rotate(-45deg);
}

/* ---- Navigation dots -------------------------------------------------- */
.acb-gallery .acb-gallery__dots {
	list-style: none;
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 8px;
	width: 100%;
	margin: var(--acb-thumb-gap) 0 0;
	padding: 0;
	box-sizing: border-box;
}

.acb-gallery .acb-gallery__dot-item {
	margin: 0;
	padding: 0;
}

.acb-gallery .acb-gallery__dot {
	display: block;
	width: var(--acb-dot-size);
	height: var(--acb-dot-size);
	margin: 0;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 50% !important;
	background: var(--acb-dot-color) !important;
	box-shadow: none !important;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.acb-gallery .acb-gallery__dot.is-active {
	background: var(--acb-dot-active) !important;
}

.acb-gallery .acb-gallery__dot:focus-visible {
	outline: 3px solid var(--acb-focus-color);
	outline-offset: 2px;
}

/* ---- Thumbnail strip (windowed filmstrip) ----------------------------- */
/* The viewport clips to N thumbnails; the track holds them all and slides via
   --acb-thumb-start so the active thumbnail stays in view. Adding more images
   grows the dots, not the visible row. */
.acb-gallery .acb-gallery__thumbs-viewport {
	width: 100%;
	margin-top: var(--acb-thumb-gap);
	overflow: hidden;
}

.acb-gallery .acb-gallery__thumbs {
	list-style: none;
	display: flex;
	flex-wrap: nowrap;
	width: 100%;
	gap: var(--acb-thumb-gap);
	margin: 0;
	padding: 0;
	transform: translateX(calc(var(--acb-thumb-start, 0) * (var(--acb-thumb-itemw) + var(--acb-thumb-gap)) * -1));
}

.acb-gallery .acb-gallery__thumb-item {
	flex: 0 0 var(--acb-thumb-itemw);
	min-width: 0;
	margin: 0;
	padding: 0;
}

/* Button reset. !important on these few properties guarantees the image fills
   the rounded box and theme button chrome (the gold border/padding) is gone. */
.acb-gallery .acb-gallery__thumb {
	position: relative;
	display: block;
	width: 100%;
	margin: 0;
	padding: 0 !important;
	border: 0 !important;
	border-radius: var(--acb-thumb-radius);
	background: var(--acb-thumb-bg) !important;
	box-shadow: none !important;
	box-sizing: border-box;
	aspect-ratio: var(--acb-thumb-aspect);
	overflow: hidden;
	cursor: pointer;
	opacity: var(--acb-inactive-opacity);
	-webkit-appearance: none;
	appearance: none;
	font: inherit;
	color: inherit;
	-webkit-tap-highlight-color: transparent;
}

/* The image fills the whole box, edge to edge, clipped to the radius. */
.acb-gallery .acb-gallery__thumb img {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	padding: 0;
	object-fit: cover;
	border-radius: 0;
	pointer-events: none;
}

/* Selection ring drawn over the image edges (no layout shift, follows radius).
   Inactive colour defaults to transparent, so inactive thumbs sit flush. */
.acb-gallery .acb-gallery__thumb::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 2;
	border-radius: inherit;
	box-shadow: inset 0 0 0 var(--acb-active-border-width) var(--acb-inactive-border-color);
	pointer-events: none;
}

.acb-gallery .acb-gallery__thumb.is-active::after {
	box-shadow: inset 0 0 0 var(--acb-active-border-width) var(--acb-active-border-color);
}

.acb-gallery .acb-gallery__thumb:hover,
.acb-gallery .acb-gallery__thumb.is-active {
	opacity: 1;
}

/* Visible keyboard focus. Drawn on ::after (inside the element, above the image)
   so the filmstrip viewport's overflow:hidden can't clip it. The transparent
   outline keeps a focus indicator in Windows High Contrast / forced-colors mode.
   This rule follows .is-active::after so focus wins when a thumb is both. */
.acb-gallery .acb-gallery__thumb:focus-visible {
	opacity: 1;
	outline: 2px solid transparent;
	outline-offset: 2px;
}

.acb-gallery .acb-gallery__thumb:focus-visible::after {
	box-shadow: inset 0 0 0 3px var(--acb-focus-color);
}

/* Fallback for browsers that don't support :focus-visible. */
.acb-gallery .acb-gallery__thumb:focus {
	opacity: 1;
}

/* Play badge on video thumbnails. */
.acb-gallery .acb-gallery__thumb-badge {
	position: absolute;
	top: 50%;
	left: 50%;
	z-index: 3;
	transform: translate(-50%, -50%);
	display: flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	background: var(--acb-play-bg);
	box-shadow: 0 1px 5px rgba(0, 0, 0, 0.35);
	pointer-events: none;
}

.acb-gallery .acb-gallery__thumb-badge::before {
	content: "";
	width: 0;
	height: 0;
	margin-left: 3px;
	border-style: solid;
	border-width: 6px 0 6px 10px;
	border-color: transparent transparent transparent var(--acb-play-icon);
}

/* ---- Motion ----------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
	.acb-gallery .acb-gallery__main-img,
	.acb-gallery .acb-gallery__thumb {
		transition: opacity 0.2s ease;
	}

	.acb-gallery .acb-gallery__thumb::after {
		transition: box-shadow 0.15s ease;
	}

	.acb-gallery .acb-gallery__play-icon,
	.acb-gallery .acb-gallery__arrow {
		transition: transform 0.15s ease, opacity 0.15s ease;
	}

	.acb-gallery .acb-gallery__thumbs {
		transition: transform 0.25s ease;
	}

	.acb-gallery .acb-gallery__play:hover .acb-gallery__play-icon,
	.acb-gallery .acb-gallery__play:focus-visible .acb-gallery__play-icon {
		transform: scale(1.08);
	}

	/* Subtle dim while the next main image is preloaded, then it fades back in. */
	.acb-gallery.is-swapping .acb-gallery__main-img {
		opacity: 0.25;
	}
}

/* ---- Lightbox (click to enlarge) -------------------------------------- */
/* The overlay is moved to <body> by JS, so it is NOT nested under .acb-gallery.
   It gets its own root class and resets theme button chrome with !important,
   the same defensive approach used above for the in-gallery controls. */
.acb-gallery-lightbox {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: clamp(12px, 4vw, 48px);
	background: rgba(15, 23, 38, 0.92);
	box-sizing: border-box;
}

.acb-gallery-lightbox[hidden] {
	display: none;
}

.acb-gallery-lightbox * {
	box-sizing: border-box;
}

.acb-gallery-lightbox__backdrop {
	position: absolute;
	inset: 0;
	cursor: zoom-out;
}

.acb-gallery-lightbox__figure {
	position: relative;
	z-index: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	max-width: 100%;
	max-height: 100%;
	margin: 0;
	pointer-events: none; /* clicks fall through to the backdrop to close */
}

.acb-gallery-lightbox__img {
	display: block;
	width: auto;
	height: auto;
	max-width: 100%;
	max-height: 84vh;
	object-fit: contain;
	border-radius: 8px;
	background: #ffffff;
	box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
	pointer-events: auto;
}

.acb-gallery-lightbox__caption {
	max-width: 60ch;
	margin-top: 14px;
	color: #ffffff;
	font-size: 14px;
	line-height: 1.4;
	text-align: center;
}

.acb-gallery-lightbox__caption:empty {
	display: none;
}

/* Buttons: reset theme chrome, then style. Brand blue with white icons so they
   stay clearly visible whatever the enlarged image looks like behind them. */
.acb-gallery-lightbox button {
	position: absolute;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 50% !important;
	background: #4790CD !important;
	color: #ffffff;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35) !important;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.acb-gallery-lightbox button:hover {
	background: #3A7CB8 !important;
}

.acb-gallery-lightbox button:focus-visible {
	outline: 3px solid #8FC0EE;
	outline-offset: 2px;
}

.acb-gallery-lightbox button[hidden] {
	display: none;
}

.acb-gallery-lightbox__close {
	top: clamp(10px, 3vw, 24px);
	right: clamp(10px, 3vw, 24px);
	width: 46px;
	height: 46px;
}

.acb-gallery-lightbox__nav {
	top: 50%;
	transform: translateY(-50%);
	width: 52px;
	height: 52px;
}

.acb-gallery-lightbox__nav--prev {
	left: clamp(8px, 3vw, 28px);
}

.acb-gallery-lightbox__nav--next {
	right: clamp(8px, 3vw, 28px);
}

.acb-gallery-lightbox__nav--next svg {
	transform: scaleX(-1);
}

/* Lock background scroll while the lightbox is open. */
html.acb-lightbox-open,
html.acb-lightbox-open body {
	overflow: hidden;
}

@media (prefers-reduced-motion: no-preference) {
	.acb-gallery-lightbox:not([hidden]) {
		animation: acb-lightbox-fade 0.18s ease;
	}

	.acb-gallery-lightbox__img {
		transition: opacity 0.2s ease;
	}

	@keyframes acb-lightbox-fade {
		from { opacity: 0; }
		to   { opacity: 1; }
	}
}

/* On small screens give the arrows a little more room from the edges and shrink
   the controls slightly. */
@media (max-width: 560px) {
	.acb-gallery-lightbox__nav {
		width: 44px;
		height: 44px;
	}

	.acb-gallery-lightbox__img {
		max-height: 80vh;
	}
}
