/* ==========================================================================
   VNS Before/After Slider
   ========================================================================== */

/* ── Wrapper ─────────────────────────────────────────────────────────────── */

.vns-wrap {
	position: relative;
}

/* ── Canvas: the full background area ───────────────────────────────────── */

.vns-canvas {
	position: relative;
	width: 100%;
	overflow: hidden;
	/* aspect-ratio set inline from the user-selected canvas ratio (default 16/9) */
}

/* ── Background layer ────────────────────────────────────────────────────── */

.vns-canvas__bg {
	position: absolute;
	inset: 0;
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
	pointer-events: none;
	transition: background-image 0.3s ease;
}

/* ── Stage: the image pair, centred in the canvas ────────────────────────── */
/*
 * Absolutely centred so the background shows around it.
 * width + aspect-ratio are set inline (scale % + image ratio from PHP).
 */
.vns-stage {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	overflow: hidden;
	cursor: ew-resize;
	user-select: none;
	-webkit-user-select: none;
	box-shadow: 0 4px 28px rgba(0, 0, 0, 0.25);
}

/* ── Before / After images ───────────────────────────────────────────────── */

.vns-after,
.vns-before {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;      /* cover = no transparent bars; for same-ratio images = no cropping */
	object-position: center;
	pointer-events: none;
	-webkit-user-drag: none;
	user-select: none;
}

/*
 * clip-path on a replaced element (<img>) is GPU-composited in all modern
 * browsers — no layout reflow on every drag frame.
 * will-change promotes it to its own compositor layer.
 */
.vns-before {
	z-index: 1;
	will-change: clip-path;
	/* clip-path: inset(0 X% 0 0) — set by JS */
}

/* ── Divider line ────────────────────────────────────────────────────────── */

.vns-divider {
	position: absolute;
	top: 0;
	bottom: 0;
	width: 2px;
	background: rgba(255, 255, 255, 0.85);
	z-index: 2;
	transform: translateX(-50%);
	cursor: ew-resize;
	/*
	 * touch-action: none tells the browser to hand ALL touch events to JS and
	 * not attempt any native scroll/pan gesture — the single most important
	 * property for lag-free touch drag.
	 */
	touch-action: none;
	outline: none;
	/* left set by JS */
}

.vns-divider:focus-visible {
	outline: 3px solid #0073aa;
	outline-offset: 3px;
}

/* ── Handle knob ─────────────────────────────────────────────────────────── */

.vns-divider__handle {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.92);
	border: 2px solid rgba(255, 255, 255, 0.92);
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 5px;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
	pointer-events: none;
	transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.vns-divider:active .vns-divider__handle {
	transform: translate(-50%, -50%) scale(1.1);
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.38);
}

/* ── Arrows inside handle ────────────────────────────────────────────────── */

.vns-arrow {
	display: block;
	width: 0;
	height: 0;
	flex-shrink: 0;
}

.vns-arrow--left {
	border-top: 6px solid transparent;
	border-bottom: 6px solid transparent;
	border-right: 8px solid #444;
}

.vns-arrow--right {
	border-top: 6px solid transparent;
	border-bottom: 6px solid transparent;
	border-left: 8px solid #444;
}

/* ── Labels ──────────────────────────────────────────────────────────────── */

.vns-label {
	position: absolute;
	bottom: 12px;
	z-index: 3;
	padding: 3px 10px;
	background: rgba(0, 0, 0, 0.45);
	color: #fff;
	font-size: 0.7rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	border-radius: 2px;
	pointer-events: none;
	user-select: none;
}

.vns-label--before { left: 12px; }
.vns-label--after  { right: 12px; }

/* ── Background selector controls ───────────────────────────────────────── */

.vns-controls {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding-top: 10px;
}

.vns-bg-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 12px;
	border: 2px solid transparent;
	border-radius: 4px;
	background: #f2f2f2;
	color: inherit;
	font-size: 0.85rem;
	line-height: 1.2;
	cursor: pointer;
	transition: border-color 0.15s ease, background 0.15s ease;
}

.vns-bg-btn:hover {
	background: #e5e5e5;
}

.vns-bg-btn--active {
	border-color: currentColor;
	background: #fff;
}

.vns-bg-btn__thumb {
	display: block;
	width: 32px;
	height: 32px;
	object-fit: cover;
	border-radius: 2px;
	flex-shrink: 0;
}

.vns-bg-btn__label {
	display: block;
}
