/*
 * The chips field (0.102.0, Fields::chips(); CONTRACT §8.14): compiled on its own (assets/chips.css) and loaded with
 * assets/chips.js by the builder that prints one or by the schema form, so the common path pays nothing. The chips are
 * the searchable select's (kit/select.css: rooster-admin-combo__chip), the box is the field's recipe (ra-control),
 * the suggestions are the select's popup list, under the box. As wide as its column, never past it (FE-F2): the box
 * wraps its chips over as many lines as they need.
 */

@reference "./chrome.css";

.rooster-admin-chips {
	@apply relative w-full max-w-[min(40rem,100%)] text-start;
}

.rooster-admin-chips__box {
	@apply ra-control flex min-h-8 cursor-text flex-wrap items-center gap-1 py-0.5 ps-1 pe-1;
}

.rooster-admin-chips__box:focus-within {
	@apply ra-control-focus;
}

.rooster-admin-chips.is-invalid .rooster-admin-chips__box,
.rooster-admin-field.is-invalid .rooster-admin-chips__box {
	@apply border-destructive;
}

.rooster-admin-chips__input.rooster-admin-chips__input {
	@apply m-0 h-7 min-h-0 min-w-24 flex-1 border-0 bg-transparent px-1 py-0 text-sm text-foreground shadow-none outline-none;

	@variant focus {
		@apply shadow-none outline-none;
	}

	@variant disabled {
		@apply cursor-not-allowed;
	}
}

.rooster-admin-chips__count {
	@apply m-0 mt-1 text-xs text-secondary-foreground;
}

.rooster-admin-chips__store {
	display: none;
}

/* The suggestions: the searchable select's popup list, under the box. */
.rooster-admin-chips__suggest {
	@apply absolute inset-x-0 top-full z-(--ra-z-pop) mt-1 box-border rounded-md border border-border bg-card text-sm text-foreground shadow-pop;
}

.rooster-admin-chips__suggest[hidden] {
	display: none;
}

/* The option the keys reached is aria-selected (the listbox's rule), shown as the select's active one, not as chosen. */
.rooster-admin-chips__suggest .rooster-admin-combo__option[aria-selected="true"] {
	@apply bg-muted font-normal text-foreground;
}

.rooster-admin-chips__suggest .rooster-admin-combo__option[aria-selected="true"]::after {
	content: none;
}

.rooster-admin-chips__suggest .rooster-admin-combo__option:hover {
	@apply bg-muted;
}
