/*
 * Image compare: the two images share one grid cell; the second is clipped from the divider on (clip-path reads
 * --rt-image-compare-position, which image-compare.js moves). The box is the first image's size, or an aspect ratio
 * (both images then cover it). The handle and the labels take the text colour; the range covers the box for the
 * keyboard and screen readers only, the pointer goes to the box. The original theme: rtthemes/image-compare with its own
 * original-theme-only CSS; colours, type, ratio and radius are the block's settings.
 */
.rt-image-compare {
	position: relative;
	display: grid;
	grid-template: 100% / 100%;
	overflow: hidden;
	isolation: isolate;
	user-select: none;
	touch-action: pan-y;
	cursor: ew-resize;
}

:where(.rt-image-compare) {
	color: var(--rt-color-on-image);
	font-size: var(--rt-font-size-small);
	line-height: 1.4;
}

.rt-image-compare--vertical {
	touch-action: pan-x;
	cursor: ns-resize;
}

.rt-image-compare__image {
	grid-area: 1 / 1;
	margin: 0;
}

.rt-image-compare__image img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	-webkit-user-drag: none;
}

.rt-image-compare__image ~ .rt-image-compare__image {
	clip-path: inset(0 0 0 var(--rt-image-compare-position, 50%));
}

.rt-image-compare--vertical > .rt-image-compare__image ~ .rt-image-compare__image {
	clip-path: inset(var(--rt-image-compare-position, 50%) 0 0 0);
}

.rt-image-compare__label {
	position: absolute;
	z-index: 1;
	top: 1rem;
	left: 1rem;
	padding: 0.25em 0.75em;
	background-color: rgb(0 0 0 / 45%);
	pointer-events: none;
}

.rt-image-compare__label[data-side="after"] {
	left: auto;
	right: 1rem;
}

.rt-image-compare--vertical > .rt-image-compare__label[data-side="after"] {
	top: auto;
	bottom: 1rem;
	left: 1rem;
	right: auto;
}

.rt-image-compare__range {
	position: absolute;
	z-index: 2;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	opacity: 0;
	direction: ltr;
	pointer-events: none;
}

.rt-image-compare--vertical > .rt-image-compare__range {
	writing-mode: vertical-lr;
}

.rt-image-compare__handle {
	position: absolute;
	z-index: 3;
	top: 50%;
	left: var(--rt-image-compare-position, 50%);
	box-sizing: border-box;
	width: 2.75rem;
	height: 2.75rem;
	border: 2px solid;
	border-radius: 50%;
	background-color: rgb(0 0 0 / 30%);
	translate: -50% -50%;
	pointer-events: none;
}

.rt-image-compare--vertical > .rt-image-compare__handle {
	top: var(--rt-image-compare-position, 50%);
	left: 50%;
}

.rt-image-compare__handle::before,
.rt-image-compare__handle::after {
	content: "";
	position: absolute;
	background-color: currentColor;
}

.rt-image-compare__handle::before {
	left: 50%;
	width: 2px;
	top: 100%;
	height: 200vmax;
	translate: -50% 0;
	box-shadow: 0 calc(-200vmax - 2.75rem) 0 currentColor;
}

.rt-image-compare--vertical > .rt-image-compare__handle::before {
	top: 50%;
	left: 100%;
	width: 200vmax;
	height: 2px;
	translate: 0 -50%;
	box-shadow: calc(-200vmax - 2.75rem) 0 0 currentColor;
}

.rt-image-compare__handle::after {
	inset: 0;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 7-5 5 5 5M15 7l5 5-5 5'/%3E%3C/svg%3E") center / 60% no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 7-5 5 5 5M15 7l5 5-5 5'/%3E%3C/svg%3E") center / 60% no-repeat;
}

.rt-image-compare--vertical > .rt-image-compare__handle::after {
	rotate: 90deg;
}

.rt-image-compare:has(> .rt-image-compare__range:focus-visible) > .rt-image-compare__handle {
	outline: 2px solid;
	outline-offset: 3px;
}
