/*
 * Flex Product Filters. Scoped to .fpf; fonts inherit from the theme.
 * Author: Faran Waseem
 */
.fpf {
	--fpf-accent: #C8102E;
	--fpf-text: inherit;
	--fpf-border: rgba(0, 0, 0, .14);
	--fpf-bg: #fff;
	--fpf-muted: rgba(0, 0, 0, .58);
	--fpf-radius: 8px;
	box-sizing: border-box;
	width: 100%;
	margin: 0 0 1.25em;
	font-size: 14px;
	line-height: 1.4;
	clear: both;
	position: relative;
	z-index: 20;
}

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

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

.fpf .fpf-form { margin: 0; }
.fpf .fpf-title { font-weight: 700; font-size: 1.1em; margin: 0 0 10px; }

.fpf .fpf-controls {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
}

/* Group buttons (summary) ------------------------------------------------- */
.fpf details.fpf-group { position: relative; margin: 0; }
.fpf .fpf-summary {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 42px;
	padding: 0 14px;
	border: 1px solid var(--fpf-border);
	border-radius: var(--fpf-radius);
	background: var(--fpf-bg);
	color: var(--fpf-text);
	font-weight: 600;
	cursor: pointer;
	list-style: none;
	user-select: none;
	transition: border-color .15s;
}
.fpf .fpf-summary::-webkit-details-marker { display: none; }
.fpf .fpf-summary::marker { content: ""; }
.fpf .fpf-summary:hover { border-color: rgba(0, 0, 0, .35); }
.fpf .fpf-summary:focus-visible { outline: 2px solid var(--fpf-accent); outline-offset: 2px; }
.fpf details[open] > .fpf-summary { border-color: var(--fpf-accent); }
.fpf .fpf-sum-val { color: var(--fpf-accent); font-weight: 600; white-space: nowrap; }
.fpf .fpf-sum-val:empty { display: none; }
.fpf .fpf-chev { flex: none; display: block; width: 12px; height: 12px; overflow: visible; transition: transform .15s; opacity: .7; }
.fpf details[open] .fpf-chev { transform: rotate(180deg); }

.fpf .fpf-panel {
	background: var(--fpf-bg);
	color: var(--fpf-text);
}
.fpf--bar .fpf-panel {
	position: absolute;
	inset-inline-start: 0;
	top: calc(100% + 6px);
	min-width: 260px;
	max-height: 360px;
	overflow: auto;
	padding: 14px;
	border: 1px solid var(--fpf-border);
	border-radius: var(--fpf-radius);
	box-shadow: 0 12px 32px -12px rgba(0, 0, 0, .28);
	z-index: 50;
}
.fpf--bar .fpf-group--price .fpf-panel { min-width: 300px; }

/* Categories ------------------------------------------------------------- */
.fpf .fpf-cats { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 2px; }
.fpf .fpf-check {
	position: relative;
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 7px 6px 7px calc(6px + var(--fpf-depth, 0) * 18px);
	border-radius: 6px;
	cursor: pointer;
	font-weight: 400;
	margin: 0;
}
.fpf .fpf-check:hover { background: rgba(0, 0, 0, .04); }
.fpf .fpf-check input {
	position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0;
}
.fpf .fpf-box {
	flex: none;
	width: 18px; height: 18px;
	border: 1.5px solid rgba(0, 0, 0, .4);
	border-radius: 4px;
	display: inline-grid;
	place-items: center;
	background: #fff;
	transition: background .12s, border-color .12s;
}
.fpf .fpf-check input:checked + .fpf-box { background: var(--fpf-accent); border-color: var(--fpf-accent); }
.fpf .fpf-check input:checked + .fpf-box::after {
	content: "";
	width: 5px; height: 9px;
	border: solid #fff; border-width: 0 2px 2px 0;
	transform: translateY(-1px) rotate(45deg);
}
.fpf .fpf-check input:focus-visible + .fpf-box { outline: 2px solid var(--fpf-accent); outline-offset: 2px; }
.fpf .fpf-check-label { flex: 1; }
.fpf .fpf-count {
	color: var(--fpf-muted);
	font-size: .86em;
	font-variant-numeric: tabular-nums;
}

/* Price -------------------------------------------------------------------- */
.fpf .fpf-range { position: relative; height: 28px; margin: 4px 9px 12px; }
.fpf .fpf-track {
	position: absolute; left: 0; right: 0; top: 50%;
	height: 4px; margin-top: -2px; border-radius: 4px;
	background: rgba(0, 0, 0, .12);
}
.fpf .fpf-fill { position: absolute; top: 0; bottom: 0; background: var(--fpf-accent); border-radius: 4px; }
.fpf .fpf-range input[type="range"] {
	position: absolute; left: -9px; right: -9px; top: 0;
	width: calc(100% + 18px); height: 28px;
	margin: 0; padding: 0;
	background: none; border: 0;
	pointer-events: none;
	-webkit-appearance: none; appearance: none;
}
.fpf .fpf-range input[type="range"]::-webkit-slider-runnable-track { background: none; border: 0; height: 28px; }
.fpf .fpf-range input[type="range"]::-moz-range-track { background: none; border: 0; }
.fpf .fpf-range input[type="range"]::-webkit-slider-thumb {
	-webkit-appearance: none; appearance: none;
	pointer-events: auto;
	width: 20px; height: 20px; margin-top: 4px;
	border-radius: 50%;
	background: #fff;
	border: 2px solid var(--fpf-accent);
	box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
	cursor: grab;
}
.fpf .fpf-range input[type="range"]::-moz-range-thumb {
	pointer-events: auto;
	width: 18px; height: 18px;
	border-radius: 50%;
	background: #fff;
	border: 2px solid var(--fpf-accent);
	box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
	cursor: grab;
}
.fpf .fpf-range input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--fpf-accent); outline-offset: 2px; }
.fpf .fpf-range input[type="range"]:focus { outline: none; }

.fpf .fpf-price-inputs { display: flex; align-items: center; gap: 8px; }
.fpf .fpf-price-inputs label {
	flex: 1; display: flex; align-items: center; gap: 4px;
	border: 1px solid var(--fpf-border); border-radius: 6px;
	padding: 0 8px; margin: 0; background: #fff; min-width: 0;
}
.fpf .fpf-price-inputs label:focus-within { border-color: var(--fpf-accent); }
.fpf .fpf-cur { color: var(--fpf-muted); }
.fpf .fpf-price-inputs input {
	width: 100%; min-width: 0; height: 38px;
	border: 0 !important; background: none !important; box-shadow: none !important;
	padding: 0 !important; margin: 0;
	font: inherit; color: inherit;
	-moz-appearance: textfield;
}
.fpf .fpf-price-inputs input:focus { outline: none; }
.fpf .fpf-price-inputs input::-webkit-outer-spin-button,
.fpf .fpf-price-inputs input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.fpf .fpf-dash { color: var(--fpf-muted); }

/* Sort ------------------------------------------------------------------ */
.fpf .fpf-sort {
	display: inline-flex; align-items: center; gap: 8px;
	margin: 0 0 0 auto;
	font-weight: 400;
}
.fpf .fpf-sort-label { color: var(--fpf-muted); white-space: nowrap; }
.fpf .fpf-select { position: relative; display: inline-block; }
.fpf .fpf-select::after {
	content: "";
	position: absolute; right: 14px; top: 50%;
	width: 7px; height: 7px; margin-top: -6px;
	border: solid currentColor; border-width: 0 1.6px 1.6px 0;
	transform: rotate(45deg); opacity: .7; pointer-events: none;
}
.fpf .fpf-select select {
	-webkit-appearance: none; appearance: none;
	min-height: 42px; margin: 0;
	padding: 0 38px 0 14px;
	border: 1px solid var(--fpf-border);
	border-radius: var(--fpf-radius);
	background: var(--fpf-bg);
	color: inherit; font: inherit; font-weight: 600;
	cursor: pointer;
	max-width: 100%;
}
.fpf .fpf-select select:focus-visible { outline: 2px solid var(--fpf-accent); outline-offset: 2px; }

/* Apply (no-JS only) -------------------------------------------------- */
.fpf .fpf-apply {
	min-height: 42px; padding: 0 18px;
	border: 0; border-radius: var(--fpf-radius);
	background: var(--fpf-accent); color: #fff;
	font: inherit; font-weight: 700; cursor: pointer;
}
.fpf.fpf-ready .fpf-actions { display: none; }

/* Chips ------------------------------------------------------------------ */
.fpf .fpf-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.fpf .fpf-chips[hidden] { display: none; }
.fpf .fpf-chip {
	display: inline-flex; align-items: center; gap: 6px;
	padding: 5px 10px 5px 12px;
	border-radius: 999px;
	background: color-mix(in srgb, var(--fpf-accent) 10%, #fff);
	color: inherit;
	text-decoration: none !important;
	font-size: .92em; font-weight: 600;
	border: 1px solid color-mix(in srgb, var(--fpf-accent) 30%, transparent);
}
.fpf .fpf-chip:hover { border-color: var(--fpf-accent); }
.fpf .fpf-x { font-size: 1.2em; line-height: 1; opacity: .7; }
.fpf .fpf-clear { color: var(--fpf-accent); font-weight: 600; font-size: .92em; text-decoration: underline; }

/* Mobile toggle ---------------------------------------------------------- */
.fpf .fpf-toggle {
	display: none;
	align-items: center; gap: 8px;
	min-height: 44px; padding: 0 16px;
	border: 1px solid var(--fpf-border); border-radius: var(--fpf-radius);
	background: var(--fpf-bg); color: inherit;
	font: inherit; font-weight: 700; cursor: pointer;
}
.fpf .fpf-badge {
	display: inline-grid; place-items: center;
	min-width: 20px; height: 20px; padding: 0 6px;
	border-radius: 999px; background: var(--fpf-accent); color: #fff;
	font-size: 12px;
}

/* Sidebar layout ----------------------------------------------------------- */
.fpf--sidebar .fpf-controls { flex-direction: column; align-items: stretch; gap: 0; }
.fpf--sidebar details.fpf-group { border-bottom: 1px solid var(--fpf-border); padding: 4px 0 12px; margin-bottom: 8px; }
.fpf--sidebar .fpf-summary { border: 0; padding: 0; min-height: 40px; width: 100%; justify-content: flex-start; }
.fpf--sidebar .fpf-summary .fpf-chev { margin-left: auto; }
.fpf--sidebar .fpf-sort { margin: 8px 0 0; flex-direction: column; align-items: stretch; gap: 6px; }
.fpf--sidebar .fpf-select, .fpf--sidebar .fpf-select select { width: 100%; }

/* Loading state on the product listing ---------------------------------- */
.fpf-loading { position: relative; }
.fpf-loading ul.products, .fpf-loading .products, .fpf-loading .woocommerce-pagination {
	opacity: .45; transition: opacity .15s; pointer-events: none;
}

/* Phones ------------------------------------------------------------------ */
@media (max-width: 767px) {
	.fpf .fpf-toggle { display: inline-flex; }
	.fpf.fpf-ready .fpf-form { display: none; margin-top: 10px; }
	.fpf.fpf-ready.is-open .fpf-form { display: block; }
	.fpf .fpf-controls { flex-direction: column; align-items: stretch; }
	.fpf details.fpf-group .fpf-summary { width: 100%; justify-content: flex-start; }
	.fpf details.fpf-group .fpf-chev { margin-left: auto; }
	.fpf--bar .fpf-panel { position: static; min-width: 0; box-shadow: none; margin-top: 6px; max-height: none; }
	.fpf .fpf-sort { margin: 0; flex-direction: column; align-items: stretch; gap: 6px; }
	.fpf .fpf-select, .fpf .fpf-select select { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
	.fpf *, .fpf-loading * { transition: none !important; }
}
