/*
 * Default rhythm for direct children of Post Content.
 *
 * Full-width sections remain outside the prose rhythm so adjacent page
 * sections can still meet edge to edge. Explicit Block Supports values remain
 * authoritative over these low-specificity defaults.
 *
 * The editor selector targets the core/post-content block itself rather than
 * a generic layout class. Combined with the child combinator, this keeps the
 * rhythm out of nested Groups, Stacks, Rows, Grids and component internals.
 */
:root .wp-block-post-content
	> :where(
		:not(p):not(h1):not(h2):not(h3):not(h4):not(h5):not(h6):not(ul):not(ol):not(.wp-block-list):not([data-type="core/list"]):not(.wp-block-spacer):not(.wp-block-separator):not(.alignfull)
	),
.editor-styles-wrapper
	[data-type="core/post-content"].wp-block-post-content
	> :where(
		:not(p):not(h1):not(h2):not(h3):not(h4):not(h5):not(h6):not(ul):not(ol):not(.wp-block-list):not([data-type="core/list"]):not(.wp-block-spacer):not(.wp-block-separator):not([data-type="core/spacer"]):not([data-type="core/separator"]):not(.alignfull):not([data-align="full"])
) {
	margin-block: var(--wp--preset--spacing--50);
}

/* Headings establish progressively stronger section boundaries. */
:root .wp-block-post-content
	> :where(h2, h2.wp-block-heading),
.editor-styles-wrapper
	[data-type="core/post-content"].wp-block-post-content
	> :where([data-type="core/heading"]:has(h2)) {
	margin-block-start: var(--wp--preset--spacing--60);
	margin-block-end: var(--wp--preset--spacing--40);
}

:root .wp-block-post-content
	> :where(h3, h3.wp-block-heading),
.editor-styles-wrapper
	[data-type="core/post-content"].wp-block-post-content
	> :where([data-type="core/heading"]:has(h3)) {
	margin-block-start: var(--wp--preset--spacing--50);
	margin-block-end: var(--wp--preset--spacing--40);
}

:root .wp-block-post-content
	> :where(h1, h4, h5, h6, h1.wp-block-heading, h4.wp-block-heading, h5.wp-block-heading, h6.wp-block-heading),
.editor-styles-wrapper
	[data-type="core/post-content"].wp-block-post-content
	> :where(
		[data-type="core/heading"]:has(h1),
		[data-type="core/heading"]:has(h4),
		[data-type="core/heading"]:has(h5),
		[data-type="core/heading"]:has(h6)
	) {
	margin-block-start: var(--wp--preset--spacing--40);
	margin-block-end: var(--wp--preset--spacing--40);
}

/* Spacer owns its height and therefore must not add external whitespace. */
:root .wp-block-post-content
	> :where(.wp-block-spacer),
.editor-styles-wrapper
	[data-type="core/post-content"].wp-block-post-content
	> :where([data-type="core/spacer"], .wp-block-spacer) {
	margin-block: 0;
}

/* A Separator gets the regular text-flow interval on both sides. */
:root .wp-block-post-content
	> :where(.wp-block-separator),
.editor-styles-wrapper
	[data-type="core/post-content"].wp-block-post-content
	> :where([data-type="core/separator"], .wp-block-separator) {
	margin-block: var(--wp--preset--spacing--30);
}

/*
 * Lists are part of editorial prose rather than generic non-text blocks.
 * Keep their rhythm symmetrical without relying on margin collapsing: the
 * list owns the space before it, while the following ordinary sibling owns
 * the space after it. Headings and structural sections keep their own rhythm.
 */
.wp-block-post-content
	> :where(.wp-block-list, ul, ol),
.editor-styles-wrapper
	[data-type="core/post-content"].wp-block-post-content
	> :where(.wp-block-list, [data-type="core/list"]) {
	margin-block-start: var(--wp--preset--spacing--40);
	margin-block-end: 0;
}

.wp-block-post-content
	> :where(.wp-block-list, ul, ol)
	+ :where(
		:not(h1):not(h2):not(h3):not(h4):not(h5):not(h6):not(.wp-block-heading):not(.wp-block-group):not(.wp-block-cover):not(.alignfull)
	),
.editor-styles-wrapper
	[data-type="core/post-content"].wp-block-post-content
	> :where(.wp-block-list, [data-type="core/list"])
	+ :where(
		:not(h1):not(h2):not(h3):not(h4):not(h5):not(h6):not(.wp-block-heading):not([data-type="core/heading"]):not(.wp-block-group):not(.wp-block-cover):not(.alignfull):not([data-align="full"])
	) {
	margin-block-start: var(--wp--preset--spacing--40);
}

/* A heading followed by a list retains the regular heading-to-copy gap. */
.wp-block-post-content
	> :where(h1, h2, h3, h4, h5, h6, .wp-block-heading)
	+ :where(.wp-block-list, ul, ol),
.editor-styles-wrapper
	[data-type="core/post-content"].wp-block-post-content
	> :where(.wp-block-heading, [data-type="core/heading"])
	+ :where(.wp-block-list, [data-type="core/list"]) {
	margin-block-start: var(--wp--preset--spacing--30);
}

/* The content edge owns the opening space; its first block must not add it. */
:root .wp-block-post-content > :where(:first-child),
.editor-styles-wrapper
	[data-type="core/post-content"].wp-block-post-content
	> :where(:first-child) {
	margin-block-start: 0;
}

/*
 * Editor-only insertion corridor between structural page sections.
 *
 * Gutenberg's sibling inserter can become difficult to hit when two full-width
 * blocks have a zero gap. The small editor-only margin gives the insertion
 * point a stable hover target without creating whitespace on the front end.
 */
.editor-styles-wrapper
	[data-type="core/post-content"].wp-block-post-content
	> :where(.wp-block-cover, .is-style-sggw-section-shell)
	+ :where(.wp-block-cover, .is-style-sggw-section-shell) {
	margin-block-start: var(--wp--preset--spacing--20) !important;
}
