/*
Theme Name: klar
Description: Ruhiges Theme für Fotogalerien: weiß, viel Raum, quadratische Kacheln. Braucht das Plugin „Foto-Galerien“.
Author: Michael Heise
Version: 0.3.0
Update URI: false
Requires at least: 6.5
Requires PHP: 8.0
Text Domain: klar
*/

/*
 * Ordnung
 * - Die Fotos sind das Einzige, das laut sein darf. Schrift, Linien und Menü treten zurück.
 * - Eine Schrift (Open Sans, Dateien liegen unter uploads/fonts), zwei Gewichte, wenige Größen.
 * - Abstände in Schritten von 8 px. Rand und Rasterabstand wachsen mit dem Fenster;
 *   die Werte müssen zu klar_raster_sizes() in inc/bilder.php passen.
 * - Keine Übergänge, keine Animationen.
 */

@font-face {
	font-family: "Open Sans";
	src: url("/wp-content/uploads/fonts/OpenSans-Light.ttf") format("truetype");
	font-weight: 300;
	font-style: normal;
	font-display: swap;
}

@font-face {
	font-family: "Open Sans";
	src: url("/wp-content/uploads/fonts/OpenSans-Regular.ttf") format("truetype");
	font-weight: 400;
	font-style: normal;
	font-display: swap;
}

@font-face {
	font-family: "Open Sans";
	src: url("/wp-content/uploads/fonts/OpenSans-Italic.ttf") format("truetype");
	font-weight: 400;
	font-style: italic;
	font-display: swap;
}

@font-face {
	font-family: "Open Sans";
	src: url("/wp-content/uploads/fonts/OpenSans-Bold.ttf") format("truetype");
	font-weight: 700;
	font-style: normal;
	font-display: swap;
}

@font-face {
	font-family: "Open Sans";
	src: url("/wp-content/uploads/fonts/OpenSans-BoldItalic.ttf") format("truetype");
	font-weight: 700;
	font-style: italic;
	font-display: swap;
}

:root {
	--papier: #ffffff;
	--tinte: #1a1a1a;
	--leise: #646464; /* 5,9 : 1 auf Weiß */
	--linie: #e3e3e3;
	--hinweis: #fff3c4;

	--schrift: "Open Sans", "Helvetica Neue", Helvetica, "Segoe UI", Roboto, Arial, sans-serif;
	--klein: 0.875rem;   /* 14 px: Fußzeile */
	--kachel: 0.9375rem; /* 15 px: Galerietitel */
	--grund: 1.0625rem;  /* 17 px: Name, Menü, Fließtext */
	--titel: clamp(1.75rem, 1.35rem + 1.4vw, 2.5rem);

	--rand: 20px;
	--luecke: 12px;
	--breite: 1440px;
}

@media (min-width: 700px) {
	:root {
		--rand: 40px;
		--luecke: 24px;
	}
}

@media (min-width: 1000px) {
	:root {
		--rand: 64px;
		--luecke: 40px;
	}
}

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

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

body {
	margin: 0;
	min-height: 100vh;
	min-height: 100dvh;
	display: flex;
	flex-direction: column;
	background: var(--papier);
	color: var(--tinte);
	font-family: var(--schrift);
	font-size: var(--grund);
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

img {
	max-width: 100%;
	height: auto;
}

a {
	color: inherit;
}

:focus-visible {
	outline: 2px solid var(--tinte);
	outline-offset: 4px;
}

.klar-unsichtbar {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

.klar-sprung {
	position: absolute;
	left: var(--rand);
	top: 8px;
	padding: 8px 12px;
	background: var(--tinte);
	color: var(--papier);
	text-decoration: none;
	transform: translateY(-200%);
}

.klar-sprung:focus {
	transform: none;
}

/* Gemeinsame Breite für Kopf, Inhalt und Fuß. */
.klar-kopf,
main,
.klar-fuss {
	width: 100%;
	max-width: calc(var(--breite) + 2 * var(--rand));
	margin-inline: auto;
	padding-inline: var(--rand);
}

/* ---------- Kopf ---------- */

.klar-kopf {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 8px 32px;
	padding-block: 32px 40px;
}

@media (min-width: 1000px) {
	.klar-kopf {
		padding-block: 48px 64px;
	}
}

.klar-name {
	font-weight: 500;
	letter-spacing: 0.005em;
	text-decoration: none;
}

.klar-menue {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 24px;
}

.klar-menue a {
	color: var(--leise);
	text-decoration: none;
}

.klar-menue a:hover,
.klar-menue a:focus-visible,
.klar-menue a[aria-current] {
	color: var(--tinte);
}

.klar-menue a:hover,
.klar-name:hover {
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.25em;
}

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

.klar-raster {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: calc(var(--luecke) * 2) var(--luecke);
}

@media (min-width: 1000px) {
	.klar-raster {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		row-gap: 56px;
	}
}

.klar-raster li {
	min-width: 0;
}

.klar-kachel {
	display: block;
	text-decoration: none;
}

.klar-raster img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 1;
	object-fit: cover;
	object-position: 50% 50%;
	background: #f2f2f2; /* Platzhalter, solange das Bild lädt */
}

.klar-raster img.klar-hoch {
	object-position: 50% 30%;
}

.klar-kachel-titel {
	display: block;
	margin-top: 12px;
	overflow-wrap: anywhere;
	font-size: var(--kachel);
	line-height: 1.4;
}

.klar-kachel:hover img {
	opacity: 0.88;
}

.klar-kachel:hover .klar-kachel-titel {
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.25em;
}

.klar-kachel:focus-visible {
	outline-offset: 6px;
}

.klar-leer {
	color: var(--leise);
}

/* Galerie mit WordPress-Kennwort */
.klar-kennwort {
	max-width: 32rem;
	padding-bottom: 32px;
}

.klar-kennwort input[type="password"] {
	font: inherit;
	padding: 8px;
	border: 1px solid var(--leise);
	max-width: 100%;
}

.klar-kennwort input[type="submit"] {
	font: inherit;
	padding: 8px 16px;
	margin-top: 8px;
	border: 1px solid var(--tinte);
	background: var(--papier);
	color: var(--tinte);
	cursor: pointer;
}

/* ---------- Seiten ---------- */

.klar-seite {
	padding-bottom: 32px;
}

.klar-titel {
	margin: 0 0 32px;
	max-width: 20em;
	font-size: var(--titel);
	font-weight: 400;
	line-height: 1.15;
	letter-spacing: -0.015em;
}

.klar-text {
	max-width: 36rem; /* etwa 70 Zeichen */
	line-height: 1.6;
}

.klar-text > :first-child {
	margin-top: 0;
}

.klar-text p,
.klar-text ul,
.klar-text ol {
	margin: 0 0 1.25em;
}

.klar-text h2,
.klar-text h3 {
	margin: 2em 0 0.6em;
	font-size: 1.1875rem;
	font-weight: 500;
	line-height: 1.3;
}

.klar-text h3 {
	font-size: var(--grund);
}

.klar-text a,
.klar-liste a {
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
}

.klar-text a:hover {
	text-decoration-thickness: 2px;
}

.klar-text figure,
.klar-text .wp-block-image {
	margin: 0 0 2em;
}

.klar-text figcaption {
	margin-top: 8px;
	color: var(--leise);
	font-size: var(--klein);
}

.klar-text hr {
	border: 0;
	border-top: 1px solid var(--linie);
	margin: 2.5em 0;
}

.klar-liste {
	list-style: none;
	margin: 0;
	padding: 0;
	line-height: 2;
}

/* ---------- Fuß ---------- */

.klar-fuss {
	margin-top: auto;
	display: flex;
	flex-direction: column;
	gap: 4px;
	padding-block: 96px 40px;
	color: var(--leise);
	font-size: var(--klein);
}

/* Zwei Gruppen (Rechtliches, Social-Links); Trenner zwischen den Einträgen.
   Am Handy je Gruppe eine Zeile, damit kein Punkt am Zeilenende hängt. */
.klar-recht,
.klar-sozial {
	display: flex;
	flex-wrap: wrap;
	margin: 0;
	padding: 0;
	list-style: none;
}

.klar-recht li + li::before,
.klar-sozial li + li::before {
	content: "·";
	margin-inline: 0.6em;
}

@media (min-width: 700px) {
	.klar-fuss {
		flex-direction: row;
		flex-wrap: wrap;
		gap: 0;
	}

	.klar-recht::after {
		content: "·";
		margin-inline: 0.6em;
	}
}

.klar-fuss a {
	text-decoration: none;
}

.klar-fuss a:hover {
	color: var(--tinte);
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.25em;
}

/* ---------- Hinweis für Admins ---------- */

.klar-hinweis {
	margin: 0;
	padding: 12px var(--rand);
	background: var(--hinweis);
	font-size: var(--klein);
}

/* ---------- Galerieseite ---------- */

/* Dichteres Raster als auf der Startseite: Abstand 8/12/16 px.
   Werte müssen zu klar_galerie_sizes() in inc/bilder.php passen. */
:root {
	--dicht: 8px;
}

@media (min-width: 700px) {
	:root {
		--dicht: 12px;
	}
}

@media (min-width: 1000px) {
	:root {
		--dicht: 16px;
	}
}

.klar-galerie {
	gap: var(--dicht);
}

@media (min-width: 700px) {
	.klar-galerie {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (min-width: 1000px) {
	.klar-galerie {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

.klar-galerie .klar-kachel:focus-visible {
	outline-offset: 3px;
}

.klar-galerieseite {
	padding-bottom: 32px;
}

.klar-zurueck {
	margin: 0 0 16px;
	color: var(--leise);
	font-size: var(--kachel);
}

.klar-zurueck-link {
	color: inherit;
	text-decoration: none;
}

.klar-zurueck-link:hover,
.klar-zurueck-link:focus-visible {
	color: var(--tinte);
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.25em;
}

.klar-galerieseite .klar-titel {
	margin-bottom: 32px;
}

/* ---------- Lightbox ---------- */

html.klar-lb-offen,
html.klar-lb-offen body {
	overflow: hidden;
}

.klar-lb {
	position: fixed;
	inset: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	overflow: hidden;
	overscroll-behavior: contain;
	background: #111; /* einzige dunkle Fläche der Seite: die Fotos stehen ohne Rahmen */
	color: #f2f2f2;
	touch-action: pan-y pinch-zoom;
}

.klar-lb[open] {
	animation: klar-lb-ein 0.2s ease-out;
}

@keyframes klar-lb-ein {
	from {
		opacity: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.klar-lb[open] {
		animation: none;
	}
}

.klar-lb-buehne {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

/* Bildfläche = ganzes Bild im Verhältnis des Originals, nie größer als das Fenster
   (Rand für Knöpfe: Handy unten 64 px, oben 56 px; Rechner seitlich 88 px). */
.klar-lb-bild {
	--r: 1.5;
	display: block;
	width: min(100vw, calc((100vh - 120px) * var(--r)));
	width: min(100vw, calc((100dvh - 120px) * var(--r)));
	height: auto;
	max-width: none;
	aspect-ratio: var(--r);
	object-fit: contain;
}

@media (min-width: 700px) {
	.klar-lb-bild {
		width: min(calc(100vw - 176px), calc((100vh - 112px) * var(--r)));
		width: min(calc(100vw - 176px), calc((100dvh - 112px) * var(--r)));
	}
}

.klar-lb-fehler .klar-lb-bild {
	visibility: hidden;
}

.klar-lb-hinweis {
	position: absolute;
	left: 24px;
	right: 24px;
	top: 50%;
	margin: 0;
	transform: translateY(-50%);
	text-align: center;
	color: #b8b8b8;
	pointer-events: none;
}

.klar-lb-knopf {
	position: absolute;
	display: grid;
	place-items: center;
	width: 48px;
	height: 48px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: #cfcfcf;
	cursor: pointer;
}

.klar-lb-knopf[hidden] {
	display: none;
}

.klar-lb-knopf svg {
	fill: none;
	stroke: currentColor;
	stroke-width: 1.5;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.klar-lb-knopf:hover {
	background: rgba(255, 255, 255, 0.1);
	color: #fff;
}

.klar-lb-knopf:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
	color: #fff;
}

.klar-lb-zu {
	top: 4px;
	right: 4px;
}

.klar-lb-zurueck,
.klar-lb-weiter {
	bottom: 8px;
}

.klar-lb-zurueck {
	left: 8px;
}

.klar-lb-weiter {
	right: 8px;
}

.klar-lb-zaehler {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 20px;
	margin: 0;
	text-align: center;
	font-size: var(--klein);
	font-variant-numeric: tabular-nums;
	color: #b8b8b8;
	pointer-events: none;
}

@media (min-width: 700px) {
	.klar-lb-zu {
		top: 16px;
		right: 20px;
	}

	.klar-lb-zurueck,
	.klar-lb-weiter {
		bottom: auto;
		top: calc(50% - 24px);
	}

	.klar-lb-zurueck {
		left: 20px;
	}

	.klar-lb-weiter {
		right: 20px;
	}

	.klar-lb-zaehler {
		bottom: 20px;
	}
}
