/* Expereo Filter — two multi-select dropdowns above a loop grid. */

.efg {
	--efg-bg: #ffffff;
	--efg-text: #0b1b34;
	--efg-radius: 10px;
	--efg-accent: #0b1b34;
	/* Default to the resting colours, so hover changes nothing until someone
	   asks it to. */
	--efg-bg-hover: var(--efg-bg);
	--efg-text-hover: var(--efg-text);
	/* Extra width on the open panel, on top of whatever its longest option
	   needs. Measured: 50 here makes the panel 50px wider than 0 does. */
	--efg-panel-extra: 50px;
	--efg-check-size: 16px;
	--efg-check-border: 1px;
	--efg-check-border-color: rgba(11, 27, 52, 0.45);
	--efg-check-radius: 3px;
	/* Falls back to the trigger's colour, so the list matches until told not to. */
	--efg-option-text: var(--efg-text);
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
	position: relative;
}

.efg__field {
	position: relative;
}

.efg__trigger {
	display: inline-flex;
	align-items: center;
	gap: 28px;
	margin: 0;
	padding: 14px 18px;
	background: var(--efg-bg);
	color: var(--efg-text);
	border: 1px solid rgba(11, 27, 52, 0.14);
	border-radius: var(--efg-radius);
	font: inherit;
	line-height: 1.2;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

/* Themes style bare buttons, and this is one. Pin every interactive state or
   the trigger picks up the theme's button hover colours instead of its own. */
.efg__trigger:hover,
.efg__trigger:focus,
.efg__trigger:active,
.efg__trigger:focus-visible {
	background: var(--efg-bg-hover);
	color: var(--efg-text-hover);
	box-shadow: none;
}

/* Keeping the ring: the rule above exists to stop a theme recolouring the
   button, not to strip the only cue a keyboard user gets. */
.efg__trigger:focus-visible {
	outline: 2px solid var(--efg-accent);
	outline-offset: 2px;
}

.efg__caret {
	width: 0;
	height: 0;
	border-left: 5px solid transparent;
	border-right: 5px solid transparent;
	border-top: 6px solid currentColor;
	transition: transform 0.2s ease;
}

.efg__trigger[aria-expanded="true"] .efg__caret {
	transform: rotate(180deg);
}

/* The panel is taken out of flow so opening one cannot push the grid down. */
.efg__panel {
	position: absolute;
	z-index: 20;
	top: calc(100% + 6px);
	left: 0;
	min-width: calc(100% + var(--efg-panel-extra));
	max-height: 320px;
	overflow-y: auto;
	padding: 14px 18px;
	background: var(--efg-bg);
	border: 1px solid rgba(11, 27, 52, 0.14);
	border-radius: var(--efg-radius);
	box-shadow: 0 12px 28px rgba(11, 27, 52, 0.12);
}

.efg__option {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 6px 0;
	color: var(--efg-option-text);
	white-space: nowrap;
	cursor: pointer;
}

/* Drawn rather than native: a browser checkbox ignores border-width, so the
   only way to make that adjustable is to take the control over. The tick is a
   background image, not a pseudo-element, because ::after on an input is not
   dependable across browsers. */
.efg__option input {
	width: var(--efg-check-size);
	height: var(--efg-check-size);
	margin: 0;
	flex: 0 0 auto;
	box-sizing: border-box;
	border: var(--efg-check-border) solid var(--efg-check-border-color);
	border-radius: var(--efg-check-radius);
	background: transparent no-repeat center / 68%;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	transition: background-color 0.15s ease, border-color 0.15s ease;
}

.efg__option input:checked {
	background-color: var(--efg-accent);
	border-color: var(--efg-accent);
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23fff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='3 8.5 6.5 12 13 4.5'/%3E%3C/svg%3E");
}

.efg__option input:focus-visible {
	outline: 2px solid var(--efg-accent);
	outline-offset: 2px;
}

.efg__empty {
	margin: 0;
	opacity: 0.6;
	white-space: nowrap;
}

/* Dim the page's grid while the replacement is in flight, without collapsing
   its height — the layout jumping would be worse than the wait. */
.efg--busy .efg__trigger {
	opacity: 0.6;
	pointer-events: none;
}

@media (max-width: 480px) {
	.efg__field,
	.efg__trigger {
		width: 100%;
	}

	.efg__trigger {
		justify-content: space-between;
	}
}
