/* One page container (see inc/layout.php). Pages are full width; plain
   editor content sits in the same column MaxiBlocks sections use for
   their content: 90% of the window, at most 1170px. MaxiBlocks sections
   keep their own full-width backgrounds. The header uses the same
   column (style.css). */

.rhsa-page-container {
	--rhsa-container: 1170px;
	--rhsa-column: min(var(--rhsa-container), 90%);
	--rhsa-space: 64px;
}

.rhsa-page-container .entry-content {
	margin: 0;
	padding-bottom: 0 !important;
}

/* Every block placed directly on a page goes in the column, except
   MaxiBlocks sections (container blocks), which run full width and set
   their own inner width, and sections that manage their own column.
   Margins are set outright (not "auto") and win over per-block margins
   (MaxiBlocks gives some blocks their own), and the width is capped
   rather than set, so fixed-width embeds keep their size and line up
   with the column's left edge. */
.rhsa-page-container .entry-content > :not(.wp-block-maxi-blocks-container-maxi):not(.rec):not(.rec-programs):not(.alignfull):not(style):not(script) {
	box-sizing: border-box;
	margin-left: max(5%, (100% - var(--rhsa-container)) / 2) !important;
	margin-right: max(5%, (100% - var(--rhsa-container)) / 2) !important;
}
.rhsa-page-container .entry-content > :not(.wp-block-maxi-blocks-container-maxi):not(.rec):not(.rec-programs):not(.alignfull):not(style):not(script):not(iframe):not(img):not(video) {
	max-width: var(--rhsa-column) !important;
}
/* Running text stops at a readable length: 720px, about 75 characters a
   line at 16px. Placed straight on a page, a paragraph or list keeps the
   column's left edge (the rules above read these variables), and a
   centered one is centered. Inside groups and columns the same cap
   applies. Text that follows a centered heading in the same section sits
   in a centered 720px column (still left-aligned inside it) until a
   heading that isn't centered comes along, and so does
   text in a Group block set to a 720px content width. The cap measures
   the text alone: a paragraph that pads its own sides (the homepage
   hero's intro) already sets its line length, and keeps it. */
.rhsa-page-container .entry-content > :is(p.wp-block-paragraph, .wp-block-list) { --rhsa-column: min(720px, 90%); }
.rhsa-page-container .entry-content > :is(p.wp-block-paragraph, .wp-block-list).has-text-align-center,
.rhsa-page-container .entry-content > :is(h1, h2, h3, h4).has-text-align-center ~ :is(p.wp-block-paragraph, .wp-block-list):not(:is(h1, h2, h3, h4):not(.has-text-align-center) ~ *) { --rhsa-container: 720px; }
.rhsa-page-container .entry-content * :is(p.wp-block-paragraph, .wp-block-list):not(.rec-programs *):not(form *) { box-sizing: content-box; max-width: 720px; }
.rhsa-page-container .entry-content * :is(p.wp-block-paragraph.has-text-align-center, :is(h1, h2, h3, h4).has-text-align-center ~ :is(p.wp-block-paragraph, .wp-block-list):not(:is(h1, h2, h3, h4):not(.has-text-align-center) ~ *)):not(.is-layout-flex > *):not(.rec-programs *):not(form *) { margin-left: auto; margin-right: auto; }

/* A heading that opens a section of plain content gets the same space
   above it wherever it falls (margins collapse into it). */
.rhsa-page-container .entry-content > h2:not(:first-child) { margin-top: var(--rhsa-space); }

/* The old parent theme (and sometimes the block's own settings) padded top-level Group and
   Columns blocks as if they were boxes. Without a background that just
   pushes the content in from the column, so it is removed. */
.rhsa-page-container .entry-content > :is(.wp-block-group, .wp-block-columns):not(.has-background) {
	padding-left: 0 !important;
	padding-right: 0 !important;
}

/* Embeds placed straight on a page keep their own size, but never run
   past the column (the Crypto page's donation widget is 390px wide). */
.rhsa-page-container .entry-content > iframe,
.rhsa-page-container .entry-content > img,
.rhsa-page-container .entry-content > video { display: block; max-width: var(--rhsa-column) !important; }
.rhsa-page-container .entry-content > img { height: auto; }

/* Breathing room when a page starts or ends with plain content rather
   than a full-width section (MaxiBlocks or core; each brings its own
   padding). */
.rhsa-page-container .entry-content > :first-child:not(.wp-block-maxi-blocks-container-maxi):not(.rec):not(.rec-programs):not(.alignfull) { margin-top: var(--rhsa-space); }
.rhsa-page-container .entry-content > :last-child:not(.wp-block-maxi-blocks-container-maxi):not(.rec):not(.rec-programs):not(.alignfull) { margin-bottom: var(--rhsa-space); }

@media (max-width: 600px) {
	.rhsa-page-container { --rhsa-space: 40px; }
}
