/* Shared article shell; native block styles can override these defaults. */
:where(.sggw-single-post) {
	--sggw-entry-shell-padding: var(--wp--preset--spacing--70);
	--sggw-entry-header-gap: var(--wp--preset--spacing--60);
	--sggw-entry-section-gap: var(--wp--preset--spacing--50);
	--sggw-entry-content-gap: var(--sggw-entry-section-gap);
	--sggw-entry-intro-gap: var(--wp--preset--spacing--50);
	/* Native gap sanitization accepts preset references, not arbitrary var(). */
	--wp--preset--spacing--entry-section: var(--sggw-entry-section-gap);
	--wp--preset--spacing--entry-intro: var(--sggw-entry-intro-gap);
}

/* The empty introduction must not leave a second section gap, including an
 * unsaved Elementor toggle which keeps the hidden slots in the DOM. */
:where(.sggw-single-post__header + .sggw-single-post__content),
.sggw-post-hide-image.sggw-post-hide-excerpt .sggw-post-intro:not(:has(> :not(.sggw-post-intro__image, .sggw-post-intro__excerpt))) + :where(.sggw-single-post__content),
.sggw-post-hide-image .sggw-post-intro:has(> .sggw-post-intro__image:only-child) + :where(.sggw-single-post__content),
.sggw-post-hide-excerpt .sggw-post-intro:has(> .sggw-post-intro__excerpt:only-child) + :where(.sggw-single-post__content) {
	--sggw-entry-content-gap: var(--sggw-entry-header-gap);
}

/* Actual article headings, including HTML inside Text Editor. Component and
 * library recipes keep their fonts. Set the variables on eligible headings,
 * rather than on the shell, so they cannot leak into those boundaries. */
:where(.sggw-single-post__header, .sggw-single-post__content, .sggw-entry-editor)
	:is(h1, h2, h3, h4, h5, h6, .elementor-heading-title):not(:where(
		.sggw-heading-recipe-column *, [class*="wp-block-sggw-"] *,
		.wp-block-query *, .wp-block-post-template *,
		.sggw-post-component, .sggw-post-component *, [data-e-type="e-component"] *,
		.elementor-widget:not(.elementor-widget-text-editor, .elementor-widget-heading, [data-atomic]) *,
		.elementor[data-elementor-type]:not([data-elementor-type="wp-post"]) *,
		.sggw-elementor-cover__heading, .sggw-elementor-cover__heading *,
		.sggw-faculty-contact__heading, .sggw-faculty-contact__heading *
	)) {
	--sggw-entry-heading-family: var(--wp--preset--font-family--display);
	--sggw-entry-heading-weight: var(--wp--custom--typography--font-weight--bold);
	font-family: var(--sggw-entry-heading-family);
	font-weight: var(--sggw-entry-heading-weight);
}

/*
 * The regular-post template uses Core blocks and the existing wide layout.
 * Native block controls own colors, type, spacing and desktop column count.
 * This adapter only handles alignment, absent introductory blocks and reflow.
 */

:where(.sggw-single-post__header .wp-block-post-title) {
	text-wrap: balance;
}

:where(.sggw-post-intro.is-layout-grid) {
	align-items: center;
}

:where(.sggw-post-intro) > * {
	min-inline-size: 0;
}

:where(.sggw-post-intro.is-layout-grid) > * {
	margin-block: 0;
}

/* A single introductory slot shares the centred text column. Two slots keep
 * their native grid tracks; administrator-added blocks keep their own width. */
:where(.sggw-post-intro.is-layout-grid > .sggw-post-intro__image,
	.sggw-post-intro.is-layout-grid > .sggw-post-intro__excerpt) {
	inline-size: 100%;
	max-inline-size: 900px;
	justify-self: center;
}

/* Dynamic Core blocks disappear when their post has no corresponding data. */
.sggw-post-intro.is-layout-grid:has(> :only-child) {
	grid-template-columns: minmax(0, 1fr);
}

/* Editor-only flags follow native document settings without removing the slots. */
.sggw-post-hide-image .sggw-post-intro > .sggw-post-intro__image,
.sggw-post-hide-excerpt .sggw-post-intro > .sggw-post-intro__excerpt {
	display: none;
}

:is(.sggw-post-hide-image, .sggw-post-hide-excerpt) .sggw-post-intro.is-layout-grid {
	grid-template-columns: minmax(0, 1fr);
}

.sggw-post-hide-image.sggw-post-hide-excerpt .sggw-post-intro:not(:has(> :not(.sggw-post-intro__image, .sggw-post-intro__excerpt))),
.sggw-post-hide-image .sggw-post-intro:has(> .sggw-post-intro__image:only-child),
.sggw-post-hide-excerpt .sggw-post-intro:has(> .sggw-post-intro__excerpt:only-child) {
	display: none;
}

/* One viewport gutter; Gutenberg's nested default groups inherit article width.
 * The Post Content layout in the template also exposes these sizes in editor. */
.sggw-single-post :where(.sggw-single-post__content) {
	padding-inline: 0;
	--wp--style--global--content-size: 900px;
}

@media (width < 48rem) {
	:where(.sggw-single-post) {
		--sggw-entry-shell-padding: var(--wp--preset--spacing--50);
		--sggw-entry-header-gap: var(--wp--preset--spacing--50);
		--sggw-entry-section-gap: var(--wp--preset--spacing--40);
		--sggw-entry-intro-gap: var(--wp--preset--spacing--40);
	}

	.sggw-post-intro.is-layout-grid {
		grid-template-columns: minmax(0, 1fr);
	}
}
