/*
 * Flank: two children side by side, one at its natural size and one filling what is left.
 *
 * Typical uses: thumbnail + description, field + button. Neither child needs a width; they wrap
 * when the filling child can no longer claim `--sh-flank-content-min` of the row — content-driven,
 * not a viewport breakpoint.
 *
 * The flanking child is the first one. Add `flank-end` to move it to the last:
 * `<div class="flank flank-end">`.
 *
 * Knobs:
 * - `--sh-gap` (default `var(--sh-space-md)`) — space between the two children.
 * - `--sh-align` (default `flex-start`) — cross-axis alignment of the children.
 * - `--sh-flank-size` (default `auto`) — target inline size of the flanking child.
 * - `--sh-flank-content-min` (default `50%`) — the share of the row the filling child needs before
 *   the two wrap onto separate lines.
 *
 * `--sh-flank-size` and `--sh-flank-content-min` are read on the *children*, so unlike the other
 * knobs they are ordinary inheriting custom properties. Set them on the `.flank` itself.
 */

.flank {
	display: flex;
	flex-wrap: wrap;
	gap: var(--sh-gap, var(--sh-space-md));
	align-items: var(--sh-align, flex-start);
}

.flank > * {
	flex-grow: 1;
	flex-basis: var(--sh-flank-size, auto);
}

/* The filling child: the last one, or the first one under `flank-end`. `flex-grow: 999` is what
   makes it soak up every spare pixel while the flank keeps its basis. */

.flank > :last-child,
.flank.flank-end > :first-child {
	flex-grow: 999;
	flex-basis: 0;
	min-inline-size: var(--sh-flank-content-min, 50%);
}

/* Under `flank-end` the last child goes back to flanking. Two classes deep, so this outranks the
   rule above at equal source order. */

.flank.flank-end > :last-child {
	flex-grow: 1;
	flex-basis: var(--sh-flank-size, auto);
	min-inline-size: auto;
}
