/**
 * Aktuelles: Beitragskarten (Seite „Aktuelles“, Startseiten-Abschnitt, Archive), Einzelbeitrag,
 * Paginierung, leerer Zustand und Platzhalter ohne Beitragsbild (aus inc/news.php).
 *
 * Karten ohne schwere Rahmen: Bild in Theme-Form (Radius md, immer 3/2), darunter Datum, Titel,
 * Auszug und „Weiterlesen“. Die ganze Karte ist klickbar, der Titel bleibt ein eigener Link.
 * Raster: 1 Spalte, ab 782px 2, ab 1100px 3. Ein einzelner Beitrag steht breit (Bild neben Text),
 * zwei Beiträge teilen sich die Zeile, bei ungerader Anzahl im Zweier-Raster steht der erste breit:
 * so entstehen keine halb leeren Reihen.
 */

/* ---------- Raster ---------- */

.ezam-news-grid.ezam-news-grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--wp--preset--spacing--60) var(--wp--preset--spacing--50);
	margin-block: 0;
	padding: 0;
	list-style: none;
}

/* Listenpunkte sind Karten: ohne die Zeilenlängen-Grenze für Fließtext-Listen (theme.css, 70ch). */
.ezam-news-grid.ezam-news-grid > li {
	min-width: 0;
	max-width: none;
	margin: 0;
}

@media (min-width: 782px) {
	.ezam-news-grid.ezam-news-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (min-width: 1100px) {
	.ezam-news-grid.ezam-news-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	/* Genau zwei Beiträge: zwei gleich breite Spalten statt einer leeren dritten (Editor: siehe unten). */
	.ezam-news-grid.ezam-news-grid:has(> li:nth-child(2):last-child:not([class*="block-editor-block-"])) {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

/* ---------- Karte ---------- */

.ezam-news-card {
	position: relative;
	isolation: isolate;
	display: flex;
	flex-direction: column;
	gap: var(--wp--preset--spacing--30);
	height: 100%;
}

.ezam-news-card.ezam-news-card > * {
	margin-block: 0;
}

.ezam-news-card__media {
	margin: 0;
	overflow: hidden;
	border-radius: var(--wp--custom--radius--md, 1.25rem);
	background-color: var(--wp--preset--color--sage-wash);
}

.ezam-news-card__media img,
.ezam-news-single__media img {
	display: block;
	width: 100%;
	object-fit: cover;
	/* Gesichter sitzen meist im oberen Bilddrittel: beim Zuschneiden auf 3/2 bleibt der Kopf im Bild. */
	object-position: 50% 30%;
	border-radius: inherit;
}

.ezam-news-card__body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: 0.5rem;
}

.ezam-news-card__body.ezam-news-card__body > * {
	margin-block: 0;
}

.ezam-news-card__date,
.ezam-news-single__date {
	font-variant-numeric: lining-nums tabular-nums;
	letter-spacing: 0.01em;
}

.ezam-news-card__title {
	line-height: 1.25;
	/* Titel sind kurz und wichtig: ganze Wörter umbrechen, nicht trennen. */
	hyphens: manual;
	-webkit-hyphens: manual;
}

.ezam-news-card__title a {
	position: relative;
	z-index: 2;
	color: var(--wp--preset--color--blue);
	text-decoration-line: underline;
	text-decoration-color: transparent;
	text-decoration-thickness: 2px;
	text-underline-offset: 0.2em;
}

.ezam-news-card__title a:hover,
.ezam-news-card:hover .ezam-news-card__title a {
	text-decoration-color: currentColor;
}

.ezam-news-card__excerpt p {
	margin: 0;
	max-width: 60ch;
}

/* „Weiterlesen“ sitzt unten: Karten einer Reihe enden auf einer Linie. */
.ezam-news-card .ezam-news-card__more {
	display: inline-flex;
	align-self: flex-start;
	align-items: center;
	gap: 0.5em;
	min-height: 2.75rem;
	margin-top: auto;
	font-family: var(--wp--preset--font-family--raleway);
	font-size: 1.0625rem;
	font-weight: 700;
	font-variant-numeric: lining-nums;
	color: var(--wp--preset--color--blue);
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.25em;
}

.ezam-news-card .ezam-news-card__more::after,
.ezam-news-all a::after {
	content: "";
	flex: none;
	width: 1.25em;
	height: 1.25em;
	background-color: currentColor;
	-webkit-mask: url("../../icons/regular/arrow-right.svg") center / contain no-repeat;
	mask: url("../../icons/regular/arrow-right.svg") center / contain no-repeat;
}

.ezam-news-card:hover .ezam-news-card__more {
	color: var(--wp--preset--color--coral-dark);
	text-decoration-thickness: 2px;
}

/*
 * Die ganze Karte ist klickbar: „Weiterlesen“ spannt eine unsichtbare Ebene über die Karte.
 * Nur im Frontend, im Editor bleiben Bild, Titel und Auszug einzeln auswählbar.
 */
:where(body:not(.editor-styles-wrapper)) .ezam-news-card .ezam-news-card__more::before {
	content: "";
	position: absolute;
	z-index: 1;
	inset: 0;
	border-radius: var(--wp--custom--radius--md, 1.25rem);
}

@media (prefers-reduced-motion: no-preference) {
	.ezam-news-card__media img {
		transition: scale var(--ezam-slow) var(--ezam-ease);
	}

	.ezam-news-card .ezam-news-card__more::after,
	.ezam-news-all a::after {
		transition: translate var(--ezam-base) var(--ezam-ease);
	}

	.ezam-news-card:hover .ezam-news-card__media img {
		scale: 1.03;
	}

	.ezam-news-card:hover .ezam-news-card__more::after,
	.ezam-news-all a:hover::after {
		translate: 0.3em 0;
	}
}

/*
 * Breite Karte, Bild neben dem Text:
 * - ein einzelner Beitrag (etwa der erste nach der Eröffnung) ab 1100px,
 * - im zweispaltigen Raster (782 bis 1099px) bei ungerader Anzahl der erste Beitrag,
 *   damit keine Karte allein in der letzten Reihe steht (3 auf der Startseite, 9 auf „Aktuelles“).
 *
 * Website-Editor: Der Query-Loop setzt dort hinter den bearbeitbaren Beitrag eine ausgeblendete
 * Vorschau desselben Beitrags (li mit style="display: none"), es gibt also einen Listenpunkt mehr.
 * Editor-Listenpunkte tragen Klassen „block-editor-block-…“; für sie zählen die Regeln um eins
 * verschoben (ein Beitrag = zwei Listenpunkte, ungerade Anzahl = gerade Zahl an Listenpunkten),
 * damit die Vorschau dem Frontend entspricht.
 */
@media (min-width: 1100px) {
	.ezam-news-grid.ezam-news-grid > li:only-child,
	.ezam-news-grid.ezam-news-grid > li[class*="block-editor-block-"]:first-child:nth-last-child(2) {
		grid-column: 1 / -1;
	}

	/* Editor, genau zwei Beiträge (drei Listenpunkte): wie im Frontend zwei gleich breite Spalten. */
	.ezam-news-grid.ezam-news-grid:has(> li[class*="block-editor-block-"]:nth-child(3):last-child) {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.ezam-news-grid > li:only-child .ezam-news-card,
	.ezam-news-grid > li[class*="block-editor-block-"]:first-child:nth-last-child(2) .ezam-news-card {
		display: grid;
		grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
		gap: var(--wp--preset--spacing--60);
		align-items: center;
	}

	.ezam-news-grid > li:only-child .ezam-news-card__body,
	.ezam-news-grid > li[class*="block-editor-block-"]:first-child:nth-last-child(2) .ezam-news-card__body {
		gap: 0.75rem;
	}

	.ezam-news-grid > li:only-child .ezam-news-card__title,
	.ezam-news-grid > li[class*="block-editor-block-"]:first-child:nth-last-child(2) .ezam-news-card__title {
		font-size: clamp(1.625rem, 1.1rem + 1.1vw, 2rem) !important;
		line-height: 1.2;
	}

	.ezam-news-grid > li:only-child .ezam-news-card__more,
	.ezam-news-grid > li[class*="block-editor-block-"]:first-child:nth-last-child(2) .ezam-news-card__more {
		margin-top: var(--wp--preset--spacing--10);
	}
}

@media (min-width: 782px) and (max-width: 1099.98px) {
	.ezam-news-grid.ezam-news-grid > li:first-child:nth-last-child(odd):not([class*="block-editor-block-"]),
	.ezam-news-grid.ezam-news-grid > li[class*="block-editor-block-"]:first-child:nth-last-child(even) {
		grid-column: 1 / -1;
	}

	.ezam-news-grid > li:first-child:nth-last-child(odd):not([class*="block-editor-block-"]) .ezam-news-card,
	.ezam-news-grid > li[class*="block-editor-block-"]:first-child:nth-last-child(even) .ezam-news-card {
		display: grid;
		grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
		gap: var(--wp--preset--spacing--50);
		align-items: center;
	}

	.ezam-news-grid > li:first-child:nth-last-child(odd):not([class*="block-editor-block-"]) .ezam-news-card__body,
	.ezam-news-grid > li[class*="block-editor-block-"]:first-child:nth-last-child(even) .ezam-news-card__body {
		gap: 0.75rem;
	}

	.ezam-news-grid > li:first-child:nth-last-child(odd):not([class*="block-editor-block-"]) .ezam-news-card__title,
	.ezam-news-grid > li[class*="block-editor-block-"]:first-child:nth-last-child(even) .ezam-news-card__title {
		font-size: clamp(1.625rem, 1.1rem + 1.1vw, 2rem) !important;
		line-height: 1.2;
	}

	.ezam-news-grid > li:first-child:nth-last-child(odd):not([class*="block-editor-block-"]) .ezam-news-card__more,
	.ezam-news-grid > li[class*="block-editor-block-"]:first-child:nth-last-child(even) .ezam-news-card__more {
		margin-top: var(--wp--preset--spacing--10);
	}
}

/* ---------- Ohne Beitragsbild: ruhige CI-Fläche mit der Bildmarke ---------- */

.ezam-news-placeholder {
	margin: 0;
	width: 100%;
	border-radius: var(--wp--custom--radius--md, 1.25rem);
	background:
		url("../../images/logo-mark.svg") center / auto 40% no-repeat,
		var(--wp--preset--color--sage-wash);
}

/* ---------- Seite „Aktuelles“ ---------- */

/* Leere Einleitung (Seiteninhalt gelöscht): keine leere Fläche zwischen Titelband und Karten. */
.ezam-news-intro:empty {
	display: none;
}

.ezam-news-intro > :first-child {
	margin-block-start: 0;
}

.ezam-news-intro > :last-child {
	margin-block-end: 0;
}

/* Paginierung: runde Zahlen, Pillen für „Neuere“ und „Ältere Beiträge“, mindestens 48px hoch. */
.ezam-news .wp-block-query-pagination {
	gap: 0.5rem;
	margin-block-start: var(--wp--preset--spacing--60);
	font-family: var(--wp--preset--font-family--raleway);
	font-size: 1.0625rem;
	font-weight: 700;
	font-variant-numeric: lining-nums tabular-nums;
}

.ezam-news .wp-block-query-pagination > *,
.ezam-news .wp-block-query-pagination-numbers {
	margin: 0;
}

.ezam-news .wp-block-query-pagination-numbers {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.ezam-news .wp-block-query-pagination a,
.ezam-news .wp-block-query-pagination .page-numbers {
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5em;
	min-width: 3rem;
	min-height: 3rem;
	padding: 0 1rem;
	border: 2px solid var(--wp--preset--color--blue-light);
	border-radius: var(--wp--custom--radius--pill, 999px);
	color: var(--wp--preset--color--blue);
	text-decoration: none;
	transition:
		background-color var(--ezam-fast) var(--ezam-ease),
		border-color var(--ezam-fast) var(--ezam-ease),
		color var(--ezam-fast) var(--ezam-ease);
}

.ezam-news .wp-block-query-pagination a:hover {
	border-color: var(--wp--preset--color--blue);
	background-color: var(--wp--preset--color--blue-wash);
	color: var(--wp--preset--color--ink);
}

.ezam-news .wp-block-query-pagination .page-numbers.current {
	border-color: var(--wp--preset--color--blue);
	background-color: var(--wp--preset--color--blue);
	color: var(--wp--preset--color--base);
}

.ezam-news .wp-block-query-pagination .page-numbers.dots {
	min-width: auto;
	padding: 0 0.25rem;
	border-color: transparent;
}

.ezam-news .wp-block-query-pagination-previous::before,
.ezam-news .wp-block-query-pagination-next::after {
	content: "";
	flex: none;
	width: 1.2em;
	height: 1.2em;
	background-color: currentColor;
	-webkit-mask: url("../../icons/regular/arrow-right.svg") center / contain no-repeat;
	mask: url("../../icons/regular/arrow-right.svg") center / contain no-repeat;
}

.ezam-news .wp-block-query-pagination-previous::before {
	transform: scaleX(-1);
}

.ezam-news .wp-block-query-pagination :focus-visible {
	border-radius: var(--wp--custom--radius--pill, 999px);
}

/* Noch keine Beiträge: freundlicher Hinweis mit Telefon-Button statt einer leeren Fläche. */
.ezam-news-empty {
	position: relative;
	isolation: isolate;
	overflow: clip;
	border-radius: var(--wp--custom--radius--lg, 2rem);
}

.ezam-news-empty::after {
	content: "";
	position: absolute;
	z-index: -1;
	right: clamp(-1.5rem, -1vw, 0rem);
	bottom: -1rem;
	width: clamp(6rem, 12vw, 9rem);
	aspect-ratio: 340 / 650;
	background: url("../../images/deko-blatt-zweig.webp") center / contain no-repeat;
	opacity: 0.6;
	pointer-events: none;
}

.ezam-news-empty > * {
	max-width: min(40rem, 100%);
}

@media (max-width: 599.98px) {
	.ezam-news-empty::after {
		opacity: 0.35;
	}
}

/* ---------- Startseiten-Abschnitt ---------- */

.ezam-news-teaser__head > * {
	margin-block: 0;
}

.ezam-news-all {
	font-family: var(--wp--preset--font-family--raleway);
	font-size: 1.125rem;
	font-weight: 700;
	font-variant-numeric: lining-nums;
}

.ezam-news-all a {
	display: inline-flex;
	align-items: center;
	gap: 0.5em;
	min-height: 3rem;
	color: var(--wp--preset--color--blue);
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.25em;
}

.ezam-news-all a:hover {
	color: var(--wp--preset--color--coral-dark);
	text-decoration-thickness: 2px;
}

/* ---------- Einzelbeitrag ---------- */

/* „Alle Neuigkeiten“ über dem Datum im Titelband: Pfeil nach links, klar als Rückweg erkennbar. */
.ezam-news-back {
	margin-block: 0;
	font-family: var(--wp--preset--font-family--raleway);
	font-size: 1rem;
	font-weight: 700;
	font-variant-numeric: lining-nums;
}

.ezam-news-back a {
	display: inline-flex;
	align-items: center;
	gap: 0.45em;
	min-height: 2.75rem;
	color: var(--wp--preset--color--blue);
	text-decoration: underline;
	text-decoration-color: transparent;
	text-decoration-thickness: 2px;
	text-underline-offset: 0.25em;
}

.ezam-news-back a::before {
	content: "";
	flex: none;
	width: 1.2em;
	height: 1.2em;
	background-color: currentColor;
	-webkit-mask: url("../../icons/regular/arrow-right.svg") center / contain no-repeat;
	mask: url("../../icons/regular/arrow-right.svg") center / contain no-repeat;
	transform: scaleX(-1);
}

.ezam-news-back a:hover {
	color: var(--wp--preset--color--ink);
	text-decoration-color: currentColor;
}

@media (prefers-reduced-motion: no-preference) {
	.ezam-news-back a::before {
		transition: translate var(--ezam-base) var(--ezam-ease);
	}

	.ezam-news-back a:hover::before {
		translate: -0.25em 0;
	}
}

.ezam-page-title .ezam-news-single__date {
	margin-block: 0;
}

.ezam-news-single__media {
	margin: 0;
	overflow: hidden;
	border-radius: var(--wp--custom--radius--md, 1.25rem);
}

.ezam-news-single__media.ezam-news-placeholder {
	background-size: auto 48%, auto;
}

/* Beitragstext: Zwischenüberschriften mit Luft davor, der folgende Text rückt näher heran. */
.ezam-news-single__content > :is(h2, h3) {
	margin-block-start: var(--wp--preset--spacing--50);
}

.ezam-news-single__content > :is(h2, h3):first-child {
	margin-block-start: 0;
}

.ezam-news-single__content > :is(h2, h3) + * {
	margin-block-start: 0.75rem;
}

.ezam-news-single__content > h2 + h3 {
	margin-block-start: var(--wp--preset--spacing--30);
}

/* Vorheriger / nächster Beitrag: zwei große Link-Flächen, Beschriftung klein darüber. */
.ezam-news-single__nav.ezam-news-single__nav {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--wp--preset--spacing--30);
}

@media (min-width: 600px) {
	.ezam-news-single__nav.ezam-news-single__nav {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.ezam-news-single__nav .post-navigation-link-next {
		grid-column: 2;
		text-align: right;
	}
}

/* Nur ein Beitrag: keine leere Trennlinie (höhere Spezifität als das Raster darüber). */
.ezam-news-single__nav.ezam-news-single__nav:not(:has(a)) {
	display: none;
}

.ezam-news-single__nav .wp-block-post-navigation-link {
	margin: 0;
}

.ezam-news-single__nav .wp-block-post-navigation-link a {
	display: flex;
	flex-direction: column;
	gap: 0.2rem;
	padding-block: 0.5rem;
	font-family: var(--wp--preset--font-family--raleway);
	font-size: var(--wp--preset--font-size--large);
	font-weight: 700;
	line-height: 1.3;
	color: var(--wp--preset--color--blue);
	text-decoration: none;
}

.ezam-news-single__nav .post-navigation-link__label {
	display: inline-flex;
	align-items: center;
	gap: 0.4em;
	font-family: var(--wp--preset--font-family--lato);
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--sage-dark);
}

.ezam-news-single__nav .post-navigation-link-next .post-navigation-link__label {
	justify-content: flex-end;
}

.ezam-news-single__nav .post-navigation-link__title {
	text-decoration: underline;
	text-decoration-color: transparent;
	text-decoration-thickness: 2px;
	text-underline-offset: 0.2em;
	transition: text-decoration-color var(--ezam-fast) var(--ezam-ease);
}

.ezam-news-single__nav a:hover .post-navigation-link__title {
	text-decoration-color: currentColor;
}

.ezam-news-single__nav .post-navigation-link-previous .post-navigation-link__label::before,
.ezam-news-single__nav .post-navigation-link-next .post-navigation-link__label::after {
	content: "";
	flex: none;
	width: 1.1em;
	height: 1.1em;
	background-color: currentColor;
	-webkit-mask: url("../../icons/regular/arrow-right.svg") center / contain no-repeat;
	mask: url("../../icons/regular/arrow-right.svg") center / contain no-repeat;
}

.ezam-news-single__nav .post-navigation-link-previous .post-navigation-link__label::before {
	transform: scaleX(-1);
}

@media print {
	.ezam-news-card .ezam-news-card__more,
	.ezam-news-single__nav,
	.ezam-news-back,
	.ezam-news-placeholder {
		display: none;
	}
}
