/*
 * Topmedicus filters.
 *
 * One DOM structure, two presentations: a static sidebar from 1025px up, a
 * bottom sheet below it. Nothing is duplicated, so a control can never be
 * checked in one place and stuck in another.
 *
 * Tokens mirror the child theme so the panel matches the rest of the shop.
 */

/*
 * Tokens live on :root, not on .tmf.
 *
 * Below 1025px the JS reparents the panel, scrim and trigger to <body> so
 * position:fixed cannot be trapped by an Elementor ancestor. Anything scoped to
 * .tmf would stop inheriting the moment that happens — which silently turns
 * `background: var(--tmf-white)` into an invalid declaration and leaves a
 * fully transparent sheet. Global tokens survive the move.
 */
:root {
	--tmf-ink: #2d3134;
	--tmf-muted: #767b80;
	--tmf-line: #eceef0;
	--tmf-sage: #f2f5f3;
	--tmf-white: #fff;
	--tmf-radius: 12px;
	--tmf-sans: 'Jost', sans-serif;
	--tmf-serif: 'Playfair Display', serif;
}

/* Typography is applied to each reparentable root, not inherited from .tmf. */
.tmf,
.tmf__panel,
.tmf__fab {
	font-family: var(--tmf-sans, sans-serif);
	color: var(--tmf-ink, #2d3134);
}

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

/* ---------- panel shell ---------- */

.tmf__panel {
	/* Hard fallback: this must never resolve to transparent. */
	background: #fff;
	background: var(--tmf-white, #fff);
	border-radius: var(--tmf-radius, 12px);
	padding: 26px;
	box-shadow: 0 10px 30px rgba(0, 0, 0, .03);
}

.tmf__head,
.tmf__foot {
	display: none; /* sheet-only chrome */
}

/* ---------- active chips ---------- */

.tmf__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 22px;
}

.tmf__chip {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	padding: 5px 11px;
	border: 1px solid var(--tmf-line);
	border-radius: 20px;
	background: #fdf8f5;
	font-size: 12px;
	line-height: 1.4;
	color: var(--tmf-ink);
	text-decoration: none;
	transition: border-color .18s ease, background .18s ease;
}

.tmf__chip:hover {
	border-color: var(--tmf-ink);
	color: var(--tmf-ink);
}

.tmf__chip svg {
	flex: 0 0 auto;
	color: var(--tmf-muted);
}

.tmf__chip--clear {
	background: transparent;
	border-style: dashed;
	color: var(--tmf-muted);
}

/* ---------- groups ---------- */

.tmf__group {
	padding-bottom: 18px;
	margin-bottom: 22px;
	border-bottom: 1px solid var(--tmf-line);
}

.tmf__group:last-child {
	margin-bottom: 0;
	padding-bottom: 0;
	border-bottom: none;
}

.tmf__title {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	width: 100%;
	padding: 0;
	margin: 0 0 13px;
	border: 0;
	background: none;
	cursor: pointer;
	font-family: var(--tmf-serif);
	font-size: 18px;
	font-weight: 500;
	line-height: 1.3;
	color: var(--tmf-ink);
	text-align: left;
}

.tmf__chevron {
	flex: 0 0 auto;
	color: var(--tmf-muted);
	transition: transform .2s ease;
}

.tmf__title[aria-expanded="false"] .tmf__chevron {
	transform: rotate(-90deg);
}

.tmf__title[aria-expanded="false"] + .tmf__list,
.tmf__title[aria-expanded="false"] + .tmf__range {
	display: none;
}

.tmf__title[aria-expanded="false"] ~ .tmf__more {
	display: none;
}

/* ---------- options ---------- */

.tmf__opt {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 9px;
	font-size: 14px;
	line-height: 1.45;
	color: var(--tmf-muted);
	cursor: pointer;
	user-select: none;
	transition: color .15s ease;
}

.tmf__opt:last-child {
	margin-bottom: 0;
}

.tmf__opt:hover {
	color: var(--tmf-ink);
}

.tmf__opt input {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
	pointer-events: none;
}

.tmf__box {
	flex: 0 0 auto;
	width: 16px;
	height: 16px;
	border: 1px solid #d7ded9;
	border-radius: 4px;
	background: #fff;
	background: var(--tmf-white, #fff);
	position: relative;
	transition: background .15s ease, border-color .15s ease;
}

.tmf__box::after {
	content: "";
	position: absolute;
	top: 1px;
	left: 5px;
	width: 4px;
	height: 8px;
	border: solid var(--tmf-white);
	border-width: 0 2px 2px 0;
	transform: rotate(45deg) scale(0);
	transition: transform .15s ease;
}

.tmf__opt:hover .tmf__box {
	border-color: var(--tmf-ink);
}

.tmf__opt input:checked ~ .tmf__box {
	background: #2d3134;
	background: var(--tmf-ink, #2d3134);
	border-color: var(--tmf-ink, #2d3134);
}

.tmf__opt input:checked ~ .tmf__box::after {
	transform: rotate(45deg) scale(1);
}

.tmf__opt input:focus-visible ~ .tmf__box {
	outline: 2px solid #b8c7be;
	outline-offset: 2px;
}

.tmf__name {
	flex: 1 1 auto;
	min-width: 0;
}

.tmf__count {
	flex: 0 0 auto;
	padding: 2px 8px;
	border-radius: 10px;
	background: #f2f5f3;
	background: var(--tmf-sage, #f2f5f3);
	font-size: 11px;
	line-height: 1.5;
	color: var(--tmf-muted);
}

/*
 * Unavailable in the current selection. Made unmistakable rather than merely
 * faded — an option that looks live but ignores taps reads as a broken filter.
 */
.tmf__opt.is-disabled {
	opacity: .45;
	cursor: not-allowed;
	text-decoration: line-through;
	text-decoration-color: rgba(118, 123, 128, .5);
}

.tmf__opt.is-disabled .tmf__box {
	background: #f4f6f5;
	border-color: #e4e8e6;
}

.tmf__opt.is-disabled:hover {
	color: var(--tmf-muted);
}

.tmf__opt.is-disabled:hover .tmf__box {
	border-color: #d7ded9;
}

/* collapsed overflow */

.tmf__list.is-collapsed .tmf__opt[data-overflow] {
	display: none;
}

.tmf__more {
	margin-top: 11px;
	padding: 0;
	border: 0;
	background: none;
	cursor: pointer;
	font-family: var(--tmf-sans);
	font-size: 13px;
	color: var(--tmf-muted);
	text-decoration: underline;
	text-underline-offset: 3px;
}

.tmf__more:hover {
	color: var(--tmf-ink);
}

/* ---------- price range ---------- */

.tmf__slider {
	position: relative;
	height: 26px;
	margin: 4px 0 2px;
}

.tmf__track {
	position: absolute;
	top: 11px;
	left: 0;
	right: 0;
	height: 3px;
	border-radius: 3px;
	background: var(--tmf-line);
}

.tmf__track-fill {
	position: absolute;
	top: 0;
	height: 100%;
	border-radius: 3px;
	background: var(--tmf-ink);
}

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

.tmf__thumb::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 15px;
	height: 15px;
	border: 2px solid var(--tmf-ink);
	border-radius: 50%;
	background: var(--tmf-white);
	cursor: grab;
	pointer-events: auto;
}

.tmf__thumb::-moz-range-thumb {
	width: 15px;
	height: 15px;
	border: 2px solid var(--tmf-ink);
	border-radius: 50%;
	background: var(--tmf-white);
	cursor: grab;
	pointer-events: auto;
}

.tmf__thumb::-moz-range-track {
	background: none;
}

.tmf__inputs {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: 8px;
}

.tmf__input {
	flex: 1 1 0;
	min-width: 0;
}

.tmf__input input {
	width: 100%;
	padding: 7px 10px;
	border: 1px solid var(--tmf-line);
	border-radius: 8px;
	background: var(--tmf-white);
	font-family: var(--tmf-sans);
	font-size: 13px;
	color: var(--tmf-ink);
}

.tmf__input input:focus {
	outline: none;
	border-color: #b8c7be;
}

.tmf__dash {
	flex: 0 0 auto;
	color: var(--tmf-muted);
}

/* ---------- mobile trigger ---------- */

.tmf__fab {
	display: none;
	position: fixed;
	left: 50%;
	bottom: 22px;
	/*
	 * Above the theme's mobile drawer chrome (.tm-overlay 998, .tm-drawer 999)
	 * so the trigger is never buried by header markup.
	 */
	z-index: 1001;
	transform: translateX(-50%);
	align-items: center;
	gap: 9px;
	padding: 13px 24px;
	border: 0;
	border-radius: 30px;
	background: #2d3134;
	background: var(--tmf-ink, #2d3134);
	box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
	cursor: pointer;
	font-family: var(--tmf-sans);
	font-size: 13px;
	font-weight: 500;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: #fff;
}

.tmf__fab-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 20px;
	height: 20px;
	padding: 0 6px;
	border-radius: 10px;
	background: #fff;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0;
	color: var(--tmf-ink);
}

.tmf__scrim {
	display: none;
}

/* ---------- bottom sheet, below 1025px ---------- */

@media (max-width: 1024px) {

	.tmf__fab {
		display: inline-flex;
	}

	.tmf__scrim {
		position: fixed;
		inset: 0;
		z-index: 1002;
		background: rgba(45, 49, 52, .45);
		opacity: 0;
		pointer-events: none;
		transition: opacity .28s ease;
	}

	/*
	 * Keep the [hidden] attribute authoritative — an author `display` would
	 * silently beat it and leave a full-viewport layer over the page.
	 */
	.tmf__scrim[hidden] {
		display: none;
	}

	.tmf__scrim:not([hidden]) {
		display: block;
		opacity: 1;
		pointer-events: auto;
	}

	.tmf__panel {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 1003;
		display: flex;
		flex-direction: column;
		max-height: 86vh;
		padding: 0;
		border-radius: 18px 18px 0 0;
		box-shadow: 0 -12px 40px rgba(0, 0, 0, .2);
		transform: translateY(101%);
		transition: transform .32s cubic-bezier(.32, .72, 0, 1);
		visibility: hidden;
	}

	/*
	 * Keyed off the panel itself, not an ancestor: the JS reparents the panel
	 * to <body> at this breakpoint, so a `.tmf.is-open .tmf__panel` descendant
	 * selector would stop matching.
	 */
	.tmf__panel.is-open {
		transform: translateY(0);
		visibility: visible;
	}

	.tmf__head {
		display: flex;
		align-items: center;
		justify-content: space-between;
		position: relative;
		flex: 0 0 auto;
		padding: 18px 20px 14px;
		border-bottom: 1px solid var(--tmf-line, #eceef0);
		background: #fff;
		background: var(--tmf-white, #fff);
	}

	/* The sheet overlays page content — every layer must be opaque. */
	.tmf__chips,
	.tmf__body {
		background: #fff;
		background: var(--tmf-white, #fff);
	}

	/* grab handle */
	.tmf__head::before {
		content: "";
		position: absolute;
		top: 8px;
		left: 50%;
		width: 38px;
		height: 4px;
		border-radius: 2px;
		background: var(--tmf-line);
		transform: translateX(-50%);
	}

	.tmf__head-title {
		font-family: var(--tmf-serif);
		font-size: 19px;
		font-weight: 500;
	}

	.tmf__close {
		display: inline-flex;
		padding: 4px;
		border: 0;
		background: none;
		cursor: pointer;
		color: var(--tmf-muted);
	}

	.tmf__chips {
		flex: 0 0 auto;
		margin: 0;
		padding: 14px 20px 0;
	}

	.tmf__body {
		flex: 1 1 auto;
		/*
		 * min-height:0 is load-bearing. A flex item defaults to min-height:auto
		 * and will not shrink below its content, so overflow-y:auto never gets
		 * a constrained box to scroll inside — the list simply overflows and is
		 * clipped by the sheet's max-height, leaving every option past the fold
		 * visible-but-untappable.
		 */
		min-height: 0;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
		overscroll-behavior: contain;
		padding: 18px 20px;
	}

	.tmf__foot {
		display: flex;
		align-items: center;
		gap: 12px;
		flex: 0 0 auto;
		padding: 14px 20px calc(14px + env(safe-area-inset-bottom));
		border-top: 1px solid var(--tmf-line, #eceef0);
		background: #fff;
		background: var(--tmf-white, #fff);
	}

	.tmf__reset {
		flex: 0 0 auto;
		padding: 12px 18px;
		border: 1px solid var(--tmf-line, #eceef0);
		border-radius: 26px;
		font-size: 13px;
		color: #767b80;
		color: var(--tmf-muted, #767b80);
		text-decoration: none;
	}

	.tmf__apply {
		flex: 1 1 auto;
		padding: 13px 20px;
		border: 0;
		border-radius: 26px;
		background: #2d3134;
		background: var(--tmf-ink, #2d3134);
		cursor: pointer;
		font-family: var(--tmf-sans);
		font-size: 13px;
		font-weight: 500;
		letter-spacing: .06em;
		text-transform: uppercase;
		color: #fff;
	}

	/* tap targets */
	.tmf__opt {
		margin-bottom: 0;
		padding: 9px 0;
	}

	body.tmf-locked {
		overflow: hidden;
	}
}

/* ---------- loading ---------- */

.tmf-results-loading {
	opacity: .45;
	transition: opacity .18s ease;
	pointer-events: none;
}

/* Respect users who ask for less motion. */
@media (prefers-reduced-motion: reduce) {
	.tmf__panel,
	.tmf__scrim,
	.tmf__box::after,
	.tmf__chevron {
		transition: none;
	}
}
