/* SDB Before & After comparison slider. */

.sdb-ba {
	--ba-pos: 50%;
	position: relative;
	width: 100%;
	max-width: 100%;
}

.sdb-ba__frame {
	position: relative;
	overflow: hidden;
	aspect-ratio: var(--ba-ratio, 4 / 3);
	touch-action: pan-y; /* horizontal drags move the slider, vertical still scrolls the page */
	cursor: ew-resize;
	user-select: none;
	-webkit-user-select: none;
}

.sdb-ba__frame img.sdb-ba__img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
	pointer-events: none;
	-webkit-user-drag: none;
}

/* The after photo is clipped by a wrapper (not the img itself) so the
   alignment transform on the img doesn't move the clip edge. */
.sdb-ba__after {
	position: absolute;
	inset: 0;
	clip-path: inset(0 0 0 var(--ba-pos));
	transition: clip-path 0.35s ease;
}

.sdb-ba__after img.sdb-ba__img--after {
	transform: translate(var(--ba-x, 0%), var(--ba-y, 0%)) scale(var(--ba-scale, 1));
	transform-origin: center center;
}

.sdb-ba__divider {
	position: absolute;
	top: 0;
	bottom: 0;
	left: var(--ba-pos);
	width: var(--ba-line-w, 2px);
	transform: translateX(-50%);
	background: var(--ba-line-color, #fff);
	box-shadow: 0 0 6px rgba(0, 0, 0, 0.35);
	transition: left 0.35s ease;
	z-index: 3;
}

/* No easing while the user is actively moving it — 1:1 tracking. */
.sdb-ba.is-dragging .sdb-ba__after,
.sdb-ba.is-hovering .sdb-ba__after,
.sdb-ba.is-dragging .sdb-ba__divider,
.sdb-ba.is-hovering .sdb-ba__divider {
	transition: none;
}

.sdb-ba__handle {
	position: absolute;
	top: 50%;
	left: 50%;
	width: var(--ba-handle-size, 44px);
	height: var(--ba-handle-size, 44px);
	transform: translate(-50%, -50%);
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: var(--ba-handle-bg, #fff);
	color: var(--ba-icon-color, #333);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
	cursor: ew-resize;
}

.sdb-ba__handle svg {
	width: 60%;
	height: 60%;
	display: block;
}

.sdb-ba__handle:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.sdb-ba__label {
	position: absolute;
	top: 12px;
	padding: 4px 10px;
	border-radius: 4px;
	background: rgba(0, 0, 0, 0.55);
	color: #fff;
	font-size: 14px;
	line-height: 1.4;
	pointer-events: none;
	z-index: 2;
}

.sdb-ba__label--before {
	left: 12px;
}

.sdb-ba__label--after {
	right: 12px;
}
