/**
 * Before After Image Comparison for Elementor
 * All selectors are class-based and scoped to .bai to avoid theme/plugin conflicts.
 */

.bai {
	--bai-pos: 50%;
	--bai-fit: cover;
	--bai-before-pos: center center;
	--bai-after-pos: center center;
	--bai-divider-color: #ffffff;
	--bai-divider-width: 2px;
	--bai-divider-opacity: 1;
	--bai-handle-size: 44px;
	--bai-handle-hover-scale: 1;
	--bai-icon-w: 18px;
	--bai-icon-h: 18px;
	--bai-ease: cubic-bezier(0.22, 0.61, 0.36, 1);

	position: relative;
	display: block;
	width: 100%;
	max-width: 100%;
	height: 500px;
	margin: 0;
	padding: 0;
	overflow: hidden;
	border-radius: 16px;
	box-sizing: border-box;
	isolation: isolate;
	-webkit-user-select: none;
	user-select: none;
	-webkit-touch-callout: none;
	-webkit-tap-highlight-color: transparent;
	touch-action: pan-y; /* Allow vertical page scroll, capture horizontal drags. */
	cursor: ew-resize;
}

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

.bai--vertical {
	touch-action: pan-x;
	cursor: ns-resize;
}

.bai--static {
	touch-action: auto;
	cursor: default;
}

/* ---------- Images (both fixed, full size; only the clip moves) ---------- */

.bai .bai__img {
	position: absolute;
	top: 0;
	left: 0;
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	object-fit: var(--bai-fit);
	pointer-events: none;
	-webkit-user-drag: none;
	user-select: none;
}

.bai .bai__img--after {
	z-index: 1;
	object-position: var(--bai-after-pos);
}

.bai .bai__img--before {
	z-index: 2;
	object-position: var(--bai-before-pos);
	-webkit-clip-path: inset(0 calc(100% - var(--bai-pos)) 0 0);
	clip-path: inset(0 calc(100% - var(--bai-pos)) 0 0);
}

.bai--vertical .bai__img--before {
	-webkit-clip-path: inset(0 0 calc(100% - var(--bai-pos)) 0);
	clip-path: inset(0 0 calc(100% - var(--bai-pos)) 0);
}

/* ---------- Divider layer (GPU translated, no layout work while dragging) ---------- */

.bai .bai__divider {
	position: absolute;
	top: 0;
	left: 0;
	z-index: 3;
	width: 100%;
	height: 100%;
	pointer-events: none;
	transform: translate3d(var(--bai-pos), 0, 0);
	will-change: transform;
}

.bai--vertical .bai__divider {
	transform: translate3d(0, var(--bai-pos), 0);
}

.bai .bai__line {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	width: var(--bai-divider-width);
	background-color: var(--bai-divider-color);
	opacity: var(--bai-divider-opacity);
	transform: translateX(-50%);
}

.bai--vertical .bai__line {
	top: 0;
	right: 0;
	bottom: auto;
	left: 0;
	width: 100%;
	height: var(--bai-divider-width);
	transform: translateY(-50%);
}

/* ---------- Handle ---------- */

.bai .bai__handle {
	position: absolute;
	top: 50%;
	left: 0;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	width: var(--bai-handle-size);
	height: var(--bai-handle-size);
	margin: 0;
	padding: 0;
	border: 0 solid transparent;
	border-radius: 50%;
	background-color: #ffffff;
	color: #1f1f1f;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.16);
	line-height: 0;
	pointer-events: auto;
	cursor: ew-resize;
	outline: none;
	transform: translate(-50%, -50%);
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s var(--bai-ease);
}

.bai--vertical .bai__handle {
	top: 0;
	left: 50%;
	cursor: ns-resize;
}

.bai .bai__handle:hover,
.bai.is-dragging .bai__handle {
	transform: translate(-50%, -50%) scale(var(--bai-handle-hover-scale));
}

.bai .bai__handle:focus-visible {
	outline: 2px solid #ffffff;
	outline-offset: 3px;
	box-shadow: 0 0 0 5px rgba(0, 0, 0, 0.35);
}

.bai--static .bai__handle,
.bai--static .bai__handle:hover {
	cursor: default;
	transform: translate(-50%, -50%);
}

.bai .bai__handle-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: var(--bai-icon-w);
	height: var(--bai-icon-h);
	pointer-events: none;
}

.bai .bai__handle-icon svg {
	display: block;
	width: 100%;
	height: 100%;
	max-width: 100%;
	max-height: 100%;
	overflow: visible;
}

.bai--vertical .bai__icon-default {
	transform: rotate(90deg);
}

/* ---------- Labels ---------- */

.bai .bai__label {
	--bai-label-x: 28px;
	--bai-label-y: 28px;

	position: absolute;
	bottom: var(--bai-label-y);
	z-index: 4;
	display: inline-block;
	margin: 0;
	padding: 6px 13px;
	border-radius: 10px;
	background-color: #ffffff;
	color: #1f1f1f;
	font-size: 12px;
	font-weight: 600;
	line-height: 1.4;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	white-space: nowrap;
	pointer-events: none;
}

.bai .bai__label--before {
	left: var(--bai-label-x);
}

.bai .bai__label--after {
	right: var(--bai-label-x);
}

.bai--vertical .bai__label--before {
	top: var(--bai-label-y);
	bottom: auto;
	left: var(--bai-label-x);
}

.bai--vertical .bai__label--after {
	right: auto;
	bottom: var(--bai-label-y);
	left: var(--bai-label-x);
}

/* ---------- Animated jumps (click / keyboard), never during drag ---------- */

.bai.is-animating .bai__divider {
	transition: transform 0.35s var(--bai-ease);
}

.bai.is-animating .bai__img--before {
	transition: clip-path 0.35s var(--bai-ease), -webkit-clip-path 0.35s var(--bai-ease);
}

/* ---------- Mobile defaults (Elementor responsive controls override these) ---------- */

@media (max-width: 767px) {
	.bai .bai__label {
		padding: 5px 11px;
		font-size: 11px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.bai .bai__handle,
	.bai.is-animating .bai__divider,
	.bai.is-animating .bai__img--before {
		transition: none;
	}
}
