/*
 * Section Block — shared base styles for full-width section blocks.
 * Used by publication-list, featured-publications, publication-related,
 * publication-citations, publication-podcasts, and future section blocks.
 *
 * Structure:
 *   .section-block           — full-width wrapper (alignfull), padding, background
 *   .section-block__inner    — content-width constraint
 *   .section-block__heading  — consistent h2
 *
 * Background modifiers:
 *   .section-block--warm     — warm neutral background
 *   .section-block--cream    — cream background
 */

/* --- Wrapper --- */

.section-block {
    padding-block: var(--section-padding);
    margin-block: 0;
}

/* --- Inner constraint --- */

.section-block__inner {
    width: min(var(--max-width-content), 100% - 2 * var(--site-padding));
    margin-inline: auto;
}

/* --- Heading --- */

.section-block__heading {
    font-family: var(--font-serif);
    font-size: clamp(var(--text-2xl), 3.5vw, var(--text-5xl));
    font-weight: var(--font-weight-semibold);
    color: var(--color-blue-dark);
    margin: 0 0 var(--space-6);
}

/* --- Background modifiers --- */

.section-block--warm {
    background: var(--color-neutral-warm-light);
}

.section-block--cream {
    background: var(--color-cream);
}

/* --- Adjacent white sections: collapse top padding of the second --- */
/* When two section-blocks without a background modifier sit next to each
   other, remove the top padding of the second to avoid a double-gap. */

.section-block:not(.section-block--warm):not(.section-block--cream)
+ .section-block:not(.section-block--warm):not(.section-block--cream) {
    padding-block-start: 0;
}

/* Cross-class white-section adjacency. Any wrapper that marks itself as
   .is-white-section (currently content-section, program-listing,
   certificate-listing) collapses top padding when it follows another
   white-marked wrapper. .section-block doesn't carry the marker yet — it
   relies on the rule above. Future cleanup: stamp .is-white-section on
   white section-blocks too, drop the rule above, generalize to other
   colors via similar markers (or data-bg=""). */

.is-white-section + .is-white-section,
.section-block:not(.section-block--warm):not(.section-block--cream) + .is-white-section,
.is-white-section + .section-block:not(.section-block--warm):not(.section-block--cream) {
    padding-block-start: 0;
}

/* Editor: In the block editor, each block is a .block-editor-block-list__block.
   Some blocks merge section-block onto that wrapper (useBlockProps on <section>),
   others nest section-block as a child inside a <div> wrapper.
   Define a "white-section wrapper" as either case, then collapse padding
   when two are adjacent. */

/* Shorthand: a wrapper that IS or CONTAINS a white section-block */
/* Case A: wrapper + wrapper → target merged section-block */
.block-editor-block-list__block:is(
    .section-block:not(.section-block--warm):not(.section-block--cream),
    :has(> .section-block:not(.section-block--warm):not(.section-block--cream))
)
+ .section-block.block-editor-block-list__block:not(.section-block--warm):not(.section-block--cream) {
    padding-block-start: 0;
}

/* Case B: wrapper + wrapper → target nested child section-block */
.block-editor-block-list__block:is(
    .section-block:not(.section-block--warm):not(.section-block--cream),
    :has(> .section-block:not(.section-block--warm):not(.section-block--cream))
)
+ .block-editor-block-list__block:not(.section-block)
> .section-block:not(.section-block--warm):not(.section-block--cream) {
    padding-block-start: 0;
}

/* --- Person singles: alternate section-block backgrounds --- */
/* Courses and/or publications may or may not appear, so the first
   section-block present should always be warm, the second white, etc. */

.single-brsl_person .section-block:nth-child(odd of .section-block) {
    background: var(--color-neutral-warm-light);
}

/* On person singles, the alternating backgrounds mean adjacent sections always
   contrast — restore padding that the white+white collapse rule removes.
   Specificity must match or exceed the collapse rule (5 classes). */
.single-brsl_person .section-block:not(.section-block--warm):not(.section-block--cream)
+ .section-block:not(.section-block--warm):not(.section-block--cream) {
    padding-block-start: var(--section-padding);
}

