/*
 * chbeck — image comparer (§6 #11). Loaded only on pages that use the pattern.
 * Without JS the two images simply stack (the .is-enhanced class is added by JS).
 */

.chbeck-comparer {
	max-width: 900px;
	margin-inline: auto;
}
.chbeck-comparer__img {
	margin: 0;
}
.chbeck-comparer__img img {
	display: block;
	width: 100%;
	height: auto;
}

/* Enhanced state: images overlap, divider drives the reveal. */
.chbeck-comparer.is-enhanced .chbeck-comparer__viewport {
	position: relative;
	overflow: hidden;
	border-radius: 6px;
	touch-action: pan-y;
	user-select: none;
}
.chbeck-comparer.is-enhanced .chbeck-comparer__img {
	position: absolute;
	inset: 0;
}
.chbeck-comparer.is-enhanced .chbeck-comparer__img img {
	height: 100%;
	object-fit: cover;
}
.chbeck-comparer.is-enhanced .chbeck-comparer__img--before {
	position: relative; /* defines the height of the viewport */
}
.chbeck-comparer.is-enhanced .chbeck-comparer__img--after {
	clip-path: inset(0 0 0 var(--chbeck-pos, 50%));
}

/* Divider + handle (the focusable slider). */
.chbeck-comparer__divider {
	position: absolute;
	top: 0;
	bottom: 0;
	left: var(--chbeck-pos, 50%);
	width: 2px;
	background: #ffffff;
	box-shadow: 0 0 0 1px rgba(16, 16, 16, 0.25);
	transform: translateX(-1px);
}
.chbeck-comparer__handle {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: #ffffff;
	border: 2px solid var(--wp--preset--color--accent);
	color: var(--wp--preset--color--accent);
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: ew-resize;
	box-shadow: 0 2px 8px rgba(16, 16, 16, 0.3);
	padding: 0;
}
.chbeck-comparer__handle:focus-visible {
	outline: 3px solid var(--wp--preset--color--accent);
	outline-offset: 3px;
}

/* Editable text labels on each side. These are ordinary authored paragraphs, not
   generated markup — the script only relocates them into the viewport. Without
   JS they stay in the flow under the images, so the overlay styling below is
   scoped to the enhanced state; unenhanced they read as plain captions. */
.chbeck-comparer__caption {
	margin: 0.25rem 0 0;
	font-size: 0.8rem;
	color: var(--wp--preset--color--muted);
}
.chbeck-comparer.is-enhanced .chbeck-comparer__caption {
	position: absolute;
	bottom: 0.75rem;
	margin: 0;
	padding: 0.25rem 0.6rem;
	background: rgba(16, 16, 16, 0.7);
	color: #ffffff;
	border-radius: 3px;
	pointer-events: none;
}
.chbeck-comparer.is-enhanced .chbeck-comparer__caption--before { left: 0.75rem; }
.chbeck-comparer.is-enhanced .chbeck-comparer__caption--after { right: 0.75rem; }
