/**
 * Kubota Europe carousel — the shared slider component.
 *
 * Layout (viewport / track / item), the crossfade and the control below the
 * items — teal prev/next chevrons with a dots pager whose active dot is an
 * elongated teal pill (Figma 3721-2893, reused as-is by every slider of the
 * design). The engine in `kbeu-carousel.js` translates the track and drives the
 * control; the items themselves are styled by each element (product highlights,
 * promotions, stories slider, news carousels).
 *
 * Everything an element may vary is a custom property on the root, so an element
 * overrides tokens instead of rules:
 *
 *   --kbeu-carousel-gap               distance between items
 *   --kbeu-carousel-per-view          items per view (keep in sync with the root's
 *                                     `data-kbeu-per-view*` attributes the engine
 *                                     reads; the 860px mobile rule below mirrors
 *                                     the engine's default breakpoint)
 *   --kbeu-carousel-item-w            item width in centered mode only
 *                                     (`data-kbeu-align="center"`)
 *   --kbeu-carousel-dot-size          pager dot diameter
 *   --kbeu-carousel-dot-active-width  active dot (pill) width
 *   --kbeu-carousel-dot / -accent     dot colour / active + arrows colour
 *
 * Load order: element stylesheets depend on this handle, so their tokens and
 * item rules come later in the cascade.
 */

.kbeu-carousel {
	--kbeu-carousel-gap: clamp( 20px, 2vw, 29px );
	--kbeu-carousel-per-view: 2;
	--kbeu-carousel-item-w: 44%;
	--kbeu-carousel-dot-size: 8px;
	--kbeu-carousel-dot-active-width: 28px;
	--kbeu-carousel-dot: var( --kbeu-color-border-alt );
	--kbeu-carousel-accent: var( --kbeu-color-teal );
	--kbeu-carousel-accent-hover: var( --kbeu-color-teal-dark );
}

/* Viewport clips the overflowing track. */
.kbeu-carousel__viewport {
	overflow: hidden;
}

.kbeu-carousel__track {
	display: flex;
	align-items: stretch;
	gap: var( --kbeu-carousel-gap );
	/* Pages change with a crossfade: the JS fades the track out, repositions it
	   instantly, then fades it back in (no horizontal sliding). An opacity fade is
	   gentle enough to keep even under prefers-reduced-motion. */
	transition: opacity 0.3s ease;
	will-change: opacity;
}

.kbeu-carousel__track.is-fading {
	opacity: 0;
}

/* N items per view: the width is derived from the per-view token and the gap. */
.kbeu-carousel__item {
	flex: 0 0 calc( ( 100% - ( var( --kbeu-carousel-per-view ) - 1 ) * var( --kbeu-carousel-gap ) ) / var( --kbeu-carousel-per-view ) );
	min-width: 0;
	display: flex;
}

/* A lone item spans the full width instead of a column. */
.kbeu-carousel__item:only-child {
	flex-basis: 100%;
}

/* Centered mode: fixed item width, the engine centers the current one (a lone
   item keeps its width and is centered too). */
.kbeu-carousel[data-kbeu-align='center'] .kbeu-carousel__item,
.kbeu-carousel[data-kbeu-align='center'] .kbeu-carousel__item:only-child {
	flex-basis: var( --kbeu-carousel-item-w );
}

/* Control: prev/next chevrons + dots pager. */
.kbeu-carousel__control {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: clamp( 16px, 2.5vw, 32px );
	margin-top: clamp( 28px, 3vw, 48px );
}

.kbeu-carousel__control[hidden] {
	display: none;
}

.kbeu-carousel__arrow {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	background: none;
	color: var( --kbeu-carousel-accent );
	cursor: pointer;
	transition: color 0.2s ease, opacity 0.2s ease;
}

.kbeu-carousel__arrow:hover {
	color: var( --kbeu-carousel-accent-hover );
}

.kbeu-carousel__arrow:disabled {
	opacity: 0.3;
	cursor: default;
}

.kbeu-carousel__dots {
	display: flex;
	align-items: center;
	gap: 10px;
}

.kbeu-carousel__dot {
	width: var( --kbeu-carousel-dot-size );
	height: var( --kbeu-carousel-dot-size );
	padding: 0;
	border: 0;
	border-radius: calc( var( --kbeu-carousel-dot-size ) / 2 );
	background: var( --kbeu-carousel-dot );
	cursor: pointer;
	transition: width 0.25s ease, background 0.25s ease;
}

.kbeu-carousel__dot.is-active {
	width: var( --kbeu-carousel-dot-active-width );
	background: var( --kbeu-carousel-accent );
	cursor: default;
}

/* One item per view on mobile (the engine's default breakpoint). */
@media ( max-width: 860px ) {
	.kbeu-carousel {
		--kbeu-carousel-per-view: 1;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.kbeu-carousel__arrow,
	.kbeu-carousel__dot {
		transition: none;
	}
}
