/*------------------------------------------------------------------------------
# Margins (Vertical spacing)
------------------------------------------------------------------------------*/

/* Don't add top margin to top-level blocks (header, title, main, footer) */
:root :where(.wp-site-blocks) > * {
	margin-block-start: 0 !important; 
}

/* Add top margin to main unless its the post content or a featured image */
main > :first-child:not(.wp-block-post-content):not(.wp-block-post-featured-image):not(.wp-block-cover) {
	margin-block-start: var(--wp--style--block-gap);
}

/* Push top margin down on Groups and Columns that have template parts in them */
// :root :where(.is-layout-flow) > .wp-block-template-part > *:not(.wp-block-template-part),
// :root :where(.is-layout-constrained) > .wp-block-template-part > *:not(.wp-block-template-part) {
:root :where(.is-layout-flow) > .wp-block-template-part > *,
:root :where(.is-layout-constrained) > .wp-block-template-part > * {
 	margin-block-start: var(--wp--style--block-gap);
}

:root :where(.is-layout-flow) > .wp-block-template-part > :first-child:not(.wp-block-comments),
:root :where(.is-layout-constrained) > .wp-block-template-part > :first-child:not(.wp-block-comments) {
	margin-block-start: 0;
}

/* But don't put any top margin on the individual columns */
:root :where(.wp-block-columns-is-layout-flow) > .wp-block-column,
:root :where(.wp-block-columns-is-layout-constrained) > .wp-block-column {
	margin-block-start: 0;
}

/* 
 * Push top margin on Post Content down to the block level so users can control 
 * it by adjusting margin on the block itself.
 */
.wp-site-blocks .wp-block-post-content {
	margin-block-start: 0;
// 	margin-top: 0;
}

:root :where(.wp-block-post-content) > :first-child:not(.wp-block-cover) { //,
// .wp-block-post-content > :last-child {
	margin-block-start: var(--wp--style--block-gap);
}

/* 
 * But don't add it when the Template has columns (i.e. there is a Sidebar) and 
 * the Post Content is the first thing in the column (i.e. No Featured Image before 
 * it)*/
main > .wp-block-columns > .wp-block-column > :first-child.wp-block-post-content > :first-child {
	margin-block-start: 0;
}

/* Add bottom margin to main unless its the post content, then add it to that */
main > :last-child:not(.wp-block-post-content),
// main > :last-child:not(.wp-block-post-content):not(.wp-block-template-part),
:root :where(.is-layout-flow).wp-block-post-content > :last-child,
:root :where(.is-layout-constrained).wp-block-post-content > :last-child {	
	margin-block-end: var(--wp--style--block-gap);
}
