/* Before & After Slider */
.bas {
	--bas-pos: 50%;
	--bas-line: #fff;
	--bas-line-width: 3px;
	--bas-knob-size: 44px;
	--bas-knob-bg: #fff;
	--bas-knob-color: #222;
	--bas-label-bg: rgba(0, 0, 0, .55);
	--bas-label-color: #fff;
	--bas-radius: 0px;

	position: relative;
	display: block;
	width: 100%;
	max-width: 100%;
	overflow: hidden;
	line-height: 0;
	border-radius: var(--bas-radius);
	cursor: ew-resize;
	touch-action: pan-y;            /* vertikalni scroll na mobitelu i dalje radi */
	-webkit-user-select: none;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
	isolation: isolate;
	margin-block: 1.5em;
}

.bas[data-orientation="vertical"] {
	cursor: ns-resize;
	touch-action: pan-x;
}

.bas .bas__img {
	display: block;
	width: 100%;
	height: auto;
	max-width: none;
	margin: 0;
	pointer-events: none;
	-webkit-user-drag: none;
	user-select: none;
}

.bas__layer { position: relative; }

/* "Prije" sloj je iznad i odrezan na poziciju klizača */
.bas__before {
	position: absolute;
	inset: 0;
	clip-path: inset(0 calc(100% - var(--bas-pos)) 0 0);
	will-change: clip-path;
}
.bas[data-orientation="vertical"] .bas__before {
	clip-path: inset(0 0 calc(100% - var(--bas-pos)) 0);
}
.bas__before .bas__img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Linija + kružić */
.bas__handle {
	position: absolute;
	top: 0;
	bottom: 0;
	left: var(--bas-pos);
	width: var(--bas-line-width);
	margin-left: calc(var(--bas-line-width) / -2);
	background: var(--bas-line);
	box-shadow: 0 0 6px rgba(0, 0, 0, .35);
	pointer-events: none;
	z-index: 2;
}
.bas[data-orientation="vertical"] .bas__handle {
	top: var(--bas-pos);
	bottom: auto;
	left: 0;
	right: 0;
	width: auto;
	height: var(--bas-line-width);
	margin-left: 0;
	margin-top: calc(var(--bas-line-width) / -2);
}

.bas__knob {
	position: absolute;
	top: 50%;
	left: 50%;
	width: var(--bas-knob-size);
	height: var(--bas-knob-size);
	transform: translate(-50%, -50%);
	display: grid;
	place-items: center;
	border-radius: 50%;
	background: var(--bas-knob-bg);
	color: var(--bas-knob-color);
	box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
	transition: transform .15s ease;
}
.bas[data-orientation="vertical"] .bas__knob svg { transform: rotate(90deg); }
.bas.is-dragging .bas__knob { transform: translate(-50%, -50%) scale(1.1); }

/* Natpisi — "Prije" je unutar odrezanog sloja pa se prirodno skriva/otkriva */
.bas__label {
	position: absolute;
	top: 12px;
	padding: 6px 10px;
	font: 600 13px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	letter-spacing: .02em;
	color: var(--bas-label-color);
	background: var(--bas-label-bg);
	border-radius: 4px;
	pointer-events: none;
	white-space: nowrap;
}
.bas__label--before { left: 12px; }
.bas__label--after  { right: 12px; }
.bas[data-orientation="vertical"] .bas__label { top: auto; }
.bas[data-orientation="vertical"] .bas__label--before { top: 12px; left: 12px; }
.bas[data-orientation="vertical"] .bas__label--after  { bottom: 12px; right: 12px; }

/* Range input: nevidljiv, ali fokusabilan (tipkovnica + čitači ekrana) */
.bas__range {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	border: 0;
	opacity: 0;
}
/* Fokus s tipkovnice prikazujemo na kružiću */
.bas:has(.bas__range:focus-visible) .bas__knob {
	outline: 3px solid #2271b1;
	outline-offset: 3px;
}

@media (max-width: 600px) {
	.bas { --bas-knob-size: 40px; }
	.bas__label { font-size: 11px; padding: 4px 8px; top: 8px; }
	.bas__label--before { left: 8px; }
	.bas__label--after  { right: 8px; }
}

@media (prefers-reduced-motion: reduce) {
	.bas__knob { transition: none; }
}
