/* Custom Product Gallery. Colours and sizes come from the settings page as CSS variables. */

.cpg,
.cpg *,
.cpg-lightbox,
.cpg-lightbox * {
	box-sizing: border-box;
}

.cpg {
	position: relative;
	width: 100%;
}

.cpg-stage {
	position: relative;
}

/* ---- Slider ---- */

.cpg-track {
	display: flex;
	margin: 0;
	padding: 0;
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	overscroll-behavior-x: contain;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
}

.cpg-track::-webkit-scrollbar {
	display: none;
}

.cpg-track:focus-visible {
	outline: 2px solid var(--cpg-arrow);
	outline-offset: 2px;
}

.cpg-slide {
	flex: 0 0 100%;
	min-width: 0;
	aspect-ratio: 1 / 1;
	overflow: hidden;
	background: var(--cpg-bg);
	scroll-snap-align: start;
	scroll-snap-stop: always;
}

.cpg .cpg-link {
	display: block;
	width: 100%;
	height: 100%;
	cursor: zoom-in;
}

/* Multiply turns the white baked into each photo into the background colour. */
.cpg .cpg-slide img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	object-fit: contain;
	mix-blend-mode: multiply;
}

/* ---- Brand logo, top right ---- */

.cpg-brand {
	position: absolute;
	top: var(--cpg-brand-offset);
	right: var(--cpg-brand-offset);
	z-index: 2;
	width: var(--cpg-brand-w);
	max-width: 40%;
	line-height: 0;
	mix-blend-mode: multiply;
}

.cpg .cpg-brand img {
	display: block;
	width: 100%;
	height: auto;
	margin: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
}

/* ---- Buttons (reset against theme and Elementor button styles) ---- */

.cpg .cpg-btn,
.cpg .cpg-btn:hover,
.cpg .cpg-btn:focus,
.cpg .cpg-btn:active,
.cpg-lightbox .cpg-btn,
.cpg-lightbox .cpg-btn:hover,
.cpg-lightbox .cpg-btn:focus,
.cpg-lightbox .cpg-btn:active {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	color: var(--cpg-arrow);
	font: inherit;
	line-height: 1;
	text-decoration: none;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	-webkit-tap-highlight-color: transparent;
}

.cpg .cpg-btn:focus-visible,
.cpg-lightbox .cpg-btn:focus-visible {
	outline: 2px solid var(--cpg-arrow);
	outline-offset: 2px;
}

.cpg .cpg-btn svg,
.cpg-lightbox .cpg-btn svg {
	display: block;
	width: 24px;
	height: 24px;
}

.cpg-flip {
	display: block;
	transform: scaleX(-1);
}

/* ---- View toggle, top left ---- */

.cpg-toolbar {
	position: absolute;
	top: 10px;
	left: 10px;
	z-index: 2;
	display: flex;
	gap: 6px;
}

.cpg .cpg-view,
.cpg .cpg-view:hover,
.cpg .cpg-view:focus,
.cpg .cpg-view:active {
	flex-direction: column;
	gap: 3px;
	min-width: 40px;
	padding: 2px;
	opacity: 0.35;
	transition: opacity 0.2s;
}

.cpg .cpg-view:hover,
.cpg .cpg-view[aria-pressed="true"] {
	opacity: 1;
}

.cpg .cpg-view svg {
	width: 30px;
	height: 30px;
}

.cpg-view-label {
	font-size: 8px;
	font-weight: 600;
	line-height: 1;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

/* ---- Dots, inside the image at bottom centre ---- */

.cpg-dots {
	position: absolute;
	left: 50%;
	bottom: 10px;
	z-index: 2;
	display: flex;
	align-items: center;
	transform: translateX(-50%);
}

.cpg .cpg-dot,
.cpg .cpg-dot:hover,
.cpg .cpg-dot:focus,
.cpg .cpg-dot:active {
	padding: 8px 3px;
}

.cpg .cpg-dot::before {
	content: "";
	display: block;
	width: 6px;
	height: 6px;
	border-radius: 3px;
	background: var(--cpg-dot);
	transition: width 0.25s ease, background-color 0.25s ease;
}

.cpg .cpg-dot.is-active::before {
	width: 20px;
	background: var(--cpg-dot-active);
}

/* ---- Arrows, below the image at bottom right ---- */

.cpg-footer {
	display: flex;
	justify-content: flex-end;
	margin-top: 8px;
}

.cpg-arrows {
	display: flex;
	gap: 8px;
}

.cpg .cpg-arrow {
	width: calc(var(--cpg-arrow-size) + 8px);
	height: calc(var(--cpg-arrow-size) + 8px);
	transition: opacity 0.2s;
}

.cpg .cpg-arrow:hover {
	opacity: 0.6;
}

.cpg .cpg-arrow svg,
.cpg-lightbox .cpg-lb-nav svg {
	width: var(--cpg-arrow-size);
	height: var(--cpg-arrow-size);
}

/* ---- Lightbox: a centred panel over a dimmed page ---- */

html.cpg-lock {
	overflow: hidden;
}

dialog.cpg-lightbox {
	position: fixed;
	inset: 0;
	width: min(92vw, 92vh, 1000px);
	height: min(92vw, 92vh, 1000px);
	max-width: none;
	max-height: none;
	margin: auto;
	padding: 0;
	border: 0;
	background: var(--cpg-bg);
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
	overflow: hidden;
}

dialog.cpg-lightbox::backdrop {
	background: rgba(0, 0, 0, 0.6);
}

.cpg-lb-stage {
	width: 100%;
	height: 100%;
}

.cpg-lightbox .cpg-lb-img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: contain;
	mix-blend-mode: multiply;
}

.cpg-lightbox .cpg-lb-close,
.cpg-lightbox .cpg-lb-nav {
	position: absolute;
	z-index: 2;
}

.cpg-lightbox .cpg-lb-close {
	top: 8px;
	right: 8px;
	width: 44px;
	height: 44px;
}

.cpg-lightbox .cpg-lb-nav {
	top: 50%;
	width: calc(var(--cpg-arrow-size) + 12px);
	height: calc(var(--cpg-arrow-size) + 12px);
	transform: translateY(-50%);
}

.cpg-lightbox .cpg-lb-prev {
	left: 8px;
}

.cpg-lightbox .cpg-lb-next {
	right: 8px;
}

.cpg-lb-count {
	position: absolute;
	bottom: 14px;
	left: 0;
	right: 0;
	color: var(--cpg-arrow);
	font-size: 13px;
	line-height: 1;
	text-align: center;
	pointer-events: none;
}

.cpg-lightbox[data-count="1"] .cpg-lb-nav,
.cpg-lightbox[data-count="1"] .cpg-lb-count {
	display: none;
}

@media (prefers-reduced-motion: reduce) {
	.cpg .cpg-dot::before,
	.cpg .cpg-view,
	.cpg .cpg-arrow {
		transition: none;
	}
}
