/* ==========================================================================
   HILFSMITTELVERLAG – BASE
   Struktur-CSS, das theme.json nicht ausdrücken kann (Frame, Reset, Zustände).

   REGEL: Hier stehen KEINE Design-Werte. Jeder Wert kommt als var() aus
   theme.json. Wer einen Wert ändern will, ändert theme.json – nicht diese Datei.
   ========================================================================== */

/* ==========================================================================
   1. SEMANTISCHE ALIASE
   Kurznamen für die von WordPress erzeugten Token. Aliase verweisen nur,
   sie kopieren keine Werte – theme.json bleibt die einzige Quelle.

   Im übrigen CSS bitte ausschließlich diese Kurznamen verwenden. Grund:
   WordPress schreibt Slugs in Kebab-Case um – aus dem Slug "h1" würde die
   Variable "--wp--preset--font-size--h-1". Solche Abweichungen fallen nicht
   auf, sie führen nur dazu, dass eine Angabe stillschweigend wirkungslos
   bleibt. Die Slugs in theme.json sind deshalb so gewählt, dass Slug und
   Variablenname identisch sind.
   ========================================================================== */

:root {
	/* Farben */
	--color-bg: var(--wp--preset--color--bg);
	--color-text: var(--wp--preset--color--text);
	--color-muted: var(--wp--preset--color--muted);
	--color-muted-bg: var(--wp--preset--color--muted-bg);
	--color-muted-bg-hover: var(--wp--preset--color--muted-bg-hover);
	--color-accent: var(--wp--preset--color--accent);
	--color-border-soft: var(--wp--preset--color--border-soft);
	--color-success: var(--wp--preset--color--success);
	--color-error: var(--wp--preset--color--error);
	--color-border: var(--wp--preset--color--text);

	/* Schrift */
	--font-headline: var(--wp--preset--font-family--headline);
	--font-body: var(--wp--preset--font-family--body);
	--font-ui: var(--wp--preset--font-family--ui);

	--font-size-h1: var(--wp--preset--font-size--headline-xl);
	--font-size-h2: var(--wp--preset--font-size--headline-lg);
	--font-size-h3: var(--wp--preset--font-size--headline-md);
	--font-size-h4: var(--wp--preset--font-size--headline-sm);
	--font-size-body: var(--wp--preset--font-size--body);
	--font-size-lead: var(--wp--preset--font-size--lead);
	--font-size-ui: var(--wp--preset--font-size--ui);
	--font-size-meta: var(--wp--preset--font-size--meta);
	--font-size-sm: var(--wp--preset--font-size--sm);
	--font-size-xs: var(--wp--preset--font-size--xs);
	--font-size-lg: var(--wp--preset--font-size--lg);

	--line-height-h1: var(--wp--custom--line-height--headline-xl);
	--line-height-h2: var(--wp--custom--line-height--headline-lg);
	--line-height-h3: var(--wp--custom--line-height--headline-md);
	--line-height-h4: var(--wp--custom--line-height--headline-sm);
	--line-height-body: var(--wp--custom--line-height--body);
	--line-height-lead: var(--wp--custom--line-height--lead);
	--line-height-ui: var(--wp--custom--line-height--ui);
	--line-height-meta: var(--wp--custom--line-height--meta);

	/* Abstände */
	--space-xs: var(--wp--preset--spacing--xs);
	--space-sm: var(--wp--preset--spacing--sm);
	--space-md: var(--wp--preset--spacing--md);
	--space-lg: var(--wp--preset--spacing--lg);
	--space-xl: var(--wp--preset--spacing--xl);
	--space-2xl: var(--wp--preset--spacing--xxl);
	--space-3xl: var(--wp--preset--spacing--xxxl);
	--space-4xl: var(--wp--preset--spacing--xxxxl);

	/* Radien, Übergänge, Rahmen */
	--radius-sm: var(--wp--custom--radius--sm);
	--radius-md: var(--wp--custom--radius--md);
	--radius-lg: var(--wp--custom--radius--lg);
	--transition-fast: var(--wp--custom--transition--fast);
	--transition-base: var(--wp--custom--transition--base);
	--transition-slow: var(--wp--custom--transition--slow);
	--transition-button: var(--wp--custom--transition--button);
	--border-width: var(--wp--custom--frame--border-width);

	/* Frame (Passepartout) – Mobile-Werte, Desktop siehe Media Query */
	--frame-outer-margin: var(--wp--custom--frame--outer-margin-mobile);
	--frame-inner-padding: var(--wp--custom--frame--inner-padding-mobile);
	--frame-border-width: var(--wp--custom--frame--border-width);
	--frame-max-width: var(--wp--custom--frame--max-width);

	/* Grid */
	--grid-columns: var(--wp--custom--grid--columns);
	--grid-gap: var(--wp--custom--grid--gap-mobile);
}

@media (min-width: 768px) {
	:root {
		--grid-gap: var(--wp--custom--grid--gap-tablet);
	}
}

@media (min-width: 1024px) {
	:root {
		--frame-outer-margin: var(--wp--custom--frame--outer-margin-desktop);
		--frame-inner-padding: var(--wp--custom--frame--inner-padding-desktop);
		--grid-gap: var(--wp--custom--grid--gap-desktop);
	}
}

/* ==========================================================================
   2. RESET
   ========================================================================== */

*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-rendering: optimizeLegibility;
}

body {
	transition: background-color var(--transition-base), color var(--transition-base);
}

img,
picture,
video,
canvas,
svg {
	display: block;
	max-width: 100%;
	height: auto;
}

input,
button,
textarea,
select {
	font: inherit;
}

/* ==========================================================================
   3. FRAME (Passepartout)
   Aufbau: Outer Margin → Rahmen → Inner Padding → Inhalt.
   Regel: Kein Element durchbricht den Frame.

   Der Rahmen sitzt auf .site-frame. Dieser Wrapper wird in header.php
   geöffnet und in footer.php geschlossen – außerhalb der Reichweite des
   Editors, damit er nicht versehentlich entfernt werden kann.
   ========================================================================== */

body {
	padding: var(--frame-outer-margin);
	min-height: 100vh;
}

/* Der Rahmen sitzt immer am Browserrand (nur der Außenabstand davor).
   Breit wird er mit dem Fenster – der Inhalt darin aber nicht: Kopf,
   Inhalt und Fuß enden bei der Frame-Höchstbreite und stehen mittig.
   So wie auf der Live-Seite hilfsmittelverlag.de. */
.site-frame {
	display: flex;
	flex-direction: column;
	min-height: calc(100vh - (var(--frame-outer-margin) * 2));
	padding: var(--frame-inner-padding);
	border: var(--frame-border-width) solid var(--color-border);
	overflow-x: clip;
}

.site-frame > .site-header,
.site-frame > .site-main,
.site-frame > .site-footer {
	width: 100%;
	max-width: calc(var(--frame-max-width) - (var(--frame-inner-padding) * 2));
	margin-inline: auto;
}

/* Hauptinhalt füllt den Frame, damit der Fußbereich unten sitzt */
.site-frame > .site-main {
	flex: 1;
}

/* Mobile: verhindert horizontales Überlaufen im Frame */
@media (max-width: 1023px) {
	.site-frame {
		overflow-x: hidden;
	}
}

/* ==========================================================================
   4. TYPOGRAFIE-HILFSKLASSEN
   Ergänzen die Element-Styles aus theme.json.
   ========================================================================== */

/* Überschriften-Optik ohne Überschriften-Ebene. Nötig, wo eine Größe gezeigt
   oder zitiert wird, ohne die Gliederung der Seite zu verändern. */
.h1,
.h2,
.h3,
.h4 {
	font-family: var(--font-headline);
	font-weight: 500;
}

.h1 {
	font-size: var(--font-size-h1);
	line-height: var(--line-height-h1);
	letter-spacing: var(--wp--custom--letter-spacing--headline-xl);
}

.h2 {
	font-size: var(--font-size-h2);
	line-height: var(--line-height-h2);
	letter-spacing: var(--wp--custom--letter-spacing--headline-lg);
}

.h3 {
	font-size: var(--font-size-h3);
	line-height: var(--line-height-h3);
}

.h4 {
	font-size: var(--font-size-h4);
	line-height: var(--line-height-h4);
}

.lead {
	font-size: var(--font-size-lead);
	line-height: var(--line-height-lead);
}

.text-ui {
	font-family: var(--font-ui);
	font-size: var(--font-size-ui);
	line-height: var(--line-height-ui);
}

.text-meta {
	font-family: var(--font-ui);
	font-size: var(--font-size-meta);
	line-height: var(--line-height-meta);
}

.text-muted {
	color: var(--color-muted);
}

/* ==========================================================================
   5. LINKS
   Unterstreichung wächst von links – ersetzt die Standard-Unterstreichung.
   ========================================================================== */

.link {
	position: relative;
	display: inline-block;
	text-decoration: none;
}

.link::after {
	content: '';
	position: absolute;
	bottom: 0;
	left: 0;
	width: 100%;
	height: var(--border-width);
	background-color: currentColor;
	transform: scaleX(0);
	transform-origin: left;
	transition: transform var(--transition-base);
}

.link:hover::after {
	transform: scaleX(1);
}

/* Ohne Verzögerung zurück */
.link:not(:hover)::after {
	transition: none;
}

.link:hover {
	text-decoration: none;
}

/* ==========================================================================
   6. TRENNLINIEN
   Von Frame-Innenkante zu Frame-Innenkante.
   ========================================================================== */

.rule {
	border: none;
	border-top: var(--border-width) solid var(--color-border);
	margin: var(--space-lg) 0;
}

@media (max-width: 1023px) {
	.rule {
		margin: 0;
	}

	.rule--major {
		border-top-width: calc(var(--border-width) * 2);
	}
}

.rule-vertical {
	border: none;
	border-left: var(--border-width) solid var(--color-border);
	height: 100%;
}

/* ==========================================================================
   7. BILDER
   ========================================================================== */

.img-rounded {
	border-radius: var(--radius-lg);
}

.img-hover {
	overflow: hidden;
	border-radius: var(--radius-lg);
}

.img-hover img {
	transition: transform var(--transition-slow);
}

.img-hover:hover img {
	transform: scale(var(--wp--custom--image--hover-scale));
}

/* ==========================================================================
   8. BARRIEREFREIHEIT
   ========================================================================== */

.screen-reader-text,
.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

:focus-visible {
	outline: calc(var(--border-width) * 2) solid var(--color-text);
	outline-offset: 2px;
}

:focus:not(:focus-visible) {
	outline: none;
}

/* Sprunglink von WordPress */
.skip-link:focus {
	background-color: var(--color-text);
	color: var(--color-bg);
	font-family: var(--font-ui);
	font-size: var(--font-size-ui);
	padding: var(--space-sm) var(--space-md);
	border-radius: 0 0 var(--radius-sm) var(--radius-sm);
	z-index: 9999;
}

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

/* ==========================================================================
   9. TEXTAUSWAHL
   ========================================================================== */

::selection {
	background-color: var(--color-text);
	color: var(--color-bg);
}

/* ==========================================================================
   10. INHALTSBREITE
   Lesetexte auf angenehme Zeilenlänge begrenzen.
   ========================================================================== */

.prose {
	max-width: var(--wp--custom--content-width--prose);
}

/* ==========================================================================
   11. DARK-MODE-UMSCHALTER
   ========================================================================== */

.theme-toggle {
	--toggle-width: 52px;
	--toggle-height: 26px;
	--toggle-icon-size: 16px;
	--toggle-icon-offset: 5px;

	position: relative;
	width: var(--toggle-width);
	height: var(--toggle-height);
	padding: 0;
	border: var(--border-width) solid var(--color-text);
	border-radius: var(--toggle-height);
	background: transparent;
	cursor: pointer;
	overflow: hidden;
	flex: none;
}

.theme-toggle:focus,
.theme-toggle:active {
	outline: none;
	box-shadow: none;
	-webkit-tap-highlight-color: transparent;
}

.theme-toggle:focus-visible {
	outline: calc(var(--border-width) * 2) solid var(--color-text);
	outline-offset: 2px;
}

.theme-toggle__icons {
	position: absolute;
	top: 50%;
	left: var(--toggle-icon-offset);
	transform: translateY(-50%);
	width: var(--toggle-icon-size);
	height: var(--toggle-icon-size);
	transition: left var(--transition-base);
}

.theme-toggle__icon {
	position: absolute;
	top: 0;
	left: 0;
	width: var(--toggle-icon-size);
	height: var(--toggle-icon-size);
	color: var(--color-text);
	transition: opacity var(--transition-fast);
}

.theme-toggle__icon--moon {
	opacity: 0;
}

[data-theme='dark'] .theme-toggle__icons {
	left: calc(
		var(--toggle-width) - var(--toggle-icon-size) - var(--toggle-icon-offset) -
			(var(--border-width) * 2)
	);
}

[data-theme='dark'] .theme-toggle__icon--sun {
	opacity: 0;
}

[data-theme='dark'] .theme-toggle__icon--moon {
	opacity: 1;
}

/* ==========================================================================
   12. KOPFBEREICH
   ========================================================================== */

.site-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-lg);
	flex-wrap: wrap;
}

.site-title {
	font-family: var(--font-ui);
	font-size: var(--font-size-ui);
	font-weight: 700;
	text-transform: uppercase;
	margin: 0;
}

.site-header__end {
	display: flex;
	align-items: center;
	gap: var(--space-lg);
}

/* ==========================================================================
   13. NAVIGATION
   Ohne JavaScript bleibt die Navigation sichtbar. Erst wenn das Skript
   geladen hat (.has-js-nav), wird sie auf schmalen Bildschirmen eingeklappt.
   ========================================================================== */

.site-nav__list,
.footer-nav__list {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-lg);
	list-style: none;
	margin: 0;
	padding: 0;
}

.site-nav a,
.footer-nav a {
	text-decoration: none;
}

.site-nav a:hover,
.footer-nav a:hover {
	text-decoration: underline;
}

.site-nav .current-menu-item > a {
	text-decoration: underline;
}

.nav-toggle {
	display: none;
	padding: var(--space-xs) var(--space-sm);
	background: transparent;
	border: var(--border-width) solid var(--color-text);
	border-radius: var(--radius-sm);
	color: inherit;
	cursor: pointer;
}

@media (max-width: 767px) {
	.has-js-nav .nav-toggle {
		display: block;
	}

	.has-js-nav .site-nav {
		display: none;
		flex-basis: 100%;
		width: 100%;
		margin-top: var(--space-md);
	}

	.has-js-nav .site-nav.is-open {
		display: block;
	}

	.has-js-nav .site-nav__list {
		flex-direction: column;
		align-items: flex-start;
		gap: var(--space-md);
	}

	/* Der Umschalter steht im Kopf vor dem aufgeklappten Menü. */
	.site-header__end {
		flex-wrap: wrap;
	}
}

/* ==========================================================================
   14. INHALTSBEREICH
   Ersetzt das "constrained layout" der Block-Themes: Blöcke stehen auf
   Lesebreite, alignwide und alignfull dürfen darüber hinaus.
   ========================================================================== */

.site-main {
	margin-top: var(--space-2xl);
}

.entry-title {
	margin-top: 0;
}

.entry-content > * {
	max-width: var(--wp--style--global--content-size);
	margin-inline: auto;
}

.entry-content > * + * {
	margin-block-start: var(--wp--style--block-gap);
}

.entry-content > .alignwide {
	max-width: var(--wp--style--global--wide-size);
}

.entry-content > .alignfull {
	max-width: none;
}

/* Seiten mit dem Template "ohne Textbreiten-Begrenzung" */
.entry-content--full > * {
	max-width: none;
}

.alignleft {
	float: left;
	margin-right: var(--space-lg);
	margin-bottom: var(--space-lg);
}

.alignright {
	float: right;
	margin-left: var(--space-lg);
	margin-bottom: var(--space-lg);
}

.aligncenter {
	margin-inline: auto;
}

.entry-thumbnail {
	margin: var(--space-xl) 0;
	overflow: hidden;
	border-radius: var(--radius-lg);
}

.entry-meta {
	margin-top: var(--space-sm);
}

/* ==========================================================================
   15. BEITRAGSLISTEN
   ========================================================================== */

.post-list {
	display: flex;
	flex-direction: column;
	gap: var(--space-2xl);
	margin-top: var(--space-xl);
}

.post-list__item > * {
	margin-block: 0;
}

.post-list__item > * + * {
	margin-block-start: var(--space-sm);
}

.archive-description {
	margin-top: var(--space-md);
}

.pagination {
	margin-top: var(--space-2xl);
}

.pagination .nav-links {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-md);
}

.page-links {
	margin-top: var(--space-lg);
	display: flex;
	gap: var(--space-sm);
}

/* ==========================================================================
   16. FUSSBEREICH
   ========================================================================== */

.site-footer {
	margin-top: var(--space-3xl);
}

.site-footer__inner {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: var(--space-md);
	margin-top: var(--space-lg);
}

.site-footer__inner p {
	margin: 0;
}
