/**
 * Before / After Reveal — front-end styles.
 *
 * The reveal is a single custom property, --cba-pos, so dragging only ever
 * writes one value and the browser composites the rest.
 */

.cba {
	--cba-pos: 50%;
	--cba-line-color: #fff;
	--cba-line-width: 2px;
	--cba-grip-size: 54px;
	--cba-label-offset: 20px;
	display: block;
}

.cba-frame {
	position: relative;
	overflow: hidden;
	aspect-ratio: 16 / 9;
	background: #11150f;
	touch-action: pan-y;
	user-select: none;
	-webkit-user-select: none;
}

.cba-height-auto .cba-frame { aspect-ratio: auto; }

.cba-img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: center;
}

.cba-height-auto .cba-img--after { position: relative; height: auto; }
.cba-height-auto .cba-img--before { position: absolute; inset: 0; height: 100%; }

.cba-img--after { position: absolute; inset: 0; }

/* The clipped layer holds the "before" image at full size, so the image itself
   never scales while the reveal moves — only the clip does. */
.cba-clip {
	position: absolute;
	inset: 0;
	overflow: hidden;
	will-change: clip-path;
	clip-path: inset(0 calc(100% - var(--cba-pos)) 0 0);
}

.cba-axis-vertical .cba-clip {
	clip-path: inset(0 0 calc(100% - var(--cba-pos)) 0);
}

.cba-clip .cba-img { position: absolute; inset: 0; }

/* ---------------------------------------------------------------- divider */

.cba-divider {
	position: absolute;
	top: 0;
	bottom: 0;
	left: var(--cba-pos);
	z-index: 3;
	display: flex;
	align-items: center;
	justify-content: center;
	transform: translateX(-50%);
	pointer-events: none;
}

.cba-axis-vertical .cba-divider {
	inset: var(--cba-pos) 0 auto 0;
	bottom: auto;
	transform: translateY(-50%);
}

.cba-line {
	position: absolute;
	top: 0;
	bottom: 0;
	width: var(--cba-line-width);
	background: var(--cba-line-color);
	box-shadow: 0 0 14px rgba(0, 0, 0, .28);
}

.cba-axis-vertical .cba-line {
	inset: 0 0 auto 0;
	width: auto;
	height: var(--cba-line-width);
}

.cba-grip {
	position: relative;
	display: grid;
	place-items: center;
	width: var(--cba-grip-size);
	height: var(--cba-grip-size);
	border-radius: 50%;
	background: #fff;
	color: #16211b;
	font-size: calc(var(--cba-grip-size) * .36);
	box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
	transition: transform .25s cubic-bezier(.22, 1, .36, 1);
}

.cba-grip svg { width: 1em; height: 1em; fill: currentColor; }

/* Default grip: two opposing chevrons drawn in CSS, no icon library needed. */
.cba-grip-default {
	position: relative;
	width: .9em;
	height: .55em;
}

.cba-grip-default::before,
.cba-grip-default::after {
	content: "";
	position: absolute;
	top: 50%;
	width: .32em;
	height: .32em;
	border-top: 2px solid currentColor;
	border-right: 2px solid currentColor;
}

.cba-grip-default::before { left: 0; transform: translateY(-50%) rotate(-135deg); }
.cba-grip-default::after  { right: 0; transform: translateY(-50%) rotate(45deg); }

.cba-axis-vertical .cba-grip-default { transform: rotate(90deg); }

.cba-frame.is-dragging .cba-grip { transform: scale(1.08); }
.cba-frame.is-sweeping .cba-clip { transition: clip-path 900ms cubic-bezier(.22, 1, .36, 1); }
.cba-frame.is-sweeping .cba-divider { transition: left 900ms cubic-bezier(.22, 1, .36, 1), top 900ms cubic-bezier(.22, 1, .36, 1); }

/* The real control: a range input stretched over the frame. It is invisible
   but fully operable, which is what gives us keyboard and AT support for
   free — no fake ARIA slider. */
.cba-range {
	position: absolute;
	inset: 0;
	z-index: 4;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	opacity: 0;
	cursor: ew-resize;
	-webkit-appearance: none;
	appearance: none;
}

.cba-axis-vertical .cba-range { cursor: ns-resize; }
.cba-mode-hover .cba-range { cursor: crosshair; }

.cba-range::-webkit-slider-thumb { -webkit-appearance: none; width: 44px; height: 100%; }
.cba-range::-moz-range-thumb { width: 44px; height: 100%; border: 0; opacity: 0; }

.cba-range:focus-visible ~ .cba-divider .cba-grip {
	outline: 3px solid #e5c58a;
	outline-offset: 3px;
}

/* ----------------------------------------------------------------- labels */

.cba-label {
	position: absolute;
	z-index: 2;
	top: var(--cba-label-offset);
	padding: 8px 14px;
	border-radius: 2px;
	background: rgba(12, 16, 13, .55);
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: .14em;
	text-transform: uppercase;
	backdrop-filter: blur(4px);
	pointer-events: none;
	transition: opacity .25s linear;
}

.cba-label--before { left: var(--cba-label-offset); }
.cba-label--after  { right: var(--cba-label-offset); }

.cba-axis-vertical .cba-label--after {
	top: auto;
	right: var(--cba-label-offset);
	bottom: var(--cba-label-offset);
}

/* ---------------------------------------------------------------- caption */

.cba-caption { margin-top: 22px; }
.cba-title { margin: 0 0 8px; font-size: 1.3rem; font-weight: 500; letter-spacing: -.02em; }
.cba-text { margin: 0; font-size: .95rem; line-height: 1.75; }

.cba-link {
	display: inline-flex;
	align-items: center;
	gap: 12px;
	margin-top: 14px;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: .13em;
	text-transform: uppercase;
	text-decoration: none;
}

.cba-link span:first-child { border-bottom: 1px solid currentColor; padding-bottom: 3px; }
.cba-link-icon { display: inline-flex; font-size: 17px; transition: transform .25s; }
.cba-link:hover .cba-link-icon { transform: translate3d(3px, -3px, 0); }
.cba-link-icon svg { width: 1em; height: 1em; fill: currentColor; }

.cba-empty {
	display: grid;
	place-items: center;
	min-height: 200px;
	border: 1px dashed currentColor;
	opacity: .6;
	font-size: 14px;
	text-align: center;
	padding: 20px;
}

.screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

@media (prefers-reduced-motion: reduce) {
	.cba-frame.is-sweeping .cba-clip,
	.cba-frame.is-sweeping .cba-divider { transition: none; }
	.cba-grip { transition: none; }
}
