/* @svelte-lean/styles — toolbar (Tier 1; roving focus comes from @svelte-lean/primitives/toolbar).
 * Markup: <div data-slean="toolbar" role="toolbar" aria-label="…"> around buttons, toggles, a
 * toggle-group, links and a select; <div role="separator"> between groups of controls. The
 * controls bring their own stylesheets; this file lays out the bar, draws the separators and
 * flattens a nested toggle group and unpressed toggles into the bar. Load it after toggle.css and
 * toggle-group.css. Option: data-slean-orientation="vertical" (with aria-orientation). */
@layer slean.reset, slean.tokens, slean.base, slean.components, slean.compositions, slean.utilities;
@import './toggle.css';
@import './toggle-group.css';

@layer slean.compositions {
	:where([data-slean='toolbar']) {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		gap: var(--slean-space-1);
		padding: var(--slean-space-1);
		border: 1px solid var(--slean-border);
		border-radius: var(--slean-radius-md);
		background: var(--slean-surface);
		color: var(--slean-fg);
	}

	:where([data-slean='toolbar'][data-slean-orientation='vertical']) {
		flex-direction: column;
		flex-wrap: nowrap;
		align-items: stretch;
		inline-size: max-content;
	}

	/* Separators run across the bar: a vertical rule in a horizontal toolbar and the reverse. */
	:where([data-slean='toolbar'] [role='separator']) {
		flex: none;
		align-self: stretch;
		inline-size: 1px;
		margin-block: var(--slean-space-1);
		margin-inline: var(--slean-space-1);
		border: 0;
		background: var(--slean-border);
	}

	:where([data-slean='toolbar'][data-slean-orientation='vertical'] [role='separator']) {
		inline-size: auto;
		block-size: 1px;
		margin-inline: var(--slean-space-1);
	}

	/* A toggle group inside the bar shares its surface: no second border, no inset. */
	:where([data-slean='toolbar'] [data-slean='toggle-group']) {
		padding: 0;
		border-color: transparent;
		background: transparent;
	}

	:where([data-slean='toolbar'] [data-slean='toggle']:not([aria-pressed='true'])) {
		border-color: transparent;
	}

	@media (pointer: coarse) {
		:where([data-slean='toolbar']) {
			gap: var(--slean-space-2);
		}
	}

	@media (forced-colors: active) {
		:where([data-slean='toolbar']) {
			border-color: CanvasText;
		}

		:where([data-slean='toolbar'] [role='separator']) {
			background: CanvasText;
		}
	}
}
