/*
 * MISO Block: zentrales Stylesheet.
 *
 * Hier steht nur, was theme.json nicht abbilden kann. Jede Farbe, jeder Abstand
 * und jede Schriftgröße kommt aus den theme.json-Variablen (--wp--preset--*,
 * --wp--custom--*), damit ein Child-Theme die Marke allein über sein theme.json
 * umstellen kann. Geladen im Frontend und im Editor (functions.php).
 *
 * 1. Grundlagen und Fokus
 * 2. Buttons (Primär, Sekundär = Kontur, Tertiär = Textlink)
 * 3. Kopfzeile und Navigation
 * 4. Flächen (Block-Stile "Fläche hell" und "Fläche dunkel")
 * 5. Icons (Lucide, lokal unter assets/icons)
 * 6. Kacheln und Schritte (Pattern-Klassen)
 * 7. Bilder, Spalten, Zitat, Listen
 * 8. Bewegung reduzieren
 */

/* 1. Grundlagen und Fokus ------------------------------------------------ */

body {
	overflow-wrap: break-word;
	-webkit-font-smoothing: antialiased;
}

/* Lange deutsche Komposita brechen mobil um statt seitlich herauszuragen. */
@media (max-width: 600px) {
	:where(h1, h2, h3, .wp-block-heading) {
		hyphens: auto;
	}
}

/* Fokus-Ring: immer sichtbar, nie dieselbe Erscheinung wie Hover. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible,
.wp-element-button:focus-visible,
.wp-block-button__link:focus-visible {
	outline: var(--wp--custom--focus--width) solid var(--miso-focus-color, var(--wp--preset--color--accent));
	outline-offset: var(--wp--custom--focus--offset);
}

/* 2. Buttons ------------------------------------------------------------- */

.wp-block-button__link,
.wp-element-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--wp--preset--spacing--20);
	min-height: var(--wp--custom--touch-target);
	min-width: var(--wp--custom--touch-target);
	transition:
		background-color var(--wp--custom--transition),
		border-color var(--wp--custom--transition),
		color var(--wp--custom--transition);
}

/* Sekundär (Kernstil "Kontur"): gleiche Maße wie Primär, Hover füllt. */
.wp-block-button.is-style-outline > .wp-block-button__link {
	padding: var(--wp--preset--spacing--20) var(--wp--preset--spacing--40);
	border-color: var(--wp--preset--color--accent);
	color: var(--wp--preset--color--accent);
}

.wp-block-button.is-style-outline > .wp-block-button__link:hover {
	border-color: var(--wp--preset--color--accent);
	background-color: var(--wp--preset--color--accent);
	color: var(--wp--preset--color--on-accent);
}

/* Tertiär (Block-Stil "Textlink"): nur Text mit Pfeil. */
.wp-block-button.is-style-text > .wp-block-button__link {
	padding-right: 0;
	padding-left: 0;
	border-color: transparent;
	background-color: transparent;
	color: var(--wp--preset--color--accent);
	text-decoration: underline;
	text-underline-offset: 0.2em;
}

.wp-block-button.is-style-text > .wp-block-button__link::after {
	content: "";
	width: 1.1em;
	height: 1.1em;
	background-color: currentColor;
	-webkit-mask: url("../icons/arrow-right.svg") center / contain no-repeat;
	mask: url("../icons/arrow-right.svg") center / contain no-repeat;
}

.wp-block-button.is-style-text > .wp-block-button__link:hover {
	border-color: transparent;
	background-color: transparent;
	color: var(--wp--preset--color--contrast);
}

/* 3. Kopfzeile und Navigation ------------------------------------------- */

.miso-header {
	border-bottom: 1px solid var(--wp--preset--color--base-2);
}

/* Telefon, Button und Menü-Schalter geben nie nach, schrumpfen darf nur das Logo. */
.miso-header :is(.miso-telefon, .miso-header__aktion, .wp-block-navigation) {
	flex-shrink: 0;
}

.miso-header .miso-header__aktion .wp-block-button__link {
	white-space: nowrap;
}

.miso-header .wp-block-site-logo {
	flex-shrink: 1;
	min-width: 0;
}

.wp-block-navigation .wp-block-navigation-item__content {
	display: inline-flex;
	align-items: center;
	min-height: var(--wp--custom--touch-target);
	text-decoration: none;
}

.wp-block-navigation .wp-block-navigation-item__content:hover,
.wp-block-navigation .current-menu-item > .wp-block-navigation-item__content {
	text-decoration: underline;
	text-decoration-thickness: 2px;
	text-underline-offset: 0.35em;
}

.wp-block-navigation__responsive-container-open,
.wp-block-navigation__responsive-container-close {
	min-width: var(--wp--custom--touch-target);
	min-height: var(--wp--custom--touch-target);
	justify-content: center;
}

/* Telefonnummer in der Kopfzeile: gut sichtbar, mobil nur als Icon. */
.miso-telefon a {
	display: inline-flex;
	align-items: center;
	min-height: var(--wp--custom--touch-target);
	min-width: var(--wp--custom--touch-target);
	font-weight: 700;
	color: var(--wp--preset--color--contrast);
	text-decoration: none;
	white-space: nowrap;
}

.miso-telefon a::before {
	content: "";
	flex: none;
	width: 1.25rem;
	height: 1.25rem;
	margin-inline-end: var(--wp--preset--spacing--20);
	background-color: currentColor;
	-webkit-mask: url("../icons/phone.svg") center / contain no-repeat;
	mask: url("../icons/phone.svg") center / contain no-repeat;
}

.miso-telefon a:hover {
	text-decoration: underline;
}

@media (max-width: 781px) {
	/* Menü-Schalter mobil ganz rechts, wie gelernt. */
	.miso-header .wp-block-navigation {
		order: 9;
	}

	.miso-header .miso-telefon a {
		justify-content: center;
		font-size: 0;
	}

	.miso-header .miso-telefon a::before {
		margin: 0;
	}
}

@media (max-width: 479px) {
	/* Schmale Handys: alles bleibt in einer Zeile, auch der Anfrage-Button. */
	.miso-header .alignwide,
	.miso-header .alignwide > .wp-block-group {
		gap: var(--wp--preset--spacing--20);
	}

	.miso-header .wp-block-site-logo img {
		max-width: 110px;
		height: auto;
	}

	.miso-header:has(.wp-block-site-logo img) .wp-block-site-title {
		display: none;
	}

	.miso-header .miso-header__aktion .wp-block-button__link {
		padding-right: var(--wp--preset--spacing--30);
		padding-left: var(--wp--preset--spacing--30);
	}
}

/* Textlinks in Fußzeile und Seitennavigation: Tippfläche mindestens 44 px hoch. */
footer :where(p, li) > a,
.wp-block-query-pagination a,
.wp-block-query-pagination .page-numbers,
.post-navigation-link a {
	display: inline-flex;
	align-items: center;
	min-height: var(--wp--custom--touch-target);
}

.wp-block-query-pagination .page-numbers {
	justify-content: center;
	min-width: var(--wp--custom--touch-target);
}

/* 4. Flächen ------------------------------------------------------------- */

:where(.is-style-flaeche-hell, .is-style-flaeche-dunkel) {
	padding: var(--wp--preset--spacing--50);
}

.is-style-flaeche-hell {
	background-color: var(--wp--preset--color--base-2);
	color: var(--wp--preset--color--contrast);
}

/* Dunkle Fläche als Block-Stil oder über die Hintergrundfarbe "contrast" aus der Palette. */
.is-style-flaeche-dunkel,
.has-contrast-background-color:not(.has-text-color),
.has-accent-background-color:not(.has-text-color) {
	color: var(--wp--preset--color--base);
}

.is-style-flaeche-dunkel {
	background-color: var(--wp--preset--color--contrast);
}

/*
 * Dunkler Kontext: dunkle Fläche (Stil oder Palettenfarbe), Akzentfläche und Cover ohne helles Bild.
 * Bedienelemente bekommen einen Rand in Grundfarbe, damit ihre Begrenzung
 * 3:1 gegen den Untergrund erreicht (WCAG 1.4.11), Fokus wird hell.
 */
:is(.is-style-flaeche-dunkel, .has-contrast-background-color, .has-accent-background-color, .wp-block-cover:not(.is-light)) {
	--miso-focus-color: var(--wp--preset--color--base);
}

:is(.is-style-flaeche-dunkel, .has-contrast-background-color, .has-accent-background-color, .wp-block-cover:not(.is-light)) .wp-block-button__link {
	border-color: var(--wp--preset--color--base);
}

:is(.is-style-flaeche-dunkel, .has-contrast-background-color, .has-accent-background-color, .wp-block-cover:not(.is-light)) .wp-block-button__link:hover,
:is(.is-style-flaeche-dunkel, .has-contrast-background-color, .has-accent-background-color, .wp-block-cover:not(.is-light)) .wp-block-button.is-style-outline > .wp-block-button__link:hover {
	border-color: var(--wp--preset--color--base);
	background-color: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
}

:is(.is-style-flaeche-dunkel, .has-contrast-background-color, .has-accent-background-color, .wp-block-cover:not(.is-light)) .wp-block-button.is-style-outline > .wp-block-button__link {
	color: var(--wp--preset--color--base);
}

:is(.is-style-flaeche-dunkel, .has-contrast-background-color, .has-accent-background-color, .wp-block-cover:not(.is-light)) .wp-block-button.is-style-text > .wp-block-button__link,
:is(.is-style-flaeche-dunkel, .has-contrast-background-color, .has-accent-background-color, .wp-block-cover:not(.is-light)) .wp-block-button.is-style-text > .wp-block-button__link:hover {
	border-color: transparent;
	background-color: transparent;
	color: var(--wp--preset--color--base);
}

:is(.is-style-flaeche-dunkel, .has-contrast-background-color, .has-accent-background-color, .wp-block-cover:not(.is-light)) a:where(:not(.wp-element-button)) {
	color: inherit;
}

/* Helle Fläche innerhalb einer dunklen (zum Beispiel Kacheln): zurück auf hell. */
:is(.is-style-flaeche-dunkel, .has-contrast-background-color, .has-accent-background-color, .wp-block-cover:not(.is-light)) :is(.is-style-flaeche-hell, .has-base-background-color, .has-base-2-background-color) {
	--miso-focus-color: var(--wp--preset--color--accent);
}

:is(.is-style-flaeche-dunkel, .has-contrast-background-color, .has-accent-background-color, .wp-block-cover:not(.is-light)) :is(.is-style-flaeche-hell, .has-base-background-color, .has-base-2-background-color) .wp-block-button__link {
	border-color: var(--wp--preset--color--accent);
}

:is(.is-style-flaeche-dunkel, .has-contrast-background-color, .has-accent-background-color, .wp-block-cover:not(.is-light)) :is(.is-style-flaeche-hell, .has-base-background-color, .has-base-2-background-color) :is(.wp-block-button.is-style-outline, .wp-block-button.is-style-text) > .wp-block-button__link {
	color: var(--wp--preset--color--accent);
}

/* 5. Icons --------------------------------------------------------------- */

/*
 * Ein Icon setzt man über die Zusatzklasse miso-icon-<name> am Absatz.
 * Verfügbare Namen entsprechen den Dateien in assets/icons (Lucide, ISC-Lizenz).
 */
[class*="miso-icon-"]::before {
	content: "";
	display: inline-block;
	flex: none;
	width: 1.25rem;
	height: 1.25rem;
	margin-inline-end: var(--wp--preset--spacing--20);
	vertical-align: -0.2em;
	background-color: currentColor;
	-webkit-mask: var(--miso-icon) center / contain no-repeat;
	mask: var(--miso-icon) center / contain no-repeat;
}

.miso-icon-arrow-right { --miso-icon: url("../icons/arrow-right.svg"); }
.miso-icon-phone { --miso-icon: url("../icons/phone.svg"); }
.miso-icon-mail { --miso-icon: url("../icons/mail.svg"); }
.miso-icon-map-pin { --miso-icon: url("../icons/map-pin.svg"); }
.miso-icon-clock { --miso-icon: url("../icons/clock.svg"); }
.miso-icon-check { --miso-icon: url("../icons/check.svg"); }

/* Icon im Button: Zusatzklasse miso-icon-<name> am Button-Block. Das Icon sitzt im Link, nicht davor. */
.wp-block-button[class*="miso-icon-"]::before {
	content: none;
}

.wp-block-button[class*="miso-icon-"] > .wp-block-button__link::before {
	content: "";
	flex: none;
	width: 1.1em;
	height: 1.1em;
	background-color: currentColor;
	-webkit-mask: var(--miso-icon) center / contain no-repeat;
	mask: var(--miso-icon) center / contain no-repeat;
}

/* 6. Kacheln und Schritte ----------------------------------------------- */

/* Kachel: die Überschrift trägt den Link, die ganze Fläche ist klickbar. */
.miso-kachel {
	position: relative;
	transition: background-color var(--wp--custom--transition);
}

.miso-kachel :where(h2, h3, h4) a {
	color: inherit;
	text-decoration: none;
}

.miso-kachel :where(h2, h3, h4) a::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
}

.miso-kachel :where(h2, h3, h4) a::after {
	content: "";
	display: inline-block;
	width: 0.8em;
	height: 0.8em;
	margin-inline-start: 0.35em;
	background-color: var(--wp--preset--color--accent);
	-webkit-mask: url("../icons/arrow-right.svg") center / contain no-repeat;
	mask: url("../icons/arrow-right.svg") center / contain no-repeat;
}

.miso-kachel:hover :where(h2, h3, h4) a {
	text-decoration: underline;
	text-underline-offset: 0.2em;
}

/* Fokus sitzt am Link, sichtbar wird er an der ganzen Kachel. */
.miso-kachel :where(h2, h3, h4) a:focus-visible {
	outline: none;
}

.miso-kachel:has(a:focus-visible) {
	outline: var(--wp--custom--focus--width) solid var(--miso-focus-color, var(--wp--preset--color--accent));
	outline-offset: var(--wp--custom--focus--offset);
}

.miso-schritt-nummer {
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--x-large);
	font-weight: 700;
	line-height: 1;
	color: var(--wp--preset--color--accent);
}

:is(.is-style-flaeche-dunkel, .has-contrast-background-color) .miso-schritt-nummer {
	color: inherit;
}

/* 7. Bilder, Spalten, Zitat, Listen ------------------------------------ */

/*
 * Spalten-Stil "Bild rechts": Im Markup steht das Bild zuerst, damit es mobil
 * oben steht. Ab 782 px (Umbruchpunkt des Spalten-Blocks) rückt es nach rechts.
 */
@media (min-width: 782px) {
	.wp-block-columns.is-style-bild-rechts {
		flex-direction: row-reverse;
	}
}

.wp-block-image :where(img),
.wp-block-media-text__media :where(img),
.miso-kachel {
	border-radius: var(--wp--custom--radius);
}

.wp-block-image :where(img) {
	display: block;
	max-width: 100%;
	height: auto;
}

.wp-block-quote {
	margin-inline: 0;
	padding-inline-start: var(--wp--preset--spacing--40);
	border-inline-start: 4px solid var(--wp--preset--color--accent);
}

.wp-block-quote cite {
	display: block;
	margin-top: var(--wp--preset--spacing--30);
	font-size: var(--wp--preset--font-size--small);
	font-style: normal;
	font-weight: 600;
	color: var(--wp--preset--color--contrast-2);
}

:is(.is-style-flaeche-dunkel, .has-contrast-background-color) .wp-block-quote cite {
	color: inherit;
}

.is-style-haken {
	padding-inline-start: 0;
	list-style: none;
}

.is-style-haken li {
	position: relative;
	padding-inline-start: 1.75em;
}

.is-style-haken li::before {
	content: "";
	position: absolute;
	top: 0.2em;
	left: 0;
	width: 1.2em;
	height: 1.2em;
	background-color: var(--wp--preset--color--accent);
	-webkit-mask: url("../icons/check.svg") center / contain no-repeat;
	mask: url("../icons/check.svg") center / contain no-repeat;
}

:is(.is-style-flaeche-dunkel, .has-contrast-background-color) .is-style-haken li::before {
	background-color: currentColor;
}

/* 8. Bewegung reduzieren ------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		transition-duration: 0.01ms !important;
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		scroll-behavior: auto !important;
	}
}
