/* AG Before After */

.ag-ba {
	position: relative;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	background: var(--ag-stone);
	touch-action: pan-y;
	user-select: none;
	-webkit-user-select: none;
}

@media (max-width: 640px) {
	.ag-ba {
		aspect-ratio: 4 / 3;
	}
}

.ag-ba__layer {
	position: absolute;
	inset: 0;
}

/* The "before" photo sits on top and is clipped to the left of the handle. */
.ag-ba__layer--before {
	clip-path: inset(0 calc(100% - var(--ag-ba-pos, 50%)) 0 0);
}

.ag-ba__img,
.ag-ba .ag-placeholder {
	position: absolute;
	inset: 0;
	display: flex;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
}

.ag-ba__tag {
	position: absolute;
	bottom: 16px;
	z-index: 1;
	padding: 6px 12px;
	background: rgba(30, 29, 27, 0.82);
	color: var(--ag-ivory);
	font-size: 0.6875rem;
	font-weight: 600;
	letter-spacing: 0.16em;
	line-height: 1.4;
	text-transform: uppercase;
}

.ag-ba__tag--before {
	left: 16px;
}

.ag-ba__tag--after {
	right: 16px;
}

.ag-ba__handle {
	position: absolute;
	top: 0;
	bottom: 0;
	left: var(--ag-ba-pos, 50%);
	z-index: 2;
	width: 1.5px;
	margin-left: -0.75px;
	background: var(--ag-ivory);
	pointer-events: none;
}

.ag-ba__grip {
	position: absolute;
	top: 50%;
	left: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 2px;
	width: 52px;
	height: 52px;
	border-radius: 50%;
	background: var(--ag-ivory);
	box-shadow: 0 6px 20px rgba(30, 29, 27, 0.3);
	color: var(--ag-charcoal);
	transform: translate(-50%, -50%);
	transition: transform var(--ag-speed, 0.3s) var(--ag-ease, ease), background-color var(--ag-speed, 0.3s) var(--ag-ease, ease);
}

/* The real control: an invisible range input stretched over the whole image. */
.ag-ba__range {
	position: absolute;
	inset: 0;
	z-index: 3;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	cursor: ew-resize;
	opacity: 0;
	-webkit-appearance: none;
	appearance: none;
}

.ag-ba__range::-webkit-slider-thumb {
	width: 52px;
	height: 100vh;
	-webkit-appearance: none;
	appearance: none;
}

.ag-ba__range::-moz-range-thumb {
	width: 52px;
	height: 100vh;
	border: 0;
}

.ag-ba:hover .ag-ba__grip {
	transform: translate(-50%, -50%) scale(1.06);
}

/* Visible focus on the handle when the range input has keyboard focus. */
.ag-ba:has(.ag-ba__range:focus-visible) .ag-ba__grip {
	background: var(--ag-brass);
	outline: 2px solid var(--ag-charcoal);
	outline-offset: 3px;
}

.ag-ba:has(.ag-ba__range:focus-visible) {
	outline: 2px solid var(--ag-brass-text);
	outline-offset: 4px;
}
