/* Keep Core blocks stable while legacy classes are migrated. */
/* Wird im Frontend (scripts.php) und im Block-Editor-Canvas (add_editor_style) geladen. */

/* Volle Breite (alignfull): negative Margins nicht an Vorfahren abschneiden (z. B. Spalte/Shell) */
.entry-content.wp-block-post-content.is-layout-constrained,
.editor-styles-wrapper :where(.is-layout-constrained, .wp-block-post-content.is-layout-constrained),
body.editor-styles-wrapper :where(.is-layout-constrained, .wp-block-post-content.is-layout-constrained) {
	overflow-x: visible;
}

/*
 * Gleicher Selektor wie Core Global Styles: max-width über
 * --wp--style--global--content-size (responsive Stufen: source/scss/_wp-global-layout.scss).
 */
.entry-content.is-layout-constrained > :where(:not(.alignleft):not(.alignright):not(.alignfull)) {
	max-width: var(--wp--style--global--content-size);
}

main .wp-block,
.wp-site-blocks .wp-block {
	box-sizing: border-box;
}

.wp-block-image img,
.wp-block-cover img,
.wp-block-media-text__media img,
.wp-block-gallery img {
	height: auto;
	max-width: 100%;
}

.wp-block-navigation .wp-block-navigation-item__content {
	text-decoration: none;
}

.wp-block-query .wp-block-post-template {
	list-style: none;
	margin-left: 0;
	padding-left: 0;
}

/* Flow-Layout-Gruppe: Core-Abstände am Wrapper abschalten */
.wp-block-group.is-layout-flow.wp-block-group-is-layout-flow {
	margin: 0;
}

/*
 * Core Global Styles (theme.json blockGap):
 * :where(.is-layout-flow) > :first-child { margin-block-start: 0 }
 * :where(.is-layout-flow) > * { margin-block-start: 2.5rem }
 * Ein vorangestelltes <style> (z. B. dynamisches Block-CSS) zählt als erstes Kind —
 * der eigentliche Block wird Kind 2+ und bekommt ungewollten Abstand (Header, Spalten).
 */
:where(.is-layout-flow) > style:first-child + *,
.entry-content > .tw-site-header-bg,
.wp-block-post-content > .tw-site-header-bg,
.wp-block-column.is-layout-flow > .tw-megamenu-shell,
.wp-block-column.is-layout-flow > .wp-block-twtheme-megamenu {
	margin-block-start: 0;
	margin-block-end: 0;
}

/* Site-Header: kompakte Flow-Kinder ohne Core-Block-Gap-Margin */
header.wp-block-template-part :where(.is-layout-flow) > * {
	margin-block-start: 0;
	margin-block-end: 0;
}

/*
 * Site-Footer (Template-Part): kein Abstand durch Core Block-Gap
 * (:where(.wp-site-blocks) > * { margin-block-start: 2.5rem }).
 */
.wp-site-blocks > footer.wp-block-template-part,
footer.wp-block-template-part {
	margin: 0;
	margin-block: 0;
}
