/* Case content only. Inline spacing chosen in Gutenberg still takes priority. */
:is(.portfolio-case__content, .editor-styles-wrapper) {
	--case-text-gap: 16px;
	--wp--style--block-gap: var(--case-text-gap);
}

/* Use one-sided spacing so parent-theme margins cannot accumulate. */
:is(.portfolio-case__content, .editor-styles-wrapper) :where(p, h2, h3, h4, h5, h6, .wp-block-image, .wp-block-columns, .wp-block-group) {
	margin-block: 0;
}

:is(.portfolio-case__content, .editor-styles-wrapper) :is(p, ul, ol) + :is(p, ul, ol) {
	margin-block-start: var(--case-text-gap);
}

/* Section separation, including text/image rows and numbered concept groups. */
:is(.portfolio-case__content, .editor-styles-wrapper) :is(p, ul, ol, .wp-block-image, .wp-block-columns, .wp-block-group) + :is(h2, h3, h4, h5, h6) {
	margin-block-start: 48px;
}
:is(.portfolio-case__content, .editor-styles-wrapper) :is(p, ul, ol, .wp-block-image, .wp-block-columns, .wp-block-group) + :is(.wp-block-image, .wp-block-columns, .wp-block-group) {
	margin-block-start: 32px;
}
:is(.portfolio-case__content, .editor-styles-wrapper) :is(.wp-block-image, .wp-block-columns) + p {
	margin-block-start: 32px;
}
:is(.portfolio-case__content, .editor-styles-wrapper) .wp-block-group + p {
	margin-block-start: 12px;
}

/* A heading also owns the gap when its text is wrapped in columns/a group. */
:is(.portfolio-case__content, .editor-styles-wrapper) h2 + * {
	margin-block-start: 24px;
}
:is(.portfolio-case__content, .editor-styles-wrapper) h3 + * {
	margin-block-start: 20px;
}
:is(.portfolio-case__content, .editor-styles-wrapper) :is(h4, h5, h6) + * {
	margin-block-start: 12px;
}

/* Flex stacks use gap rather than collapsing margins. Columns retain their
   horizontal gutter; only their mobile stacking distance is normalized. */
:is(.portfolio-case__content, .editor-styles-wrapper) .is-layout-flex.is-vertical {
	gap: 12px;
}
:is(.portfolio-case__content, .editor-styles-wrapper) .is-layout-flex.is-vertical > * {
	margin-block: 0;
}
/* Gutenberg Row owns both horizontal and wrapped-row spacing through gap.
   Do not apply prose sibling margins to its direct children. */
:is(.portfolio-case__content, .editor-styles-wrapper) .wp-block-group.is-layout-flex:not(.is-vertical) > * {
	margin-block: 0;
}
:is(.portfolio-case__content, .editor-styles-wrapper) .wp-block-columns {
	row-gap: 32px;
}
/* Existing intentional spacers elsewhere remain explicit, without extra gaps. */
:is(.portfolio-case__content, .editor-styles-wrapper) .wp-block-spacer,
:is(.portfolio-case__content, .editor-styles-wrapper) .wp-block-spacer + * {
	margin-block-start: 0;
}
