/* @svelte-lean/styles — checkbox group (Tier 1; the select-all box comes from
 * @svelte-lean/primitives/checkbox-group). Markup: <fieldset data-slean="checkbox-group">
 * <legend>…</legend> <label><input type="checkbox" data-slean="checkbox" data-slean-part="all">
 * All</label> <label><input type="checkbox" name="…" value="…" data-slean="checkbox"> …</label> …
 * </fieldset>. The checkboxes are drawn by checkbox.css (import it too). The fieldset is unstyled
 * apart from its spacing; the members after the label of the all box are indented under it, as
 * MUI's parent checkbox. Option: data-slean-orientation="horizontal" puts the members on one
 * wrapping row under the all box, without the indent. */
@layer slean.reset, slean.tokens, slean.base, slean.components, slean.compositions, slean.utilities;

@layer slean.components {
	:where([data-slean='checkbox-group']) {
		display: flex;
		flex-direction: column;
		align-items: flex-start;
		gap: var(--slean-space-2);
		min-inline-size: 0;
		margin: 0;
		padding: 0;
		border: 0;
	}

	:where([data-slean='checkbox-group'] > legend) {
		padding: 0;
		margin-block-end: var(--slean-space-1);
		color: var(--slean-fg);
		font-size: var(--slean-text-sm);
		font-weight: var(--slean-font-weight-medium);
	}

	/* The members under the select-all box are indented by the box and its gap. */
	/* Members are labels and nested groups (fieldsets); naming them keys the rule on an element. */
	:where([data-slean='checkbox-group'] > label:has([data-slean-part='all']) ~ label),
	:where([data-slean='checkbox-group'] > label:has([data-slean-part='all']) ~ fieldset) {
		margin-inline-start: calc(1.125rem + var(--slean-space-2));
	}

	:where([data-slean='checkbox-group'][data-slean-orientation='horizontal']) {
		flex-direction: row;
		flex-wrap: wrap;
		align-items: center;
		column-gap: var(--slean-space-4);
	}

	:where([data-slean='checkbox-group'][data-slean-orientation='horizontal'] > legend),
	:where(
		[data-slean='checkbox-group'][data-slean-orientation='horizontal']
			> label:has([data-slean-part='all'])
	) {
		inline-size: 100%;
	}

	:where(
		[data-slean='checkbox-group'][data-slean-orientation='horizontal']
			> label:has([data-slean-part='all'])
			~ label
	),
	:where(
		[data-slean='checkbox-group'][data-slean-orientation='horizontal']
			> label:has([data-slean-part='all'])
			~ fieldset
	) {
		margin-inline-start: 0;
	}

	:where([data-slean='checkbox-group']:disabled > legend) {
		color: var(--slean-fg-muted);
	}

	@media (forced-colors: active) {
		:where([data-slean='checkbox-group']:disabled > legend) {
			color: GrayText;
		}
	}
}
