/*
 * Filter Everything Ultimate - front end
 * Colours and radii are overridden per site by an inline block of custom
 * properties scoped to .feult (see Settings::inline_css()).
 */

.feult {
	--feult-accent: #4f46e5;
	--feult-on-accent: #fff;
	--feult-radius: 8px;
	--feult-btn-radius: 999px;
	--feult-gap: 14px;
	--feult-border: #d5d8dd;
	--feult-field-bg: #fff;
	--feult-field-h: 44px;
	--feult-muted: #6b7280;
	position: relative;
	font-size: 0.95em;
}

.feult *,
.feult *::before,
.feult *::after {
	box-sizing: border-box;
}

.feult.is-loading .feult__filters,
.feult.is-loading .feult__footer {
	opacity: 0.55;
	pointer-events: none;
}

.feult-results-loading {
	opacity: 0.5;
	transition: opacity 0.15s ease;
}

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

.feult__title {
	margin: 0 0 var(--feult-gap);
}

/* Horizontal search bar */

.feult--horizontal .feult__filters {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 12px;
}

.feult--horizontal .feult-filter {
	flex: 1 1 200px;
	min-width: 180px;
	margin: 0;
	padding: 0;
	border: 0;
}

.feult--horizontal .feult-filter--search_field {
	flex-basis: 260px;
}

.feult--horizontal .feult-filter__body {
	max-height: none;
	overflow: visible;
}

.feult--horizontal .feult__submit {
	flex: 0 0 auto;
	margin-left: auto;
}

/* Fields */

.feult-select,
.feult-search__input,
.feult-range__inputs input[type="number"],
.feult-date input[type="date"] {
	width: 100%;
	min-width: 0;
	height: var(--feult-field-h);
	padding: 0 40px 0 14px;
	border: 1px solid var(--feult-border);
	border-radius: var(--feult-radius);
	background-color: var(--feult-field-bg);
	color: inherit;
	font: inherit;
	line-height: 1.2;
	appearance: none;
	-webkit-appearance: none;
}

.feult-search__input,
.feult-range__inputs input[type="number"],
.feult-date input[type="date"] {
	padding-right: 12px;
}

.feult-select {
	background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23374151' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 12px center;
	background-size: 16px 16px;
	cursor: pointer;
}

.feult-select[multiple] {
	height: auto;
	min-height: var(--feult-field-h);
	padding: 8px 12px;
	background-image: none;
}

.feult-select:focus-visible,
.feult-search__input:focus-visible,
.feult-range__inputs input:focus-visible,
.feult-date input:focus-visible,
.feult-value:focus-visible,
.feult__chip:focus-visible,
.feult-btn:focus-visible,
.feult-filter__toggle:focus-visible,
.feult-filter__search:focus-visible {
	outline: 2px solid var(--feult-accent);
	outline-offset: 2px;
}

/* Buttons */

.feult-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	height: var(--feult-field-h);
	padding: 0 28px;
	border: 1px solid transparent;
	border-radius: var(--feult-btn-radius);
	background: var(--feult-accent);
	color: var(--feult-on-accent);
	font: inherit;
	font-weight: 600;
	line-height: 1;
	text-decoration: none;
	cursor: pointer;
	transition: filter 0.15s ease;
}

.feult-btn:hover,
.feult-btn:focus {
	filter: brightness(0.92);
	color: var(--feult-on-accent);
}

.feult-btn--primary {
	min-width: 160px;
}

.feult-btn--go {
	flex: 0 0 auto;
	padding: 0 16px;
}

.feult-btn--clear {
	height: 34px;
	padding: 0 16px;
	border-color: var(--feult-border);
	background: transparent;
	color: inherit;
	font-size: 0.9em;
}

.feult-btn--clear:hover,
.feult-btn--clear:focus {
	border-color: var(--feult-accent);
	color: var(--feult-accent);
	filter: none;
}

.feult-btn__x {
	font-size: 1.15em;
	line-height: 1;
}

/* Footer and chips */

.feult__footer {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin-top: var(--feult-gap);
}

.feult__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.feult__chip {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 3px 12px;
	border: 1px solid var(--feult-border);
	border-radius: var(--feult-btn-radius);
	background: var(--feult-field-bg);
	color: inherit;
	font-size: 0.85em;
	line-height: 1.7;
	text-decoration: none;
}

.feult__chip:hover {
	border-color: var(--feult-accent);
	color: var(--feult-accent);
}

.feult__chip-name {
	opacity: 0.65;
}

.feult__chip-x {
	font-size: 1.1em;
	opacity: 0.6;
}

/* Vertical layout */

.feult--vertical .feult-filter {
	margin-bottom: var(--feult-gap);
	padding-bottom: var(--feult-gap);
	border-bottom: 1px solid var(--feult-border);
}

.feult--vertical .feult-filter:last-child {
	border-bottom: 0;
}

.feult--vertical .feult-filter__body {
	max-height: 320px;
	overflow-y: auto;
}

.feult--vertical .feult__submit .feult-btn {
	width: 100%;
}

.feult-filter__title {
	display: block;
	width: 100%;
	margin: 0 0 8px;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	font-weight: 600;
	text-align: left;
}

.feult-filter__toggle {
	position: relative;
	padding-right: 22px;
	cursor: pointer;
}

.feult-filter__toggle::after {
	content: "";
	position: absolute;
	top: 50%;
	right: 4px;
	width: 7px;
	height: 7px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	opacity: 0.6;
	transform: translateY(-70%) rotate(45deg);
	transition: transform 0.15s ease;
}

.feult-filter.is-collapsed .feult-filter__toggle::after {
	transform: translateY(-30%) rotate(-135deg);
}

.feult-filter.is-collapsed .feult-filter__body {
	display: none;
}

.feult-filter__search {
	width: 100%;
	margin-bottom: 8px;
	padding: 6px 10px;
	border: 1px solid var(--feult-border);
	border-radius: var(--feult-radius);
	font: inherit;
}

/* Value lists */

.feult-values {
	margin: 0;
	padding: 0;
	list-style: none;
}

.feult-values--child {
	margin-left: 18px;
}

.feult-value-item[hidden] {
	display: none;
}

.feult-value {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 4px 0;
	color: inherit;
	text-decoration: none;
}

.feult-value:hover .feult-value__label {
	text-decoration: underline;
}

.feult-value.is-disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

.feult-value.is-disabled:hover .feult-value__label {
	text-decoration: none;
}

.feult-value__box {
	position: relative;
	flex: 0 0 auto;
	width: 18px;
	height: 18px;
	border: 1px solid var(--feult-border);
	background: var(--feult-field-bg);
}

.feult-value__box--check {
	border-radius: 4px;
}

.feult-value__box--radio {
	border-radius: 50%;
}

.feult-value.is-selected .feult-value__box {
	border-color: var(--feult-accent);
	background: var(--feult-accent);
}

.feult-value.is-selected .feult-value__box--check::after {
	content: "";
	position: absolute;
	top: 2px;
	left: 5px;
	width: 5px;
	height: 9px;
	border: solid var(--feult-on-accent);
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
}

.feult-value.is-selected .feult-value__box--radio::after {
	content: "";
	position: absolute;
	inset: 4px;
	border-radius: 50%;
	background: var(--feult-on-accent);
}

.feult-value__label {
	flex: 1 1 auto;
	min-width: 0;
}

.feult-value__count {
	color: var(--feult-muted);
	font-size: 0.85em;
}

.feult-value__swatch {
	flex: 0 0 auto;
	width: 24px;
	height: 24px;
	border: 1px solid var(--feult-border);
	border-radius: 50%;
}

.feult-value__image img {
	display: block;
	width: 28px;
	height: 28px;
	border-radius: 4px;
	object-fit: cover;
}

.feult-value.is-selected .feult-value__swatch,
.feult-value.is-selected .feult-value__image img {
	outline: 2px solid var(--feult-accent);
	outline-offset: 2px;
}

.feult-filter--labels .feult-values,
.feult-filter--colors .feult-values,
.feult-filter--images .feult-values {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.feult-filter--labels .feult-value {
	padding: 4px 14px;
	border: 1px solid var(--feult-border);
	border-radius: var(--feult-btn-radius);
}

.feult-filter--labels .feult-value.is-selected {
	border-color: var(--feult-accent);
	background: var(--feult-accent);
	color: var(--feult-on-accent);
}

.feult-filter--colors .feult-value__label,
.feult-filter--images .feult-value__label {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
}

/* Range and date */

.feult-range__track {
	--feult-from: 0%;
	--feult-to: 100%;
	position: relative;
	height: 26px;
}

.feult-range__track::before {
	content: "";
	position: absolute;
	top: 50%;
	right: 0;
	left: 0;
	height: 4px;
	border-radius: 2px;
	background: linear-gradient(to right, var(--feult-border) var(--feult-from), var(--feult-accent) var(--feult-from), var(--feult-accent) var(--feult-to), var(--feult-border) var(--feult-to));
	transform: translateY(-50%);
}

.feult-range__track input[type="range"] {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 26px;
	margin: 0;
	background: none;
	pointer-events: none;
	appearance: none;
	-webkit-appearance: none;
}

.feult-range__track input[type="range"]::-webkit-slider-runnable-track {
	background: none;
}

.feult-range__track input[type="range"]::-webkit-slider-thumb {
	width: 18px;
	height: 18px;
	border: 2px solid var(--feult-on-accent);
	border-radius: 50%;
	background: var(--feult-accent);
	box-shadow: 0 0 0 1px var(--feult-accent);
	cursor: pointer;
	pointer-events: auto;
	appearance: none;
	-webkit-appearance: none;
}

.feult-range__track input[type="range"]::-moz-range-thumb {
	width: 16px;
	height: 16px;
	border: 2px solid var(--feult-on-accent);
	border-radius: 50%;
	background: var(--feult-accent);
	cursor: pointer;
	pointer-events: auto;
}

.feult-range__readout {
	display: flex;
	justify-content: space-between;
	gap: 6px;
	margin: 4px 0 8px;
	color: var(--feult-muted);
	font-size: 0.9em;
}

.feult-range__inputs,
.feult-date,
.feult-search {
	display: flex;
	align-items: center;
	gap: 8px;
}

.feult-control {
	min-width: 0;
	margin: 0;
}

/* Sort shortcode */

.feult-sort {
	display: inline-flex;
	align-items: center;
	gap: 8px;
}

/* Style variants */

.feult--style-pill .feult-select,
.feult--style-pill .feult-search__input,
.feult--style-pill .feult-range__inputs input[type="number"],
.feult--style-pill .feult-date input[type="date"] {
	padding-left: 20px;
	border-radius: var(--feult-btn-radius);
}

.feult--style-bare .feult-select,
.feult--style-bare .feult-search__input,
.feult--style-bare .feult-range__inputs input,
.feult--style-bare .feult-date input,
.feult--style-bare .feult-btn {
	all: revert;
}

/* Loader */

.feult__loader {
	position: absolute;
	inset: 0;
	display: none;
	align-items: center;
	justify-content: center;
	pointer-events: none;
}

.feult.is-loading .feult__loader {
	display: flex;
}

.feult__spinner {
	width: 24px;
	height: 24px;
	border: 3px solid var(--feult-border);
	border-top-color: var(--feult-accent);
	border-radius: 50%;
	animation: feult-spin 0.7s linear infinite;
}

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

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

	.feult-btn,
	.feult-filter__toggle::after,
	.feult-results-loading {
		transition: none;
	}
}

@media screen and (max-width: 782px) {
	.feult--horizontal .feult__filters {
		flex-direction: column;
		align-items: stretch;
	}

	.feult--horizontal .feult__submit {
		margin-left: 0;
	}

	.feult-btn--primary {
		width: 100%;
	}
}

/* Block editor preview: keep links from navigating away. */
.block-editor-block-list__block .feult a,
.block-editor-block-list__block .feult button,
.block-editor-block-list__block .feult input,
.block-editor-block-list__block .feult select {
	pointer-events: none;
}
