/**
 * Gap between a heading and its neighbours (ISS-0060, ISS-0081).
 *
 * AFTER (ISS-0060): `flow.heading-N.after`, the gap between a heading and what follows. Loaded by default since
 * ISS-0080: Apparence's default aeration writes it (8 → 12 px, fluid).
 *
 * BEFORE (ISS-0081): `flow.heading-N.before`, the gap above h2 to h6 — what Apparence's prose gives a section
 * title (56 / 36 / 28 px, a flat value) and WordPress did not: a heading took the block gap (24 px), far too tight
 * under a 34 px h2. The token is in `em` — of the heading's OWN size, as Tailwind Typography does (2 / 1.6 / 1.5 em):
 * h2 1.65 em, h3 to h6 1.3 em. At Moyen on a desktop that is Apparence's 56 / 36 / 28 px. It follows the aeration
 * through the heading size (Compact / Moyen / Aéré scale the titles), shrinks with them on a phone, and follows a
 * size the webmaster sets in Styles. A px multiple of the block gap did none of this: 80 px over a 28 px h2 in Aéré.
 * Three rules keep it from going wrong:
 *   - h1 has no rule: it opens the page, it keeps the plain flow gap, as Tailwind and GitHub treat it;
 *   - a FIRST child never gets it (`:where(:not(:first-child))` — zero specificity, so the order below still
 *     decides): WordPress zeroes a first child's margin, and a rule above (0,1,0) would bring the gap back;
 *   - a heading right after a heading keeps the AFTER gap of the one above, so a subtitle stays attached: the
 *     BEFORE rules come first, the AFTER rules second, same specificity, the later one wins.
 *
 * Specificity (0,1,1) beats WordPress's flow gap (0,1,0); a margin set on the block itself (inline style) still
 * wins — the webmaster keeps the last word. Both halves load together, behind the `jetstream_heading_flow` filter.
 */

/* BEFORE — above a heading (ISS-0081). */
:where(.is-layout-flow, .is-layout-constrained) > .wp-block-heading:is(h2):where(:not(:first-child)) {
	margin-block-start: var(--wp--custom--semantic--spacing--flow--heading-2--before);
}

:where(.is-layout-flow, .is-layout-constrained) > .wp-block-heading:is(h3):where(:not(:first-child)) {
	margin-block-start: var(--wp--custom--semantic--spacing--flow--heading-3--before);
}

:where(.is-layout-flow, .is-layout-constrained) > .wp-block-heading:is(h4):where(:not(:first-child)) {
	margin-block-start: var(--wp--custom--semantic--spacing--flow--heading-4--before);
}

:where(.is-layout-flow, .is-layout-constrained) > .wp-block-heading:is(h5):where(:not(:first-child)) {
	margin-block-start: var(--wp--custom--semantic--spacing--flow--heading-5--before);
}

:where(.is-layout-flow, .is-layout-constrained) > .wp-block-heading:is(h6):where(:not(:first-child)) {
	margin-block-start: var(--wp--custom--semantic--spacing--flow--heading-6--before);
}

/* AFTER — below a heading (ISS-0060). */
:where(.is-layout-flow, .is-layout-constrained) > .wp-block-heading:is(h1) + * {
	margin-block-start: var(--wp--custom--semantic--spacing--flow--heading-1--after);
}

:where(.is-layout-flow, .is-layout-constrained) > .wp-block-heading:is(h2) + * {
	margin-block-start: var(--wp--custom--semantic--spacing--flow--heading-2--after);
}

:where(.is-layout-flow, .is-layout-constrained) > .wp-block-heading:is(h3) + * {
	margin-block-start: var(--wp--custom--semantic--spacing--flow--heading-3--after);
}

:where(.is-layout-flow, .is-layout-constrained) > .wp-block-heading:is(h4) + * {
	margin-block-start: var(--wp--custom--semantic--spacing--flow--heading-4--after);
}

:where(.is-layout-flow, .is-layout-constrained) > .wp-block-heading:is(h5) + * {
	margin-block-start: var(--wp--custom--semantic--spacing--flow--heading-5--after);
}

:where(.is-layout-flow, .is-layout-constrained) > .wp-block-heading:is(h6) + * {
	margin-block-start: var(--wp--custom--semantic--spacing--flow--heading-6--after);
}
