/*
 * Shared page geometry, loaded last on the frontend AND in Gutenberg.
 * A wide section owns the gutter; its full-width background does not.
 * Keep these rules structural: no page IDs, text matching or saved-content edits.
 */
:root,
.editor-styles-wrapper {
	--ubc-shell-size: var(--wp--style--global--wide-size, 1280px);
	--ubc-reading-size: var(--wp--style--global--content-size, 760px);
}

/* Core applies wideSize inside constrained layouts, but not inside flow layouts.
 * Cover content and the editor root need the same contract. Nested wide blocks
 * inside an existing wide section are deliberately not given another gutter.
 */
:where(main, .editor-styles-wrapper) :is(.wp-block-post-content, .alignfull, .wp-block-cover__inner-container, .is-root-container) > .alignwide {
	box-sizing: border-box;
	width: 100%;
	max-width: var(--ubc-shell-size) !important;
	margin-inline: auto !important;
	padding-inline: var(--ubc-shell-gutter) !important;
}

/* The outer band only paints the background. Padding belongs to its shell. */
:where(main, .editor-styles-wrapper) :is(.alignfull, .wp-block-cover__inner-container):has(> .alignwide) {
	padding-inline: 0 !important;
}

/* A left-positioned cover otherwise shrink-wraps its inner container. */
:where(main, .editor-styles-wrapper) .wp-block-cover.alignfull:has(> .wp-block-cover__inner-container > .alignwide) {
	padding-inline: 0 !important;
}

:where(main, .editor-styles-wrapper) .wp-block-cover.alignfull > .wp-block-cover__inner-container:has(> .alignwide) {
	width: 100% !important;
}

/* Gutenberg's root padding is not an inset for every nested copy group.
 * Reset only the inherited core tokens: authored card/form padding survives.
 */
:where(main, .editor-styles-wrapper) .alignwide .has-global-padding {
	--wp--style--root--padding-left: 0px;
	--wp--style--root--padding-right: 0px;
}

/* Reading measure must not auto-centre a section's heading or its layout grid.
 * Explicit centre/right layout choices and floated blocks remain available.
 */
:where(main, .editor-styles-wrapper) .alignwide.is-layout-constrained:not(.is-content-justification-center):not(.is-content-justification-right) > :not(.alignleft):not(.alignright):not(.alignfull) {
	margin-inline: 0 !important;
}

:where(main, .editor-styles-wrapper) .alignwide.is-layout-constrained > :is(.is-layout-grid, .is-layout-flex, .is-layout-flow, .wp-block-columns, .wp-block-query) {
	max-width: none !important;
}

/* New editorial pages: a full-width block canvas, with readable text aligned
 * to the same left edge as the title. Wide/full blocks retain their native role.
 */
.ubc-editorial-page-body {
	padding-inline: 0;
}

.ubc-editorial-page-body > .ubc-editorial-page-content {
	max-width: none;
	padding-inline: 0;
}

.ubc-editorial-page-content > :not(.alignwide):not(.alignfull):not(.alignleft):not(.alignright) {
	width: calc(100% - 2 * var(--ubc-shell-gutter));
	max-width: var(--ubc-reading-size);
	margin-left: max(var(--ubc-shell-gutter), calc((100% - var(--ubc-shell-size)) / 2 + var(--ubc-shell-gutter))) !important;
	margin-right: auto !important;
}

.ubc-editorial-page-content .has-global-padding {
	--wp--style--root--padding-left: 0px;
	--wp--style--root--padding-right: 0px;
}

/* Full-bleed media use the actual content width, excluding the scrollbar.
 * Their inner, column-facing spacing remains part of the media composition.
 */
.ubc-support-page-women,
.ubc-camp-place {
	container-type: inline-size;
}

.ubc-support-page-women .wp-block-media-text__content {
	padding-left: max(var(--ubc-shell-gutter), calc((100cqw - var(--ubc-shell-size)) / 2 + var(--ubc-shell-gutter)));
}

.ubc-camp-place .wp-block-media-text__content {
	padding-right: max(var(--ubc-shell-gutter), calc((100cqw - var(--ubc-shell-size)) / 2 + var(--ubc-shell-gutter)));
}

.ubc-legal-content {
	width: calc(100% - 2 * var(--ubc-shell-gutter));
	margin-left: max(var(--ubc-shell-gutter), calc((100% - var(--ubc-shell-size)) / 2 + var(--ubc-shell-gutter))) !important;
}

/* WordPress may omit native alignment classes on root editor blocks. The
 * editor.BlockListBlock adapter restores them from the existing attributes,
 * without changing the stored blocks. Full-width chapters own their gutters. */
.editor-styles-wrapper .is-root-container:has(> .alignfull, > .alignwide) {
	padding-inline: 0;
}
.editor-styles-wrapper .is-root-container > .alignfull {
	width: 100%;
	max-width: none;
	margin-inline: 0;
}
