/**
 * Kubota Europe filter bar — the shared look of the front-end filter forms.
 *
 * Figma nodes 4926-716 / 5103-1517 (division spec filter) and 3727-7784 (news
 * filter), which are the same component: a 51px-tall row — a black "All …" pill
 * (268 wide), then one white pill per facet (265 wide, 1px teal border, teal
 * medium label + chevron) 21px apart, and, pushed to the right end of the row,
 * the "Search by name" box (459 wide, 1px light grey border, magnifier). A pill
 * opens a panel hanging under it holding the facet's controls; the list of radio
 * circles is shared here, a facet's own control (the spec filter's range slider)
 * is styled by its element.
 *
 * Used by `vc_kbeu_spec_filter` (root `kbeu-fb kbeu-sf`) and `vc_kbeu_news_filter`
 * (root `kbeu-fb kbeu-nf`): the form carries `kbeu-fb`, the shared parts carry
 * `kbeu-fb__*` classes, and each element's stylesheet depends on this handle so its
 * own rules come later in the cascade. Tokens (`--kbeu-fb-*`) live on `.kbeu-fb`
 * so an element can retune them.
 *
 * The bar fills whatever width its WPBakery row gives it (no breakout, no own
 * max width) and wraps on narrow screens. Sizes are `clamp()`s whose maximum
 * is the Figma value (2560 artboard, vw = px / 25.6). Font "Inter"
 * comes from the plugin's fonts stylesheet (this handle depends on
 * `kbeu-fonts`), referenced through `--kbeu-font-principal`.
 *
 * Progressive enhancement: without the script the panels lay open under the bar
 * as plain form controls; once it adds `.is-enhanced` they hang under their pill,
 * one open at a time, and the fallback "Apply filters" submit disappears.
 */

/* A bar printed `hidden` (an element with nothing to filter by) stays out of
   the flow whatever the theme does to `form`. */
.kbeu-fb[hidden] {
	display: none;
}

.kbeu-fb {
	--kbeu-fb-teal: var( --kbeu-color-teal );
	--kbeu-fb-ink: var( --kbeu-color-ink-alt );
	--kbeu-fb-line: var( --kbeu-color-line );
	--kbeu-fb-h: clamp( 40px, 1.99vw, 51px );
	--kbeu-fb-gap: clamp( 12px, 0.82vw, 21px );
	--kbeu-fb-fs: clamp( 15px, 0.78vw, 20px );
	--kbeu-fb-pill-w: clamp( 170px, 10.35vw, 265px );
	--kbeu-fb-radius: 15px;

	/* Fills its WPBakery column; the row decides site width vs full width. */
	position: relative;
	width: 100%;
	margin: 0;
	padding: clamp( 20px, 1.6vw, 41px ) 0 clamp( 20px, 1.68vw, 43px );
	font-family: var( --kbeu-font-principal );
	font-size: var( --kbeu-fb-fs );
	line-height: 1.2;
	color: var( --kbeu-fb-ink );
}

.kbeu-fb__bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var( --kbeu-fb-gap );
}

/* --- "All …" ------------------------------------------------------------------ */

.kbeu-fb .kbeu-fb__all {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-width: clamp( 170px, 10.47vw, 268px );
	height: var( --kbeu-fb-h );
	padding: 0 clamp( 16px, 1.02vw, 26px );
	border: 1px solid var( --kbeu-fb-ink );
	border-radius: var( --kbeu-fb-radius );
	background: var( --kbeu-fb-ink );
	color: #fff;
	font-weight: 700;
	text-decoration: none;
	white-space: nowrap;
	transition: background-color 0.2s ease, color 0.2s ease;
}

.kbeu-fb .kbeu-fb__all:hover,
.kbeu-fb .kbeu-fb__all:focus-visible {
	background: #000;
	color: #fff;
	outline: none;
}

.kbeu-fb .kbeu-fb__all:focus-visible {
	box-shadow: 0 0 0 3px var( --kbeu-fb-teal );
}

/* --- Facet pills -------------------------------------------------------------- */

.kbeu-fb__facet {
	position: relative;
}

.kbeu-fb .kbeu-fb__pill {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: clamp( 8px, 0.55vw, 14px );
	box-sizing: border-box;
	min-width: var( --kbeu-fb-pill-w );
	height: var( --kbeu-fb-h );
	margin: 0;
	padding: 0 clamp( 16px, 1.02vw, 26px );
	border: 1px solid var( --kbeu-fb-teal );
	border-radius: var( --kbeu-fb-radius );
	background: #fff;
	color: var( --kbeu-fb-teal );
	font-family: inherit;
	font-size: var( --kbeu-fb-fs );
	font-weight: 500;
	line-height: 1.2;
	white-space: nowrap;
	cursor: pointer;
	transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.kbeu-fb .kbeu-fb__pill:hover,
.kbeu-fb .kbeu-fb__pill:focus-visible,
.kbeu-fb .kbeu-fb__pill[aria-expanded='true'] {
	background: rgba( 0, 168, 169, 0.08 );
	color: var( --kbeu-fb-teal );
	outline: none;
}

.kbeu-fb .kbeu-fb__pill:focus-visible {
	box-shadow: 0 0 0 3px rgba( 0, 168, 169, 0.35 );
}

/* A facet with a value applied: filled pill. */
.kbeu-fb__facet.is-set .kbeu-fb__pill {
	background: var( --kbeu-fb-teal );
	color: #fff;
}

/* A pill drawn with nothing to choose yet (listing filters, "Pills" = always):
   the design's pill, muted and inert. */
.kbeu-fb .kbeu-fb__pill:disabled,
.kbeu-fb .kbeu-fb__pill:disabled:hover {
	background: #fff;
	color: var( --kbeu-fb-teal );
	opacity: 0.45;
	cursor: default;
}

.kbeu-fb__chevron {
	width: clamp( 18px, 0.94vw, 24px );
	height: clamp( 18px, 0.94vw, 24px );
	flex: 0 0 auto;
	transition: transform 0.2s ease;
}

.kbeu-fb .kbeu-fb__pill[aria-expanded='true'] .kbeu-fb__chevron {
	transform: rotate( 180deg );
}

/* --- Panels ------------------------------------------------------------------- */

/* Not enhanced: the panels lay open under the bar (plain form controls). */
.kbeu-fb__panel {
	box-sizing: border-box;
	width: 100%;
	margin-top: 8px;
	padding: clamp( 14px, 0.94vw, 24px ) clamp( 14px, 0.94vw, 24px );
	border: 1px solid var( --kbeu-fb-teal );
	border-radius: var( --kbeu-fb-radius );
	background: #fff;
}

/* Enhanced: hanging under the pill, one open at a time, above the content. */
.kbeu-fb.is-enhanced .kbeu-fb__panel {
	display: none;
	position: absolute;
	top: calc( 100% + 8px );
	left: 0;
	z-index: 30;
	width: max( 100%, var( --kbeu-fb-pill-w ) );
	margin: 0;
	box-shadow: 0 12px 30px rgba( 0, 0, 0, 0.12 );
}

.kbeu-fb.is-enhanced .kbeu-fb__facet.is-open .kbeu-fb__panel {
	display: block;
}

/* Right-aligned panel when the pill sits near the right edge (set by the script). */
.kbeu-fb.is-enhanced .kbeu-fb__facet.is-flipped .kbeu-fb__panel {
	left: auto;
	right: 0;
}

/* --- Options ------------------------------------------------------------------- */

.kbeu-fb__options {
	display: flex;
	flex-direction: column;
	gap: clamp( 10px, 0.63vw, 16px );
	margin: 0;
	padding: 0;
	list-style: none;
}

.kbeu-fb__option label {
	display: flex;
	align-items: center;
	gap: clamp( 10px, 0.55vw, 14px );
	margin: 0;
	cursor: pointer;
	font-size: clamp( 14px, 0.63vw, 16px );
	font-weight: 300;
	line-height: 1.3;
	color: var( --kbeu-fb-ink );
}

.kbeu-fb .kbeu-fb__radio {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect( 0 0 0 0 );
	border: 0;
}

/* 20px circle, teal ring; a teal dot when chosen. */
.kbeu-fb__option-mark {
	position: relative;
	flex: 0 0 auto;
	box-sizing: border-box;
	width: 20px;
	height: 20px;
	border: 1px solid var( --kbeu-fb-teal );
	border-radius: 50%;
	background: #fff;
}

.kbeu-fb__option-mark::after {
	content: '';
	position: absolute;
	inset: 4px;
	border-radius: 50%;
	background: var( --kbeu-fb-teal );
	opacity: 0;
	transition: opacity 0.15s ease;
}

.kbeu-fb .kbeu-fb__radio:checked + .kbeu-fb__option-mark::after {
	opacity: 1;
}

.kbeu-fb .kbeu-fb__radio:focus-visible + .kbeu-fb__option-mark {
	box-shadow: 0 0 0 3px rgba( 0, 168, 169, 0.35 );
}

/* --- Search ------------------------------------------------------------------- */

.kbeu-fb__search {
	position: relative;
	display: flex;
	align-items: center;
	box-sizing: border-box;
	flex: 0 1 clamp( 220px, 17.93vw, 459px );
	width: clamp( 220px, 17.93vw, 459px );
	min-width: 220px;
	max-width: 100%;
	height: var( --kbeu-fb-h );
	margin-left: auto;
	border: 1px solid var( --kbeu-fb-line );
	border-radius: var( --kbeu-fb-radius );
	background: #fff;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.kbeu-fb__search:focus-within {
	border-color: var( --kbeu-fb-teal );
	box-shadow: 0 0 0 3px rgba( 0, 168, 169, 0.2 );
}

/* `!important`s and the `[type=submit]` in the selectors: Impreza styles every
   `input[type=search]` (min-height, line-height, end padding) and, with
   `!important`s of its own, every `[type=submit]:not(.w-btn)` (button style 1:
   fill, white text, padding) — rules this box has to out-rank. */
.kbeu-fb .kbeu-fb__input {
	flex: 1 1 auto;
	box-sizing: border-box;
	width: 100%;
	height: 100%;
	min-height: 0 !important;
	min-width: 0;
	margin: 0;
	padding: 0 clamp( 12px, 0.86vw, 22px ) !important;
	border: 0;
	border-radius: var( --kbeu-fb-radius );
	background: transparent;
	font-family: inherit;
	font-size: var( --kbeu-fb-fs );
	font-weight: 500;
	line-height: 1.2 !important;
	color: var( --kbeu-fb-ink );
	box-shadow: none;
	outline: none;
}

/* Impreza also paints every focused input (`input:not([type=submit]):focus`:
   alternate background + a 2px ring) — the box itself shows the focus (above),
   so the input stays transparent while typing. */
.kbeu-fb .kbeu-fb__search .kbeu-fb__input:focus {
	background: transparent;
	border-color: transparent;
	box-shadow: none;
	color: var( --kbeu-fb-ink );
}

.kbeu-fb .kbeu-fb__input::placeholder {
	color: var( --kbeu-fb-ink );
	opacity: 1;
}

.kbeu-fb .kbeu-fb__input::-webkit-search-cancel-button {
	-webkit-appearance: none;
	appearance: none;
}

.kbeu-fb .kbeu-fb__search .kbeu-fb__submit[type='submit'] {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: var( --kbeu-fb-h );
	height: 100%;
	margin: 0;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 0 var( --kbeu-fb-radius ) var( --kbeu-fb-radius ) 0;
	background: transparent !important;
	color: var( --kbeu-fb-ink ) !important;
	box-shadow: none !important;
	cursor: pointer;
}

.kbeu-fb .kbeu-fb__search .kbeu-fb__submit[type='submit']::before {
	display: none;
}

.kbeu-fb .kbeu-fb__search .kbeu-fb__submit[type='submit']:hover,
.kbeu-fb .kbeu-fb__search .kbeu-fb__submit[type='submit']:focus-visible {
	color: var( --kbeu-fb-teal ) !important;
	outline: none;
}

.kbeu-fb__magnifier {
	width: clamp( 18px, 0.9vw, 23px );
	height: clamp( 18px, 0.9vw, 23px );
}

/* News and case study filters: every control sits together in one row, centred both ways;
   the search box follows the facet pills instead of going to the right end. */
.kbeu-nf .kbeu-fb__bar,
.kbeu-csf .kbeu-fb__bar {
	align-items: center;
	justify-content: center;
}

.kbeu-nf .kbeu-fb__search,
.kbeu-csf .kbeu-fb__search {
	margin-left: 0;
}

/* --- Fallback submit (no search box, no JS) ------------------------------------- */

.kbeu-fb .kbeu-fb__apply[type='submit'] {
	margin-top: var( --kbeu-fb-gap );
	padding: 0 clamp( 16px, 1.02vw, 26px ) !important;
	height: var( --kbeu-fb-h );
	border: 1px solid var( --kbeu-fb-teal ) !important;
	border-radius: var( --kbeu-fb-radius );
	background: var( --kbeu-fb-teal ) !important;
	color: #fff !important;
	font-family: inherit;
	font-size: var( --kbeu-fb-fs );
	font-weight: 500;
	cursor: pointer;
}

.kbeu-fb.is-enhanced .kbeu-fb__apply {
	display: none;
}

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

@media ( max-width: 1199px ) {
	.kbeu-fb__search {
		margin-left: 0;
	}
}

@media ( max-width: 640px ) {
	.kbeu-fb .kbeu-fb__all,
	.kbeu-fb .kbeu-fb__pill {
		min-width: 0;
		flex: 1 1 calc( 50% - var( --kbeu-fb-gap ) );
	}

	.kbeu-fb__facet {
		flex: 1 1 calc( 50% - var( --kbeu-fb-gap ) );
		min-width: 0;
	}

	.kbeu-fb .kbeu-fb__pill {
		width: 100%;
	}

	.kbeu-fb__search {
		width: 100%;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.kbeu-fb .kbeu-fb__pill,
	.kbeu-fb .kbeu-fb__all,
	.kbeu-fb__chevron,
	.kbeu-fb__option-mark::after {
		transition: none;
	}
}
