/*
 * Loose text blocks on a PAGE (F23).
 *
 * The parent's page owl (`.entry-content > * + *`, 0,1,0) puts one --kd-section-gap
 * (120 / 96 / 64) between every pair of top-level blocks. That is right between
 * stacked pattern sections, wrong between paragraphs, headings, lists, images,
 * separators, embeds and buttons typed straight onto a page. This partial restores
 * normal text rhythm ONLY where a loose text block follows another loose text block.
 *
 * Do NOT key on `.kd-section`: 24 of the 35 LTS patterns do not carry it. The list
 * below is by block type, so a pattern (a group / cover / columns root) is never
 * matched and keeps the full section gap before and after it, including a loose
 * H2 that follows a pattern.
 *
 * Specificity: `.entry-content:not(<prose> .entry-content) > :is(..) + :is(..)`
 * is 0,5,0 (the :not() argument counts 0,2,0 and each :is() its most specific
 * argument, 0,1,0); the heading rule adds `.wp-block-heading`, 0,5,1. Both beat the
 * owl's 0,1,0, so no !important. A margin set with the Spacing control is an inline
 * style and beats this rule, as intended.
 * Scope: the parent's "prose" test (`.kd-single`) plus the LTS article template's
 * `main.lts-article` (the child's single-post template replaces `.kd-single`). Single
 * posts and CPTs keep the parent's and lts-article.css's rhythm. It is keyed on the
 * ancestor, not `body:not(.single)`, because editor styles rewrite a leading `body`
 * to `.editor-styles-wrapper`, which never has `.single` (Show template in the post
 * editor renders `.entry-content` too).
 *
 * Editor: the page owl needs `.entry-content`, which the post editor's root container
 * does not have, so the editor shows the default block gap. Only the heading
 * grouping is restated there (pages only, like lts-article.css does for posts).
 */

.entry-content:not(:is(.kd-single, .lts-article) .entry-content)
	> :is(
		p,
		h2,
		h3,
		h4,
		h5,
		h6,
		ul,
		ol,
		.wp-block-quote,
		.wp-block-pullquote,
		.wp-block-code,
		.wp-block-image,
		.wp-block-gallery,
		.wp-block-embed,
		.wp-block-table,
		.wp-block-details,
		.wp-block-separator,
		.wp-block-buttons
	)
	+ :is(
		p,
		h2,
		h3,
		h4,
		h5,
		h6,
		ul,
		ol,
		.wp-block-quote,
		.wp-block-pullquote,
		.wp-block-code,
		.wp-block-image,
		.wp-block-gallery,
		.wp-block-embed,
		.wp-block-table,
		.wp-block-details,
		.wp-block-separator,
		.wp-block-buttons
	) {
	margin-block-start: var(--wp--preset--spacing--40); /* 24 */
}

/* A heading groups with what follows it, so it sits further from the text above. */
.entry-content:not(:is(.kd-single, .lts-article) .entry-content)
	> :is(
		p,
		h2,
		h3,
		h4,
		h5,
		h6,
		ul,
		ol,
		.wp-block-quote,
		.wp-block-pullquote,
		.wp-block-code,
		.wp-block-image,
		.wp-block-gallery,
		.wp-block-embed,
		.wp-block-table,
		.wp-block-details,
		.wp-block-separator,
		.wp-block-buttons
	)
	+ :is(h2, h3).wp-block-heading {
	margin-block-start: var(--wp--preset--spacing--50); /* 40 */
}

/* Editor parity (pages): same heading grouping on the root container. */
.editor-styles-wrapper.post-type-page
	.is-root-container
	> :is(
		p,
		h2,
		h3,
		h4,
		h5,
		h6,
		ul,
		ol,
		.wp-block-quote,
		.wp-block-pullquote,
		.wp-block-code,
		.wp-block-image,
		.wp-block-gallery,
		.wp-block-embed,
		.wp-block-table,
		.wp-block-details,
		.wp-block-separator,
		.wp-block-buttons
	)
	+ :is(h2, h3).wp-block-heading {
	margin-block-start: var(--wp--preset--spacing--50);
}
