/* Article prose only. !important deliberately overrides Core inline spacing and
   Spectra's generated per-block spacing; typography and layout remain separate. */
:is(body.single-post #primary .entry-content, .editor-styles-wrapper.post-type-post .is-root-container) {
    --lh-article-text-gap:16px;
    --lh-article-section-gap:32px;
    --lh-article-media-gap:24px;
    --lh-article-item-gap:8px;
    --wp--style--block-gap:var(--lh-article-text-gap);
    overflow-wrap:anywhere;
}

/* Each content block owns only its leading space. Internal wrappers add none. */
:is(body.single-post #primary .entry-content, .editor-styles-wrapper.post-type-post .is-root-container)
:where(p,h1,h2,h3,h4,h5,h6,ul,ol,blockquote,pre,figure,
    .wp-block-group,.wp-block-columns,.wp-block-column,.wp-block-buttons,
    .wp-block-uagb-container,.wp-block-uagb-advanced-heading,.wp-block-uagb-image,
    .wp-block-uagb-buttons,.wp-block-uagb-icon-list):where(:not(#ez-toc-container *)) {
    --lh-article-block-gap:var(--lh-article-text-gap);
    margin:0 !important;
    padding:0 !important;
}

:is(body.single-post #primary .entry-content, .editor-styles-wrapper.post-type-post .is-root-container)
:where(h1,h2,h3,h4,h5,h6,.wp-block-uagb-advanced-heading:has(> :is(h1,h2,h3,h4,h5,h6))) {
    --lh-article-block-gap:var(--lh-article-section-gap);
}
:is(body.single-post #primary .entry-content, .editor-styles-wrapper.post-type-post .is-root-container)
:where(figure,blockquote,pre,.wp-block-group,.wp-block-columns,.wp-block-uagb-container,.wp-block-uagb-image) {
    --lh-article-block-gap:var(--lh-article-media-gap);
}

/* Works for plain HTML, native blocks and Spectra block wrappers at any depth. */
:is(body.single-post #primary .entry-content, .editor-styles-wrapper.post-type-post .is-root-container)
:where(p,h1,h2,h3,h4,h5,h6,ul,ol,blockquote,pre,figure,div,hr) +
:where(p,h1,h2,h3,h4,h5,h6,ul,ol,blockquote,pre,figure,
    .wp-block-group,.wp-block-columns,.wp-block-buttons,.wp-block-uagb-container,
    .wp-block-uagb-advanced-heading,.wp-block-uagb-image,.wp-block-uagb-buttons,.wp-block-uagb-icon-list):where(:not(#ez-toc-container *)) {
    margin-top:var(--lh-article-block-gap,var(--lh-article-text-gap)) !important;
}

:is(body.single-post #primary .entry-content, .editor-styles-wrapper.post-type-post .is-root-container)
:where(.wp-block-group,.wp-block-column,.wp-block-uagb-container,.uagb-container-inner-blocks-wrap,.wp-block-group__inner-container) {
    row-gap:0 !important;
    column-gap:var(--lh-article-media-gap) !important;
}
:is(body.single-post #primary .entry-content, .editor-styles-wrapper.post-type-post .is-root-container)
:where(.uagb-container-inner-blocks-wrap,.wp-block-group__inner-container,.uagb-image__figure,.uagb-image__figure img) {
    margin:0 !important;
    padding:0 !important;
}

/* Keep actual columns/rows and galleries as layouts, with one shared gap. */
:is(body.single-post #primary .entry-content, .editor-styles-wrapper.post-type-post .is-root-container)
:where(.wp-block-columns,.wp-block-gallery,.wp-block-buttons,.wp-block-uagb-buttons,.wp-block-group.is-layout-flex,.wp-block-group.is-layout-grid,
    .wp-block-uagb-container:has(> .wp-block-uagb-container),.uagb-container-inner-blocks-wrap:has(> .wp-block-uagb-container)) {
    gap:var(--lh-article-media-gap) !important;
}
:is(body.single-post #primary .entry-content, .editor-styles-wrapper.post-type-post .is-root-container)
:where(.wp-block-columns,.wp-block-gallery,.wp-block-buttons,.wp-block-group.is-layout-flex,.wp-block-group.is-layout-grid,
    .wp-block-uagb-container,.uagb-container-inner-blocks-wrap) > :is(.wp-block-column,.wp-block-uagb-container),
:is(body.single-post #primary .entry-content, .editor-styles-wrapper.post-type-post .is-root-container)
:where(.wp-block-gallery,.wp-block-buttons,.wp-block-group.is-layout-flex,.wp-block-group.is-layout-grid) > * {
    margin-block:0 !important;
}

:is(body.single-post #primary .entry-content, .editor-styles-wrapper.post-type-post .is-root-container)
:where(ul,ol):where(:not(#ez-toc-container *)) { padding-inline-start:24px !important; }
:is(body.single-post #primary .entry-content, .editor-styles-wrapper.post-type-post .is-root-container)
:where(li):where(:not(#ez-toc-container *)) { margin:0 !important;padding:0 !important; }
:is(body.single-post #primary .entry-content, .editor-styles-wrapper.post-type-post .is-root-container)
:where(li + li,li > ul,li > ol):where(:not(#ez-toc-container *)) { margin-top:var(--lh-article-item-gap) !important; }

:is(body.single-post #primary .entry-content, .editor-styles-wrapper.post-type-post .is-root-container)
:where(figcaption,.wp-element-caption,.uagb-image-caption) { margin:8px 0 0 !important;padding:0 !important; }
:is(body.single-post #primary .entry-content, .editor-styles-wrapper.post-type-post .is-root-container)
:where(blockquote,pre) { padding:16px 24px !important; }
:is(body.single-post #primary .entry-content, .editor-styles-wrapper.post-type-post .is-root-container)
:where(table) { margin:0 !important; }
:is(body.single-post #primary .entry-content, .editor-styles-wrapper.post-type-post .is-root-container)
:where(th,td) { padding:12px 16px !important; }
:is(body.single-post #primary .entry-content, .editor-styles-wrapper.post-type-post .is-root-container)
:where(.wp-block-button__link,.uagb-buttons-repeater) { padding:12px 24px !important;margin:0 !important; }

/* Alignment is a content choice, independent of standardized vertical spacing. */
:is(body.single-post #primary .entry-content, .editor-styles-wrapper.post-type-post .is-root-container)
:where(.aligncenter) { margin-inline:auto !important; }
:is(body.single-post #primary .entry-content, .editor-styles-wrapper.post-type-post .is-root-container)
:where(.alignright) { margin-inline-start:auto !important; }

:is(body.single-post #primary .entry-content, .editor-styles-wrapper.post-type-post .is-root-container)
:where(.uagb-buttons__wrap) { gap:var(--lh-article-media-gap) !important;margin:0 !important;padding:0 !important; }
:is(body.single-post #primary .entry-content, .editor-styles-wrapper.post-type-post .is-root-container)
:where(.uagb-icon-list__wrap,.uagb-icon-list__content-wrap) { gap:var(--lh-article-item-gap) !important;margin:0 !important;padding:0 !important; }

/* Gutenberg adds a wrapper around Spectra's heading, unlike its saved markup. */
.editor-styles-wrapper.post-type-post .is-root-container
[data-type="uagb/advanced-heading"]:has(:is(h1,h2,h3,h4,h5,h6)) { --lh-article-block-gap:var(--lh-article-section-gap); }
.editor-styles-wrapper.post-type-post .is-root-container
[data-type="uagb/advanced-heading"] > .wp-block-uagb-advanced-heading { margin:0 !important;padding:0 !important; }
