/**
 * WC Filtro Prodotti Avanzato — stili front-end.
 * Volutamente neutri: colori e raggi ereditano dal tema tramite le variabili qui sotto.
 */

.wcaf {
	--wcaf-accent: currentColor;
	--wcaf-border: rgba(0, 0, 0, .12);
	--wcaf-muted: rgba(0, 0, 0, .55);
	--wcaf-bg-soft: rgba(0, 0, 0, .04);
	--wcaf-radius: 6px;

	position: relative;
	font-size: .95em;
	line-height: 1.45;
}

@media (prefers-color-scheme: dark) {
	.wcaf {
		--wcaf-border: rgba(255, 255, 255, .18);
		--wcaf-muted: rgba(255, 255, 255, .62);
		--wcaf-bg-soft: rgba(255, 255, 255, .07);
	}
}

.wcaf__title {
	font-weight: 600;
	margin: 0 0 .75em;
}

/* Filtri attivi ------------------------------------------------------- */

.wcaf__active {
	margin-bottom: 1em;
}

.wcaf__chips {
	list-style: none;
	margin: 0 0 .5em;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: .4em;
}

.wcaf__chip {
	margin: 0;
}

.wcaf__chip-remove {
	display: inline-flex;
	align-items: center;
	gap: .45em;
	padding: .25em .6em;
	border: 1px solid var(--wcaf-border);
	border-radius: 999px;
	background: var(--wcaf-bg-soft);
	text-decoration: none;
	font-size: .85em;
	line-height: 1.6;
}

.wcaf__chip-remove:hover,
.wcaf__chip-remove:focus {
	border-color: currentColor;
	text-decoration: none;
}

.wcaf__chip-x {
	font-size: 1.15em;
	opacity: .6;
}

.wcaf__reset {
	font-size: .85em;
	text-decoration: underline;
	opacity: .75;
}

/* Sezioni ------------------------------------------------------------- */

.wcaf__section {
	border-top: 1px solid var(--wcaf-border);
	padding: .35em 0;
}

.wcaf__section:last-of-type {
	border-bottom: 1px solid var(--wcaf-border);
}

.wcaf__section-title {
	cursor: pointer;
	font-weight: 600;
	list-style: none;
	padding: .6em 1.5em .6em 0;
	position: relative;
	user-select: none;
}

.wcaf__section-title::-webkit-details-marker {
	display: none;
}

.wcaf__section-title::after {
	content: "";
	position: absolute;
	right: .25em;
	top: 50%;
	width: .5em;
	height: .5em;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: translateY(-70%) rotate(45deg);
	opacity: .55;
	transition: transform .15s ease;
}

.wcaf__section[open] > .wcaf__section-title::after {
	transform: translateY(-25%) rotate(-135deg);
}

.wcaf__section-body {
	padding: 0 0 .9em;
}

/* Elenchi di voci ----------------------------------------------------- */

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

.wcaf__item-wrap {
	margin: 0;
}

.wcaf__item {
	display: flex;
	align-items: center;
	gap: .55em;
	padding: .3em 0;
	text-decoration: none;
	color: inherit;
}

.wcaf__item:hover .wcaf__label,
.wcaf__item:focus .wcaf__label {
	text-decoration: underline;
}

.wcaf__box {
	flex: 0 0 auto;
	width: 1em;
	height: 1em;
	border: 1px solid var(--wcaf-border);
	border-radius: 3px;
	position: relative;
	background: transparent;
}

.wcaf__item.is-selected .wcaf__box {
	background: currentColor;
	border-color: currentColor;
}

.wcaf__item.is-selected .wcaf__box::after {
	content: "";
	position: absolute;
	left: .3em;
	top: .1em;
	width: .25em;
	height: .5em;
	border-right: 2px solid #fff;
	border-bottom: 2px solid #fff;
	transform: rotate(45deg);
}

.wcaf__item.is-selected .wcaf__label {
	font-weight: 600;
}

.wcaf__label {
	flex: 1 1 auto;
}

.wcaf__count {
	flex: 0 0 auto;
	font-size: .8em;
	color: var(--wcaf-muted);
	font-variant-numeric: tabular-nums;
}

.wcaf__item.is-empty {
	opacity: .45;
}

/* Prezzo -------------------------------------------------------------- */

.wcaf__slider {
	position: relative;
	height: 1.6em;
	margin: .4em 0 .2em;
}

.wcaf__slider-track {
	position: absolute;
	left: 0;
	right: 0;
	top: 50%;
	height: 4px;
	margin-top: -2px;
	border-radius: 2px;
	background: var(--wcaf-border);
}

.wcaf__slider-fill {
	position: absolute;
	top: 0;
	bottom: 0;
	background: currentColor;
	border-radius: 2px;
}

.wcaf__range {
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	background: none;
	pointer-events: none;
	-webkit-appearance: none;
	appearance: none;
}

.wcaf__range:focus {
	outline: none;
}

.wcaf__range::-webkit-slider-thumb {
	pointer-events: auto;
	-webkit-appearance: none;
	appearance: none;
	width: 1.05em;
	height: 1.05em;
	border-radius: 50%;
	background: #fff;
	border: 2px solid currentColor;
	cursor: grab;
	box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}

.wcaf__range::-moz-range-thumb {
	pointer-events: auto;
	width: 1.05em;
	height: 1.05em;
	border-radius: 50%;
	background: #fff;
	border: 2px solid currentColor;
	cursor: grab;
	box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}

.wcaf__range:focus-visible::-webkit-slider-thumb {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.wcaf__range::-moz-range-track {
	background: transparent;
}

.wcaf__price-inputs {
	display: flex;
	align-items: center;
	gap: .4em;
	margin: .6em 0;
}

.wcaf__price-field {
	flex: 1 1 0;
	min-width: 0;
	margin: 0;
}

.wcaf__price-input {
	width: 100%;
	min-width: 0;
	padding: .35em .5em;
	border: 1px solid var(--wcaf-border);
	border-radius: var(--wcaf-radius);
	background: transparent;
	color: inherit;
	font-size: .95em;
}

.wcaf__price-sep,
.wcaf__currency {
	flex: 0 0 auto;
	color: var(--wcaf-muted);
	font-size: .9em;
}

/* Con JS attivo lo slider applica da solo: il pulsante serve solo in fallback. */
.wcaf__apply {
	font-size: .9em;
}

.js .wcaf__apply,
body.wcaf-has-js .wcaf__apply {
	display: none;
}

/* Stato di caricamento ------------------------------------------------ */

.wcaf.is-loading {
	pointer-events: none;
}

.wcaf__spinner {
	display: none;
	position: absolute;
	top: .5em;
	right: 0;
	width: 1.1em;
	height: 1.1em;
	border: 2px solid var(--wcaf-border);
	border-top-color: currentColor;
	border-radius: 50%;
	animation: wcaf-spin .7s linear infinite;
}

.wcaf.is-loading .wcaf__spinner {
	display: block;
}

.wcaf-updating {
	opacity: .45;
	transition: opacity .15s ease;
}

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

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

	.wcaf__section-title::after {
		transition: none;
	}
}

/* Aggancio automatico sopra la griglia: layout orizzontale, non da sidebar. */
.wcaf-auto--before_loop {
	margin-bottom: 1.5em;
	padding: 1em 1.25em;
	border: 1px solid var(--wcaf-border, rgba(0, 0, 0, .12));
	border-radius: 8px;
}

@media (min-width: 782px) {
	.wcaf-auto--before_loop .wcaf {
		display: grid;
		grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
		gap: 0 1.5em;
		align-items: start;
	}

	.wcaf-auto--before_loop .wcaf__title,
	.wcaf-auto--before_loop .wcaf__active {
		grid-column: 1 / -1;
	}

	.wcaf-auto--before_loop .wcaf__section:last-of-type {
		border-bottom: none;
	}
}

/* Fallback se il tema non definisce la classe di WordPress. */
.wcaf .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	white-space: nowrap;
}
