/*
 * Menü „Barrierefreiheit“ (template-parts/anzeige.php, assets/js/anzeige.js) und die Anzeigemodi.
 * Die Modi hängen als Klassen am <html> (anzeige-schrift-1 bis 3, anzeige-zeilen, anzeige-kontrast,
 * anzeige-links, anzeige-lesen, anzeige-einfach, bewegung-aus) und werden vor dem ersten Zeichnen gesetzt.
 */

/* ---------- Knopf unten links und im Fuß ---------- */

/* Lage des Knopfs; das Fenster und die Vorlese-Leiste stehen darüber. Taski hat die Ecke unten rechts. */
:root {
	--zugang-rand: max(20px, env(safe-area-inset-left, 0px));
	--zugang-unten: max(20px, env(safe-area-inset-bottom, 0px));
	--zugang-groesse: 56px;
	--zugang-ueber: calc(var(--zugang-unten) + var(--zugang-groesse) + 12px);
}

@media (max-width: 640px) {
	:root {
		--zugang-rand: max(16px, env(safe-area-inset-left, 0px));
		--zugang-unten: max(16px, env(safe-area-inset-bottom, 0px));
		--zugang-groesse: 48px;
	}
}

.zugang-knopf {
	position: fixed;
	left: var(--zugang-rand);
	bottom: var(--zugang-unten);
	z-index: 59; /* unter Taskis offenem Fenster (60) */
	display: inline-grid;
	place-items: center;
	width: var(--zugang-groesse);
	height: var(--zugang-groesse);
	padding: 0;
	border: 1px solid rgba(60, 184, 255, 0.45);
	border-radius: 50%;
	background: var(--tl-nacht);
	box-shadow: 0 14px 34px -14px rgba(0, 7, 14, 0.8), 0 0 0 4px rgba(0, 167, 254, 0.08);
	color: #ffffff;
	cursor: pointer;
	transition: background-color 0.2s, border-color 0.2s;
}

/* Vor anzeige.js (anzeige-frueh.js setzt .js-frueh) steht der Knopf schon da, damit er nicht nachträglich auftaucht */
.js-frueh .zugang-knopf[hidden] {
	display: inline-grid;
}

.zugang-knopf .icon {
	width: 30px;
	height: 30px;
	stroke-width: 1.5;
}

.zugang-knopf:hover,
.zugang-knopf:focus-visible,
.zugang-knopf[aria-expanded="true"] {
	border-color: var(--tl-blau);
	background: #031726;
}

.zugang-knopf:focus-visible {
	outline-color: var(--tl-blau);
}

.zugang-knopf[hidden],
.fuss__zugang[hidden] {
	display: none;
}

/* Das Einwilligungsbanner steht unten links; solange es offen ist, bleibt der Weg über den Fuß. */
.einwilligung-offen .zugang-knopf {
	display: none !important;
}

/* Taski füllt auf dem Handy den Bildschirm; dahinter bliebe der Knopf erreichbar, aber verdeckt. */
@media (max-width: 640px) {
	html.ki-offen .zugang-knopf {
		display: none;
	}
}

.fuss__zugang {
	display: block;
}

/* Platz am Seitenende, damit der Knopf die letzte Zeile des Fußes nicht verdeckt */
.fuss {
	padding-bottom: 76px;
}

/* ---------- Menü als Fenster über dem Knopf ---------- */

.anzeige {
	position: fixed;
	inset: auto auto var(--zugang-ueber) var(--zugang-rand);
	width: min(400px, calc(100vw - 2 * var(--zugang-rand)));
	max-width: none;
	height: auto;
	max-height: min(640px, calc(100vh - var(--zugang-ueber) - 16px));
	max-height: min(640px, calc(100dvh - var(--zugang-ueber) - 16px));
	margin: 0;
	padding: 0 22px 22px;
	overflow-y: auto;
	overscroll-behavior: contain;
	border: 1px solid rgba(60, 184, 255, 0.35);
	border-radius: 18px;
	background: var(--tl-nacht);
	box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.75);
	color: var(--tl-text-hell);
	font-size: 1rem;
	line-height: 1.5;
}

.anzeige[open] {
	display: flex;
	flex-direction: column;
	gap: 22px;
}

.anzeige::backdrop {
	background: rgba(0, 7, 14, 0.25);
}

@media (prefers-reduced-motion: no-preference) {
	.anzeige[open] {
		transform-origin: left bottom;
		animation: anzeige-auf 0.18s ease-out;
	}
}

.bewegung-aus .anzeige[open] {
	animation: none;
}

@keyframes anzeige-auf {
	from { opacity: 0; transform: translateY(8px) scale(0.98); }
	to { opacity: 1; transform: none; }
}

.anzeige :focus-visible {
	outline-color: #ffffff;
}

.anzeige__kopf {
	position: sticky;
	top: 0;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin: 0 -22px;
	padding: 12px 22px 10px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.1);
	background: var(--tl-nacht);
}

.anzeige__titel {
	display: flex;
	align-items: center;
	gap: 12px;
	color: #ffffff;
	font-family: var(--tl-schrift-titel);
	font-size: 1.375rem;
	font-weight: 700;
	line-height: 1.25;
}

.anzeige__titel .icon {
	width: 30px;
	height: 30px;
	color: var(--tl-blau-titel);
	stroke-width: 1.5;
}

.anzeige__zu {
	display: inline-grid;
	place-items: center;
	width: 44px;
	height: 44px;
	flex: none;
	margin-right: -10px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: #ffffff;
	cursor: pointer;
}

.anzeige__zu:hover,
.anzeige__zu:focus-visible {
	background: rgba(255, 255, 255, 0.1);
}

.anzeige__hinweis {
	color: var(--tl-grau-dunkel);
	font-size: 0.9375rem;
}

.anzeige__gruppe {
	display: grid;
	gap: 12px;
	min-width: 0;
	margin: 0;
	padding: 20px 0 0;
	border: 0;
	border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.anzeige__legende {
	float: left; /* legend als Zeile im Raster, nicht im Rahmen */
	width: 100%;
	margin: 0 0 12px;
	padding: 0;
	color: #ffffff;
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.3;
}

.anzeige__legende + * {
	clear: both;
}

.anzeige__unterlegende {
	float: left;
	width: 100%;
	margin: 4px 0 8px;
	padding: 0;
	color: var(--tl-grau-dunkel);
	font-size: 0.875rem;
	font-weight: 500;
}

.anzeige__klein {
	color: var(--tl-grau-dunkel);
	font-size: 0.875rem;
}

.anzeige__fehlt {
	padding: 12px 14px;
	border: 1px solid rgba(255, 255, 255, 0.22);
	border-radius: var(--tl-radius);
	color: var(--tl-text-hell);
	font-size: 0.9375rem;
}

.anzeige__vorlesen {
	display: grid;
	gap: 12px;
}

.anzeige__vorlesen[hidden],
.anzeige__fehlt[hidden] {
	display: none;
}

.anzeige__vorlesen-knopf {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	min-height: 48px;
	padding: 0 20px;
	border: 0;
	border-radius: var(--tl-radius);
	background: var(--tl-blau);
	color: var(--tl-tinte);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.anzeige__vorlesen-knopf:hover,
.anzeige__vorlesen-knopf:focus-visible {
	background: #3cb8ff;
}

/* Stufen: Radioknöpfe als Reihe von Feldern */
.anzeige__stufen {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

.anzeige__gruppe.anzeige__stufen {
	padding-top: 20px;
}

/* Gleich breite Felder: Tempo in drei, Schriftgröße in zwei Spalten */
.anzeige__stufen--tempo,
.anzeige__stufen--schrift {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
}

.anzeige__stufen--schrift {
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.anzeige__stufen--tempo > legend,
.anzeige__stufen--schrift > legend {
	grid-column: 1 / -1;
	margin-bottom: 0;
}

.anzeige__stufe {
	position: relative;
	flex: 1 1 auto;
	min-width: 0;
}

.anzeige__stufe input {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	opacity: 0;
	cursor: pointer;
}

.anzeige__stufe > span {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	min-height: 44px;
	padding: 6px 12px;
	border: 1px solid rgba(255, 255, 255, 0.3);
	border-radius: var(--tl-radius);
	color: var(--tl-text-hell);
	font-size: 0.9375rem;
	text-align: center;
	white-space: nowrap;
}

.anzeige__stufe input:checked + span {
	border-color: var(--tl-blau);
	background: var(--tl-blau);
	color: var(--tl-tinte);
	font-weight: 600;
}

.anzeige__stufe input:focus-visible + span {
	outline: 3px solid #ffffff;
	outline-offset: 3px;
}

.anzeige__stufe input:hover + span {
	border-color: var(--tl-blau);
}

.anzeige__muster {
	font-family: var(--tl-schrift-titel);
	font-weight: 700;
	line-height: 1;
}

.anzeige__stufe--0 .anzeige__muster { font-size: 0.875rem; }
.anzeige__stufe--1 .anzeige__muster { font-size: 1rem; }
.anzeige__stufe--2 .anzeige__muster { font-size: 1.125rem; }
.anzeige__stufe--3 .anzeige__muster { font-size: 1.3125rem; }

/* Schalter */
.anzeige__schalter {
	display: grid;
	gap: 4px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.anzeige__schalter li {
	display: grid;
	gap: 0;
}

.anzeige__schalter-knopf {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	width: 100%;
	min-height: 44px;
	padding: 6px 0;
	border: 0;
	background: none;
	color: #ffffff;
	font: inherit;
	font-weight: 500;
	text-align: left;
	cursor: pointer;
}

.anzeige__regler {
	position: relative;
	width: 46px;
	height: 26px;
	flex: none;
	border: 1px solid rgba(255, 255, 255, 0.55);
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.08);
	transition: background-color 0.2s;
}

.anzeige__regler::after {
	content: "";
	position: absolute;
	top: 3px;
	left: 3px;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: #ffffff;
	transition: transform 0.2s var(--tl-ease);
}

.anzeige__schalter-knopf[aria-checked="true"] .anzeige__regler {
	border-color: var(--tl-blau);
	background: var(--tl-blau);
}

.anzeige__schalter-knopf[aria-checked="true"] .anzeige__regler::after {
	background: var(--tl-tinte);
	transform: translateX(20px);
}

.anzeige__schalter-text {
	padding-bottom: 8px;
	color: var(--tl-grau-dunkel);
	font-size: 0.875rem;
}

.anzeige__fuss {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px 20px;
	margin-top: auto;
	padding-top: 20px;
	border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.anzeige__zuruecksetzen {
	min-height: 44px;
	padding: 0 18px;
	border: 1px solid rgba(255, 255, 255, 0.45);
	border-radius: var(--tl-radius);
	background: transparent;
	color: #ffffff;
	font: inherit;
	font-weight: 500;
	cursor: pointer;
}

.anzeige__zuruecksetzen:hover,
.anzeige__zuruecksetzen:focus-visible {
	border-color: #ffffff;
	background: rgba(255, 255, 255, 0.08);
}

.anzeige__hilfe {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	color: var(--tl-blau-hell);
	text-decoration: underline;
	text-underline-offset: 3px;
}

/* ---------- Leiste beim Vorlesen ---------- */

/* Unten bleibt beim Scrollen Platz, damit Taski und der Knopf unten links nie ein fokussiertes Element verdecken (WCAG 2.4.11) */
html {
	scroll-padding-bottom: 96px;
}

/* Beim Vorlesen steht die Leiste über dem Knopf unten links */
html.liest-vor {
	scroll-padding-bottom: 150px;
}

.vorlese-leiste {
	position: fixed;
	bottom: var(--zugang-ueber);
	left: var(--zugang-rand);
	z-index: 90;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 10px;
	max-width: calc(100% - 32px);
	padding: 6px 6px 6px 16px;
	border: 1px solid var(--tl-blau);
	border-radius: 28px;
	background: var(--tl-nacht);
	color: #ffffff;
	box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.6);
	font-size: 0.9375rem;
}

.vorlese-leiste[hidden] {
	display: none;
}

.vorlese-leiste > .icon {
	width: 22px;
	height: 22px;
	color: var(--tl-blau-titel);
}

.vorlese-leiste__stand {
	min-width: 5.5em;
}

.vorlese-leiste__knopf {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: 44px;
	padding: 0 14px;
	border: 1px solid rgba(255, 255, 255, 0.35);
	border-radius: 22px;
	background: transparent;
	color: #ffffff;
	font: inherit;
	cursor: pointer;
}

.vorlese-leiste__knopf:hover,
.vorlese-leiste__knopf:focus-visible {
	border-color: #ffffff;
	background: rgba(255, 255, 255, 0.1);
}

.vorlese-leiste :focus-visible {
	outline-color: #ffffff;
}

.vorlese-leiste__knopf .icon {
	width: 18px;
	height: 18px;
}

.vorlese-leiste .icon--play {
	display: none;
	fill: currentColor;
}

.vorlese-leiste.ist-angehalten .icon--play {
	display: block;
}

.vorlese-leiste.ist-angehalten .icon--pause {
	display: none;
}

.vorlese-leiste .icon--stopp {
	fill: currentColor;
	stroke: none;
}

/* Auf dem Handy in einer Zeile, solange der Platz reicht (ab etwa 360 px) */
@media (max-width: 420px) {
	.vorlese-leiste {
		gap: 8px;
		padding-left: 12px;
	}

	.vorlese-leiste__knopf {
		padding: 0 10px;
	}
}

/* Der Block, der gerade gelesen wird */
.vorlesen-aktiv {
	border-radius: 3px;
	outline: 3px solid var(--tl-blau) !important;
	outline-offset: 4px;
	background-color: rgba(0, 167, 254, 0.12);
}

/* ---------- In einfachen Worten ---------- */

.einfach-bereich {
	padding: 28px 0 0;
	background: var(--tl-weiss);
}

.einfach {
	max-width: 72ch;
	border-left: 4px solid var(--tl-blau-text);
	border-radius: 0 var(--tl-radius) var(--tl-radius) 0;
	background: #eef6fc;
	color: var(--tl-tinte);
}

.einfach > summary {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 48px;
	padding: 10px 18px;
	color: var(--tl-tinte);
	font-weight: 600;
	cursor: pointer;
	list-style: none;
}

.einfach > summary::-webkit-details-marker {
	display: none;
}

.einfach > summary::after {
	content: "";
	width: 9px;
	height: 9px;
	margin-left: auto;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: translateY(-2px) rotate(45deg);
}

.einfach[open] > summary::after {
	transform: translateY(2px) rotate(-135deg);
}

.einfach > summary .icon {
	width: 22px;
	height: 22px;
	color: var(--tl-blau-text);
}

.einfach__text {
	display: grid;
	gap: 6px;
	padding: 0 18px 18px 50px;
	font-size: 1.0625rem;
	line-height: 1.65;
}

.anzeige-einfach .einfach {
	max-width: none;
	border-left-width: 6px;
	background: #e3f1fb;
}

.anzeige-einfach .einfach__text {
	font-size: 1.1875rem;
}

/* ---------- Modus: Schriftgröße ---------- */

html.anzeige-schrift-1 { font-size: 112.5%; }
html.anzeige-schrift-2 { font-size: 125%; }
html.anzeige-schrift-3 { font-size: 150%; }

/* Feste Breiten und Höhen aus dem Entwurf geben bei größerer Schrift nach */
/* Lange deutsche Wörter trennen statt über den Rand laufen lassen; „anywhere“ hält auch die Mindestbreite
   in Rastern klein (E-Mail-Adressen, Listen), getrennt wird trotzdem zuerst nach Silben */
html[class*="anzeige-schrift-"] :is(h1, h2, h3, h4, p, li, dd, dt, td, th, summary, label, address, a, .titel-2) {
	-webkit-hyphens: auto;
	hyphens: auto;
	overflow-wrap: anywhere;
}

html[class*="anzeige-schrift-"] .knopf {
	max-width: 100%;
	padding-block: 8px;
	text-align: center;
	white-space: normal;
}

html[class*="anzeige-schrift-"] .karte {
	height: auto;
	min-height: 300px;
}

html[class*="anzeige-schrift-"] .karte__inhalt {
	height: auto;
	padding-bottom: 184px; /* Platz für Bild und Link unten in der Karte */
}

html[class*="anzeige-schrift-"] .karte__bild {
	height: 168px;
}

html[class*="anzeige-schrift-"] :is(.karte__text, .schritt__text, .ablauf__text) {
	max-width: none !important;
}

/* ---------- Modus: mehr Zeilenabstand ---------- */

.anzeige-zeilen :is(main, .fuss, .ki__verlauf, .anzeige) :is(p, li, dd, dt, td, th, blockquote, summary, figcaption, label, address):not([aria-hidden="true"] *) {
	line-height: 1.9 !important;
}

.anzeige-zeilen :is(main, .fuss) :is(h1, h2, h3, h4):not([aria-hidden="true"] *) {
	line-height: 1.45 !important;
}

.anzeige-zeilen main :is(p, ul, ol, dl, blockquote) + :is(p, ul, ol, dl, blockquote, h2, h3, h4) {
	margin-top: 1.5em;
}

.anzeige-zeilen main {
	word-spacing: 0.08em;
}

/* ---------- Modus: Links unterstreichen ---------- */

.anzeige-links a:not(.knopf):not(.logo):not(.sprunglink) {
	text-decoration-line: underline !important;
	text-decoration-thickness: max(1px, 0.08em);
	text-underline-offset: 0.2em;
}

/* ---------- Modus: Bewegung anhalten (auch Knopf auf der Startseite) ---------- */

html.bewegung-aus {
	scroll-behavior: auto !important;
}

.bewegung-aus *,
.bewegung-aus *::before,
.bewegung-aus *::after {
	animation-duration: 0.001ms !important;
	animation-delay: 0s !important;
	animation-iteration-count: 1 !important;
	transition-duration: 0.001ms !important;
	transition-delay: 0s !important;
	scroll-behavior: auto !important;
}

.bewegung-aus.zeigen-bereit [data-zeigen]:not(.ist-sichtbar) {
	opacity: 1;
	transform: none;
}

/* ---------- Modus: Lesemodus ---------- */

.anzeige-lesen :is(.waben, .held__bild, .held__hintergrund, .seitenkopf__bild, .seitenkopf__zeichen, .seitenleiste, .systeme, .bewegung-schalter, .abschluss) {
	display: none !important;
}

.anzeige-lesen .seite__raster {
	grid-template-columns: minmax(0, 1fr);
}

.anzeige-lesen :is(.prosa, .einfach) {
	max-width: 66ch;
	margin-inline: auto;
}

.anzeige-lesen .prosa {
	font-size: 1.125rem;
}

.anzeige-lesen .seitenkopf__raster {
	grid-template-columns: minmax(0, 1fr);
}

.anzeige-lesen .seitenkopf__text {
	max-width: 66ch;
}

/* ---------- Modus: hoher Kontrast ---------- */

.anzeige-kontrast {
	--tl-grau-dunkel: #ffffff;
	--tl-grau-hell: #08111b;
	--tl-text-hell: #ffffff;
	--tl-blau-text: #00508a;
	--tl-blau-hell: #9fdcff;
	--tl-blau-titel: #6fcbff;
	--tl-linie-dunkel: rgba(255, 255, 255, 0.6);
}

.anzeige-kontrast .prosa,
.anzeige-kontrast .prosa :is(p, li, dd, dt, td, th, blockquote, figcaption) {
	color: #000000;
}

.anzeige-kontrast :is(.kopf, .held, .seitenkopf, .stimmen, .abschluss, .fuss, .systeme, .menue, .anzeige, .vorlese-leiste) :is(p, li, dd, dt, address, small, figcaption):not(.ueberzeile):not([aria-hidden="true"] *) {
	color: #ffffff;
}

.anzeige-kontrast :is(.anzeige__regler, .anzeige__stufe > span, .anzeige__zuruecksetzen, .vorlese-leiste__knopf, .zugang-knopf) {
	border-color: #ffffff;
}

.anzeige-kontrast :focus-visible {
	outline-width: 4px;
}

/* ---------- Erzwungene Farben (Windows-Kontrastmodus) ---------- */

@media (forced-colors: active) {
	.anzeige__regler {
		border: 2px solid ButtonText;
	}

	.anzeige__regler::after {
		background: ButtonText;
	}

	.anzeige__schalter-knopf[aria-checked="true"] .anzeige__regler {
		border-color: Highlight;
		background: Highlight;
	}

	.anzeige__schalter-knopf[aria-checked="true"] .anzeige__regler::after {
		background: HighlightText;
	}

	.anzeige__stufe input:checked + span {
		border: 3px solid Highlight;
	}

	.vorlesen-aktiv {
		outline-color: Highlight !important;
	}

	.einfach {
		border: 1px solid CanvasText;
		border-left-width: 4px;
	}
}

/* Startseite: unter dem Kopfbereich auf dunklem Grund */
.einfach-bereich--dunkel {
	padding: 0 0 32px;
	background: var(--tl-nacht);
}

.einfach-bereich--dunkel .einfach {
	border-left-color: var(--tl-blau);
	background: var(--tl-karte-dunkel);
	color: var(--tl-text-hell);
}

.einfach-bereich--dunkel .einfach > summary {
	color: #ffffff;
}

.einfach-bereich--dunkel .einfach > summary .icon {
	color: var(--tl-blau-titel);
}

.einfach-bereich--dunkel :focus-visible {
	outline-color: #ffffff;
}

.anzeige-einfach .einfach-bereich--dunkel .einfach {
	background: #10263a;
}

.einfach-bereich + .seite {
	padding-top: 40px;
}

html[class*="anzeige-schrift-"] .badge-beleg {
	max-width: calc(100% - 8px);
	white-space: normal;
}
