/*
 * RF Filters - everything that lives inside the More filters panel.
 *
 * The checkbox lists, their in-list search and their show more toggle only ever
 * render in here, along with the bottom sheet itself, the accordion, the
 * pending-apply bar, and the media query that turns all three into a plain sidebar
 * from 768px up.
 */

.rf-filters .rf-panel[hidden] {
	display: none;
}

.rf-filters .rf-panel {
	position: fixed;
	inset: 0;
	z-index: var(--rf-z);
}

.rf-filters .rf-panel__scrim {
	position: absolute;
	inset: 0;
	background: rgba(15, 23, 42, 0.5);
	opacity: 0;
	transition: opacity 0.24s ease-out;
}

.rf-filters .rf-panel.is-open .rf-panel__scrim {
	opacity: 1;
}

.rf-filters .rf-panel__sheet {
	position: absolute;
	right: 0;
	bottom: 0;
	left: 0;
	display: flex;
	flex-direction: column;
	max-height: 88vh;
	max-height: 88dvh;
	border-radius: 16px 16px 0 0;
	background: var(--rf-surface);
	box-shadow: 0 -8px 40px rgba(15, 23, 42, 0.24);
	transform: translateY(100%);
	transition: transform 0.28s var(--rf-ease);
	will-change: transform;
}

.rf-filters .rf-panel.is-open .rf-panel__sheet {
	transform: translateY(0);
}

.rf-filters .rf-panel.is-dragging .rf-panel__sheet {
	transition: none;
}

.rf-filters .rf-panel__grabber {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 24px;
	padding-top: 8px;
	touch-action: none;
	cursor: grab;
}

.rf-filters .rf-panel__grabber span {
	width: 40px;
	height: 4px;
	border-radius: 999px;
	background: #d4d6db;
}

.rf-filters .rf-panel__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--rf-gap);
	padding: 6px 16px 12px;
	border-bottom: 1px solid var(--rf-line);
}

.rf-filters .rf-panel__title {
	margin: 0;
	color: var(--rf-ink);
	font-size: 18px;
	font-weight: 700;
}

.rf-filters .rf-panel__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--rf-tap);
	height: var(--rf-tap);
	margin-right: -10px;
	border: 0;
	border-radius: 999px;
	background: none;
	color: var(--rf-muted);
	cursor: pointer;
}

.rf-filters .rf-panel__close:hover {
	background: var(--rf-surface-2);
	color: var(--rf-text);
}

.rf-filters .rf-panel__body {
	flex: 1 1 auto;
	padding: 4px 16px 16px;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
}

.rf-filters .rf-panel__foot {
	display: flex;
	gap: 10px;
	padding: 12px 16px;
	padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
	border-top: 1px solid var(--rf-line);
	background: var(--rf-surface);
}

.rf-filters .rf-panel__foot .jet-smart-filters-apply-button,
.rf-filters .rf-panel__foot .apply-filters {
	flex: 1 1 auto;
	display: flex;
}

.rf-filters .rf-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 1 1 auto;
	min-height: var(--rf-tap);
	padding: 0 18px;
	border-radius: var(--rf-radius);
	font-size: 16px;
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.15s ease-out, border-color 0.15s ease-out;
}

.rf-filters .rf-btn--ghost {
	flex: 0 0 auto;
	min-width: 96px;
	border: 1px solid var(--rf-line);
	background: var(--rf-surface);
	color: var(--rf-text);
}

.rf-filters .rf-btn--ghost:hover,
.rf-filters .rf-btn--ghost:focus,
.rf-filters .rf-btn--ghost:active {
	background: var(--rf-surface);
	color: var(--rf-text);
}

.rf-filters .rf-btn--ghost:hover {
	border-color: var(--rf-text);
}

.rf-filters .rf-btn--primary {
	width: 100%;
	border: 1px solid var(--rf-primary);
	background: var(--rf-primary);
	color: #fff;
}

/*
 * These three states have to be spelled out. The reset in rf-filters.css strips the
 * background off any focused or pressed button at (0,2,1) to stop the theme turning
 * it magenta, and the base rule above is only (0,2,0) - so without this the Apply
 * button goes transparent the moment it is tapped.
 */
.rf-filters .rf-btn--primary:focus,
.rf-filters .rf-btn--primary:active {
	background: var(--rf-primary);
	color: #fff;
}

.rf-filters .rf-btn--primary:hover {
	background: #1247bb;
	border-color: #1247bb;
	color: #fff;
}

.rf-filters .rf-btn--primary[disabled],
.rf-filters .rf-btn--primary.jsf_disabled {
	opacity: 0.45;
	cursor: default;
}

/* ----------------------------------------------------------------- accordion */

.rf-filters .rf-acc {
	border-bottom: 1px solid var(--rf-line);
}

.rf-filters .rf-acc__heading {
	margin: 0;
	font-size: inherit;
	font-weight: inherit;
}

.rf-filters .rf-acc__title {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	min-height: 52px;
	padding: 8px 0;
	border: 0;
	background: none;
	color: var(--rf-text);
	font-size: 16px;
	font-weight: 600;
	text-align: left;
	cursor: pointer;
}

/* (0,3,1), so it beats the neutralising reset in rf-filters.css. */
.rf-filters .rf-acc__title:hover {
	color: var(--rf-primary);
}

.rf-filters .rf-acc__label {
	flex: 1 1 auto;
}

.rf-filters .rf-acc__count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 20px;
	height: 20px;
	padding: 0 6px;
	border-radius: 999px;
	background: var(--rf-primary);
	color: #fff;
	font-size: 12px;
	font-weight: 700;
}

.rf-filters .rf-acc__title .rf-icon--chevron {
	color: var(--rf-muted);
	transition: transform 0.2s ease-out;
}

.rf-filters .rf-acc__title[aria-expanded="true"] .rf-icon--chevron {
	transform: rotate(180deg);
}

.rf-filters .rf-acc__panel[hidden] {
	display: none;
}

.rf-filters .rf-acc__panel {
	padding: 0 0 14px;
}

/* ------------------------------------------------------------- pending apply */

.rf-filters .rf-applybar[hidden] {
	display: none;
}

.rf-filters .rf-applybar {
	position: fixed;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: calc(var(--rf-z) - 1);
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 16px;
	padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
	border-top: 1px solid var(--rf-line);
	background: var(--rf-surface);
	box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.12);
	transform: translateY(100%);
	transition: transform 0.24s var(--rf-ease);
}

.rf-filters .rf-applybar.is-visible {
	transform: translateY(0);
}

.rf-filters .rf-applybar__text {
	flex: 1 1 auto;
	color: var(--rf-muted);
	font-size: 14px;
}

.rf-filters .rf-applybar .jet-smart-filters-apply-button {
	flex: 0 0 auto;
}

.rf-filters .rf-applybar .rf-btn--primary {
	width: auto;
	min-width: 140px;
}

/* ------------------------------------------------- 768px and up: no sheet at all */

/*
 * Every selector in here carries the same `.rf-filters` prefix as the rules above.
 * That is not style: a media query does not add specificity, so a bare
 * `.rf-panel__head` here would quietly lose to `.rf-filters .rf-panel__head` above
 * and the panel header would reappear on a laptop.
 */
@media (min-width: 768px) {

	.rf-filters .rf-filters__actions {
		display: none;
	}

	.rf-filters .rf-panel,
	.rf-filters .rf-panel[hidden] {
		position: static;
		display: block;
		margin-top: 12px;
	}

	.rf-filters .rf-panel__scrim,
	.rf-filters .rf-panel__grabber,
	.rf-filters .rf-panel__close {
		display: none;
	}

	.rf-filters .rf-panel__sheet {
		position: static;
		max-height: none;
		border-radius: 0;
		box-shadow: none;
		transform: none;
		transition: none;
	}

	/* Nothing is behind a button here, so "More filters" would be a lie, and the
	   result count belongs beside the results rather than in the sidebar. */
	.rf-filters .rf-panel__head,
	.rf-filters .rf-filters__meta {
		display: none;
	}

	.rf-filters .rf-panel__body {
		padding: 0;
		overflow: visible;
	}

	/* One Apply per screen. In a sidebar the bar below is always in reach, so the
	   panel's own footer would only be a second copy of it. */
	.rf-filters .rf-panel__foot {
		display: none;
	}

	.rf-filters .rf-applybar,
	.rf-filters .rf-applybar[hidden] {
		position: sticky;
		display: flex;
		padding-left: 0;
		padding-right: 0;
		padding-bottom: 12px;
		box-shadow: none;
		transform: none;
	}
}

@media (prefers-reduced-motion: reduce) {

	.rf-filters .rf-panel__sheet,
	.rf-filters .rf-panel__scrim,
	.rf-filters .rf-applybar,
	.rf-filters .rf-acc__title .rf-icon--chevron,
	.rf-filters .rf-group--chips .jet-checkboxes-list__button {
		transition: none;
	}
}
