/* Malzknecht Post-Sidebar — Sticky Wrapper */

.mps-post-sidebar {
	--mps-sticky-top: 100px;
	box-sizing: border-box;
}

.mps-post-sidebar > * + * {
	margin-top: 1em;
}

/*
 * Sticky greift am aside.widget (nicht am inneren wrapper) — sonst klebt
 * es nur innerhalb der 73px-Widget-Hoehe und ist quasi unsichtbar.
 */
aside.widget.mps-has-sticky {
	position: sticky;
	top: var(--mps-sticky-top, 100px);
	align-self: flex-start;
	z-index: 1;
}

aside.widget.mps-has-sticky .mps-post-sidebar.mps-is-sticky {
	position: static;
	top: auto;
}

/*
 * Astra setzt overflow auf body — das killt position:sticky komplett.
 * Mit :has() scoped wir den Override auf Singular-Views mit unserem Widget.
 */
body.single:has(aside.widget.mps-has-sticky),
body.single:has(aside.widget.mps-has-sticky) html,
body.single:has(aside.widget.mps-has-sticky) #page,
body.single:has(aside.widget.mps-has-sticky) #content,
body.single:has(aside.widget.mps-has-sticky) .ast-container {
	overflow: visible !important;
	overflow-x: visible !important;
	overflow-y: visible !important;
}

/*
 * Sidebar-Container hochziehen, damit das aside in der ganzen Sidebar-Spalte
 * Platz zum Stickyen hat (sonst klebt es nur bis Ende der natuerlichen
 * Widget-Stack-Hoehe — ca. 615px).
 */
body.single:has(aside.widget.mps-has-sticky) .sidebar-main {
	height: 100%;
}

/* Astras Sticky-Header beruecksichtigen */
.ast-primary-sticky-header-active aside.widget.mps-has-sticky,
body.ast-header-break-point aside.widget.mps-has-sticky {
	--mps-sticky-top: 130px;
}

/* Mobile (Astra Mobile-Breakpoint): Sticky aus, alles auf default */
@media (max-width: 921px) {
	aside.widget.mps-has-sticky {
		position: static;
		top: auto;
	}
	body.single:has(aside.widget.mps-has-sticky),
	body.single:has(aside.widget.mps-has-sticky) html,
	body.single:has(aside.widget.mps-has-sticky) #page,
	body.single:has(aside.widget.mps-has-sticky) #content,
	body.single:has(aside.widget.mps-has-sticky) .ast-container {
		overflow: revert !important;
	}
	body.single:has(aside.widget.mps-has-sticky) .sidebar-main {
		height: auto;
	}
}
