/* Before After Carousel */
.bac-carousel {
	--bac-accent: #d22b2b;
	--bac-gap: 20px;
	--bac-ratio: 3 / 4;
	--bac-per-view: var(--bac-desktop, 3);
	position: relative;
	width: 100%;
	box-sizing: border-box;
}

.bac-carousel *,
.bac-carousel *::before,
.bac-carousel *::after {
	box-sizing: border-box;
}

/* Tablet: 2 slides */
@media (max-width: 1024px) {
	.bac-carousel {
		--bac-per-view: var(--bac-tablet, 2);
		--bac-gap: 16px;
	}
}

/* Mobile: 1 slide */
@media (max-width: 767px) {
	.bac-carousel {
		--bac-per-view: var(--bac-mobile, 1);
	}
}

.bac-viewport {
	position: relative;
}

.bac-track {
	display: flex;
	gap: var(--bac-gap);
	overflow-x: auto;
	overflow-y: hidden;
	direction: ltr;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
	margin: 0;
	padding: 0;
}

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

.bac-slide {
	flex: 0 0 calc((100% - (var(--bac-per-view) - 1) * var(--bac-gap)) / var(--bac-per-view));
	min-width: 0;
	scroll-snap-align: start;
}

.bac-card {
	height: 100%;
	background: #141414;
	border-radius: 12px;
	overflow: hidden;
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

/* Before + After side by side */
.bac-pair {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 2px;
	background: var(--bac-accent);
}

/* Fixed-size image box: the box keeps the same size whatever the image dimensions */
.bac-carousel .bac-img {
	position: relative;
	margin: 0;
	padding: 0;
	width: 100%;
	aspect-ratio: var(--bac-ratio);
	overflow: hidden;
	background: #222;
}

.bac-carousel .bac-img img {
	position: absolute;
	top: 0;
	left: 0;
	width: 100% !important;
	height: 100% !important;
	max-width: none !important;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 0 !important;
	object-fit: cover;
	object-position: center top;
	display: block;
}

/* Fallback for older browsers without aspect-ratio support */
@supports not (aspect-ratio: 1 / 1) {
	.bac-carousel .bac-img {
		height: 0;
		padding-top: 133.33%;
	}
}

/* Small labels */
.bac-label {
	position: absolute;
	top: 8px;
	left: 8px;
	z-index: 2;
	padding: 3px 9px;
	border-radius: 999px;
	font-size: 11px;
	font-weight: 700;
	line-height: 1.4;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: #fff;
	pointer-events: none;
}

.bac-label--before {
	background: rgba(0, 0, 0, 0.75);
}

.bac-label--after {
	background: var(--bac-accent);
}

.bac-title {
	padding: 12px 14px;
	color: #fff;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.3;
	text-align: center;
	border-top: 2px solid var(--bac-accent);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Arrows */
.bac-carousel .bac-nav {
	position: absolute;
	top: 50%;
	z-index: 3;
	width: 40px;
	height: 40px;
	min-width: 0;
	padding: 0;
	margin: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 0;
	border-radius: 50%;
	background: var(--bac-accent);
	color: #fff;
	cursor: pointer;
	transform: translateY(-50%);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
	transition: transform 0.2s ease, opacity 0.2s ease;
}

.bac-carousel .bac-nav:hover,
.bac-carousel .bac-nav:focus-visible {
	background: var(--bac-accent);
	color: #fff;
	transform: translateY(-50%) scale(1.08);
}

.bac-carousel .bac-nav:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

.bac-prev {
	left: -12px;
}

.bac-next {
	right: -12px;
}

@media (max-width: 767px) {
	.bac-prev {
		left: 6px;
	}

	.bac-next {
		right: 6px;
	}

	.bac-carousel .bac-nav {
		width: 34px;
		height: 34px;
	}
}

/* Dots */
.bac-dots {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 8px;
	margin-top: 16px;
}

.bac-carousel .bac-dot {
	width: 10px;
	height: 10px;
	min-width: 0;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 50%;
	background: #c9c9c9;
	cursor: pointer;
	transition: background 0.2s ease, width 0.2s ease;
}

.bac-carousel .bac-dot.is-active {
	width: 24px;
	border-radius: 999px;
	background: var(--bac-accent);
}

/* When all slides fit in a single view */
.bac-carousel.bac-static .bac-nav,
.bac-carousel.bac-static .bac-dots {
	display: none;
}

@media (prefers-reduced-motion: reduce) {
	.bac-track {
		scroll-behavior: auto;
	}
}
