/* Public member directory (miki_app.member_directory_api).
   Visual language copied from the Good Event public pages (search strip, list
   header band, 12px cards, pill chips) with the kibesuisse event palette
   hardcoded: miki_app cannot import good_event's theme. The pages are shown on
   kibesuisse.ch in an iframe (?embed=1), which drops the page shell. */
.miki-directory {
	--md-primary: #578d1f;
	--md-primary-rgb: 87, 141, 31;
	--md-primary-soft: #def8bc;
	--md-secondary: #96c11f;
	--md-accent: #0078bd;
	--md-warning: #f39200;
	--md-danger: #e30613;
	--md-text: #1d1d1d;
	--md-text-muted: #5f6368;
	--md-muted: #f1f1f1;
	--md-surface: #ffffff;
	--md-border: #e4e4e4;
	--md-radius: 12px;
	--md-gutter: 24px;
	color: var(--md-text);
	line-height: 1.55;
}

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

.miki-directory a {
	color: var(--md-accent);
	text-decoration: none;
}

.miki-directory a:hover {
	text-decoration: underline;
}

.md-visually-hidden {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

/* --- page shell ---------------------------------------------------------- */
body.miki-directory-page {
	margin: 0;
	background: #fafafa;
	font-family: "Open Sans", Arial, Helvetica, sans-serif;
}

/* Framed: let kibesuisse.ch's page background show through. */
body.miki-directory-page--embed {
	background: transparent;
}

.md-shell-header {
	background: #fff;
	border-bottom: 1px solid #e4e4e4;
	padding: 14px max(24px, calc((100% - 1180px) / 2));
}

.md-shell-brand img {
	display: block;
	height: 36px;
	width: auto;
}

/* --- search strip ------------------------------------------------------- */
.md-search-strip {
	background: var(--md-surface);
	border-bottom: 1px solid var(--md-border);
	padding: 10px var(--md-gutter);
	position: sticky;
	top: 0;
	z-index: 1001;
}

.md-search-bar {
	display: flex;
	align-items: center;
	gap: 8px;
	max-width: 1180px;
	margin: 0 auto;
}

.md-search-input {
	display: flex;
	align-items: center;
	gap: 8px;
	flex: 1;
	min-width: 0;
	margin: 0;
	padding: 2px 16px;
	border: 1px solid var(--md-border);
	border-radius: 999px;
	background: var(--md-surface);
	cursor: text;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.md-search-input:focus-within {
	border-color: var(--md-primary);
	box-shadow: 0 0 0 3px rgba(var(--md-primary-rgb), 0.18);
}

.md-search-input svg,
.md-search-submit svg {
	fill: none;
	stroke: currentColor;
	stroke-width: 2.2;
	stroke-linecap: round;
	flex-shrink: 0;
}

.md-search-input svg {
	color: var(--md-text-muted);
}

.md-search-input input {
	flex: 1;
	min-width: 0;
	padding: 8px 0;
	border: 0;
	background: transparent;
	color: var(--md-text);
	font: inherit;
	font-size: 15px;
	outline: none;
}

.md-canton {
	height: 40px;
	padding: 0 34px 0 14px;
	border: 1px solid var(--md-border);
	border-radius: 999px;
	background: var(--md-surface)
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235f6368' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E")
		no-repeat right 14px center;
	color: var(--md-text);
	font: inherit;
	font-size: 14px;
	font-weight: 600;
	appearance: none;
	cursor: pointer;
}

.md-canton:focus {
	border-color: var(--md-primary);
	outline: none;
	box-shadow: 0 0 0 3px rgba(var(--md-primary-rgb), 0.18);
}

.md-search-submit {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--md-primary);
	color: #fff;
	cursor: pointer;
	flex-shrink: 0;
	transition: background-color 0.15s ease;
}

.md-search-submit:hover,
.md-search-submit:focus-visible {
	background: var(--md-secondary);
}

/* --- header band --------------------------------------------------------- */
.md-header {
	background: linear-gradient(
		135deg,
		rgba(var(--md-primary-rgb), 0.12) 0%,
		rgba(var(--md-primary-rgb), 0.04) 55%,
		var(--md-surface) 100%
	);
	border-bottom: 1px solid var(--md-border);
	padding: 28px var(--md-gutter) 24px;
}

.md-header-inner {
	max-width: 1180px;
	margin: 0 auto;
}

.md-header h1 {
	margin: 0;
	color: var(--md-text);
	font-size: clamp(28px, 4vw, 42px);
	font-weight: 700;
	line-height: 1.15;
}

.md-lead {
	max-width: 800px;
	margin: 12px 0 18px;
	font-size: 17px;
}

.md-back {
	display: inline-block;
	margin-bottom: 10px;
	font-size: 14px;
	font-weight: 600;
}

/* --- chips ----------------------------------------------------------------- */
.md-list-links,
.md-region-nav {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}

.md-list-links-label {
	margin-right: 4px;
	white-space: nowrap;
	color: var(--md-text-muted);
	font-size: 13px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.miki-directory .md-chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	height: 32px;
	padding: 0 14px;
	border: 1px solid rgba(var(--md-primary-rgb), 0.25);
	border-radius: 999px;
	background: var(--md-surface);
	color: var(--md-primary);
	font-size: 13px;
	font-weight: 600;
	white-space: nowrap;
	transition: background-color 0.15s ease, border-color 0.15s ease;
}

.miki-directory .md-chip:hover {
	background: var(--md-primary-soft);
	border-color: var(--md-primary);
	text-decoration: none;
}

.md-count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 22px;
	height: 20px;
	padding: 0 7px;
	border-radius: 999px;
	background: var(--md-muted);
	color: var(--md-text-muted);
	font-size: 12px;
	font-weight: 700;
}

/* --- content --------------------------------------------------------------- */
/* 1180px of content, like the search strip and the header band above it. */
.md-page {
	max-width: calc(1180px + 2 * var(--md-gutter));
	margin: 0 auto;
	padding: 24px var(--md-gutter) 48px;
}

/* With results: list on the left, the map stays in view on the right. */
@media (min-width: 1024px) {
	.md-page--split {
		display: grid;
		grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
		gap: 24px;
		align-items: start;
	}

	.md-page--split .md-map-card {
		position: sticky;
		top: 84px;
		margin-bottom: 0;
	}

	.md-page--split .miki-directory__map {
		height: calc(100vh - 110px);
		min-height: 420px;
		max-height: 760px;
	}

	.md-page--split .md-row {
		grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
	}

	.md-page--split .md-row-web {
		grid-column: 1 / -1;
	}

	.md-page--split .md-list-links {
		grid-column: 1 / -1;
	}
}

/* Framed: keep the side gutter (on a phone the frame is the full screen width,
   and without it cards and chips touch the edge; on a desktop it lines the map
   up with the search bar), and end on the content, not on a margin. */
.miki-directory--embed .md-page {
	padding: 16px var(--md-gutter) 24px;
}

.miki-directory--embed .md-page > :last-child {
	margin-bottom: 0;
}

/* The iframe is sized to the content, so 100vh would be the content's own
   height: the split map would grow the frame until max-height. A fixed height
   keeps the frame as tall as the results, and "sticky" has no scroll to use. */
@media (min-width: 1024px) {
	.miki-directory--embed .md-page--split .md-map-card {
		position: static;
	}

	.miki-directory--embed .md-page--split .miki-directory__map {
		height: 560px;
	}
}

.md-map-card {
	overflow: hidden;
	border: 1px solid var(--md-border);
	border-radius: var(--md-radius);
	background: var(--md-muted);
	box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
	margin-bottom: 24px;
}

.miki-directory__map {
	height: 560px;
	position: relative;
	z-index: 0;
}

.md-results-head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 8px 16px;
	margin-bottom: 16px;
}

.md-results-count {
	margin: 0;
	font-size: 18px;
	font-weight: 700;
}

.md-reset {
	font-size: 14px;
	font-weight: 600;
}

.md-region-nav {
	margin-bottom: 20px;
}

.md-group {
	margin-bottom: 20px;
	overflow: hidden;
	border: 1px solid var(--md-border);
	border-radius: var(--md-radius);
	background: var(--md-surface);
	box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
	scroll-margin-top: 80px;
}

.md-group-title {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0;
	padding: 14px 18px;
	border-bottom: 1px solid var(--md-border);
	background: linear-gradient(90deg, rgba(var(--md-primary-rgb), 0.08), transparent 70%);
	color: var(--md-text);
	font-size: 17px;
	font-weight: 700;
}

.md-dot {
	width: 12px;
	height: 12px;
	border-radius: 50%;
	flex-shrink: 0;
}

.md-dot--kita {
	background: var(--md-warning);
}

.md-dot--seb {
	background: var(--md-danger);
}

.md-dot--tfo {
	background: var(--md-secondary);
}

.md-rows {
	margin: 0;
	padding: 0;
	list-style: none;
}

.md-row {
	display: grid;
	grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1.2fr);
	gap: 4px 16px;
	align-items: baseline;
	padding: 10px 18px;
	border-top: 1px solid var(--md-muted);
}

.md-row:first-child {
	border-top: 0;
}

.md-row:hover {
	background: #fbfdf8;
}

.md-row[data-lat] {
	cursor: pointer;
}

.md-row[data-lat]:focus-visible {
	outline: 2px solid var(--md-primary);
	outline-offset: -2px;
}

.md-row-name strong {
	font-weight: 600;
}

.md-row-place {
	color: var(--md-text-muted);
	font-size: 14px;
}

.md-row-web {
	font-size: 14px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

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

.miki-directory .md-badge {
	display: inline-flex;
	align-items: center;
	height: 22px;
	margin-left: 8px;
	padding: 0 10px;
	border-radius: 999px;
	background: var(--md-warning);
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	white-space: nowrap;
	vertical-align: middle;
}

.miki-directory .md-badge--candidate {
	background: #fff4e0;
	color: #9a5b00;
	box-shadow: inset 0 0 0 1px var(--md-warning);
}

.miki-directory .md-badge:hover {
	text-decoration: none;
}

/* --- map furniture ------------------------------------------------------ */
.miki-directory__legend {
	padding: 8px 12px;
	border-radius: 10px;
	background: rgba(255, 255, 255, 0.95);
	box-shadow: 0 2px 10px rgba(16, 24, 40, 0.14);
	color: var(--md-text);
	font-size: 12px;
	line-height: 1.7;
}

.miki-directory__legend summary {
	cursor: pointer;
	font-weight: 700;
}

.miki-directory__legend ul {
	margin: 4px 0 0;
	padding: 0;
	list-style: none;
}

.miki-directory__legend img {
	margin-right: 4px;
	vertical-align: middle;
}

.miki-directory__cluster {
	background: url("../images/member_directory/cluster.svg") center / contain no-repeat;
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	line-height: 60px;
	text-align: center;
}

.miki-directory .leaflet-popup-content-wrapper {
	border-radius: 10px;
}

.miki-directory .leaflet-popup-content {
	margin: 12px 16px;
	font-size: 13px;
	line-height: 1.5;
}

.miki-directory .leaflet-container {
	font-family: inherit;
}

/* --- small screens -------------------------------------------------------- */
@media (max-width: 720px) {
	.miki-directory {
		--md-gutter: 14px;
	}

	.md-search-bar {
		flex-wrap: wrap;
	}

	.md-search-input {
		flex-basis: 100%;
	}

	.md-canton {
		flex: 1;
	}

	.md-list-links {
		flex-wrap: nowrap;
		overflow-x: auto;
		margin: 0 calc(-1 * var(--md-gutter));
		padding: 0 var(--md-gutter) 4px;
		scrollbar-width: none;
	}

	.md-lead {
		font-size: 15px;
	}

	.miki-directory__map {
		height: 420px;
	}

	.md-row {
		grid-template-columns: 1fr;
		padding: 10px 14px;
	}
}
