/* Horizontes Grants Map — 3-column layout: filters | map | aggregates. */

.hgm {
	--hgm-p1: 0%;
	--hgm-p2: 100%;
	--hgm-blue: #2f3df0;
	--hgm-navy: #1e1e6e;
	--hgm-amber: #f5b301;
	--hgm-orange: #f58220;
	--hgm-border: #e5e7eb;
	--hgm-muted: #6b7280;
	--hgm-panel: #f4f6f8;
}

.hgm-grid {
	display: grid;
	grid-template-columns: 280px minmax(0, 1fr) 340px;
	gap: 0;
	align-items: stretch;
	border: 1px solid var(--hgm-border);
	border-radius: 0.25rem;
	overflow: hidden;
}

/* ---------- filters (left, blue rail) ---------- */

.hgm-filters {
	background: var(--hgm-blue);
	color: #fff;
	padding: 1.1rem 1.1rem 1.25rem;
}

.hgm-filters-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 1.1rem;
}

.hgm-filters-title {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	font-weight: 600;
	font-size: 1rem;
}

.hgm-filters-icon {
	width: 15px;
	height: 15px;
	flex: none;
}

.hgm-collapse {
	background: transparent;
	border: none;
	color: #fff;
	font-size: 1.6rem;
	line-height: 1;
	cursor: pointer;
	padding: 0 0.25rem;
}

.hgm-field {
	margin-bottom: 1rem;
}

.hgm-field>label {
	display: block;
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	margin-bottom: 0.4rem;
	color: #fff;
}

.hgm-field select {
	width: 100%;
	padding: 0.6rem 0.8rem;
	border: 1px solid rgba(255, 255, 255, 0.35);
	border-radius: 0.65rem;
	background: var(--hgm-navy);
	color: #fff;
	font-size: 0.85rem;
	appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23fff' stroke-width='2' fill='none'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 0.8rem center;
}

.hgm-field select option {
	color: #111;
}

.hgm-pills {
	display: flex;
	justify-content: space-between;
	gap: 0.75rem;
	margin-bottom: 0.55rem;
}

.hgm-pills input[type="number"] {
	width: 45%;
	text-align: center;
	padding: 0.5rem 0.25rem;
	border: 1px solid rgba(255, 255, 255, 0.35);
	border-radius: 999px;
	background: var(--hgm-navy);
	color: #fff;
	font-size: 0.85rem;
	-moz-appearance: textfield;
	appearance: textfield;
}

.hgm-pills input[type="number"]::-webkit-outer-spin-button,
.hgm-pills input[type="number"]::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.hgm-slider {
	position: relative;
	height: 1.5rem;
}

/* Dedicated track + fill: native tracks are transparent so the selected
   span renders identically in every browser. */
.hgm-track {
	position: absolute;
	left: 0;
	right: 0;
	top: 50%;
	transform: translateY(-50%);
	height: 6px;
	border-radius: 3px;
	background: var(--hgm-navy);
	pointer-events: none;
}

.hgm-fill {
	position: absolute;
	top: 0;
	bottom: 0;
	left: var(--hgm-p1);
	right: calc(100% - var(--hgm-p2));
	border-radius: 3px;
	background: rgba(255, 255, 255, 0.6);
	pointer-events: none;
}

.hgm-slider input[type="range"] {
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	margin: 0;
	pointer-events: none;
	-webkit-appearance: none;
	appearance: none;
	background: transparent;
	height: 1.5rem;
}

#hgm-from {
	z-index: 4;
}

#hgm-to {
	z-index: 5;
}

.hgm-slider input[type="range"]::-webkit-slider-runnable-track {
	height: 6px;
	border-radius: 3px;
	background: transparent;
}

.hgm-slider input[type="range"]::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	pointer-events: auto;
	width: 18px;
	height: 18px;
	margin-top: -6px;
	border-radius: 50%;
	background: var(--hgm-amber);
	border: none;
	cursor: pointer;
}

.hgm-slider input[type="range"]::-moz-range-track {
	height: 6px;
	border-radius: 3px;
	background: transparent;
}

.hgm-slider input[type="range"]::-moz-range-thumb {
	pointer-events: auto;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: var(--hgm-amber);
	border: none;
	cursor: pointer;
}

.hgm-reset {
	background: transparent;
	border: none;
	color: #cdd3ff;
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
	padding: 0.25rem 0;
}

.hgm-reset:hover {
	color: #fff;
}

/* collapsed rail */
.hgm-collapsed .hgm-grid {
	grid-template-columns: 56px minmax(0, 1fr) 340px;
}

.hgm-collapsed .hgm-filters {
	padding: 1rem 0.5rem;
}

.hgm-collapsed .hgm-filters-head {
	justify-content: center;
	margin-bottom: 0;
}

.hgm-collapsed .hgm-filters-title {
	display: none;
}

.hgm-collapsed .hgm-filters-body {
	display: none;
}

/* ---------- map (center) ---------- */

.hgm-mapwrap {
	position: relative;
	background: #eef1f4;
	min-width: 0;
	display: flex;
	flex-direction: column;
}

.hgm-map {
	flex: 1 1 auto;
	width: 100%;
	min-height: 560px;
	z-index: 1;
	background: #eef1f4;
}

.hgm-legend {
	position: absolute;
	left: 0.75rem;
	bottom: 0.75rem;
	z-index: 500;
	background: rgba(255, 255, 255, 0.96);
	border: 1px solid var(--hgm-border);
	border-radius: 0.25rem;
	padding: 0.6rem 0.75rem;
	font-size: 0.78rem;
	color: #374151;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.hgm-legend-title {
	font-weight: 700;
	margin-bottom: 0.3rem;
}

.hgm-legend-row {
	display: flex;
	align-items: center;
	gap: 0.45rem;
	line-height: 1.55;
}

.hgm-swatch {
	display: inline-block;
	width: 14px;
	height: 14px;
	border-radius: 2px;
	border: 1px solid rgba(0, 0, 0, 0.15);
}

.hgm-swatch-nodata {
	background: #fff;
}

/* ---------- results (right) ---------- */

.hgm-results {
	background: var(--hgm-panel);
	padding: 1.25rem 1.1rem;
	max-height: 700px;
	overflow-y: auto;
	position: relative;
}

.hgm-info-btn {
	position: absolute;
	top: 1.1rem;
	right: 1rem;
	width: 22px;
	height: 22px;
	border: 1.5px solid #111827;
	border-radius: 50%;
	background: #fff;
	color: #111827;
	font-style: italic;
	font-family: Georgia, serif;
	font-size: 0.8rem;
	font-weight: 700;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	padding: 0;
}

.hgm-info-btn:hover {
	background: #111827;
	color: #fff;
}

.hgm-summary {
	padding-right: 2rem;
}

.hgm-loc {
	font-size: 0.8rem;
	font-weight: 700;
	letter-spacing: 0.1em;
	color: #111827;
}

.hgm-total {
	font-size: 2rem;
	font-weight: 800;
	color: var(--hgm-orange);
	margin: 0.2rem 0 0.1rem;
	letter-spacing: -0.01em;
}

.hgm-sub {
	font-size: 0.85rem;
	color: #374151;
}

.hgm-sub strong {
	color: #111827;
}

.hgm-count {
	font-size: 0.9rem;
	margin: 0.7rem 0 0.6rem;
	color: #111827;
}

.hgm-projects {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	background: #fff;
	border: 1px solid var(--hgm-border);
	border-radius: 0.25rem;
	padding: 0.6rem 0.8rem;
	font-size: 0.9rem;
	color: #111827;
	cursor: pointer;
	margin: 0.7rem 0 0.75rem;
}

.hgm-plus {
	flex: none;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	background: var(--hgm-blue);
	color: #fff;
	font-weight: 700;
	font-size: 0.95rem;
	line-height: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.hgm-cards-collapsed .hgm-cards {
	display: none;
}

.hgm-dialog {
	border: 1px solid var(--hgm-border);
	border-radius: 0.5rem;
	padding: 1.1rem 1.25rem;
	max-width: min(480px, 90vw);
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
	font-size: 0.88rem;
	color: #374151;
}

.hgm-dialog::backdrop {
	background: rgba(17, 24, 39, 0.5);
}

.hgm-dialog-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 0.6rem;
}

.hgm-dialog-title {
	font-weight: 800;
	font-size: 1rem;
	color: #111827;
}

.hgm-dialog-close {
	background: none;
	border: none;
	font-size: 1.5rem;
	line-height: 1;
	color: #6b7280;
	cursor: pointer;
	padding: 0 0.1rem;
}

.hgm-dialog-close:hover {
	color: #111827;
}

.hgm-dialog p {
	margin: 0 0 0.7rem;
}

.hgm-dialog p:last-child {
	margin: 0;
}

.hgm-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem;
	margin-bottom: 0.75rem;
}

.hgm-chip {
	font-size: 0.75rem;
	background: #fff4e8;
	border: 1px solid #fed7aa;
	color: #9a3412;
	border-radius: 999px;
	padding: 0.15rem 0.6rem;
}

.hgm-search {
	margin: 0.75rem 0 0.1rem;
}

.hgm-search input {
	width: 100%;
	padding: 0.55rem 0.75rem;
	border: 1px solid var(--hgm-border);
	border-radius: 0.5rem;
	font-size: 0.85rem;
	background: #fff;
}

.hgm-cards {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.hgm-card {
	border: 1px solid var(--hgm-border);
	border-radius: 0.25rem;
	padding: 0.8rem 0.9rem;
	background: #fff;
}

.hgm-card-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 0.5rem;
	width: 100%;
	background: none;
	border: none;
	padding: 0;
	cursor: pointer;
	text-align: left;
	font: inherit;
	color: inherit;
}

.hgm-card-title {
	font-size: 1rem;
	margin: 0;
	line-height: 1.3;
	font-weight: 700;
}

.hgm-card-head:hover .hgm-card-title {
	color: var(--hgm-orange);
}

.hgm-card-chev {
	flex: none;
	width: 20px;
	height: 20px;
	border: 1.5px solid #111827;
	border-radius: 50%;
	color: #111827;
	font-size: 0.7rem;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.hgm-card-body {
	margin-top: 0.45rem;
}

.hgm-card-recip {
	font-size: 0.85rem;
	font-weight: 600;
	margin-top: 0.15rem;
}

.hgm-card-award {
	font-size: 0.85rem;
	color: var(--hgm-muted);
}

.hgm-card-period {
	font-size: 0.82rem;
	color: var(--hgm-muted);
	margin-top: 0.45rem;
}

.hgm-card-period strong {
	color: #6b7280;
	font-weight: 600;
}

.hgm-card-loc {
	font-size: 0.8rem;
	color: var(--hgm-muted);
	margin-top: 0.25rem;
}

.hgm-card-desc {
	font-size: 0.83rem;
	color: #4b5563;
	margin: 0.4rem 0 0;
	display: -webkit-box;
	/* -webkit-line-clamp: 6; */
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.hgm-card-more {
	display: inline-block;
	margin-top: 0.6rem;
	padding: 0.35rem 0.95rem;
	border: 1px solid var(--hgm-blue);
	color: var(--hgm-blue);
	border-radius: 999px;
	font-size: 0.8rem;
	font-weight: 700;
	text-decoration: none;
}

.hgm-card-more:hover {
	background: var(--hgm-blue);
	color: #fff;
}

.hgm-empty {
	color: var(--hgm-muted);
	font-size: 0.9rem;
}

/* ---------- country modal (hover tooltip + tap popup) ---------- */

.hgm-tip.leaflet-tooltip {
	background: #fff;
	border: 1px solid var(--hgm-border);
	border-radius: 0.35rem;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
	padding: 0.6rem 0.75rem;
	font-family: inherit;
	font-size: 0.85rem;
	color: #111827;
}

.hgm-tip.leaflet-tooltip-top:before,
.hgm-tip.leaflet-tooltip-bottom:before {
	display: none;
}

.hgm-tip-title {
	display: flex;
	align-items: center;
	gap: 0.45rem;
	font-weight: 600;
	margin-bottom: 0.2rem;
}

.hgm-flag {
	width: 22px;
	height: auto;
	border-radius: 2px;
	box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.hgm-tip-amount {
	font-weight: 800;
	font-size: 1rem;
}

.hgm-tip-pct {
	color: #4b5563;
	font-size: 0.8rem;
}

.hgm-tip-nodata {
	color: var(--hgm-muted);
}

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
	.hgm-grid {
		grid-template-columns: 240px minmax(0, 1fr);
	}

	.hgm-collapsed .hgm-grid {
		grid-template-columns: 56px minmax(0, 1fr);
	}

	.hgm-results {
		grid-column: 1 / -1;
		max-height: none;
	}
}

@media (max-width: 720px) {

	.hgm-grid,
	.hgm-collapsed .hgm-grid {
		grid-template-columns: minmax(0, 1fr);
	}

	/* Mobile order: filter pane first, then map, then cards. */
	.hgm-filters {
		order: 1;
	}

	.hgm-mapwrap {
		order: 2;
	}

	.hgm-results {
		order: 3;
		max-height: none;
	}

	/* Filter box starts vertically collapsed (accordion); tap header to open. */
	.hgm-filters-body {
		display: none;
	}

	.hgm-mobile-open .hgm-filters-body {
		display: block;
	}

	.hgm-filters-head {
		margin-bottom: 0;
		cursor: pointer;
	}

	.hgm-mobile-open .hgm-filters-head {
		margin-bottom: 1.1rem;
	}

	.hgm-map {
		min-height: 380px;
	}

	/* Legend flows under the map instead of overlaying it. */
	.hgm-mapwrap {
		background: #fff;
	}

	.hgm-legend {
		position: static;
		margin: 0.6rem;
		box-shadow: none;
	}
}