/* ==========================================================================
   SECTION RHYTHM — the whitespace at a join between two stacked sections
   ==========================================================================
   v9b brief, Round 62 (item BA2), client: "the gaps between sections are
   inconsistent and several are too big — the gap above the Designers Edit
   heading is the size I want."

   THE ARITHMETIC, which is the whole bug. pb-shell gives every .section a full
   --section-gap of padding on BOTH sides. So an ordinary join between two plain
   sections is padding-bottom + padding-top = TWO gaps, while the join beside a
   full-bleed band is ONE, purely because the band pads zero and only the
   neighbour contributes. Add .section--tight on --section-gap-s and you get a
   third and a fourth size. Measured on this theme at 1440px before this file
   existed: 113.8, 92.9, 56.9 and 36px joins on the home page — four sizes, none
   of them chosen. This was read as a tuning problem for several rounds and
   "fixed" one section at a time, which is why it kept coming back: no amount of
   nudging one section makes a sum of two terms equal a sum of one.

   THE FIX, in three rules. Normalise every plain section to a full gap per side
   [A], then halve BOTH facing sides wherever two plain sections actually meet
   [B] — so that join totals exactly one --section-gap, the reference, unchanged.
   Every other edge is left alone: a section facing a band, a hero, a breadcrumb
   or the end of the flow keeps its whole gap, because there is no facing
   padding to pair with and the whitespace beside a band lives entirely in its
   neighbour. Net effect: one join size everywhere, at every width.

   Stating it as "halve where two meet" rather than "halve everything, then put
   the full gap back at the edges" is what keeps this short. The edge cases are
   the majority of the awkward ones — first child, last child, either side of
   each band, under the breadcrumb — and every one of them is handled by not
   being mentioned.

   SCOPE: GLOBAL, not front-page-only. v9b scoped this to home.css and left its
   own inner-page sheets on the old arithmetic, because the mockup has one CSS
   file per page. This theme has no per-page sheets — the primitive is shared,
   so the same double gap lands on every template, and measurably did: the
   Designers' Edit page had the identical 113.8px joins at 1440. Scoping to the
   home page here is also not really available: this install has no static front
   page (show_on_front is "posts"), so front-page.php never executes and the
   `home` body class lands on the blog index, not on the home preview. A page-id
   selector would key the site's vertical rhythm to a database row. To narrow
   this later, put a body-level selector in front of the three rules; nothing
   else needs to change.

   SPECIFICITY, and the trap in it — v9b lost a round to this one. The weights
   are deliberate and are the first thing to check before editing:

     [A] normalise   main {plain}                       (0,2,1)
     [B] halve       main {plain} meeting {plain}        (0,4,1)

   [A] must clear pb-shell's `.section` and `.section--tight`, both (0,1,0), and
   pb-range's `.pb-range .home-faq` at (0,2,0). The leading `main` type selector
   buys that on SPECIFICITY rather than on load order — this project has been
   bitten by order-dependent ties before, and the block sheets load BEFORE the
   theme parts here, not after, so "later in the cascade" is not a safe instinct.
   [B] must clear [A], which it does by carrying the plain-section compound
   twice. v9b's first cut inverted this: it wrote the BASE with :not(), did not
   account for :not() contributing the specificity of its argument, and the base
   came out heavier than the edge rules — every join silently came out half
   size, the reference included.

   WHAT COUNTS AS A PLAIN SECTION. .section and .section--tight are the shell
   primitive. .trick was named alongside them because the editorial callout from
   blocks/pb_ec_{slug}/ duplicated `padding-block: var(--section-gap)` without
   carrying .section, and the durable fix was said to be for that block to carry
   .section. IT DOES NOW (2026-08-18, the v9b restructure), and it also carries
   .section--recessed, so it has moved into the EXCLUDED list below — correct by
   this file's own rule, because the band paints a visible ground and its padding
   is band geometry rather than join whitespace. .trick is kept in the :is() list
   as a no-op safety net for any stored markup predating that change; if you are
   auditing dead selectors, this is one, and removing it changes nothing today.

   WHAT IS EXCLUDED, and why only these. A section is excluded when it paints
   its own visible ground, because then its padding is band GEOMETRY — interior
   space inside a coloured area — rather than join whitespace, and halving it
   would shrink the band rather than the gap:
     .section--recessed  --surface-recessed is bone-deep, a visibly distinct well
     .cta-band           near-black ground; its half gap centres the copy
                         against the flush footer, stated by its own block sheet
     .shop-band          pads zero so the photograph fills the band
   .section--inverse is deliberately NOT excluded: v9b flattened
   --surface-inverse to white, so it paints white on a white page ground and
   there is no visible edge — its padding really is join whitespace. Check the
   token before adding anything to this list; it is the difference between a
   band and an ordinary section. .shop-band has no block in this theme yet and
   is listed because it is the band the reference design pairs the REFERENCE
   join with, so a later port is already covered.

   ASSUMPTION worth knowing: [B] uses adjacent-sibling matching, so it needs the
   two sections to be true DOM neighbours. A non-rendering element emitted
   between them (a stray inline <style>, say) would break the match and that one
   join would revert to the old double gap. There are none inside <main> on any
   template today — verified, not assumed — and the failure is visible rather
   than silent, so this is not guarded against.

   WHY .section--tight IS FOLDED IN. Once a join has to be one size everywhere,
   a "tighter" variant is a contradiction: it can only reintroduce a second
   size. So --section-gap-s no longer sets vertical rhythm at a join and the
   modifier keeps only whatever else it carries. This is v9b's call, not a new
   one — its home fix overrides .section--tight the same way.
   ========================================================================== */

/* [A] Normalise. Every plain section is one full gap per side. On .section this
   restates what pb-shell already says; the real work is pulling .section--tight
   off --section-gap-s and .trick under the same roof. */
main :is(.section, .section--tight, .trick):not(.section--recessed, .cta-band, .shop-band) {
  padding-block: var(--section-gap);
}

/* [B] Halve where two plain sections MEET, so the pair totals one gap. Both
   halves are needed: each section is only ever responsible for its own side. */
main :is(.section, .section--tight, .trick):not(.section--recessed, .cta-band, .shop-band):has(
    + :is(.section, .section--tight, .trick):not(.section--recessed, .cta-band, .shop-band)
  ) {
  padding-bottom: calc(var(--section-gap) / 2);
}

main :is(.section, .section--tight, .trick):not(.section--recessed, .cta-band, .shop-band)
  + :is(.section, .section--tight, .trick):not(.section--recessed, .cta-band, .shop-band) {
  padding-top: calc(var(--section-gap) / 2);
}
