/* @svelte-lean/styles — descriptions (Tier 0, a <dl> of label and value pairs).
 * Markup: <dl data-slean="descriptions"> <div><dt>Plan</dt><dd>Team</dd></div> … </dl>. Each
 * <div> group is one grid cell: as many 14rem columns as fit the width, or at most the count in
 * data-slean-columns (1 to 4) and still one column when the width is narrower than 14rem.
 * data-slean-layout="inline" puts the label beside the value (several <dd> stack in the value
 * column). Variant: data-variant="outlined" joins the groups into bordered cells. */
@layer slean.reset, slean.tokens, slean.base, slean.components, slean.compositions, slean.utilities;

@layer slean.components {
	:where([data-slean='descriptions']) {
		display: grid;
		grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr));
		gap: var(--slean-space-4) var(--slean-space-6);
		margin: 0;
		padding: 0;
		color: var(--slean-fg);
		font-size: var(--slean-text-md);
		line-height: var(--slean-leading);
	}

	/* At most N columns: each track is at least an Nth of the width minus the gaps, never less
	 * than 14rem, and never wider than the list itself. */
	:where([data-slean='descriptions'][data-slean-columns='1']) {
		grid-template-columns: minmax(0, 1fr);
	}

	:where([data-slean='descriptions'][data-slean-columns='2']) {
		grid-template-columns: repeat(
			auto-fill,
			minmax(min(100%, max(14rem, (100% - var(--slean-space-6)) / 2)), 1fr)
		);
	}

	:where([data-slean='descriptions'][data-slean-columns='3']) {
		grid-template-columns: repeat(
			auto-fill,
			minmax(min(100%, max(14rem, (100% - 2 * var(--slean-space-6)) / 3)), 1fr)
		);
	}

	:where([data-slean='descriptions'][data-slean-columns='4']) {
		grid-template-columns: repeat(
			auto-fill,
			minmax(min(100%, max(14rem, (100% - 3 * var(--slean-space-6)) / 4)), 1fr)
		);
	}

	:where([data-slean='descriptions'] > div) {
		min-inline-size: 0;
	}

	:where([data-slean='descriptions'] dt) {
		color: var(--slean-fg-muted);
		font-size: var(--slean-text-sm);
	}

	:where([data-slean='descriptions'] dd) {
		margin: 0;
		overflow-wrap: anywhere;
	}

	/* Inline: label and value side by side; labels line up because every group in a column has
	 * the same width. */
	:where([data-slean='descriptions'][data-slean-layout='inline'] > div) {
		display: grid;
		grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
		column-gap: var(--slean-space-4);
		align-items: baseline;
	}

	:where([data-slean='descriptions'][data-slean-layout='inline'] dt) {
		grid-column: 1;
	}

	:where([data-slean='descriptions'][data-slean-layout='inline'] dd) {
		grid-column: 2;
	}

	/* Outline: every group is a cell with its own border, pulled 1px over its neighbours so two
	 * borders read as one line. */
	:where([data-slean='descriptions'][data-variant='outlined']) {
		gap: 0;
		padding-block-start: 1px;
		padding-inline-start: 1px;
	}

	:where([data-slean='descriptions'][data-variant='outlined'] > div) {
		margin-block-start: -1px;
		margin-inline-start: -1px;
		padding-block: var(--slean-space-3);
		padding-inline: var(--slean-space-4);
		border: 1px solid var(--slean-border);
	}

	@media (forced-colors: active) {
		:where([data-slean='descriptions'][data-variant='outlined'] > div) {
			border-color: CanvasText;
		}
	}
}
