/* NS Before After */
.ns-ba-wrap {
	margin: 1.5rem auto 2rem;
	box-sizing: border-box;
}
.ns-ba-wrap *,
.ns-ba-wrap *::before,
.ns-ba-wrap *::after {
	box-sizing: border-box;
}

/* Width modes */
.ns-ba-w-full {
	width: 100%;
	max-width: 100%;
}
.ns-ba-w-half {
	width: 50%;
	max-width: 50%;
	margin-left: auto;
	margin-right: auto;
}
.ns-ba-w-sixty {
	width: 60%;
	max-width: 60%;
	margin-left: auto;
	margin-right: auto;
}
.ns-ba-w-screen {
	width: 100vw;
	max-width: 100vw;
	position: relative;
	left: 50%;
	right: 50%;
	margin-left: -50vw;
	margin-right: -50vw;
}

.ns-ba {
	width: 100%;
}

.ns-ba__frame {
	position: relative;
	width: 100%;
	aspect-ratio: 16 / 10;
	overflow: hidden;
	border-radius: 16px;
	border: 1px solid rgba(255, 231, 157, 0.35);
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
	background: #0a0810;
	user-select: none;
	-webkit-user-select: none;
	touch-action: none;
}

.ns-ba-w-screen .ns-ba__frame {
	border-radius: 0;
	aspect-ratio: 21 / 9;
	min-height: 52vh;
}

.ns-ba__img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	pointer-events: none;
	max-width: none;
}

.ns-ba__img--after {
	z-index: 1;
}

.ns-ba__clip {
	position: absolute;
	inset: 0 auto 0 0;
	width: 50%;
	overflow: hidden;
	z-index: 2;
	border-right: 2px solid #ffe79d;
}

.ns-ba__frame--vertical .ns-ba__clip {
	inset: 0 0 auto 0;
	width: 100%;
	height: 50%;
	border-right: 0;
	border-bottom: 2px solid #ffe79d;
}

.ns-ba__clip .ns-ba__img--before {
	/* keep full frame size so crop aligns with after */
	width: 100%;
	height: 100%;
}

/* For horizontal: before image must match full frame size */
.ns-ba__frame--slider .ns-ba__clip .ns-ba__img--before {
	width: var(--ns-ba-frame-w, 100%);
	max-width: none;
	height: 100%;
	left: 0;
	top: 0;
	position: absolute;
}

.ns-ba__frame--vertical .ns-ba__clip .ns-ba__img--before {
	width: 100%;
	height: var(--ns-ba-frame-h, 100%);
	max-width: none;
	left: 0;
	top: 0;
	position: absolute;
}

.ns-ba__handle {
	position: absolute;
	z-index: 4;
	pointer-events: none;
}

.ns-ba__frame--slider .ns-ba__handle {
	top: 0;
	bottom: 0;
	left: 50%;
	width: 0;
}

.ns-ba__frame--vertical .ns-ba__handle {
	left: 0;
	right: 0;
	top: 50%;
	height: 0;
}

.ns-ba__knob {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 48px;
	height: 48px;
	border-radius: 50%;
	background: #ffe79d;
	color: #3d342e;
	font-weight: 700;
	font-size: 18px;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
	line-height: 1;
}

.ns-ba__range {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	opacity: 0;
	cursor: ew-resize;
	z-index: 5;
}

.ns-ba__frame--vertical .ns-ba__range {
	cursor: ns-resize;
	/* rotate range for vertical feel via JS; still opacity 0 */
	writing-mode: vertical-lr;
	direction: rtl;
}

.ns-ba__tag {
	position: absolute;
	z-index: 4;
	padding: 4px 10px;
	border-radius: 8px;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.04em;
	background: rgba(0, 0, 0, 0.55);
	color: #ffe79d;
	pointer-events: none;
	font-family: Montserrat, Arial, sans-serif;
}

.ns-ba__tag--before {
	top: 12px;
	left: 12px;
}

.ns-ba__tag--after {
	top: 12px;
	right: 12px;
}

.ns-ba__frame--vertical .ns-ba__tag--before {
	top: 12px;
	left: 12px;
	right: auto;
}

.ns-ba__frame--vertical .ns-ba__tag--after {
	bottom: 12px;
	top: auto;
	right: 12px;
}

/* Side by side */
.ns-ba__side {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
}

.ns-ba__half {
	margin: 0;
	position: relative;
	overflow: hidden;
	border-radius: 14px;
	border: 1px solid rgba(255, 231, 157, 0.3);
	background: #0a0810;
	aspect-ratio: 4 / 3;
}

.ns-ba__half img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.ns-ba__half .ns-ba__tag {
	position: absolute;
}

/* Hover */
.ns-ba__frame--hover .ns-ba__img--before {
	z-index: 2;
	transition: opacity 0.35s ease;
	opacity: 1;
}

.ns-ba__frame--hover .ns-ba__img--after {
	z-index: 1;
}

.ns-ba__frame--hover:hover .ns-ba__img--before,
.ns-ba__frame--hover.is-active .ns-ba__img--before {
	opacity: 0;
}

.ns-ba__hint {
	position: absolute;
	z-index: 4;
	left: 50%;
	bottom: 14px;
	transform: translateX(-50%);
	padding: 6px 12px;
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.55);
	color: #ffe79d;
	font-size: 12px;
	font-weight: 600;
	pointer-events: none;
	white-space: nowrap;
}

.ns-ba__frame--hover:hover .ns-ba__hint,
.ns-ba__frame--hover.is-active .ns-ba__hint {
	opacity: 0;
}

/* Editor placeholder */
.ns-ba-editor-placeholder {
	padding: 24px;
	border: 2px dashed #cfcfcf;
	border-radius: 12px;
	background: #fafafa;
	text-align: center;
	color: #555;
}

@media (max-width: 782px) {
	.ns-ba-w-half,
	.ns-ba-w-sixty {
		width: 100%;
		max-width: 100%;
	}
	.ns-ba__side {
		grid-template-columns: 1fr;
	}
	.ns-ba__knob {
		width: 42px;
		height: 42px;
		font-size: 16px;
	}
	.ns-ba-w-screen .ns-ba__frame {
		min-height: 40vh;
		aspect-ratio: 4 / 3;
	}
}
