/* ── EverPharma blocks — shared vertical rhythm ───────────────────────────────
   Loaded once for every evr block, front end and editor.

   Goal: the blocks can be placed in ANY order and still keep even distances,
   without the editor having to hand-tune a spacer between each pair.

   How it works
   ------------
   `main` is a normal block container in this theme, so adjacent siblings'
   vertical margins COLLAPSE. Giving every block the same margin on both sides
   means:

     block + block            → one gap, never two
     heading + block          → the larger of the two, never their sum
     block + block + block    → even rhythm regardless of which blocks

   That is the whole trick — it is why the spacing survives reordering. Do not
   switch these to a one-sided margin, and do not give a block wrapper
   `overflow`, `display: flow-root` or a `position` that would stop it
   collapsing with its siblings.

   An explicit spacer always wins: if the editor drops a core spacer next to a
   block, the block drops its own margin on that side so the two never add up.
   ─────────────────────────────────────────────────────────────────────────── */

/* Spacing scale from the contact-page design handoff
   (design_handoff_contact_spacing/README.md). The handoff specifies these as
   flex `gap` on a page container; here they drive collapsing margins instead,
   which lands on the same rendered spacing without turning the theme's shared
   `main` into a flex container. */
:root {
    /* --space-section: between top-level sections. */
    --evr-block-gap: 72px;

    /* --space-block: between elements inside one section
       (heading → body → cards). Also the card grid gutter. */
    --evr-gutter: 24px;
    --evr-space: 24px;

    /* Body measure. The handoff caps running copy so paragraphs stop spanning
       the full container width. */
    --evr-measure: 80ch;
    --evr-measure-short: 52ch;
}

/* Handoff: below ~900px sections drop to 48px and grids collapse to one
   column. The per-block stylesheets use the same breakpoint. */
@media (max-width: 900px) {
    :root {
        --evr-block-gap: 48px;
    }
}

/* Every block wrapper carrying the shared hook.

   Deliberately scoped to `.evr-block` alone: the older blocks (evr-affiliates,
   evr-alert-card, evr-global-cta) keep their own spacing and are NOT touched,
   so existing sections of a page render exactly as they did before. A new
   block opts into this rhythm by adding `evr-block` to its wrapper. */
.evr-block {
    margin-block: var(--evr-block-gap);
}

/* No leading gap at the top of the content area, no trailing gap at the end. */
.evr-block:first-child {
    margin-top: 0;
}

.evr-block:last-child {
    margin-bottom: 0;
}

/* An explicit core spacer wins — a spacer is a sized box, not a margin, so it
   would otherwise ADD to the gap instead of collapsing into it. This also keeps
   the block from changing the spacing of whatever sits above or below it. */
.wp-block-spacer + .evr-block {
    margin-top: 0;
}

.evr-block:has(+ .wp-block-spacer) {
    margin-bottom: 0;
}

/* ── Block-internal rhythm ────────────────────────────────────────────────── */
/* The theme pads every heading with `padding-top: 1.3rem !important`, which on
   a block's first line reads as an uneven extra gap above the block. Remove it
   only where the heading opens the block; headings further down keep it. */
.evr-block > :first-child.wp-block-heading,
.evr-block > :first-child > .wp-block-heading:first-child {
    padding-top: 0 !important;
}

/* Never let the first/last child add outer space of its own — the wrapper's
   margin is the single source of truth for the gap. */
.evr-block > :first-child {
    margin-top: 0;
}

.evr-block > :last-child {
    margin-bottom: 0;
}
