/*
 * KMN Events – map ([kmn_map]). Colors from the prototype, fonts from the theme.
 * Desktop: panel on top of the map (left). Mobile: map first, panel below.
 */

.kmn-map {
	--kmn-map-bg: #2d1087;
	--kmn-map-panel: rgba(33, 9, 103, .93);
	--kmn-map-line: rgba(255, 255, 255, .2);
	position: relative;
	display: grid;
	overflow: hidden;
	border-radius: var(--kmn-radius-lg);
	background: var(--kmn-map-bg);
	color: #fff;
}

.kmn-map__stage {
	position: relative;
	height: min(var(--kmn-map-height, 80vh), 900px);
	min-height: 420px;
	background:
		radial-gradient(circle at 30% 40%, rgba(255, 0, 201, .18), transparent 45%),
		radial-gradient(circle at 75% 65%, rgba(72, 40, 178, .55), transparent 50%),
		var(--kmn-map-bg);
}

/* MapLibre sets position: relative on the container: size it explicitly. */
.kmn-map__canvas,
.kmn-map__canvas.maplibregl-map {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
}

.kmn-map.is-loading .kmn-map__canvas::after {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	color: rgba(255, 255, 255, .8);
	content: "…";
	font-size: 2rem;
}

/* Consent overlay */
.kmn-map__consent {
	position: absolute;
	inset: 0;
	z-index: 3;
	display: grid;
	place-items: center;
	padding: 24px;
}

.kmn-map__consent[hidden] {
	display: none;
}

.kmn-map__consent-box {
	max-width: 440px;
	padding: 24px;
	border: 1px solid rgba(255, 255, 255, .25);
	border-radius: var(--kmn-radius-lg);
	background: var(--kmn-map-panel);
	box-shadow: 0 15px 50px rgba(16, 0, 59, .5);
	text-align: center;
}

.kmn .kmn-map__consent-box p {
	margin: 0 0 14px;
	font-size: .9rem;
	line-height: 1.5;
}

.kmn .kmn-map__consent-box a {
	color: #fff;
	text-decoration: underline;
}

.kmn .kmn-map__consent-title {
	font-size: 1.15rem;
	font-weight: 800;
}

.kmn .kmn-map__load {
	display: inline-flex;
	min-height: 48px;
	margin: 0 0 12px;
	border: 0;
	cursor: pointer;
}

.kmn-map__remember {
	display: block;
	font-size: .8rem;
	opacity: .85;
	cursor: pointer;
}

/* Panel: header (title + collapse button), body (chips, search, list).
   Phones: sheet over the bottom of the map. Desktop: floating box on the left. */
.kmn-map__panel {
	display: flex;
	flex-direction: column;
	background: var(--kmn-map-panel);
}

.kmn-map__head {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 16px;
}

.kmn-map__heading {
	flex: 1 1 auto;
	min-width: 0;
}

.kmn .kmn-map__kicker {
	margin-bottom: 2px;
	color: #cabaff;
	font-size: .7rem;
	font-weight: 800;
	letter-spacing: .18em;
	text-transform: uppercase;
}

.kmn .kmn-map__title {
	margin: 0;
	color: #fff;
	font-size: 1.2rem;
	font-weight: 800;
	line-height: 1.15;
}

.kmn .kmn-map__collapse {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	gap: 8px;
	min-height: 40px;
	margin: 0;
	padding: 6px 12px;
	border: 1px solid rgba(255, 255, 255, .35);
	border-radius: 999px;
	background: rgba(255, 255, 255, .08);
	color: #fff;
	font: inherit;
	font-size: .8rem;
	font-weight: 700;
	cursor: pointer;
}

.kmn .kmn-map__collapse:hover,
.kmn .kmn-map__collapse:focus-visible {
	border-color: #fff;
	background: rgba(255, 255, 255, .16);
}

.kmn-map__collapse-count {
	min-width: 1.6em;
	padding: 1px 6px;
	border-radius: 999px;
	background: var(--kmn-accent);
	font-size: .72rem;
	text-align: center;
}

.kmn-map__chevron {
	transition: transform .25s var(--kmn-ease);
}

.kmn-map.is-collapsed .kmn-map__chevron {
	transform: rotate(180deg);
}

.kmn-map__body {
	flex: 1 1 auto;
	min-height: 0; /* lets the body scroll inside the panel */
	padding: 0 16px 16px;
	overflow: auto;
	overscroll-behavior: contain;
}

.kmn-map.is-collapsed .kmn-map__body {
	display: none;
}

/* Slim scrollbar in the Museumsnacht colors instead of the light system bar. */
.kmn-map__body {
	scrollbar-width: thin;
	scrollbar-color: rgba(255, 0, 201, .75) transparent; /* thumb, track */
}

.kmn-map__body::-webkit-scrollbar {
	width: 8px;
}

.kmn-map__body::-webkit-scrollbar-track {
	margin: 6px 0;
	border-radius: 4px;
	background: rgba(255, 255, 255, .06);
}

.kmn-map__body::-webkit-scrollbar-thumb {
	border: 2px solid transparent;
	border-radius: 4px;
	background: rgba(255, 0, 201, .75) padding-box;
}

.kmn-map__body::-webkit-scrollbar-thumb:hover {
	background: #ff00c9 padding-box;
}

.kmn .kmn-map__text {
	margin-bottom: 12px;
	color: #d2c9ef;
	font-size: .85rem;
	line-height: 1.5;
}

/* Filter chips (checkbox inside, visually hidden) */
.kmn-map__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 0 0 12px;
	padding: 0;
	border: 0;
}

.kmn-map__chips[hidden] {
	display: none;
}

.kmn .kmn-map__label {
	width: 100%;
	margin: 0 0 6px;
	padding: 0;
	color: #bcb0dd;
	font-size: .7rem;
	font-weight: 700;
	letter-spacing: .12em;
	text-transform: uppercase;
	float: left; /* legend inside a flex fieldset */
}

.kmn-map__chip {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 36px;
	padding: 6px 12px;
	border: 1px solid rgba(255, 255, 255, .45);
	border-radius: 999px;
	background: rgba(255, 255, 255, .1);
	color: #fff;
	font-size: .82rem;
	line-height: 1.2;
	cursor: pointer;
	user-select: none;
	transition: opacity .2s, background-color .2s, border-color .2s;
}

.kmn-map__chip:hover {
	border-color: #fff;
}

/* Off: faded and with dashed border. */
.kmn-map__chip:has(input:not(:checked)) {
	border-style: dashed;
	background: transparent;
	opacity: .55;
}

.kmn-map__chip:has(input:focus-visible) {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

.kmn-map__dot {
	flex: 0 0 auto;
	width: 12px;
	height: 12px;
	border: 1px solid rgba(255, 255, 255, .4);
	border-radius: 50%;
}

.kmn-map__count {
	color: #bcb0dd;
	font-size: .75rem;
}

.kmn-map .kmn-map__search {
	width: auto; /* the program toolbar sets 360px on desktop */
	max-width: none;
	margin: 4px 0 6px;
}

.kmn .kmn-map__list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.kmn-map__list li[hidden] {
	display: none;
}

.kmn .kmn-map__item {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 44px;
	padding: 8px 2px;
	border-bottom: 1px solid var(--kmn-map-line);
	color: #fff;
	font-size: .88rem;
	text-decoration: none;
}

.kmn .kmn-map__item:hover,
.kmn .kmn-map__item:focus {
	color: #f3b9ea;
}

/* Phones and tablets: the panel is a sheet at the bottom of the map. */
@media (max-width: 899px) {
	.kmn-map--with-panel .kmn-map__panel {
		position: absolute;
		right: 8px;
		bottom: 8px;
		left: 8px;
		z-index: 2;
		max-height: calc(100% - 16px);
		border: 1px solid rgba(255, 255, 255, .2);
		border-radius: 16px;
		box-shadow: 0 -8px 30px rgba(16, 0, 59, .45);
	}

	/* Grip as a hint that the sheet can be opened. */
	.kmn-map--with-panel .kmn-map__head::before {
		position: absolute;
		top: 6px;
		left: 50%;
		width: 36px;
		height: 4px;
		border-radius: 2px;
		background: rgba(255, 255, 255, .35);
		content: "";
		transform: translateX(-50%);
	}

	.kmn-map--with-panel .kmn-map__head {
		position: relative;
		padding-top: 18px;
	}

	.kmn.kmn-map--with-panel .kmn-map__title {
		font-size: 1.05rem;
	}

	/* Sheet opens upwards: arrow up when closed, down when open. */
	.kmn-map--with-panel .kmn-map__chevron {
		transform: rotate(180deg);
	}

	.kmn-map--with-panel.is-collapsed .kmn-map__chevron {
		transform: none;
	}

	/* Closed sheet: only the bar "Filter & Orte" (big touch target). */
	.kmn-map--with-panel.is-collapsed .kmn-map__heading {
		display: none;
	}

	.kmn.kmn-map--with-panel.is-collapsed .kmn-map__collapse {
		flex: 1 1 auto;
		justify-content: center;
		min-height: 44px;
	}

	.kmn-map--with-panel .kmn-map__kicker {
		display: none;
	}

	/* Map controls above the closed sheet. */
	.kmn-map--with-panel .maplibregl-ctrl-bottom-right,
	.kmn-map--with-panel .kmn-map__notice {
		bottom: 84px;
	}
}

/* Message on top of the map (e.g. location not available) */
.kmn-map__notice {
	position: absolute;
	right: 60px;
	bottom: 18px;
	z-index: 3;
	max-width: min(360px, calc(100% - 80px));
	margin: 0;
	padding: 10px 14px;
	border-radius: 8px;
	background: var(--kmn-map-panel);
	color: #fff;
	font-size: .85rem;
	line-height: 1.4;
	box-shadow: 0 8px 25px rgba(16, 0, 59, .5);
}

.kmn-map__notice[hidden] {
	display: none;
}

/* Own position (MapLibre's dot), color from the settings ("Farbe Mein Standort"). */
.kmn-map .maplibregl-user-location-dot,
.kmn-map .maplibregl-user-location-dot::before {
	background-color: var(--kmn-map-user, #ff00c9);
}

.kmn-map .maplibregl-user-location-accuracy-circle {
	background-color: rgba(255, 0, 201, .15);
	background-color: color-mix(in srgb, var(--kmn-map-user, #ff00c9) 18%, transparent);
}

/* Location button active: ring in the same color. */
.kmn-map .maplibregl-ctrl button.maplibregl-ctrl-geolocate-active,
.kmn-map .maplibregl-ctrl button.maplibregl-ctrl-geolocate-background {
	box-shadow: inset 0 0 0 2px var(--kmn-map-user, #ff00c9);
}

/* Legend of the lines: sample of color and style. */
.kmn-map__routes {
	margin-top: 4px;
}

.kmn-map__line {
	flex: 0 0 auto;
	width: 26px;
	height: 0;
	border-top: 4px solid currentColor;
	border-radius: 2px;
}

.kmn-map__line--gestrichelt {
	border-top-style: dashed;
}

.kmn-map__line--gepunktet {
	border-top-style: dotted;
}

/* Markers */
.kmn-map-marker {
	width: 18px;
	height: 18px;
	margin: 0;
	padding: 0;
	border: 2px solid rgba(45, 16, 135, .9);
	border-radius: 50%;
	box-shadow: 0 0 0 2px rgba(255, 255, 255, .25);
	cursor: pointer;
	transition: transform .15s;
}

.kmn-map-marker:hover,
.kmn-map-marker:focus-visible {
	transform: scale(1.35);
	outline: none;
	box-shadow: 0 0 0 3px #fff;
}

.kmn-map-marker[hidden] {
	display: none;
}

/* Popup (rendered by MapLibre outside .kmn) */
.kmn-map-popup-wrap .maplibregl-popup-content {
	padding: 16px 18px;
	border-radius: 10px;
	background: #fff;
	color: #281261;
	box-shadow: 0 8px 35px rgba(16, 0, 75, .4);
}

.kmn-map-popup-wrap .maplibregl-popup-close-button {
	padding: 2px 8px;
	color: #281261;
	font-size: 20px;
}

.kmn-map-popup p {
	margin: 0 0 6px;
	line-height: 1.45;
}

.kmn-map-popup__type {
	color: #d5007f;
	font-size: 11px;
	font-weight: 800;
	letter-spacing: .08em;
	text-transform: uppercase;
}

.kmn-map-popup__name {
	padding-right: 16px;
	font-size: 16px;
	font-weight: 800;
}

.kmn-map-popup__address,
.kmn-map-popup__info,
.kmn-map-popup__count {
	font-size: 13px;
}

.kmn-map-popup__count {
	font-weight: 700;
}

.kmn-map-popup__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 14px;
	margin-top: 12px;
}

.kmn-map-popup-wrap .kmn-map-popup__button {
	display: inline-block;
	padding: 8px 14px;
	border-radius: 3px;
	background: #ff00c9;
	color: #fff !important;
	font-size: 13px;
	font-weight: 700;
	text-decoration: none !important;
}

.kmn-map-popup-wrap .kmn-map-popup__button:hover,
.kmn-map-popup-wrap .kmn-map-popup__button:focus {
	background: #e000b1;
	color: #fff !important;
}

.kmn-map-popup-wrap .kmn-map-popup__link {
	color: #281261 !important;
	font-size: 13px;
	font-weight: 600;
	text-decoration: underline;
}

@media (min-width: 900px) {
	.kmn-map--with-panel .kmn-map__panel {
		position: absolute;
		top: 18px;
		left: 18px;
		z-index: 2;
		width: 355px;
		max-height: calc(100% - 36px);
		border: 1px solid rgba(255, 255, 255, .2);
		border-radius: 17px;
		box-shadow: 0 15px 50px rgba(16, 0, 59, .5);
		backdrop-filter: blur(15px);
	}

	/* Collapsed: only the header remains as a compact box. */
	.kmn-map--with-panel.is-collapsed .kmn-map__panel {
		width: auto;
		max-width: 355px;
	}

	/* Consent box next to the panel. */
	.kmn-map--with-panel .kmn-map__consent {
		padding-left: 390px;
	}
}
