/* ── National Park Typeface ── */
@font-face {
	font-family: 'National Park';
	src: url('assets/fonts/NationalPark-Regular.woff') format('woff');
	font-weight: 400;
	font-style: normal;
	font-display: swap;
}
@font-face {
	font-family: 'National Park';
	src: url('assets/fonts/NationalPark-Bold.woff') format('woff');
	font-weight: 700;
	font-style: normal;
	font-display: swap;
}

/* ── Override template wrapper for app section ── */
.app-section {
	padding: 0 !important;
}
.app-section > .app-inner {
	width: 100% !important;
	max-width: 100% !important;
	padding: 0 !important;
	margin: 0 !important;
}

/* ── App layout: sidebar left, map right ── */
.tracker-app {
	display: flex !important;
	flex-direction: row !important;
	width: 100%;
	height: calc(100vh - 120px);
	min-height: 500px;
}

/* ── Sidebar panel (left) ── */
.sidebar-panel {
	flex: 0 0 360px;
	display: flex;
	flex-direction: column;
	background: #f8f9fa;
	border-right: 1px solid #e0e0e0;
	overflow: hidden;
}
.sidebar-inner {
	display: flex;
	flex-direction: column;
	height: 100%;
	padding: 1.25rem 1.25rem 1rem;
	overflow: hidden;
}

/* ── Map panel (right) ── */
.map-panel {
	flex: 1 1 auto;
	position: relative;
	min-width: 0;
}
#map {
	width: 100%;
	height: 100%;
	z-index: 1;
}
.leaflet-container { font-family: "Source Sans Pro", Helvetica, sans-serif; }

/* ── Legend overlay on map ── */
.map-legend {
	position: absolute;
	bottom: 24px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 500;
	display: flex;
	gap: 1rem;
	flex-wrap: wrap;
	justify-content: center;
	background: rgba(255,255,255,0.93);
	padding: 0.5rem 1rem;
	border-radius: 6px;
	font-size: 0.75rem;
	color: #555;
	box-shadow: 0 1px 4px rgba(0,0,0,0.15);
	pointer-events: none;
}
.legend-group {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.15rem;
}
.legend-group-label {
	font-weight: 600;
	font-size: 0.68rem;
	text-transform: uppercase;
	letter-spacing: 0.03em;
}
.legend-row {
	display: flex;
	gap: 0.6rem;
}
.legend-dot {
	display: inline-block;
	width: 12px;
	height: 12px;
	border-radius: 3px;
	margin-right: 0.2rem;
	vertical-align: middle;
}

/* ── Sidebar title ── */
.sidebar-title {
	font-family: 'National Park', "Source Sans Pro", sans-serif;
	font-size: 1.3rem;
	font-weight: 700;
	color: #2c6e49;
	margin-bottom: 0.6rem;
	flex-shrink: 0;
	text-align: center;
	letter-spacing: 0.02em;
}

/* ── Layer toggles ── */
.layer-toggles {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
	margin-bottom: 0.6rem;
	flex-shrink: 0;
}
.layer-toggle {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	font-size: 0.78rem;
	cursor: pointer;
	user-select: none;
	padding: 0.4rem 0.6rem;
	border-radius: 6px;
	border: 2px solid var(--layer-color);
	background: color-mix(in srgb, var(--layer-color) 10%, #fff);
	transition: all 0.2s ease;
}
.layer-toggle:hover {
	background: color-mix(in srgb, var(--layer-color) 18%, #fff);
}
.layer-toggle.disabled {
	border-color: #ccc;
	background: #f0f0f0;
	opacity: 0.55;
}
.layer-toggle.disabled:hover {
	opacity: 0.7;
	background: #e8e8e8;
}
.layer-toggle input[type="checkbox"] {
	appearance: none;
	-webkit-appearance: none;
	width: 18px;
	height: 18px;
	border: 2px solid var(--layer-color);
	border-radius: 4px;
	cursor: pointer;
	position: relative;
	flex-shrink: 0;
	transition: background 0.15s, border-color 0.15s;
	background: #fff;
}
.layer-toggle input[type="checkbox"]:checked {
	border-color: var(--layer-color);
	background: var(--layer-color);
}
.layer-toggle input[type="checkbox"]:checked::after {
	content: '\2713';
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
}
.layer-toggle.disabled input[type="checkbox"] {
	border-color: #bbb;
	background: #e0e0e0;
}
.layer-toggle .layer-name {
	font-weight: 600;
	flex: 1;
	color: #333;
}
.layer-toggle.disabled .layer-name {
	color: #999;
	text-decoration: line-through;
}
.layer-toggle .layer-count {
	font-size: 0.7rem;
	color: #666;
	white-space: nowrap;
	font-weight: 500;
}
.layer-toggle.disabled .layer-count {
	color: #aaa;
}

/* ── Stats bar ── */
.stats-bar {
	display: flex;
	justify-content: space-around;
	gap: 0.5rem;
	margin-bottom: 0.6rem;
	flex-shrink: 0;
}
.stat-item { text-align: center; }
.stat-value {
	font-size: 1.4rem;
	font-weight: 700;
	color: #2c6e49;
	line-height: 1;
}
.stat-label {
	font-size: 0.65rem;
	color: #888;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	margin-top: 0.15rem;
}
.progress-outer {
	width: 100%;
	height: 6px;
	background: #e0e0e0;
	border-radius: 3px;
	margin-bottom: 0.75rem;
	overflow: hidden;
	flex-shrink: 0;
}
.progress-inner {
	height: 100%;
	border-radius: 3px;
	transition: width 0.4s ease;
	background: linear-gradient(90deg, #4a7c59, #e8a735, #3565a0);
}

/* ── Search autocomplete ── */
.search-wrap {
	position: relative;
	margin-bottom: 0.6rem;
	flex-shrink: 0;
}
.search-wrap input[type="text"] {
	width: 100%;
	padding: 0.55rem 0.8rem;
	font-size: 0.88rem;
	border: 2px solid #ddd;
	border-radius: 6px;
	outline: none;
	transition: border-color 0.2s;
	box-sizing: border-box;
}
.search-wrap input[type="text"]:focus {
	border-color: #2c6e49;
}
.autocomplete-list {
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	background: #fff;
	border: 1px solid #ddd;
	border-top: none;
	border-radius: 0 0 6px 6px;
	max-height: 220px;
	overflow-y: auto;
	z-index: 1000;
	display: none;
	box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.autocomplete-list .ac-item {
	padding: 0.45rem 0.8rem;
	cursor: pointer;
	border-bottom: 1px solid #f0f0f0;
	font-size: 0.85rem;
	text-align: left;
	display: flex;
	align-items: center;
	gap: 0.4rem;
}
.autocomplete-list .ac-item:hover,
.autocomplete-list .ac-item.active {
	background: #f0f7f2;
}
.autocomplete-list .ac-item .ac-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	flex-shrink: 0;
}
.autocomplete-list .ac-item .ac-name {
	flex: 1;
}
.autocomplete-list .ac-item .ac-state {
	color: #999;
	font-size: 0.72rem;
}

/* ── Control buttons row ── */
.controls-row {
	display: flex;
	gap: 0.4rem;
	flex-wrap: wrap;
	margin-bottom: 0.6rem;
	flex-shrink: 0;
}
.controls-row .button {
	font-size: 0.7rem;
	padding: 0.35rem 0.6rem;
	flex: 1 1 auto;
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	gap: 0.3rem;
}
.btn-danger {
	background-color: #c0392b !important;
	border-color: #c0392b !important;
	color: #fff !important;
}
.btn-danger:hover {
	background-color: #a93226 !important;
}

/* ── Section label ── */
.sidebar-label {
	font-size: 0.7rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: #999;
	margin-bottom: 0.35rem;
	flex-shrink: 0;
}

/* ── Visited table ── */
.visited-table-wrap {
	flex: 1 1 auto;
	overflow-y: auto;
	border-radius: 6px;
	border: 1px solid #e0e0e0;
	min-height: 0;
}
.visited-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.78rem;
}
.visited-table thead {
	position: sticky;
	top: 0;
	z-index: 2;
}
.visited-table th {
	background: #2c6e49;
	color: #fff;
	padding: 0.45rem 0.55rem;
	text-align: left;
	font-weight: 600;
	cursor: pointer;
	user-select: none;
	white-space: nowrap;
	font-size: 0.72rem;
}
.visited-table th:hover { background: #245a3b; }
.visited-table th .sort-arrow { margin-left: 0.2rem; font-size: 0.6rem; }
.visited-table td {
	padding: 0.4rem 0.55rem;
	border-bottom: 1px solid #f0f0f0;
}
.visited-table tbody tr:hover { background: #f9f9f0; cursor: pointer; }
.visited-table .empty-msg {
	text-align: center;
	color: #999;
	padding: 1.5rem 0.75rem;
	font-style: italic;
	font-size: 0.82rem;
}
.type-dot {
	display: inline-block;
	width: 8px;
	height: 8px;
	border-radius: 50%;
	vertical-align: middle;
}

/* ── Sidebar footer ── */
.sidebar-footer {
	flex-shrink: 0;
	padding-top: 0.6rem;
	margin-top: 0.5rem;
	border-top: 1px solid #e0e0e0;
	text-align: center;
}
.sidebar-footer a {
	font-size: 0.8rem;
}
.sidebar-footer .credit {
	font-size: 0.65rem;
	color: #aaa;
	margin-top: 0.35rem;
	line-height: 1.4;
}
.sidebar-footer .credit a { color: #888; }

/* ── Tooltip ── */
.lands-tooltip {
	font-family: "Source Sans Pro", sans-serif;
	font-size: 0.85rem;
	line-height: 1.4;
}
.lands-tooltip strong { font-size: 0.95rem; }

/* ── Hidden file input ── */
#import-input { display: none; }

/* ── Footer override -- compact ── */
.compact-footer > .inner {
	padding: 1.5rem 2rem !important;
}

/* ── Responsive: stack on mobile ── */
@media (max-width: 900px) {
	.tracker-app {
		flex-direction: column !important;
		height: auto;
	}
	.map-panel {
		height: 50vh;
		min-height: 300px;
		order: 1;
	}
	.sidebar-panel {
		flex: none;
		border-right: none;
		border-bottom: 1px solid #e0e0e0;
		max-height: 55vh;
		order: 2;
	}
	.visited-table-wrap {
		max-height: 200px;
	}
	.map-legend {
		font-size: 0.65rem;
		padding: 0.35rem 0.6rem;
		gap: 0.6rem;
	}
}

/* Tracker-specific states and overrides must win over the site's global theme. */
.lands-tracker { --tracker-bg: #f8f9fa; --tracker-fg: #253b30; --tracker-muted: #4c6053; --tracker-line: #ccd5cf; --tracker-field: #fff; }
.lands-tracker.dark-mode { --tracker-bg: #202d29; --tracker-fg: #edf3ef; --tracker-muted: #c0cfc6; --tracker-line: #50655a; --tracker-field: #2b3c34; }
.sidebar-panel { background: var(--tracker-bg); color: var(--tracker-fg); }
.sidebar-inner { overflow-y: auto; }
.sidebar-title { color: #2c6e49; line-height: 1.3; }
body.dark-mode .sidebar-title, body.dark-mode .stat-value { color: #b5d5bf !important; }
.tracker-help, .tracker-status { font-size: 0.875rem; line-height: 1.4; color: var(--tracker-muted); margin-bottom: 0.65rem; }
.tracker-status:empty { display: none; }
#action-status { color: var(--tracker-fg); }
#retry-data { margin-bottom: 0.65rem; }
.layer-toggle { min-height: 44px; font-size: 0.875rem; }
.layer-toggle .layer-name, .layer-toggle .layer-count, .stat-label, .sidebar-label, .sidebar-footer .credit, .sidebar-footer .credit a { color: var(--tracker-muted); }
body.dark-mode .layer-toggle { background: var(--tracker-field); }
body.dark-mode .layer-toggle .layer-name { color: var(--tracker-fg); }
.layer-toggle input[type="checkbox"] { appearance: auto; -webkit-appearance: auto; opacity: 1; position: static; margin: 0; accent-color: var(--layer-color); }
.layer-toggle input[type="checkbox"]:checked::after { content: none; }
.controls-row .button, body.dark-mode .controls-row .button, .sidebar-footer .button, body.dark-mode .sidebar-footer .button { color: var(--tracker-fg) !important; background: var(--tracker-field) !important; box-shadow: inset 0 0 0 1px var(--tracker-line) !important; min-height: 44px; height: auto; line-height: 1.4; }
.controls-row .btn-danger, body.dark-mode .controls-row .btn-danger { color: #fff !important; background: #a52d23 !important; }
.controls-row .button:disabled { opacity: 0.55; cursor: wait; }
body.dark-mode .search-wrap input[type="text"] { background: var(--tracker-field) !important; color: var(--tracker-fg) !important; }
.search-wrap input[type="text"] { font-size: 1rem; color: var(--tracker-fg); }
.search-wrap input::placeholder { color: var(--tracker-muted); opacity: 1; }
.autocomplete-list { background: var(--tracker-field); color: var(--tracker-fg); }
.ac-item { min-height: 44px; }
body.dark-mode .ac-item:hover, body.dark-mode .ac-item.active { background: #3d5948; }
.autocomplete-list .ac-item .ac-state, .visited-table .empty-msg { color: var(--tracker-muted); }
.visited-table { color: var(--tracker-fg); }
.visited-table tbody tr:hover, body.dark-mode .visited-table tbody tr:hover { background: var(--tracker-field); }
.visited-table td { overflow-wrap: anywhere; }
.visited-table-wrap { flex: 1 0 140px; }
.map-status { position: absolute; top: 80px; left: 12px; right: 64px; z-index: 500; padding: 0.75rem; background: #fff; color: #723126; box-shadow: 0 2px 6px #0003; font-size: 0.875rem; }
body.dark-mode .leaflet-control-layers, body.dark-mode .leaflet-control-layers label, body.dark-mode .leaflet-tooltip, body.dark-mode .leaflet-tooltip strong, body.dark-mode .leaflet-control-attribution, body.dark-mode .leaflet-control-attribution a { color: #26382d !important; }
body.dark-mode .map-legend { color: #26382d; }
.stat-value, .layer-count, .visited-table { font-variant-numeric: tabular-nums; }
.lands-tracker :focus-visible { outline: 3px solid #398357; outline-offset: 3px; }
body.dark-mode :focus-visible { outline-color: #a8d84e; }
.lands-tracker ::selection { background: #b7d7c1; color: #183724; }
.sidebar-inner, .visited-table-wrap { scrollbar-color: #688a75 var(--tracker-bg); }
.search-wrap input { caret-color: #398357; }
@media (max-width: 900px) {
  .sidebar-panel { max-height: none; }
  .sidebar-inner { height: auto; overflow: visible; }
  .map-panel { flex: none; height: 50vh; height: 50svh; }
  .map-legend { width: max-content; max-width: calc(100% - 24px); box-sizing: border-box; gap: 0.6rem; }
  .visited-table-wrap { max-height: 260px; flex-basis: auto; min-height: 100px; }
}
@media (prefers-reduced-motion: reduce) {
  .lands-tracker *, .lands-tracker *::before, .lands-tracker *::after { animation: none !important; transition: none !important; }
}
.lands-tracker [hidden] { display: none !important; }
.layer-toggle input[type="checkbox"] { z-index: auto; }
body.dark-mode .search-wrap input::placeholder { color: var(--tracker-muted) !important; }
.stat-label, .legend-group-label, .sidebar-footer .credit { font-size: 0.75rem; }
.map-legend { font-size: 0.75rem; }
.progress-inner { transition: none; }
