/**
 * Kontaktkarte – Frontend-Styles.
 *
 * Farben kommen aus der Yuki-Farbpalette (CSS-Variablen des Yuki-Themes).
 * Dadurch passt sich die Karte automatisch an Light-/Dark-Mode an.
 * Die zweiten Werte sind neutrale Fallbacks, falls das Theme gewechselt wird.
 *
 * Yuki-Palette:
 *   --yuki-base-color      Haupt-Hintergrund
 *   --yuki-base-100/200/300  abgestufte Flächen und Ränder
 *   --yuki-accent-color    Text (gedämpft)
 *   --yuki-accent-active   Text (kräftig)
 *   --yuki-primary-color   Akzent-/Markenfarbe
 *
 * Die Fahne bleibt bewusst signalrot – sie soll in beiden Modi auffallen.
 */

.kk-karte,
.kk-popup {
	--kk-flaeche: var(--yuki-base-100, #f1efe9);
	--kk-kontur: var(--yuki-accent-color, #5f5f5f);
	--kk-grenze: var(--yuki-base-300, #a7a297);
	--kk-hintergrund: var(--yuki-base-color, #ffffff);
	--kk-rand: var(--yuki-base-200, #e2e2e2);
	--kk-text: var(--yuki-accent-active, #2b2b2b);
	--kk-text-hell: var(--yuki-accent-color, #8a8a8a);
	--kk-fahne: #d8232a;
	--kk-fahne-rand: #9c1218;
	--kk-fahne-hover: #f04349;
}

.kk-karte {
	max-width: 560px;
	margin: 0 auto;
}

.kk-karte svg {
	display: block;
	width: 100%;
	height: auto;
}

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

.kk-umriss {
	fill: var(--kk-flaeche);
	stroke: var(--kk-kontur);
	stroke-width: 1.5;
	stroke-linejoin: round;
}

.kk-insel {
	stroke-width: 1;
}

.kk-grenzen path {
	fill: none;
	stroke: var(--kk-grenze);
	stroke-width: 0.9;
	stroke-linejoin: round;
	stroke-linecap: round;
}

/* ------------------------------------------------------------------
 * Fahnen
 * ---------------------------------------------------------------- */

.kk-fahne {
	cursor: pointer;
	outline: none;
}

.kk-fahne-mast {
	stroke: var(--kk-kontur);
	stroke-width: 1.4;
	stroke-linecap: round;
}

.kk-fahne-tuch {
	fill: var(--kk-fahne);
	stroke: var(--kk-fahne-rand);
	stroke-width: 0.6;
	stroke-linejoin: round;
	transition: fill 0.15s ease;
}

/* Angedeutete Stofffalten im Fahnentuch */
.kk-fahne-falten {
	fill: none;
	stroke: var(--kk-fahne-rand);
	stroke-width: 0.7;
	stroke-linecap: round;
	opacity: 0.45;
	pointer-events: none;
}

.kk-fahne-fuss {
	fill: var(--kk-kontur);
}

.kk-fahne:hover .kk-fahne-tuch,
.kk-fahne:focus-visible .kk-fahne-tuch {
	fill: var(--kk-fahne-hover);
}

.kk-fahne:focus-visible .kk-fahne-fuss {
	stroke: var(--kk-fahne);
	stroke-width: 2;
}

.kk-leer {
	text-align: center;
	color: var(--kk-text-hell);
	font-size: 0.95rem;
}

/* ------------------------------------------------------------------
 * Popup
 *
 * Aufbau: Kopfzeile (kleine wehende Fahne + Titel + Bemerkung + großer
 * Schließen-Button), darunter die ausblendende rote Trennlinie, dann die
 * E-Mail-Kachel, die beiden Key-Buttons und ggf. der Beiträge-Button.
 * Auf schmalen Bildschirmen öffnet sich das Popup als Bottom-Sheet.
 * ---------------------------------------------------------------- */

.kk-popup {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.5);
	-webkit-backdrop-filter: blur(3px);
	backdrop-filter: blur(3px);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	z-index: 99999;
}

.kk-popup[hidden] {
	display: none;
}

.kk-popup-inhalt {
	position: relative;
	background: var(--kk-hintergrund);
	color: var(--kk-text);
	border: 1px solid var(--kk-rand);
	border-radius: 14px;
	max-width: 26rem;
	width: 100%;
	padding: 1.3rem 1.4rem 1.5rem;
	box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
	animation: kk-popup-auf 0.18s ease-out;
}

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

/* Kopfzeile: Fahne, Titel und Schließen-Button in einer Zeile */

.kk-popup-kopf {
	display: flex;
	align-items: flex-start;
	gap: 0.7rem;
}

.kk-popup-fahne {
	width: 1.5rem;
	height: auto;
	flex: none;
	margin-top: 0.15rem;
	color: var(--kk-text-hell);
}

.kk-popup-kopf-text {
	flex: 1;
	min-width: 0;
}

.kk-popup-titel {
	margin: 0;
	font-size: 1.3rem;
	line-height: 1.3;
	color: var(--kk-text);
	overflow-wrap: anywhere;
}

.kk-popup-schliessen {
	flex: none;
	margin: -0.3rem -0.4rem 0 0;
	width: 2.6rem;
	height: 2.6rem;
	display: flex;
	align-items: center;
	justify-content: center;
	border: none;
	border-radius: 50%;
	background: transparent;
	color: var(--kk-text-hell);
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.kk-popup-schliessen svg {
	width: 1.25rem;
	height: 1.25rem;
	display: block;
}

.kk-popup-schliessen:hover,
.kk-popup-schliessen:focus-visible {
	color: var(--kk-text);
	background: var(--kk-flaeche);
}

.kk-popup-schliessen:focus-visible {
	outline: 2px solid var(--kk-fahne);
	outline-offset: 2px;
}

/* Trennlinie: startet kräftig in Fahnenrot und läuft aus */

.kk-popup-trenner {
	display: block;
	height: 2px;
	margin: 0.85rem 0 1.1rem;
	border-radius: 1px;
	background: linear-gradient(to right,
		var(--kk-fahne) 0,
		var(--kk-fahne) 2.2rem,
		var(--kk-rand) 5.5rem,
		transparent 100%);
}

/* Kontakt-Kachel: Icon + E-Mail-Adresse */

.kk-popup-links {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 0.55rem;
}

.kk-popup-links[hidden] {
	display: none;
}

.kk-popup a.kk-chip,
.kk-popup a.kk-chip:visited {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	min-width: 0;
	padding: 0.5rem 0.65rem;
	border: 1px solid var(--kk-rand);
	border-radius: 10px;
	background: transparent;
	color: var(--kk-text);
	font-size: 0.88rem;
	font-weight: 600;
	line-height: 1.25;
	text-decoration: none;
	background-image: none;
	transition: border-color 0.15s ease, transform 0.12s ease, background-color 0.15s ease;
}

.kk-popup a.kk-chip:hover,
.kk-popup a.kk-chip:focus-visible {
	color: var(--kk-text);
	text-decoration: none;
	border-color: var(--kk-text-hell);
	background: var(--kk-flaeche);
	transform: translateY(-1px);
}

.kk-popup a.kk-chip:focus-visible {
	outline: 2px solid var(--kk-fahne);
	outline-offset: 2px;
}

.kk-chip-icon {
	flex: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 1.8rem;
	height: 1.8rem;
	border-radius: 50%;
}

.kk-chip-icon svg {
	width: 1.1rem;
	height: 1.1rem;
	display: block;
}

.kk-chip-name {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* E-Mail-Kachel über die volle Breite; Adresse darf umbrechen */

.kk-popup a.kk-chip--email {
	grid-column: 1 / -1;
	font-weight: 500;
}

.kk-chip--email .kk-chip-name {
	white-space: normal;
	overflow-wrap: anywhere;
}

.kk-popup-leer {
	margin: 0;
	color: var(--kk-text-hell);
	font-size: 0.92rem;
	text-align: center;
	padding: 0.4rem 0;
}

/* Bemerkung unter dem Titel, z. B. "Region West" */

.kk-popup-bemerkung {
	display: inline-block;
	margin-top: 0.35rem;
	padding: 0.1rem 0.6rem;
	border: 1px solid var(--kk-rand);
	border-radius: 999px;
	background: var(--kk-flaeche);
	color: var(--kk-text-hell);
	font-size: 0.78rem;
	font-weight: 600;
	letter-spacing: 0.02em;
	line-height: 1.5;
	overflow-wrap: anywhere;
}

.kk-popup-bemerkung[hidden] {
	display: none;
}

/* Die beiden Key-Buttons nebeneinander */

.kk-popup-key {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 0.55rem;
	margin-top: 0.9rem;
}

.kk-popup-key[hidden] {
	display: none;
}

.kk-popup button.kk-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.45rem;
	min-width: 0;
	width: 100%;
	margin: 0;
	padding: 0.62rem 0.7rem;
	border: 1px solid var(--kk-rand);
	border-radius: 10px;
	background: transparent;
	color: var(--kk-text);
	font-family: inherit;
	font-size: 0.88rem;
	font-weight: 600;
	line-height: 1.25;
	text-align: center;
	cursor: pointer;
	transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.12s ease;
}

.kk-popup button.kk-btn:hover,
.kk-popup button.kk-btn:focus-visible {
	border-color: var(--kk-text-hell);
	background: var(--kk-flaeche);
	transform: translateY(-1px);
}

.kk-popup button.kk-btn:focus-visible {
	outline: 2px solid var(--kk-fahne);
	outline-offset: 2px;
}

.kk-popup button.kk-btn--primaer,
.kk-popup button.kk-btn--primaer:visited {
	border-color: transparent;
	background: var(--kk-fahne);
	color: #ffffff;
}

.kk-popup button.kk-btn--primaer:hover,
.kk-popup button.kk-btn--primaer:focus-visible {
	border-color: transparent;
	background: var(--kk-fahne-hover);
	color: #ffffff;
}

.kk-popup button.kk-btn--primaer:focus-visible {
	outline: 2px solid var(--kk-text);
}

.kk-btn-icon {
	flex: none;
	display: inline-flex;
}

.kk-btn-icon svg {
	width: 1.05rem;
	height: 1.05rem;
	display: block;
}

.kk-btn-text {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* Ausklappbare Anzeige des Schlüssels */

.kk-key-box {
	margin-top: 0.7rem;
	padding: 0.7rem 0.75rem 0.6rem;
	border: 1px solid var(--kk-rand);
	border-radius: 10px;
	background: var(--kk-flaeche);
}

.kk-key-box[hidden] {
	display: none;
}

.kk-key-fingerprint {
	margin: 0 0 0.5rem;
	font-size: 0.75rem;
	line-height: 1.4;
	color: var(--kk-text-hell);
	overflow-wrap: anywhere;
}

.kk-key-fingerprint[hidden] {
	display: none;
}

.kk-key-fingerprint-label {
	display: block;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	font-size: 0.68rem;
}

.kk-key-fingerprint-wert {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	color: var(--kk-text);
}

.kk-key-text {
	max-height: 12rem;
	margin: 0;
	overflow: auto;
	padding: 0;
	border: none;
	background: transparent;
	color: var(--kk-text);
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.7rem;
	line-height: 1.4;
	/* Umbruch statt Querscrollen – beim Kopieren bleiben die echten
	   Zeilenumbrüche des Schlüssels trotzdem erhalten. */
	white-space: pre-wrap;
	overflow-wrap: anywhere;
	-webkit-overflow-scrolling: touch;
}

.kk-key-text:focus-visible {
	outline: 2px solid var(--kk-fahne);
	outline-offset: 2px;
}

.kk-popup button.kk-key-kopieren {
	display: block;
	margin: 0.55rem 0 0;
	padding: 0;
	border: none;
	background: none;
	color: var(--kk-text-hell);
	font-family: inherit;
	font-size: 0.78rem;
	font-weight: 600;
	text-decoration: underline;
	cursor: pointer;
}

.kk-popup button.kk-key-kopieren:hover,
.kk-popup button.kk-key-kopieren:focus-visible {
	color: var(--kk-text);
}

.kk-popup button.kk-key-kopieren--fertig {
	color: var(--kk-fahne);
}

/* Versteckter Speicher der Schlüssel – nie sichtbar */

.kk-key-speicher {
	display: none !important;
}

/* Beiträge-Button (Link zur WordPress-Kategorie) */

.kk-popup-aktionen {
	margin: 1rem 0 0;
}

.kk-popup a.kk-popup-beitraege,
.kk-popup a.kk-popup-beitraege:visited {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.45rem;
	width: 100%;
	padding: 0.7rem 1rem;
	border-radius: 10px;
	background: var(--kk-fahne);
	color: #ffffff !important;
	font-size: 0.95rem;
	font-weight: 700;
	line-height: 1.3;
	text-decoration: none;
	background-image: none;
	transition: background-color 0.15s ease;
}

.kk-popup a.kk-popup-beitraege:hover,
.kk-popup a.kk-popup-beitraege:focus-visible {
	background: var(--kk-fahne-hover);
	color: #ffffff !important;
	text-decoration: none;
}

.kk-popup a.kk-popup-beitraege:focus-visible {
	outline: 2px solid var(--kk-text);
	outline-offset: 2px;
}

.kk-popup-beitraege-text {
	min-width: 0;
	overflow-wrap: anywhere;
}

.kk-popup-beitraege-pfeil {
	flex: none;
	transition: transform 0.15s ease;
}

.kk-popup a.kk-popup-beitraege:hover .kk-popup-beitraege-pfeil {
	transform: translateX(2px);
}

body.kk-popup-offen {
	overflow: hidden;
}

/* Auf schmalen Bildschirmen: Popup als Bottom-Sheet von unten */

@media (max-width: 520px) {
	.kk-popup {
		align-items: flex-end;
		padding: 0;
	}

	.kk-popup-inhalt {
		max-width: none;
		border-radius: 16px 16px 0 0;
		border-left: none;
		border-right: none;
		border-bottom: none;
		padding-bottom: calc(1.4rem + env(safe-area-inset-bottom, 0px));
		animation: kk-popup-hoch 0.22s ease-out;
	}

	@keyframes kk-popup-hoch {
		from {
			opacity: 0.6;
			transform: translateY(40px);
		}
		to {
			opacity: 1;
			transform: none;
		}
	}
}

/* Reduzierte Bewegung respektieren */
@media (prefers-reduced-motion: reduce) {
	.kk-fahne-tuch,
	.kk-popup a.kk-chip,
	.kk-popup button.kk-btn,
	.kk-popup a.kk-popup-beitraege,
	.kk-popup-beitraege-pfeil,
	.kk-popup-schliessen {
		transition: none;
	}
	.kk-popup-inhalt {
		animation: none;
	}
	.kk-popup a.kk-chip:hover,
	.kk-popup button.kk-btn:hover,
	.kk-popup a.kk-popup-beitraege:hover .kk-popup-beitraege-pfeil {
		transform: none;
	}
}

/* Sehr schmale Bildschirme: Key-Buttons untereinander */
@media (max-width: 360px) {
	.kk-popup-key {
		grid-template-columns: minmax(0, 1fr);
	}
}
