/* Block spacing — a vertical rhythm for anything built in the block editor.
 *
 * WHY THIS EXISTS
 *
 * Content built from blocks ran together: sections butted against the block
 * above, a row of cards touched the next heading. Measured 24 Nov 2026 on the
 * 30th Celebration demo guide: 0px between a Columns block and the H2 after it.
 * Three things stack up to cause it:
 *
 *   1. Bootscore's own `_deprecated.scss` (marked "removed in v7") sets
 *        .is-layout-flow:not(.hide-wp-block-classes.is-layout-flow) > * { margin-block-start: 0 }
 *      — every block inside a Group or Column loses its top margin. At (0,3,0)
 *      it beats anything ordinary.
 *   2. WordPress's own block gap (24px here) is written as
 *        :root :where(.is-layout-flow) > * { margin-block-start: 24px }
 *      — zero specificity, so (1) and even Bootstrap's `h2 { margin-top: 0 }` win.
 *   3. In a classic theme the post content itself is not a layout container, so
 *      top-level blocks get no WordPress gap at all; only Bootstrap's paragraph
 *      and list bottom margins separate anything.
 *
 * WHAT THIS DOES
 *
 *   - Gives every block a bottom margin of one block gap, at ZERO specificity
 *     (:where), so any block that sets its own margin keeps it. Full-width bands
 *     (.alignfull) are left flush — the homepage hero, countdown and winners
 *     band are designed to touch.
 *   - Gives H2/H3 extra space ABOVE them when they follow something — section
 *     breaks — at a specificity that beats (1). Headings that open a container
 *     stay tight to its top.
 *
 * Loaded on the front end and inside the editor canvas, with the editor's root
 * container (.is-root-container) alongside .entry-content, so a page looks the
 * same in both. The parent rule is not removed: it is the parent theme's, and
 * Bootscore v7 drops it anyway; this overrides only what it broke.
 */

:root {
  --ep-block-gap: 1.5rem;
  --ep-section-gap: 2.75rem;
  --ep-subsection-gap: 1.75rem;
}

/* ---- 1. A gap after every block, unless the block says otherwise --------- */

:where(.entry-content, .is-root-container, .is-layout-flow, .is-layout-constrained) > :where(:not(:last-child):not(.alignfull):not(style):not(script)) {
  margin-block-end: var(--ep-block-gap);
}

/* Bands are designed to touch each other and the content around them. */
:where(.entry-content, .is-root-container) > :where(.alignfull) {
  margin-block-start: 0;
  margin-block-end: 0;
}

/* ---- 2. Section breaks: space above H2/H3 that follow something ---------- */

body .entry-content > h2:not(:first-child),
body .is-root-container > h2:not(:first-child),
body .entry-content .is-layout-flow:not(.hide-wp-block-classes.is-layout-flow) > h2:not(:first-child),
body .is-root-container .is-layout-flow:not(.hide-wp-block-classes.is-layout-flow) > h2:not(:first-child) {
  margin-block-start: var(--ep-section-gap);
}

body .entry-content > h3:not(:first-child),
body .is-root-container > h3:not(:first-child),
body .entry-content .is-layout-flow:not(.hide-wp-block-classes.is-layout-flow) > h3:not(:first-child),
body .is-root-container .is-layout-flow:not(.hide-wp-block-classes.is-layout-flow) > h3:not(:first-child) {
  margin-block-start: var(--ep-subsection-gap);
}

/* Headings inside small containers (cards, callouts, the hero, an FAQ answer)
   are labels, not section breaks: no extra space there. */
body :is(.is-style-ep-card, .is-style-ep-callout, .is-style-ep-cta-band, .ep-hub-hero, .wp-block-details) h2:not(:first-child),
body :is(.is-style-ep-card, .is-style-ep-callout, .is-style-ep-cta-band, .ep-hub-hero, .wp-block-details) h3:not(:first-child) {
  margin-block-start: 0.25rem;
}

/* A heading and the line under it belong together. */
body :is(.entry-content, .is-root-container) :is(h2, h3) + p {
  margin-block-start: 0;
}
