/**
 * Kubota Europe division categories bar (WPBakery element `vc_kbeu_division_filter`).
 *
 * Figma node 4481-2670: a white bar (103px tall @2560) whose tabs are centered —
 * 20px, medium weight, 35px apart, the active one bold with a 44×3.5px teal
 * underline — and, below the top level, a bold "‹ Back to … Range" link at the
 * left edge. The bar fills the width its WPBakery row gives it (the design's
 * edge-to-edge white and its 1893px content column are row settings, not the
 * element's). It pins below the fixed site header while scrolling (`.is-stuck`,
 * driven by `kbeu-division-filter.js` the same way the product sticky menu does it:
 * Impreza rows defeat CSS `position: sticky`).
 *
 * Sizes are `clamp()`s whose maximum is the Figma value (the artboard is 2560px
 * wide). Font "Inter" comes from the plugin's fonts stylesheet (this
 * handle depends on `kbeu-fonts`), referenced through `--kbeu-font-principal`.
 */

.kbeu-division-filter {
	--kbeu-df-teal: var( --kbeu-color-teal );
	/* Back link and tabs: Impreza's `.no-touch a:hover` out-ranks their hover colour
	   and paints it with this variable (see `kbeu-buttons.css`). */
	--color-content-link-hover: var( --kbeu-df-teal );
	--kbeu-df-ink: #000;
	/* Design: 103px tall @2560. */
	--kbeu-df-height: clamp( 64px, 4.02vw, 103px );
	/* Design: 20px labels @2560 (the header's text size). */
	--kbeu-df-fs: clamp( 15px, 0.78vw, 20px );
	/* Design: 35px between tabs. */
	--kbeu-df-gap: clamp( 18px, 1.37vw, 35px );
	/* Design: 44×3.5px underline, ~16px under the label. */
	--kbeu-df-underline-w: clamp( 32px, 1.72vw, 44px );
	--kbeu-df-underline-h: 3.5px;
	--kbeu-df-underline-gap: clamp( 10px, 0.63vw, 16px );
	/* Design: 24px chevron. */
	--kbeu-df-chevron: clamp( 18px, 0.94vw, 24px );

	/* Fills whatever width its WPBakery row/column gives it (no breakout, no
	   own max width): the row decides between site width and full width, and
	   the back link sits at the container's left edge. */
	position: relative;
	z-index: 20;
	width: 100%;
	background: #fff;
	font-family: var( --kbeu-font-principal );
	color: var( --kbeu-df-ink );
}

/* Holds the bar's place in the flow while it is pinned (inserted by the script). */
.kbeu-division-filter__placeholder {
	pointer-events: none;
}

/* Pinned below the site header: the script sets `top` (the header's live height)
   and `left`/`width` (measured on the placeholder), so the pinned bar keeps the
   width of the row it lives in. */
.kbeu-division-filter.is-stuck {
	position: fixed;
	top: 0;
	box-shadow: 0 11px 29.2px rgba( 0, 0, 0, 0.11 );
}

/* --- Layout ------------------------------------------------------------------ */

/* Three columns: back link | tabs | mirror of the back link (hidden). The side
   columns share the same minimum, so the tabs stay centered on the page exactly
   as long as they fit on one line; when they do not, the middle column shrinks
   to the space left and the tabs wrap onto further centered lines (they never
   overlap the back link). */
.kbeu-division-filter__inner {
	display: grid;
	grid-template-columns: minmax( max-content, 1fr ) minmax( 0, auto ) minmax( max-content, 1fr );
	align-items: center;
	justify-items: center;
	column-gap: var( --kbeu-df-gap );
	box-sizing: border-box;
	min-height: var( --kbeu-df-height );
	width: 100%;
}

/* --- Back link (below the top level) ----------------------------------------- */

/* Explicit rows: with sparse auto-placement the tab list (column 2, after the
   column-3 spacer in the DOM) would otherwise be pushed to a second row. */
.kbeu-division-filter__back,
.kbeu-division-filter__spacer {
	grid-row: 1;
	grid-column: 1;
	justify-self: start;
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: var( --kbeu-df-fs );
	font-weight: 700;
	line-height: 1.5;
	color: var( --kbeu-df-ink );
	text-decoration: none;
	white-space: nowrap;
	transition: color 0.2s ease;
}

.kbeu-division-filter__back:hover,
.kbeu-division-filter__back:focus-visible {
	color: var( --kbeu-df-teal );
}

.kbeu-division-filter__back-icon {
	flex: none;
	width: var( --kbeu-df-chevron );
	height: var( --kbeu-df-chevron );
	transform: rotate( 180deg );
}

/* Invisible copy of the back link in the third column, so both sides weigh the same. */
.kbeu-division-filter__spacer {
	grid-column: 3;
	justify-self: end;
	visibility: hidden;
}

/* --- Tabs -------------------------------------------------------------------- */

/* The scroller is the grid item. On wide screens it is a plain box and the list
   inside wraps; on phones the LIST scrolls horizontally inside it (below) and
   the scroller, which does not scroll, carries the edge fades so they stay put. */
.kbeu-division-filter__scroller {
	grid-row: 1;
	grid-column: 2;
	position: relative;
	max-width: 100%;
	min-width: 0;
}

.kbeu-division-filter__tabs {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 0 var( --kbeu-df-gap );
	margin: 0;
	padding: 0;
	list-style: none;
}

/* Edge fades of the phone scroller, shown by the script while there is more
   to scroll on that side. */
.kbeu-division-filter__scroller::before,
.kbeu-division-filter__scroller::after {
	content: '';
	position: absolute;
	top: 0;
	bottom: 0;
	width: 40px;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s ease;
}

.kbeu-division-filter__scroller::before {
	left: 0;
	background: linear-gradient( to right, #fff, rgba( 255, 255, 255, 0 ) );
}

.kbeu-division-filter__scroller::after {
	right: 0;
	background: linear-gradient( to left, #fff, rgba( 255, 255, 255, 0 ) );
}

.kbeu-division-filter__scroller.has-more-left::before,
.kbeu-division-filter__scroller.has-more-right::after {
	opacity: 1;
}

.kbeu-division-filter__item {
	margin: 0;
	padding: 0;
}

.kbeu-division-filter__tab {
	position: relative;
	display: block;
	padding: calc( var( --kbeu-df-underline-gap ) + var( --kbeu-df-underline-h ) ) 0;
	font-size: var( --kbeu-df-fs );
	font-weight: 500;
	line-height: 1.3;
	color: var( --kbeu-df-ink );
	text-decoration: none;
	white-space: nowrap;
	transition: color 0.2s ease;
}

/* The teal underline, centered under the label; only the active tab shows it. */
.kbeu-division-filter__tab::after {
	content: '';
	position: absolute;
	left: 50%;
	bottom: 0;
	width: var( --kbeu-df-underline-w );
	height: var( --kbeu-df-underline-h );
	transform: translateX( -50% );
	border-radius: 2px;
	background: var( --kbeu-df-teal );
	opacity: 0;
	transition: opacity 0.2s ease;
}

.kbeu-division-filter__tab:hover,
.kbeu-division-filter__tab:focus-visible {
	color: var( --kbeu-df-teal );
}

.kbeu-division-filter__tab.is-active {
	font-weight: 700;
}

.kbeu-division-filter__tab.is-active::after {
	opacity: 1;
}

/* --- In-place navigation ---------------------------------------------------------- */

/* While the target page is being fetched (`aria-busy`): the tabs dim slightly and
   the cursor says so; the swap itself is instantaneous. */
.kbeu-division-filter.is-loading {
	cursor: progress;
}

.kbeu-division-filter.is-loading .kbeu-division-filter__tab,
.kbeu-division-filter.is-loading .kbeu-division-filter__back {
	opacity: 0.6;
	transition: opacity 0.2s ease;
}

/* --- Responsive ---------------------------------------------------------------- */

/* Small screens: the back link on its own row, the tabs left-aligned and scrollable. */
@media ( max-width: 782px ) {
	.kbeu-division-filter__inner {
		grid-template-columns: minmax( 0, 1fr );
		justify-items: stretch;
		row-gap: 2px;
		padding: 10px 0 4px;
	}

	.kbeu-division-filter__back {
		grid-row: 1;
		grid-column: 1;
	}

	.kbeu-division-filter__spacer {
		display: none;
	}

	.kbeu-division-filter__scroller {
		grid-row: auto;
		grid-column: 1;
	}

	.kbeu-division-filter__tabs {
		flex-wrap: nowrap;
		justify-content: flex-start;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
	}

	.kbeu-division-filter__tabs::-webkit-scrollbar {
		display: none;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.kbeu-division-filter__back,
	.kbeu-division-filter__tab,
	.kbeu-division-filter__tab::after {
		transition: none;
	}
}
