/**
 * EtchFacets — Base styles
 *
 * Minimal styles for facet functionality. Override in your
 * Etch theme for custom look and feel.
 */

/* ── Loading state ── */
.etchfacets-template.etchfacets-loading {
	opacity: 0.4;
	pointer-events: none;
	transition: opacity 0.15s ease;
}

/* ── Ghost & hidden choices ── */
.etchfacet-ghost {
	opacity: 0.35;
	pointer-events: none;
}

.etchfacet-hidden {
	display: none !important;
}

/* ── Collapsible facet — roll up/down animation ──
   JS (initCollapsibleFacets) sets an inline max-height/opacity on click, measured
   from the choice list's real scrollHeight. This just supplies the transition and
   the pre-JS initial state (matches the server-rendered data-etchfacet-open so
   there's no flash of open content before JS runs). Scoped to collapsible facets
   only — non-collapsible facets' choice lists are untouched. */
.etchfacets-facet[data-etchfacet-collapsible="true"] .etchfacets-facet-choices {
	overflow: hidden;
	transition: max-height 0.25s ease, opacity 0.2s ease;
}

.etchfacets-facet[data-etchfacet-collapsible="true"][data-etchfacet-open="false"] .etchfacets-facet-choices {
	max-height: 0;
	opacity: 0;
}

/* ── Hierarchical tree ── */
.etchfacets-hierarchy {
	display: flex;
	flex-direction: column;
}

.etchfacets-tree-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	padding: 0.35rem 0;
}

.etchfacets-tree-children {
	padding-left: 1.25rem;
	border-left: 1px solid var(--neutral-300, #d1d5db);
	margin-left: 0.5rem;
}

.etchfacets-tree-children[hidden] {
	display: none;
}

/* Toggle +/− button */
.etchfacets-tree-toggle {
	all: unset;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 1.25rem;
	height: 1.25rem;
	border-radius: 3px;
	font-size: 0.875rem;
	font-weight: 600;
	line-height: 1;
	color: var(--neutral-500, #6b7280);
	border: 1px solid var(--neutral-300, #d1d5db);
	flex-shrink: 0;
	transition: color 0.15s ease, border-color 0.15s ease;
}

.etchfacets-tree-toggle:hover {
	color: var(--neutral-900, #111827);
	border-color: var(--neutral-400, #9ca3af);
}

.etchfacets-tree-toggle[aria-expanded="true"] {
	color: var(--neutral-900, #111827);
}

/* Small "reset to full range" icon for a single range/slider/date facet
   (price, age, reading time, rooms, …) */
.etchfacets-range-reset {
	all: unset;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 1.1rem;
	height: 1.1rem;
	margin-left: 0.25rem;
	border-radius: 50%;
	font-size: 0.8125rem;
	line-height: 1;
	color: var(--neutral-500, #6b7280);
	vertical-align: middle;
	transition: background 0.15s ease, color 0.15s ease;
}

.etchfacets-range-reset:hover {
	background: var(--neutral-200, #e5e7eb);
	color: var(--neutral-900, #111827);
}

.etchfacets-range-separator {
	color: var(--neutral-400, #9ca3af);
}

/* ── Range/slider value row — "3 – 25 min ↺" below the track ── */
.etchfacets-range-value {
	font-variant-numeric: tabular-nums;
	min-width: 1.5em;
	text-align: center;
}

/* ── Range/slider track — two overlaid native range inputs sharing one
   visual track. Each thumb's own inline `oninput` handler (the only
   scripting surface available on an Etch element) positions a real sibling
   `.etchfacets-range-fill` div directly via `.style.left`/`.style.right`
   and clamps against the other thumb so they can't cross — this avoids the
   CSS custom-property + `::after` pseudo-element approach, which cannot be
   restyled per-browser consistently. The plugin's own JS re-invokes each
   handler via the `.oninput` property after every server bounds sync/reset,
   keeping the fill bar and labels accurate. ── */
.etchfacets-range-track {
	position: relative;
	height: 1.75rem;
	display: flex;
	align-items: center;
	margin-block-start: var(--space-2xs, 0.25em);
}

.etchfacets-range-line {
	position: absolute;
	left: 0;
	right: 0;
	top: 50%;
	height: 4px;
	transform: translateY(-50%);
	background: var(--neutral-200, #e5e7eb);
	border-radius: 999px;
}

.etchfacets-range-fill {
	position: absolute;
	top: 50%;
	height: 4px;
	transform: translateY(-50%);
	background: var(--etchfacets-accent, #4f46e5);
	border-radius: 999px;
}

.etchfacets-range-track .etchfacet-min,
.etchfacets-range-track .etchfacet-max {
	position: absolute;
	inset: 0;
	width: 100%;
	margin: 0;
	appearance: none;
	-webkit-appearance: none;
	-moz-appearance: none;
	background: transparent;
	pointer-events: none;
	cursor: pointer;
}

.etchfacets-range-track .etchfacet-min {
	z-index: 3;
}

.etchfacets-range-track .etchfacet-max {
	z-index: 4;
}

/* Thumb-only pointer-events trick so both overlaid inputs stay draggable —
   Firefox has no supported way to restyle the native thumb via a stylesheet
   API here, so it falls back to the browser default. */
.etchfacets-range-track .etchfacet-min::-webkit-slider-runnable-track,
.etchfacets-range-track .etchfacet-max::-webkit-slider-runnable-track {
	-webkit-appearance: none;
	background: transparent;
	height: 4px;
}

.etchfacets-range-track .etchfacet-min::-webkit-slider-thumb,
.etchfacets-range-track .etchfacet-max::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	pointer-events: auto;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: #fff;
	border: 1px solid var(--neutral-300, #ccc);
	box-shadow: 0 1px 2px rgba(0, 0, 0, .15);
	cursor: pointer;
	margin-top: -7px;
}

/* ── Checkbox / radio labels ── */
.etchfacets-checkbox,
.etchfacets-radio {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	cursor: pointer;
	font-size: 0.9375rem;
}

/* ── Search input ── */
.etchfacets-search-input {
	width: 100%;
}

/* ── Dropdown select ── */
.etchfacets-select {
	width: 100%;
}

/* ── Reset button ── */
.etchfacets-reset {
	cursor: pointer;
}

/* ── Pagination & load more ── */
.etchfacets-pagination {
	display: flex;
	align-items: center;
	gap: 0.75rem;
}

.etchfacets-pagination-prev,
.etchfacets-pagination-next,
.etchfacets-load-more {
	cursor: pointer;
}

.etchfacets-pagination-prev:disabled,
.etchfacets-pagination-next:disabled,
.etchfacets-load-more:disabled,
.etchfacets-load-more--exhausted {
	opacity: 0.4;
	cursor: not-allowed;
}

.etchfacets-pagination-status {
	font-size: 0.8125rem;
	color: var(--neutral-500, #6b7280);
}

/* ── Count badge ── */
.etchfacet-count {
	color: var(--neutral-400, #9ca3af);
	font-size: 0.8125rem;
}

/* ── No results ── */
.etchfacets-no-results {
	padding: 2rem 1rem;
	text-align: center;
	color: var(--neutral-500, #6b7280);
}

/* ── Active filters summary ── */
.etchfacets-active-filters {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem;
	min-height: 1.75rem;
}

.etchfacets-active-filter {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	padding: 0.3rem 0.5rem 0.3rem 0.75rem;
	border-radius: 999px;
	background: var(--neutral-100, #f3f4f6);
	color: var(--neutral-700, #374151);
	font-size: 0.8125rem;
	line-height: 1.2;
}

.etchfacets-active-filter-remove {
	all: unset;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 1.1rem;
	height: 1.1rem;
	border-radius: 50%;
	color: var(--neutral-500, #6b7280);
	font-size: 0.9375rem;
	line-height: 1;
	transition: background 0.15s ease, color 0.15s ease;
}

.etchfacets-active-filter-remove:hover {
	background: var(--neutral-300, #d1d5db);
	color: var(--neutral-900, #111827);
}

/* ── Map facet ── */
.etchfacets-map {
	position: relative;
	width: 100%;
	min-height: 320px;
	background: var(--neutral-100, #f3f4f6);
}

.etchfacets-map.etchfacets-map--loading::after {
	content: "";
	position: absolute;
	inset: 0;
	background: rgba(255, 255, 255, 0.35);
	pointer-events: none;
}

.etchfacets-map.etchfacets-map--error::after {
	content: "Map unavailable — check the Google Maps API key.";
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	text-align: center;
	color: var(--neutral-500, #6b7280);
}

/* Info window */
.etchfacets-map-info {
	max-width: 220px;
	font-size: 0.875rem;
	line-height: 1.4;
}

.etchfacets-map-info-img {
	display: block;
	width: 100%;
	height: auto;
	margin-bottom: 0.5rem;
	border-radius: 4px;
}

.etchfacets-map-info-title {
	font-weight: 600;
	text-decoration: none;
}

.etchfacets-map-info-badge {
	display: inline-block;
	margin-bottom: 0.35rem;
	padding: 0.1rem 0.5rem;
	border-radius: 999px;
	font-size: 0.75rem;
	font-weight: 600;
	color: #fff;
	background: var(--etchfacets-map-badge-color, #4f46e5);
}

/* "Search this area" button */
.etchfacets-map-search-area {
	position: absolute;
	top: 12px;
	left: 50%;
	transform: translate(-50%, -8px);
	z-index: 1;
	padding: 0.5rem 1rem;
	border: none;
	border-radius: 999px;
	background: #fff;
	color: #1f2937;
	font-size: 0.875rem;
	font-weight: 600;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
	cursor: pointer;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.15s ease, transform 0.15s ease;
}

.etchfacets-map-search-area--visible {
	opacity: 1;
	pointer-events: auto;
	transform: translate(-50%, 0);
}
