/* Page rhythm after the RUB library (docs/specs/2026-10-19-page-rhythm.md):
   the gaps between the sections of a page and between the parts of a section,
   the size of section headings and page titles, and the line length of running
   text. Values are the custom properties in style.css (phone, tablet, desktop).
   Editors set nothing: the rules follow the order of the blocks. They win
   over top margins set by hand on these blocks (!important), so every page
   keeps the same rhythm; inside columns and groups hand-set gaps still work.
   Part of the RUB Chair theme. */

/* Where sections live: the page content, a light band, and a plain group that
   starts with a section heading (a section built as one group). */

/* Parts of a section: a component (cards, columns, box, query, link area …)
   after anything, and anything after a component. Text after text keeps the
   normal block gap. :where() gives these rules no weight, so the section and
   fold-box rules below win where they apply. */
:where(.wp-block-post-content, .is-style-rub-light-band, .wp-block-post-content > .wp-block-group:has(> h2:first-child)) > * + :where(:not(p, ul, ol, h1, h2, h3, h4, h5, h6, blockquote, .wp-block-buttons)),
:where(.wp-block-post-content, .is-style-rub-light-band, .wp-block-post-content > .wp-block-group:has(> h2:first-child)) > :where(:not(p, ul, ol, h1, h2, h3, h4, h5, h6, blockquote, .wp-block-buttons)) + * {
	margin-block-start: var(--rub-part-gap) !important;
}

/* Fold boxes one under the other stay a close list, fold rows touch
   (text-boxes.css). */
.wp-block-details + .wp-block-details {
	margin-block-start: 0.5rem !important;
}

.wp-block-details.is-style-rub-fold-row + .wp-block-details.is-style-rub-fold-row {
	margin-block-start: 0 !important;
}

/* A new section: before a section heading or a group that starts with one,
   and around full-width bands and the picture header (not any cover block). */
.wp-block-post-content > * + :is(h2, .wp-block-group:has(> h2:first-child)),
.wp-block-post-content > * + :is(.is-style-rub-light-band, .is-style-rub-picture-header),
.wp-block-post-content > :is(.is-style-rub-light-band, .is-style-rub-picture-header) + * {
	margin-block-start: var(--rub-section-gap) !important;
}

/* Section headings in the library's Headline 2: 48/56 on desktops, 32/36 on
   phones, fluid in between. Card titles and headings in boxes are not hit. */
:where(.wp-block-post-content, .is-style-rub-light-band, .wp-block-post-content > .wp-block-group:has(> h2:first-child)) > h2.wp-block-heading {
	font-size: clamp(2rem, 1.333rem + 1.85vw, 3rem);
	letter-spacing: -1px;
	line-height: 1.15;
}

/* Page titles in Headline 1 (sizes in style.css). */
.rub-content h1:is(.wp-block-post-title, .wp-block-query-title),
.wp-block-post-content > h1 {
	/* !important: a size picked in the editor (e.g. the site title on a new
	   chair's home page) must not make one page's title differ. */
	font-size: var(--rub-h1-size) !important;
	letter-spacing: -1.5px;
	line-height: var(--rub-h1-line);
	margin-bottom: var(--rub-part-gap) !important;
}

/* Running text no wider than 8 of 12 columns (824 px), so lines stay
   readable on the wide grid; it keeps to the left edge of the content. */
.wp-block-post-content > :is(p, ul, ol) {
	margin-left: max(0px, (100% - var(--wp--style--global--content-size, 1248px)) / 2) !important;
	margin-right: auto !important;
	max-width: 824px;
}

/* A centred paragraph stays centred on the page, just as narrow. */
.wp-block-post-content > p.has-text-align-center {
	margin-left: auto !important;
}

/* Running text of a page in the library's Rich Text “Paragraph”, 18/32 (cards,
   boxes and lists keep their own sizes). */
:where(.wp-block-post-content, .wp-block-post-content > .wp-block-group:has(> h2:first-child), .wp-block-post-content > .wp-block-columns > .wp-block-column) > p {
	line-height: 2rem;
}
