/**
 * Theme – Störer
 *
 * Roter zweizeiliger Einschub im Seitenkopf (.spnkt-page-header).
 * Quelle: Figma-Komponente „Stoerer" (Node 538:6393).
 *
 * Mobile (< 840px): im Fluss unter dem Titel, rechtsbündig, max. 280px breit,
 * läuft rechts bis zum Viewport-Rand aus (kein rechter Radius).
 * Desktop (≥ 840px): absolut rechts oben, rechtsbündig am Content-Container,
 * max. 440px breit. Ein ::after-Block füllt die Fläche vom Containerrand bis
 * zum Viewport-Rand rot auf, sodass der Störer optisch bis zum Seitenrand reicht.
 */

.spnkt-stoerer {
	position: relative;
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 0;
	box-sizing: border-box;
	/* Rechtsbündig am Inhaltsrand – schmaler Block unter dem Titel. */
	width: min( 100%, 280px );
	margin-top: 1.5rem;
	padding-top: 1rem;
	padding-bottom: 1rem;
	padding-left: var( --wp--preset--spacing--mini );
	padding-right: var( --wp--preset--spacing--mini );
	background-color: var( --wp--preset--color--primary );
	/* Nur links abgerundet (Figma standardradius) – rechts läuft der Kasten aus. */
	border-radius: var( --wp--custom--border-radius--standard ) 0 0 var( --wp--custom--border-radius--standard );
}

/*
 * Rechtsbündig statt zentriert: WordPress' constrained-Layout setzt
 * `margin-inline: auto !important` auf alle Container-Kinder. Das lässt sich
 * nur mit !important überschreiben (CLAUDE.md: letztes Mittel, hier zwingend).
 */
.spnkt-stoerer {
	margin-left: auto !important;
	margin-right: calc( -1 * var(--wp--style--root--padding-right ) ) !important;
}

/*
 * Anklickbare Variante: ist ein Link gesetzt, wird die ganze Box ein <a>.
 * Textfarbe erben (kein Link-Blau), keine Unterstreichung. Auf der gesamten
 * Fläche klickbar inkl. ::after-Auslauf bis zum Viewport-Rand (Desktop).
 */
.spnkt-stoerer--link {
	color: inherit;
	text-decoration: none;
	cursor: pointer;
}

.spnkt-stoerer--link:hover,
.spnkt-stoerer--link:focus-visible {
	background-color: var( --wp--preset--color--primary-dark );
}

/* Sichtbarer Tastatur-Fokus (WCAG 2.2 – 2.4.7 Focus Visible). */
.spnkt-stoerer--link:focus-visible {
	outline: 3px solid var( --wp--preset--color--background );
	outline-offset: -3px;
}

.spnkt-stoerer--link:hover::after,
.spnkt-stoerer--link:focus-visible::after {
	background-color: var( --wp--preset--color--primary-dark );
}

.spnkt-stoerer__zeile {
	color: var( --wp--preset--color--background );
	font-weight: 700;
	font-size: var( --wp--preset--font-size--medium-large, 1.375rem );
	line-height: 1.25;
	hyphens: auto;
	overflow-wrap: break-word;
}

@media (min-width: 1024px) {
	/* Seitenkopf wird zum Positionierungs-Anker für den absoluten Störer. */
	.spnkt-page-header {
		position: relative;
	}

	.spnkt-stoerer {
		margin-right: 0 !important;
	}

	/*
	 * Zentrier-Gap: Abstand vom Inhaltsrand des constrained Containers bis zum
	 * Viewport-Rand. content-size kommt aus theme.json (settings.layout.contentSize).
	 */
	.spnkt-stoerer {
		--spnkt-stoerer-gap: max( 0px, calc( ( 100vw - var( --wp--style--global--content-size ) ) / 2 ) );

		position: absolute;
		top: 1.5rem;
		left: auto;
		/* Rechtsbündig am Inhaltsrand des Containers (nicht am Viewport-Rand). */
		right: var( --spnkt-stoerer-gap );
		z-index: 2;
		width: 400px;
		max-width: 50%;
		min-height: 106px;
		margin: 0;
		padding-top: 1rem;
		padding-bottom: 1rem;
		padding-left: var( --wp--preset--spacing--mini );
		padding-right: var( --wp--preset--spacing--mini );
		/* Inhalt endet am Containerrand → rechts keine Rundung (::after schliesst an). */
		border-radius: var( --wp--custom--border-radius--standard ) 0 0 var( --wp--custom--border-radius--standard );
	}

	/*
	 * Roter Block füllt den Zentrier-Gap vom Containerrand bis zum Viewport-Rand.
	 * Bei Viewports ≤ contentSize ist der Gap 0 → kein Overflow, kein Scrollbalken.
	 */
	.spnkt-stoerer::after {
		content: "";
		position: absolute;
		top: 0;
		bottom: 0;
		left: 100%;
		width: var( --spnkt-stoerer-gap );
		background-color: var( --wp--preset--color--primary );
	}

	/*
	 * Schmale Variante (ACF-Feld «Breite» = schmal): reduziert die Desktop-Breite
	 * von 440px auf 300px. Der ::after-Auslauf bis zum Viewport-Rand bleibt durch
	 * die rechtsbündige Positionierung erhalten.
	 */
	.spnkt-stoerer--schmal {
		width: 300px;
	}

	.spnkt-stoerer__zeile {
		font-size: var( --wp--preset--font-size--large, 1.875rem );
		line-height: 1.4;
	}
}
