/* ==================================================================
   Medisites Core: pages built from ordinary blocks (1.2.6-beta.35; page-layout.php).

   On treatments, conditions and pages with GeneratePress's full-width content container
   (body.msc-page-layout), ordinary top-level blocks (paragraphs, headings, lists, quotes, images,
   tables, columns, groups) sit in one centred column, as B27 Post body: 68 characters of the
   page's text, never wider than the screen less the gutter. Wide-aligned blocks take the content
   width, Full width ones the page. Each run of ordinary blocks gets the section space above and
   below it. Medisites blocks (and the medical review),
   GenerateBlocks containers and Full width blocks are left as they are.

   Structure only, as shared.css: element strength (html :where(...)), so the theme's element
   margins lose and any class wins; no colours or type. --ms-measure is registered as a length so
   68ch is worked out once, at the content's text size, and headings share the same column.
   ================================================================== */

@property --ms-measure {
	syntax: '<length>';
	inherits: true;
	initial-value: 0px;
}
:where(body.msc-page-layout .entry-content) { --ms-measure: 68ch; }

/* The column */
html :where(body.msc-page-layout .entry-content) > :where(:not(.ms-block, .ms-review, .alignfull, [class*="gb-element-"], .gb-container, style, script, link)) {
	box-sizing: border-box;
	max-width: min(var(--ms-measure), 100% - 2 * var(--ms-gutter, 16px));
	margin-inline: auto;
}
html :where(body.msc-page-layout .entry-content) > :where(.alignwide) {
	max-width: min(var(--gb-container-width, 1240px) - 2 * var(--ms-gutter, 16px), 100% - 2 * var(--ms-gutter, 16px));
}
/* Lists keep an indent for their bullets (the theme's was a left margin) */
html :where(body.msc-page-layout .entry-content) > :where(ul, ol):where(:not([class*="gb-element-"])) { padding-inline-start: 1.5em; }

/* Section space around each run: at the top of the content, after a Medisites block or full-width
   block, before the next one, and at the end */
html :where(body.msc-page-layout .entry-content) > :where(:not(.ms-block, .ms-review, .alignfull, [class*="gb-element-"], .gb-container, style, script, link)):where(
	:nth-child(1 of :not(style, script, link)),
	:is(.ms-block, .ms-review, .alignfull, [class*="gb-element-"], .gb-container) + *
) {
	margin-top: var(--ms-section-space, 48px);
}
html :where(body.msc-page-layout .entry-content) > :where(:not(.ms-block, .ms-review, .alignfull, [class*="gb-element-"], .gb-container, style, script, link)):where(
	:has(+ :is(.ms-block, .ms-review, .alignfull, [class*="gb-element-"], .gb-container)),
	:has(+ :is(style, script) + :is(.ms-block, .ms-review, .alignfull, [class*="gb-element-"], .gb-container))
) {
	margin-bottom: var(--ms-section-space, 48px);
}

@media (min-width: 768px) {
	html :where(body.msc-page-layout .entry-content) > :where(:not(.ms-block, .ms-review, .alignfull, [class*="gb-element-"], .gb-container, style, script, link)) {
		max-width: min(var(--ms-measure), 100% - 2 * var(--ms-gutter, 32px));
	}
	html :where(body.msc-page-layout .entry-content) > :where(:not(.ms-block, .ms-review, .alignfull, [class*="gb-element-"], .gb-container, style, script, link)):where(
		:nth-child(1 of :not(style, script, link)),
		:is(.ms-block, .ms-review, .alignfull, [class*="gb-element-"], .gb-container) + *
	) {
		margin-top: var(--ms-section-space, 80px);
	}
	html :where(body.msc-page-layout .entry-content) > :where(:not(.ms-block, .ms-review, .alignfull, [class*="gb-element-"], .gb-container, style, script, link)):where(
		:has(+ :is(.ms-block, .ms-review, .alignfull, [class*="gb-element-"], .gb-container)),
		:has(+ :is(style, script) + :is(.ms-block, .ms-review, .alignfull, [class*="gb-element-"], .gb-container))
	) {
		margin-bottom: var(--ms-section-space, 80px);
	}
}

/* The end of the content: space before the footer when ordinary blocks come last (Ben's tester, 2026-11-05). Padding on the
   content, not a margin on the last block: GeneratePress takes the bottom margin off a last paragraph. */
html :where(body.msc-page-layout:not(.msc-has-sidebar) .entry-content):has(> :where(:not(.ms-block, .ms-review, .alignfull, [class*="gb-element-"], .gb-container, style, script, link)):nth-last-child(1 of :not(style, script, link))) { padding-bottom: var(--ms-section-space, 48px); }
@media (min-width: 768px) {
	html :where(body.msc-page-layout:not(.msc-has-sidebar) .entry-content):has(> :where(:not(.ms-block, .ms-review, .alignfull, [class*="gb-element-"], .gb-container, style, script, link)):nth-last-child(1 of :not(style, script, link))) { padding-bottom: var(--ms-section-space, 80px); }
}

/* With a sidebar (the Sidebars module puts its gutter and section space around the content): the column
   keeps the measure inside the content area, centred while the sidebar sits underneath (below 1025px; Daniel,
   test1, 2026-10-26: it hugged the left with a wide gap on the right), lined up with the content's edge beside
   the sidebar on desktop. */
html :where(body.msc-page-layout.msc-has-sidebar .entry-content) > :where(:not(.ms-block, .ms-review, .alignfull, [class*="gb-element-"], .gb-container, style, script, link)) {
	max-width: min(var(--ms-measure), 100%);
	margin-inline: auto;
}
html :where(body.msc-page-layout.msc-has-sidebar .entry-content) > :where(:not(.ms-block, .ms-review, .alignfull, [class*="gb-element-"], .gb-container, style, script, link)):where(:nth-child(1 of :not(style, script, link))) { margin-top: 0; }
html :where(body.msc-page-layout.msc-has-sidebar .entry-content) > :where(:not(.ms-block, .ms-review, .alignfull, [class*="gb-element-"], .gb-container, style, script, link)):where(:nth-last-child(1 of :not(style, script, link))) { margin-bottom: 0; }
@media (min-width: 1025px) {
	html :where(body.msc-page-layout.msc-has-sidebar .entry-content) > :where(:not(.ms-block, .ms-review, .alignfull, [class*="gb-element-"], .gb-container, style, script, link)) { margin-inline: 0; }
}
