.sacf-gallery {
	--sacf-gallery-ratio: 3 / 2;
	--sacf-gallery-thumb-ratio: 3 / 2;
	--sacf-gallery-thumbs-visible: 5;
	--sacf-gallery-thumb-rows: 2;
	/* 0 = exact fit (wrapping grid), >0 = sliver of the next item (scroll rail). */
	--sacf-gallery-thumb-peek: 0;
	--sacf-gallery-arrow-size: 48px;
	--sacf-gallery-arrow-glyph: 30px;
	--sacf-gallery-arrow-color: #fff;
	--sacf-gallery-arrow-bg: transparent;
	--sacf-gallery-arrow-offset: 8px;
	--sacf-gallery-thumb-border: #7c5ce6;
	--sacf-gallery-thumb-gap: 8px;
	--sacf-gallery-counter-bg: rgba(0, 0, 0, 0.55);
	--sacf-gallery-counter-color: #fff;
	position: relative;
	width: 100%;
}

.sacf-gallery *,
.sacf-gallery *::before,
.sacf-gallery *::after {
	box-sizing: border-box;
}

.sacf-gallery--empty {
	padding: 24px;
	border: 1px dashed #c3c4c7;
	color: #646970;
	text-align: center;
}

.sacf-gallery__main {
	position: relative;
}

.sacf-gallery__stage {
	position: relative;
	overflow: hidden;
	aspect-ratio: var(--sacf-gallery-ratio);
	background: #f6f7f7;
	/* Allow vertical page scrolling while horizontal swipes drive the slider. */
	touch-action: pan-y;
}

.sacf-gallery__slide {
	position: absolute;
	inset: 0;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.25s ease;
}

.sacf-gallery__slide.is-active {
	opacity: 1;
	visibility: visible;
}

.sacf-gallery__link {
	display: block;
	width: 100%;
	height: 100%;
	line-height: 0;
	-webkit-tap-highlight-color: transparent;
}

/* Outranks the `.elementor img { height: auto }` reset so the crop survives. */
.sacf-gallery .sacf-gallery__link img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
	object-position: center;
	-webkit-user-drag: none;
	user-select: none;
}

/* Doubled class keeps theme rules such as `.elementor button` from winning. */
.sacf-gallery .sacf-gallery__nav {
	position: absolute;
	top: 50%;
	/* Above a loaded VR iframe (z-index 3) so users can still change slides. */
	z-index: 4;
	display: flex;
	align-items: center;
	justify-content: center;
	width: var(--sacf-gallery-arrow-size);
	height: var(--sacf-gallery-arrow-size);
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--sacf-gallery-arrow-bg);
	color: var(--sacf-gallery-arrow-color);
	line-height: 1;
	cursor: pointer;
	transform: translateY(-50%);
	transition: opacity 0.2s ease, background-color 0.2s ease;
	-webkit-tap-highlight-color: transparent;
}

.sacf-gallery__nav svg {
	width: var(--sacf-gallery-arrow-glyph);
	height: var(--sacf-gallery-arrow-glyph);
	/* Keeps the light chevron readable on top of bright photos. */
	filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.45));
	pointer-events: none;
}

.sacf-gallery__nav:hover,
.sacf-gallery__nav:focus-visible {
	opacity: 0.75;
	outline: none;
}

.sacf-gallery__nav--prev {
	left: var(--sacf-gallery-arrow-offset);
}

.sacf-gallery__nav--next {
	right: var(--sacf-gallery-arrow-offset);
}

.sacf-gallery__vr {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	background: #17181c;
	background-image: radial-gradient( circle at 50% 45%, #2b2d34 0%, #14151a 70% );
}

.sacf-gallery__vr-poster {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: center;
}

/* Dims the poster so the launch button stays legible. */
.sacf-gallery__vr::before {
	content: '';
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.3);
	pointer-events: none;
}

.sacf-gallery .sacf-gallery__vr-launch {
	position: relative;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	padding: 12px 20px;
	border: 0;
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.6);
	color: #fff;
	font-size: 15px;
	line-height: 1.2;
	cursor: pointer;
	transition: background-color 0.2s ease;
	-webkit-tap-highlight-color: transparent;
}

.sacf-gallery__vr-launch:hover,
.sacf-gallery__vr-launch:focus-visible {
	background: rgba(0, 0, 0, 0.8);
	outline: none;
}

.sacf-gallery__vr-launch svg {
	width: 22px;
	height: 22px;
	flex: 0 0 auto;
}

.sacf-gallery__vr-frame {
	position: absolute;
	inset: 0;
	z-index: 3;
	width: 100%;
	height: 100%;
	border: 0;
	display: block;
}

.sacf-gallery__vr.is-loaded .sacf-gallery__vr-launch,
.sacf-gallery__vr.is-loaded::before {
	display: none;
}

.sacf-gallery__thumb--vr {
	position: relative;
}

.sacf-gallery__thumb-image--vr {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	color: #fff;
	background: #17181c;
	background-image: radial-gradient( circle at 50% 45%, #2b2d34 0%, #14151a 70% );
}

.sacf-gallery__thumb-image--vr svg {
	width: 42%;
	height: 42%;
}

.sacf-gallery__thumb-badge {
	position: absolute;
	top: 4px;
	right: 4px;
	z-index: 2;
	padding: 1px 6px;
	border-radius: 4px;
	background: rgba(0, 0, 0, 0.68);
	color: #fff;
	font-size: 10px;
	line-height: 1.6;
	font-weight: 600;
	letter-spacing: 0.02em;
	pointer-events: none;
}

.sacf-gallery__counter {
	position: absolute;
	right: 12px;
	bottom: 12px;
	z-index: 4;
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 6px 12px;
	border-radius: 999px;
	background: var(--sacf-gallery-counter-bg);
	color: var(--sacf-gallery-counter-color);
	font-size: 14px;
	line-height: 1.2;
	font-variant-numeric: tabular-nums;
	pointer-events: none;
}

.sacf-gallery__counter svg {
	width: 18px;
	height: 18px;
	flex: 0 0 auto;
}

/*
 * Desktop: wrapping grid. The visible height is capped to
 * --sacf-gallery-thumb-rows by the script, which measures a real thumbnail
 * because the row height depends on the fluid column width.
 */
.sacf-gallery__thumbnails {
	/* Also makes this the offset parent the script measures thumbnails against. */
	position: relative;
	display: flex;
	flex-wrap: wrap;
	align-content: flex-start;
	gap: var(--sacf-gallery-thumb-gap);
	margin-top: 12px;
	overflow-x: hidden;
	overflow-y: auto;
	scroll-behavior: smooth;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: thin;
	scrollbar-color: rgba(0, 0, 0, 0.25) transparent;
}

.sacf-gallery__thumbnails::-webkit-scrollbar {
	width: 6px;
	height: 6px;
}

.sacf-gallery__thumbnails::-webkit-scrollbar-track {
	background: transparent;
}

.sacf-gallery__thumbnails::-webkit-scrollbar-thumb {
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.25);
}

.sacf-gallery .sacf-gallery__thumb {
	/*
	 * peek 0 gives an exact N-per-row fit; a positive peek shrinks the items so a
	 * sliver of the next one shows. The 0.5px slack stops sub-pixel rounding from
	 * wrapping the last column onto its own row.
	 */
	flex: 0 0 calc(
		(
				100% - var(--sacf-gallery-thumb-gap) *
					(var(--sacf-gallery-thumbs-visible) - 1 + var(--sacf-gallery-thumb-peek)) - 0.5px
			) / (var(--sacf-gallery-thumbs-visible) + var(--sacf-gallery-thumb-peek))
	);
	aspect-ratio: var(--sacf-gallery-thumb-ratio);
	scroll-snap-align: start;
	display: block;
	margin: 0;
	padding: 0;
	overflow: hidden;
	border: 2px solid transparent;
	border-radius: 2px;
	background: #f6f7f7;
	cursor: pointer;
	transition: border-color 0.2s ease, opacity 0.2s ease;
	-webkit-tap-highlight-color: transparent;
}

.sacf-gallery__thumb:hover {
	opacity: 0.85;
}

.sacf-gallery__thumb.is-active {
	border-color: var(--sacf-gallery-thumb-border);
}

.sacf-gallery .sacf-gallery__thumb-image {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
	object-position: center;
}

/* When every thumbnail already fits, spread them instead of leaving a gap. */
.sacf-gallery--thumbs-fit .sacf-gallery__thumbnails {
	overflow-x: hidden;
}

.sacf-gallery--thumbs-fit .sacf-gallery__thumb {
	flex: 1 1 0;
}

.sacf-gallery--single .sacf-gallery__nav,
.sacf-gallery--single .sacf-gallery__counter {
	display: none;
}

@media (max-width: 767px) {
	.sacf-gallery {
		--sacf-gallery-ratio: 4 / 3;
		--sacf-gallery-thumb-ratio: 4 / 3;
		--sacf-gallery-thumbs-visible: 4;
		--sacf-gallery-thumb-peek: 0.3;
		--sacf-gallery-arrow-size: 44px;
		--sacf-gallery-arrow-glyph: 24px;
		--sacf-gallery-arrow-offset: 2px;
		--sacf-gallery-thumb-gap: 6px;
	}

	/* Back to a single horizontally-scrolling rail. */
	.sacf-gallery__thumbnails {
		flex-wrap: nowrap;
		overflow-x: auto;
		overflow-y: hidden;
		scroll-snap-type: x proximity;
		scrollbar-width: none;
		-ms-overflow-style: none;
	}

	.sacf-gallery__thumbnails::-webkit-scrollbar {
		display: none;
	}

	.sacf-gallery__counter {
		right: 8px;
		bottom: 8px;
		padding: 4px 10px;
		font-size: 12px;
	}

	.sacf-gallery__counter svg {
		width: 15px;
		height: 15px;
	}

	.sacf-gallery__thumbnails {
		margin-top: 8px;
	}
}
