/**
 * Lite Product Filter for WooCommerce
 *
 * Deliberately low-specificity and colour-token driven so a theme can restyle
 * it by overriding the custom properties on .wclf.
 */

.wclf {
	--wclf-text: currentColor;
	--wclf-muted: color-mix( in srgb, currentColor 55%, transparent );
	--wclf-border: color-mix( in srgb, currentColor 15%, transparent );
	--wclf-accent: #1f6feb;
	--wclf-accent-contrast: #fff;
	--wclf-radius: 6px;
	--wclf-gap: 14px;

	font-size: 0.95em;
	line-height: 1.4;
	color: var( --wclf-text );
}

/* Fallback for browsers without color-mix(). */
@supports not ( color: color-mix( in srgb, red 50%, blue ) ) {
	.wclf {
		--wclf-muted: rgba( 0, 0, 0, 0.55 );
		--wclf-border: rgba( 0, 0, 0, 0.15 );
	}
}

.wclf * {
	box-sizing: border-box;
}

.wclf-form {
	margin: 0;
}

/* ------------------------------------------------------------------ header */

.wclf-header {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 10px;
	margin-bottom: 10px;
}

.wclf-header__title {
	font-weight: 600;
	font-size: 1.05em;
}

.wclf-clear {
	font-size: 0.85em;
	text-decoration: underline;
	color: var( --wclf-muted );
	background: none;
	border: 0;
	padding: 0;
	cursor: pointer;
}

.wclf-clear:hover,
.wclf-clear:focus {
	color: var( --wclf-text );
}

.wclf-clear--hidden {
	display: none;
}

/* ------------------------------------------------------------------- chips */

.wclf-active {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-bottom: 12px;
}

.wclf-active:empty {
	display: none;
}

.wclf-chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 3px 8px;
	font-size: 0.82em;
	line-height: 1.5;
	border: 1px solid var( --wclf-border );
	border-radius: 999px;
	background: transparent;
	color: inherit;
	text-decoration: none;
	cursor: pointer;
}

.wclf-chip:hover,
.wclf-chip:focus {
	border-color: var( --wclf-accent );
	color: var( --wclf-accent );
}

.wclf-chip__x {
	font-size: 1.15em;
	line-height: 1;
	opacity: 0.7;
}

/* ------------------------------------------------------------------ groups */

.wclf-group {
	border: 0;
	border-top: 1px solid var( --wclf-border );
	margin: 0;
	padding: 0;
	min-width: 0;
}

.wclf-group:first-of-type {
	border-top: 0;
}

.wclf-group__legend {
	display: block;
	width: 100%;
	padding: 0;
	margin: 0;
	float: left; /* Keeps legend full width in older layout engines. */
}

.wclf-group__toggle,
.wclf-group__label {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	width: 100%;
	padding: 12px 0;
	background: none;
	border: 0;
	font: inherit;
	font-weight: 600;
	color: inherit;
	text-align: left;
	cursor: pointer;
}

.wclf-group__label {
	cursor: default;
}

.wclf-group__toggle:hover,
.wclf-group__toggle:focus-visible {
	color: var( --wclf-accent );
}

.wclf-group__toggle:focus-visible {
	outline: 2px solid var( --wclf-accent );
	outline-offset: 2px;
}

.wclf-group__chevron {
	width: 8px;
	height: 8px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate( -45deg );
	transform-origin: center;
	transition: transform 0.2s ease;
	opacity: 0.55;
	flex: none;
	margin: 0 3px 3px 0;
}

.wclf-group.is-open .wclf-group__chevron,
.wclf.is-panel-open .wclf-panel-toggle .wclf-group__chevron {
	transform: rotate( 45deg );
	margin: 3px 3px 0 0;
}

.wclf-group__body {
	clear: both;
}

.wclf-group__inner {
	padding-bottom: var( --wclf-gap );
}

/*
 * Sections animate open only once the script has taken over. Without
 * JavaScript the `hidden` attribute keeps closed sections closed and the
 * toggle button is hidden, so nothing becomes unreachable.
 */
.wclf--js .wclf-group__body {
	max-height: 80em;
	overflow: hidden;
	visibility: visible;
	opacity: 1;
	transition: max-height 0.25s ease, opacity 0.2s ease, visibility 0s;
}

.wclf--js .wclf-group:not( .is-open ) .wclf-group__body {
	max-height: 0;
	opacity: 0;
	visibility: hidden;
	transition: max-height 0.25s ease, opacity 0.15s ease, visibility 0s linear 0.25s;
}

/* ---------------------------------------------------------- panel toggle */

.wclf-panel-toggle {
	display: none;
	align-items: center;
	gap: 8px;
	width: 100%;
	padding: 11px 14px;
	margin-bottom: 12px;
	font: inherit;
	font-weight: 600;
	color: inherit;
	background: none;
	border: 1px solid var( --wclf-border );
	border-radius: var( --wclf-radius );
	cursor: pointer;
}

.wclf-panel-toggle:hover,
.wclf-panel-toggle:focus-visible {
	border-color: var( --wclf-accent );
	color: var( --wclf-accent );
}

.wclf-panel-toggle__label {
	flex: 1 1 auto;
	text-align: left;
}

.wclf-panel-toggle__icon {
	flex: none;
	width: 15px;
	height: 11px;
	border-top: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	position: relative;
	opacity: 0.75;
}

.wclf-panel-toggle__icon::after {
	content: "";
	position: absolute;
	left: 0;
	top: 4px;
	width: 9px;
	border-top: 2px solid currentColor;
}

.wclf-panel-toggle__count {
	flex: none;
	min-width: 20px;
	padding: 1px 6px;
	border-radius: 999px;
	background: var( --wclf-accent );
	color: var( --wclf-accent-contrast );
	font-size: 0.75em;
	line-height: 1.6;
	text-align: center;
}

.wclf-panel-toggle__count:empty {
	display: none;
}

.wclf--js.wclf--panel-always .wclf-panel-toggle {
	display: flex;
}

.wclf--js.wclf--panel-always:not( .is-panel-open ) .wclf-form {
	display: none;
}

.wclf--js.wclf--panel-always .wclf-header__title {
	display: none;
}

/* Below this width the whole panel folds away behind the button. */
@media ( max-width: 781px ) {
	.wclf--js.wclf--panel-mobile .wclf-panel-toggle {
		display: flex;
	}

	.wclf--js.wclf--panel-mobile:not( .is-panel-open ) .wclf-form {
		display: none;
	}

	.wclf--js.wclf--panel-mobile .wclf-header__title {
		display: none;
	}
}

/* -------------------------------------------------------------------- list */

.wclf-list {
	list-style: none;
	margin: 0;
	padding: 0;
	max-height: 15em;
	overflow-y: auto;
}

.wclf-list .wclf-list {
	max-height: none;
	overflow: visible;
	padding-left: 22px;
}

.wclf-item {
	margin: 0 0 2px;
	padding: 0;
}

.wclf-item::before {
	content: none;
}

/* ---------------------------------------------------------------- checkbox */

.wclf-check {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	padding: 3px 0;
	cursor: pointer;
}

.wclf-check input[type="checkbox"] {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect( 0 0 0 0 );
	white-space: nowrap;
	border: 0;
}

.wclf-check__box {
	flex: none;
	width: 16px;
	height: 16px;
	margin-top: 2px;
	border: 1px solid var( --wclf-border );
	border-radius: 3px;
	position: relative;
	transition: background-color 0.12s ease, border-color 0.12s ease;
}

.wclf-check input:checked + .wclf-check__box {
	background: var( --wclf-accent );
	border-color: var( --wclf-accent );
}

.wclf-check input:checked + .wclf-check__box::after {
	content: "";
	position: absolute;
	left: 5px;
	top: 1px;
	width: 4px;
	height: 9px;
	border: solid var( --wclf-accent-contrast );
	border-width: 0 2px 2px 0;
	transform: rotate( 45deg );
}

.wclf-check input:focus-visible + .wclf-check__box {
	outline: 2px solid var( --wclf-accent );
	outline-offset: 2px;
}

.wclf-check__label {
	flex: 1 1 auto;
	min-width: 0;
}

.wclf-count {
	color: var( --wclf-muted );
	font-size: 0.85em;
}

/* ------------------------------------------------------------------- price */

.wclf-price {
	display: flex;
	gap: 10px;
}

.wclf-price__field {
	flex: 1 1 0;
	min-width: 0;
	display: block;
}

.wclf-price__label {
	display: block;
	font-size: 0.8em;
	color: var( --wclf-muted );
	margin-bottom: 4px;
}

.wclf-price__input {
	display: flex;
	align-items: center;
	gap: 4px;
	border: 1px solid var( --wclf-border );
	border-radius: var( --wclf-radius );
	padding: 0 8px;
}

.wclf-price__input:focus-within {
	border-color: var( --wclf-accent );
}

.wclf-price__symbol {
	color: var( --wclf-muted );
	font-size: 0.9em;
}

.wclf-price input[type="number"] {
	width: 100%;
	min-width: 0;
	border: 0;
	background: none;
	padding: 8px 0;
	font: inherit;
	color: inherit;
	box-shadow: none;
	-moz-appearance: textfield;
	appearance: textfield;
}

.wclf-price input[type="number"]::-webkit-outer-spin-button,
.wclf-price input[type="number"]::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.wclf-price input[type="number"]:focus {
	outline: none;
}

/* ----------------------------------------------------------------- actions */

.wclf-actions {
	display: flex;
	align-items: center;
	gap: 10px;
	padding-top: 14px;
	border-top: 1px solid var( --wclf-border );
}

.wclf-apply {
	flex: 1 1 auto;
}

.wclf-spinner {
	display: none;
	flex: none;
	width: 16px;
	height: 16px;
	border: 2px solid var( --wclf-border );
	border-top-color: var( --wclf-accent );
	border-radius: 50%;
	animation: wclf-spin 0.7s linear infinite;
}

.wclf.is-loading .wclf-spinner {
	display: block;
}

@keyframes wclf-spin {
	to {
		transform: rotate( 360deg );
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.wclf-spinner {
		animation-duration: 2s;
	}

	.wclf-group__chevron,
	.wclf--js .wclf-group__body,
	.wclf--js .wclf-group:not( .is-open ) .wclf-group__body {
		transition: none;
	}
}

/* ---------------------------------------------------------- loading state */

.wclf-loading ul.products,
.wclf-loading .woocommerce-pagination,
.wclf-loading .woocommerce-result-count {
	opacity: 0.45;
	transition: opacity 0.15s ease;
	pointer-events: none;
}

/* Only needed when the theme has no screen-reader-text helper. */
.wclf .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect( 0 0 0 0 );
	white-space: nowrap;
	border: 0;
}
