/**
 * AF Commerce — filter sidebar and panels.
 *
 * On desktop the sidebar is a plain column. Below 1100px the same element
 * becomes an off-canvas drawer driven by the shared overlay behaviour, which is
 * why the open state is expressed as `.is-open` on the element rather than a
 * separate markup path.
 */

.af-filters-trigger {
	display: none;
	align-items: center;
	gap: 8px;
	width: 100%;
	margin-bottom: var(--af-space-md);
}

.af-filters-trigger__count {
	display: grid;
	place-items: center;
	min-width: 22px;
	height: 22px;
	padding-inline: 6px;
	border-radius: 999px;
	background: var(--af-accent);
	color: #fff;
	font-size: 11px;
	font-weight: 700;
}

.af-filters {
	min-width: 0;
}

.af-filters__header {
	display: none;
	align-items: center;
	justify-content: space-between;
	gap: var(--af-space-md);
	padding: var(--af-space-md);
	border-bottom: 1px solid var(--af-border);
}

.af-filters__title {
	margin: 0;
	font-size: var(--af-fs-h5);
}

.af-filters__close {
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	border: 0;
	border-radius: 50%;
	background: var(--af-surface);
	color: var(--af-text);
}

.af-filters__footer {
	display: none;
	padding: var(--af-space-md);
	border-top: 1px solid var(--af-border);
	background: var(--af-background);
}

/* -------------------------------------------------------------------------
 * Active filters
 * ---------------------------------------------------------------------- */

.af-filters__active {
	padding-bottom: var(--af-space-md);
	margin-bottom: var(--af-space-md);
	border-bottom: 1px solid var(--af-border);
}

.af-filters__chips {
	display: flex;
	flex-wrap: wrap;
	gap: var(--af-space-xs);
	margin: 0 0 var(--af-space-sm);
	padding: 0;
	list-style: none;
}

.af-filters__chips .af-icon {
	width: 0.9em;
	height: 0.9em;
}

.af-filters__clear {
	color: var(--af-accent);
	font-size: var(--af-fs-caption);
	font-weight: 600;
}

/* -------------------------------------------------------------------------
 * Panels
 * ---------------------------------------------------------------------- */

.af-filter {
	padding-block: var(--af-space-md);
	border-bottom: 1px solid var(--af-border);
}

.af-filter__summary {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--af-space-sm);
	cursor: pointer;
	list-style: none;
}

.af-filter__summary::-webkit-details-marker {
	display: none;
}

.af-filter__title {
	font-size: var(--af-fs-small);
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.af-filter__summary .af-icon {
	color: var(--af-muted);
	transition: transform 0.2s ease;
}

.af-filter[open] .af-filter__summary .af-icon {
	transform: rotate(180deg);
}

.af-filter__body {
	padding-top: var(--af-space-sm);
}

.af-filter__search {
	margin-bottom: var(--af-space-sm);
	min-height: 38px;
}

.af-filter__options {
	display: grid;
	gap: 2px;
	max-height: 280px;
	margin: 0;
	padding: 0;
	overflow-y: auto;
	list-style: none;
	scrollbar-width: thin;
}

.af-filter__option[hidden] {
	display: none;
}

.af-filter__link {
	display: flex;
	align-items: center;
	gap: var(--af-space-sm);
	padding: 6px 4px;
	border-radius: var(--af-radius-sm);
	color: var(--af-text);
	font-size: var(--af-fs-small);
	text-decoration: none;
}

.af-filter__link:hover {
	background: var(--af-surface);
}

.af-filter__box {
	display: grid;
	place-items: center;
	flex: none;
	width: 18px;
	height: 18px;
	border: 1px solid var(--af-border);
	border-radius: 4px;
	background: var(--af-background);
	color: transparent;
}

.af-filter__box .af-icon {
	width: 12px;
	height: 12px;
	stroke-width: 2.4;
}

.af-filter__link.is-active .af-filter__box {
	background: var(--af-primary);
	border-color: var(--af-primary);
	color: #fff;
}

.af-filter__label {
	flex: 1 1 auto;
	min-width: 0;
}

.af-filter__count {
	flex: none;
	color: var(--af-muted);
	font-size: var(--af-fs-caption);
	font-variant-numeric: tabular-nums;
}

/* Colour swatch options. */
.af-filter--color .af-filter__options {
	display: flex;
	flex-wrap: wrap;
	gap: var(--af-space-xs);
	max-height: none;
}

.af-filter--color .af-filter__link {
	flex-direction: column;
	gap: 4px;
	padding: 4px;
	text-align: center;
}

.af-filter__swatch {
	width: 28px;
	height: 28px;
	border: 1px solid var(--af-border);
	border-radius: 50%;
	background-size: cover;
}

.af-filter--color .af-filter__link.is-active .af-filter__swatch {
	outline: 2px solid var(--af-primary);
	outline-offset: 2px;
}

.af-filter--color .af-filter__label {
	font-size: 11px;
}

/* Price. */
.af-price-filter__inputs {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: var(--af-space-sm);
	margin-bottom: var(--af-space-sm);
}

.af-price-filter__field {
	display: grid;
	gap: 4px;
	margin: 0;
	font-weight: 400;
}

.af-price-filter__label {
	color: var(--af-muted);
	font-size: var(--af-fs-caption);
}

.af-price-filter input {
	min-height: 38px;
}

.af-filters__widgets {
	padding-block: var(--af-space-md);
}

/* -------------------------------------------------------------------------
 * Off-canvas below desktop
 * ---------------------------------------------------------------------- */

@media (max-width: 1099px) {
	.af-filters-trigger {
		display: inline-flex;
		justify-content: center;
	}

	.af-filters {
		position: fixed;
		inset-block: 0;
		inset-inline-start: 0;
		z-index: 90;
		display: flex;
		flex-direction: column;
		width: min(92vw, 380px);
		background: var(--af-background);
		box-shadow: var(--af-shadow-3);
		transform: translateX(-100%);
		visibility: hidden;
		transition: transform 0.25s ease, visibility 0.25s;
	}

	.af-filters.is-open {
		transform: none;
		visibility: visible;
	}

	.af-filters__header,
	.af-filters__footer {
		display: flex;
	}

	.af-filters__active,
	.af-filters__panels,
	.af-filters__widgets {
		padding-inline: var(--af-space-md);
	}

	.af-filters__panels {
		flex: 1 1 auto;
		overflow-y: auto;
		overscroll-behavior: contain;
	}

	.af-filter__options {
		max-height: none;
	}
}

/* RTL drawers slide in from the other edge; handled in rtl.css. */
