/*
 * Colours and shape can be changed from the theme, e.g.
 * .lgtf { --lgtf-accent: #a872dd; }
 */
.lgtf {
	--lgtf-accent: #a872dd;
	--lgtf-accent-text: #fff;
	--lgtf-pill-bg: #f4f4f5;
	--lgtf-pill-hover: #ebebed;
	--lgtf-text: #2d2d2d;
	--lgtf-title: #111;
	--lgtf-radius: 8px;
	margin-bottom: 32px;
	color: var(--lgtf-text);
}

.lgtf-form {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 16px 24px;
}

.lgtf--checkbox .lgtf-form {
	align-items: flex-start;
}

.lgtf-title {
	margin-right: 8px;
	color: var(--lgtf-title);
	font-size: 32px;
	font-weight: 500;
	line-height: 1.2;
}

.lgtf-field {
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

.lgtf--checkbox .lgtf-field {
	flex: 1 1 200px;
}

.lgtf-label {
	display: block;
	margin-bottom: 6px;
	padding: 0;
	font-weight: 600;
}

/* Dropdowns: a pill shows the state, the real <select> sits invisibly on top of it. */
.lgtf--dropdown .lgtf-field {
	position: relative;
	flex: 0 0 auto;
}

.lgtf--dropdown .lgtf-label {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.lgtf-pill {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 10px 16px;
	border-radius: var(--lgtf-radius);
	background: var(--lgtf-pill-bg);
	color: var(--lgtf-text);
	font-size: 16px;
	line-height: 1.5;
	white-space: nowrap;
	transition: background-color 0.15s, color 0.15s;
}

.lgtf-pill-text {
	max-width: 220px;
	overflow: hidden;
	text-overflow: ellipsis;
}

.lgtf-chevron {
	flex: none;
	opacity: 0.7;
	transition: transform 0.15s;
}

.lgtf .lgtf-select {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	opacity: 0;
	cursor: pointer;
	appearance: none;
}

.lgtf-field:hover .lgtf-pill {
	background: var(--lgtf-pill-hover);
}

.lgtf-field.is-active .lgtf-pill,
.lgtf-field:focus-within .lgtf-pill {
	background: var(--lgtf-accent);
	color: var(--lgtf-accent-text);
}

.lgtf-field.is-active .lgtf-chevron,
.lgtf-field:focus-within .lgtf-chevron {
	opacity: 1;
}

.lgtf-field:focus-within .lgtf-chevron {
	transform: rotate(180deg);
}

.lgtf-field:has(.lgtf-select:focus-visible) .lgtf-pill {
	outline: 2px solid var(--lgtf-accent);
	outline-offset: 2px;
}

/* Checkboxes */
.lgtf-options {
	max-height: 260px;
	margin: 0;
	padding: 0;
	overflow: auto;
	list-style: none;
}

.lgtf-option {
	margin: 0 0 4px;
	padding-left: calc(var(--lgtf-depth, 0) * 18px);
}

.lgtf-option label {
	display: flex;
	align-items: center;
	gap: 6px;
	cursor: pointer;
}

.lgtf-option input {
	accent-color: var(--lgtf-accent);
}

.lgtf-count,
.lgtf-empty {
	opacity: 0.6;
}

.lgtf-count {
	font-size: 0.9em;
}

.lgtf-empty {
	margin: 0;
}

/* Apply / Reset */
.lgtf-actions {
	display: flex;
	align-items: center;
	gap: 16px;
}

.lgtf .lgtf-apply {
	padding: 10px 20px;
	border: 0;
	border-radius: var(--lgtf-radius);
	background: var(--lgtf-accent);
	color: var(--lgtf-accent-text);
	font-size: 16px;
	line-height: 1.5;
	cursor: pointer;
}

.lgtf .lgtf-reset {
	color: var(--lgtf-accent);
	font-size: 15px;
	text-decoration: underline;
	text-underline-offset: 3px;
}

/* With JavaScript, auto-apply makes the button unnecessary. */
.lgtf-js .lgtf-form[data-auto="1"] .lgtf-apply {
	display: none;
}

.lgtf-loading {
	opacity: 0.5;
	pointer-events: none;
	transition: opacity 0.2s;
}

.lgtf-error {
	padding: 8px 12px;
	border: 1px dashed currentColor;
	color: #b32d2e;
}

@media (max-width: 767px) {
	.lgtf-form {
		gap: 12px;
	}

	.lgtf-title {
		flex-basis: 100%;
		margin: 0 0 4px;
		font-size: 24px;
	}

	.lgtf-pill {
		padding: 8px 14px;
		font-size: 15px;
	}
}
