/*
 * Inventory filters.
 *
 * Deliberately quiet: it borrows the page's own font and inherits colour, and
 * every colour is a variable the Elementor controls can set, so it sits inside
 * the existing design instead of fighting it.
 *
 * On a phone the panel is a drawer behind a button, because a tall stack of
 * filters above the machines pushes the machines off the screen.
 */

.spsif {
	--spsif-accent: #c8102e;
	--spsif-text: #1d1d1f;
	--spsif-muted: #6b6b70;
	--spsif-bg: #ffffff;
	--spsif-border: #dcdce0;
	--spsif-radius: 6px;

	font-family: inherit;
	color: var(--spsif-text);
	margin: 0 0 24px;
}

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

/* The button that opens the drawer. Hidden on wide screens. */
.spsif__open {
	display: none;
	align-items: center;
	gap: 8px;
	width: 100%;
	padding: 14px 16px;
	font: inherit;
	font-weight: 600;
	color: #fff;
	background: var(--spsif-accent);
	border: 0;
	border-radius: var(--spsif-radius);
	cursor: pointer;
}

.spsif__badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	font-size: 13px;
	color: var(--spsif-accent);
	background: #fff;
	border-radius: 11px;
}

.spsif__panel {
	background: var(--spsif-bg);
	border: 1px solid var(--spsif-border);
	border-radius: var(--spsif-radius);
	padding: 20px;
}

.spsif__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 14px;
}

.spsif__title {
	margin: 0;
	font-size: 20px;
	line-height: 1.2;
}

.spsif__close {
	display: none;
	/* At least 44px square, so it can be hit with a thumb. */
	width: 46px;
	height: 46px;
	font-size: 30px;
	line-height: 1;
	color: var(--spsif-muted);
	background: none;
	border: 0;
	cursor: pointer;
	padding: 0;
}

/* Chosen filters, as removable chips. */
.spsif__active {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
	padding-bottom: 14px;
	margin-bottom: 14px;
	border-bottom: 1px solid var(--spsif-border);
}

.spsif__chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 5px 10px;
	font-size: 14px;
	text-decoration: none;
	color: var(--spsif-text);
	background: #f3f3f5;
	border: 1px solid var(--spsif-border);
	border-radius: 999px;
}

.spsif__chip:hover,
.spsif__chip:focus {
	border-color: var(--spsif-accent);
	color: var(--spsif-accent);
}

.spsif__clear {
	font-size: 14px;
	color: var(--spsif-muted);
}

.spsif__group {
	padding-bottom: 16px;
	margin-bottom: 16px;
	border-bottom: 1px solid var(--spsif-border);
}

.spsif__group:last-of-type {
	border-bottom: 0;
}

.spsif__group-title {
	margin: 0 0 10px;
	font-size: 15px;
	font-weight: 700;
	letter-spacing: .01em;
}

.spsif__hint {
	margin: 0 0 10px;
	font-size: 13px;
	color: var(--spsif-muted);
}

.spsif__list {
	list-style: none;
	margin: 0;
	padding: 0;
	max-height: 260px;
	overflow-y: auto;
}

/* Only shorten a long list when JavaScript is there to lengthen it again.
   Without this, a visitor with JavaScript off saw 8 of 21 models and a
   "Show all" button that did nothing. */
.spsif--js .spsif__item.is-hidden {
	display: none;
}

.spsif:not(.spsif--js) .spsif__more {
	display: none;
}

.spsif__check {
	display: flex;
	align-items: center;
	gap: 9px;
	padding: 6px 0;
	font-size: 15px;
	cursor: pointer;
	/* Comfortable to hit with a thumb. */
	min-height: 34px;
}

.spsif__check input {
	width: 18px;
	height: 18px;
	flex: 0 0 18px;
	accent-color: var(--spsif-accent);
	margin: 0;
}

.spsif__check em {
	font-style: normal;
	color: var(--spsif-muted);
}

.spsif__more {
	margin-top: 6px;
	padding: 0;
	font: inherit;
	font-size: 14px;
	color: var(--spsif-accent);
	background: none;
	border: 0;
	cursor: pointer;
	text-decoration: underline;
}

.spsif__range {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
}

.spsif__range label {
	display: flex;
	flex-direction: column;
	gap: 4px;
	font-size: 13px;
	color: var(--spsif-muted);
}

.spsif__range input,
.spsif__range select,
.spsif__sort {
	width: 100%;
	padding: 9px 10px;
	font: inherit;
	font-size: 15px;
	color: var(--spsif-text);
	background: #fff;
	border: 1px solid var(--spsif-border);
	border-radius: var(--spsif-radius);
}

.spsif__actions {
	display: flex;
	align-items: center;
	gap: 14px;
	padding-top: 4px;
}

.spsif__submit {
	flex: 1 1 auto;
	padding: 12px 18px;
	font: inherit;
	font-weight: 600;
	color: #fff;
	background: var(--spsif-accent);
	border: 0;
	border-radius: var(--spsif-radius);
	cursor: pointer;
}

.spsif__submit:hover {
	filter: brightness(.93);
}

.spsif__reset {
	font-size: 14px;
	color: var(--spsif-muted);
	white-space: nowrap;
}

.spsif__summary {
	margin: 0 0 16px;
	font-size: 15px;
	color: var(--spsif-muted);
}

.spsif__summary--empty {
	padding: 16px;
	color: var(--spsif-text);
	background: #f8f8fa;
	border: 1px solid var(--spsif-border);
	border-radius: var(--spsif-radius);
}

/* The panel becomes a drawer behind a button in two cases.
 *
 * NARROW SCREENS (phone, small tablet) — a tall stack of filters on a narrow
 * screen pushes every machine off the bottom.
 *
 * SHORT SCREENS — the same thing happens on a wide but short screen. On a
 * 1366x768 laptop, going live on 17 Nov 2026 moved the first row of machines
 * below the fold: five whole cards showed on the first screen before the panel
 * existed, and none did after. The screen is wide enough for the panel; it is
 * not tall enough for the panel AND a machine. 1440x900 and 1920x1080 are, so
 * they keep the open panel.
 *
 * The cutoff is viewport height, not width, because that is the thing that
 * actually runs out. A desktop browser window dragged short gets the drawer
 * too, which is correct for the same reason.
 */
@media (max-width: 880px), (max-height: 820px) {
	.spsif__open {
		display: flex;
		justify-content: center;
	}

	/* The close button only means anything once the panel can be closed. */
	.spsif--js .spsif__close {
		display: block;
	}

	/* The drawer only hides itself once JavaScript has confirmed it can open
	   it again. Without this, a phone with JavaScript turned off showed the
	   button and nothing behind it, and the filters could not be reached
	   at all. */
	.spsif--js .spsif__panel {
		position: fixed;
		inset: 0;
		z-index: 99999;
		border: 0;
		border-radius: 0;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
		padding: 18px 16px 90px;
		display: none;
	}

	.spsif--js.is-open .spsif__panel {
		display: block;
	}

	/* No JavaScript: no button, panel simply shown. */
	.spsif:not(.spsif--js) .spsif__open {
		display: none;
	}

	.spsif--js.is-open .spsif__actions {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		padding: 12px 16px;
		background: var(--spsif-bg);
		border-top: 1px solid var(--spsif-border);
	}

	.spsif__list {
		max-height: none;
	}

	/* Every pixel above the grid costs a pixel of machine on a short screen,
	   so the button sits closer to the cards than the open panel does. */
	.spsif {
		margin-bottom: 14px;
	}
}

/* Headings that open and close.
 *
 * Two earlier attempts failed the same way: with every list open at once the
 * panel was 554-1,259px tall and no machine appeared on the first screen, and
 * capping its height just hid the button inside a scrollbar. Showing all the
 * filters at once is the thing that was wrong, not how it was laid out.
 *
 * Closed, each heading is one line, so the whole panel is a short bar and the
 * machines sit right under it. These are native details elements, so they open
 * and close with JavaScript turned off.
 */
.spsif__group[data-spsif-group] {
	padding: 0;
	margin: 0;
	border-bottom: 1px solid var(--spsif-border);
}

.spsif__group-title {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin: 0;
	padding: 13px 2px;
	font-size: 15px;
	font-weight: 700;
	cursor: pointer;
	list-style: none;
	/* Comfortable to hit with a thumb. */
	min-height: 46px;
}

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

.spsif__group-title::after {
	content: "";
	width: 9px;
	height: 9px;
	border-right: 2px solid var(--spsif-muted);
	border-bottom: 2px solid var(--spsif-muted);
	transform: rotate(45deg) translate(-2px, -2px);
	flex: 0 0 auto;
}

.spsif__group[open] > .spsif__group-title::after {
	transform: rotate(-135deg) translate(-2px, -2px);
}

.spsif__group-title--plain {
	cursor: default;
	min-height: 0;
	padding: 0 0 8px;
}

.spsif__group-title--plain::after {
	display: none;
}

.spsif__chosen {
	margin-left: auto;
	margin-right: 4px;
	font-size: 13px;
	font-weight: 400;
	color: var(--spsif-accent);
}

.spsif__group-body {
	padding: 0 2px 14px;
}

.spsif__group--flat {
	padding: 14px 2px;
	margin: 0;
	border-bottom: 1px solid var(--spsif-border);
}

/* Desktop: the headings sit side by side, so the bar is one or two rows. */
@media (min-width: 881px) {
	.spsif__form {
		display: grid;
		grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
		gap: 0 26px;
		align-items: start;
	}

	.spsif__actions {
		grid-column: 1 / -1;
		padding-top: 14px;
		border-top: 1px solid var(--spsif-border);
	}

	.spsif__submit {
		flex: 0 0 auto;
		min-width: 200px;
	}

	.spsif__range {
		grid-template-columns: 1fr;
		gap: 8px;
	}

	/* An opened list is tall enough to be useful without being endless, and
	   it never sits inside another scrolling box. */
	.spsif__list {
		max-height: 230px;
	}
}

@media (prefers-reduced-motion: no-preference) {
	.spsif__chip,
	.spsif__submit {
		transition: all .15s ease;
	}
}

/* A heading holding a filter is marked, not opened.
 *
 * Opening it automatically was what pushed every machine off the first screen
 * the moment anybody filtered — on a 1440x900 laptop the first machine landed
 * at 1,064px. The chips along the top already say what is applied, and the
 * count beside the heading says where, so opening it as well told the visitor
 * nothing and cost them the whole view.
 */
.spsif__group.has-chosen > .spsif__group-title {
	color: var(--spsif-accent);
}

.spsif__group.has-chosen > .spsif__group-title::after {
	border-color: var(--spsif-accent);
}

/* Desktop: trim the panel further. The page already carries its own heading,
   so the panel's title is repetition that costs vertical space. */
@media (min-width: 881px) {
	.spsif__head {
		margin-bottom: 8px;
	}

	.spsif__title {
		font-size: 16px;
	}

	.spsif__group-title {
		padding: 10px 2px;
		min-height: 40px;
	}

	.spsif__active {
		padding-bottom: 10px;
		margin-bottom: 10px;
	}

	.spsif__panel {
		padding: 14px 18px;
	}

	.spsif__actions {
		padding-top: 10px;
	}

	.spsif__submit {
		padding: 10px 18px;
	}
}

/* Keep the button's space reserved on a phone, so the page does not move
   while it loads. */
@media (max-width: 880px) {
	.spsif__open {
		min-height: 52px;
	}

	.spsif {
		min-height: 52px;
	}
}
