/**
 * NKALL Meilisearch — category filter bar.
 *
 * The dropdowns are native <details>/<summary>, so everything here is styling.
 * Remove the JavaScript and the bar still opens, closes and filters.
 *
 * Every selector is .nkall-fb-* — nothing can reach the theme.
 */

.nkall-fb {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 10px;
	margin: 0 0 18px;
	padding: 12px 0;
	border-top: 1px solid #e5e7eb;
	border-bottom: 1px solid #e5e7eb;
	font-size: 15px;
}

.nkall-fb-label {
	font-weight: 600;
	color: #374151;
	margin-right: 2px;
}

.nkall-fb-pills {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px;
	flex: 1 1 auto;
}

/* ------------------------------------------------------------------- pill */

.nkall-fb-pill {
	position: relative;
}

.nkall-fb-summary {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 14px;
	border: 1px solid #d1d5db;
	border-radius: 9999px;
	background: #fff;
	color: #374151;
	font-size: 14px;
	line-height: 1.3;
	white-space: nowrap;
	cursor: pointer;
	list-style: none;
	user-select: none;
}

/* Hide the native disclosure triangle in every engine. */
.nkall-fb-summary::-webkit-details-marker { display: none; }
.nkall-fb-summary::marker { content: ""; }

.nkall-fb-summary:hover {
	border-color: #9ca3af;
	background: #f9fafb;
}

.nkall-fb-pill.is-active > .nkall-fb-summary {
	border-color: #171717;
	background: #171717;
	color: #fff;
}

.nkall-fb-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	border-radius: 9999px;
	background: #fff;
	color: #171717;
	font-size: 12px;
	font-weight: 700;
}

.nkall-fb-caret {
	width: 0;
	height: 0;
	border-left: 4px solid transparent;
	border-right: 4px solid transparent;
	border-top: 5px solid currentColor;
	opacity: 0.7;
}

.nkall-fb-pill[open] > .nkall-fb-summary .nkall-fb-caret {
	transform: rotate(180deg);
}

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

.nkall-fb-panel {
	position: absolute;
	z-index: 60;
	top: calc(100% + 6px);
	left: 0;
	width: 260px;
	max-height: 320px;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 6px;
	border: 1px solid #e5e7eb;
	border-radius: 10px;
	background: #fff;
	box-shadow: 0 10px 28px rgba(0, 0, 0, 0.14);
}

.nkall-fb-options {
	margin: 0;
	padding: 0;
	list-style: none;
}

.nkall-fb-options li { margin: 0; }

.nkall-fb-option {
	display: flex;
	align-items: center;
	gap: 9px;
	padding: 7px 8px;
	border-radius: 6px;
	color: #374151;
	text-decoration: none;
	font-size: 14px;
	line-height: 1.35;
}

.nkall-fb-option:hover {
	background: #f3f4f6;
	color: #111827;
}

.nkall-fb-box {
	position: relative;
	flex: 0 0 18px;
	width: 18px;
	height: 18px;
	border: 1px solid #9ca3af;
	border-radius: 4px;
	background: #fff;
}

.nkall-fb-option.is-on .nkall-fb-box {
	border-color: #171717;
	background: #171717;
}

/* The tick.
   🔴 An earlier version faked this with two crossed linear-gradients. It rendered
      as a pixelated white smudge in the corner — gradients cannot draw a clean
      diagonal at this size, and the two bars did not meet. This is the standard
      two-border-and-rotate checkmark: real geometry, crisp at any zoom or DPR,
      and no image to load. Look at it after changing it; a tick is exactly the
      kind of detail that passes a DOM assertion and still looks wrong. */
.nkall-fb-option.is-on .nkall-fb-box::after {
	content: "";
	position: absolute;
	left: 6px;
	top: 2px;
	width: 4px;
	height: 9px;
	border: solid #fff;
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
}

.nkall-fb-name {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.nkall-fb-count {
	flex: 0 0 auto;
	color: #9ca3af;
	font-size: 13px;
	font-variant-numeric: tabular-nums;
}

.nkall-fb-clear-one {
	display: block;
	margin-top: 4px;
	padding: 8px;
	border-top: 1px solid #f3f4f6;
	color: #b91c1c;
	font-size: 13px;
	text-align: center;
	text-decoration: none;
}

.nkall-fb-clear-one:hover { background: #fef2f2; color: #991b1b; }

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

.nkall-fb-panel--price form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 6px;
}

.nkall-fb-price-field {
	display: flex;
	flex-direction: column;
	gap: 4px;
	font-size: 12px;
	color: #6b7280;
}

.nkall-fb-price-field input {
	width: 84px;
	/* 16px minimum, or iOS Safari zooms the page when it is focused. */
	font-size: 16px;
	padding: 7px 8px;
	border: 1px solid #d1d5db;
	border-radius: 6px;
	background: #fff;
	color: #111827;
}

.nkall-fb-price-go {
	padding: 8px 14px;
	border: 0;
	border-radius: 6px;
	background: #171717;
	color: #fff;
	font-size: 14px;
	cursor: pointer;
}

/* ----------------------------------------------------------------- toggle */

.nkall-fb-toggle {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 8px 14px;
	border: 1px solid #d1d5db;
	border-radius: 9999px;
	background: #fff;
	color: #374151;
	font-size: 14px;
	text-decoration: none;
	white-space: nowrap;
}

.nkall-fb-toggle:hover { border-color: #9ca3af; }

.nkall-fb-switch {
	position: relative;
	width: 32px;
	height: 18px;
	border-radius: 9999px;
	background: #d1d5db;
	transition: background-color 0.15s ease;
}

.nkall-fb-switch::after {
	content: "";
	position: absolute;
	top: 2px;
	left: 2px;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: #fff;
	transition: transform 0.15s ease;
}

.nkall-fb-toggle.is-on { border-color: #171717; }
.nkall-fb-toggle.is-on .nkall-fb-switch { background: #16a34a; }
.nkall-fb-toggle.is-on .nkall-fb-switch::after { transform: translateX(14px); }

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

.nkall-fb-active {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-left: auto;
	font-size: 14px;
}

.nkall-fb-total { color: #6b7280; }

.nkall-fb-clear-all {
	color: #b91c1c;
	text-decoration: underline;
}

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

@media (max-width: 640px) {
	.nkall-fb {
		gap: 8px;
		padding: 10px 0;
	}

	.nkall-fb-label { display: none; }

	/* The pill row scrolls sideways rather than wrapping into a tall stack
	   that pushes every product below the fold. */
	.nkall-fb-pills {
		flex-wrap: nowrap;
		overflow-x: auto;
		padding-bottom: 4px;
		scrollbar-width: thin;
	}

	.nkall-fb-pill,
	.nkall-fb-toggle { flex: 0 0 auto; }

	/* Anchored to the row rather than the pill, so a dropdown near the right
	   edge cannot open off-screen. */
	.nkall-fb-panel {
		position: fixed;
		left: 12px;
		right: 12px;
		width: auto;
		max-height: 55vh;
	}

	.nkall-fb-active { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
	.nkall-fb-switch,
	.nkall-fb-switch::after { transition: none; }
}

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

/* A filtered URL carries a query string, and nginx skips the page cache for
   those — so every filter click is a full uncached render with real latency.
   Without feedback the bar feels broken; the tick appears to do nothing until
   the new page paints. These rules make the wait legible. */

.nkall-fb-progress {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	height: 3px;
	z-index: 999999;
	background: rgba(23, 23, 23, 0.12);
	overflow: hidden;
}

.nkall-fb-progress::after {
	content: "";
	position: absolute;
	inset: 0;
	width: 40%;
	background: var(--nkall-meili-offer-bg, linear-gradient(90deg, #8860d0 28%, #5680e9 75%, #5ab9ea 99%));
	animation: nkall-fb-slide 1.1s ease-in-out infinite;
}

@keyframes nkall-fb-slide {
	0%   { transform: translateX(-100%); }
	100% { transform: translateX(350%); }
}

/* Dim the results so it is obvious they are now stale, and stop a second click
   landing on a product the customer is about to navigate away from. */
.nkall-fb-loading .products {
	opacity: 0.45;
	pointer-events: none;
	transition: opacity 0.15s ease;
}

.nkall-fb-loading .nkall-fb-pills {
	pointer-events: none;
}

/* The bar itself stays fully visible — the tick the customer just made is the
   one thing they need to keep seeing while they wait. */
.nkall-fb-loading .nkall-fb {
	opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
	.nkall-fb-progress::after {
		animation: none;
		width: 100%;
		opacity: 0.5;
	}

	.nkall-fb-loading .products {
		transition: none;
	}
}
