/* Viewer of results of MonitorEO-OBSNEV: catalogue (index.html) and report (report.html). */

:root {
	color-scheme: light;
	--page: #f9f9f7;
	--surface: #fcfcfb;
	--surface-2: #f2f1ed;
	--ink: #0b0b0b;
	--ink-2: #52514e;
	--muted: #6f6d68;
	--grid: #e1e0d9;
	--baseline: #c3c2b7;
	--border: rgba(11, 11, 11, 0.12);
	--accent: #2f6e1d;
	--accent-soft: #e7f0e1;
	--link: #1c5cab;
	--series-1: #2a78d6;
	--series-2: #eb6834;
	--series-3: #1baf7a;
	--series-4: #eda100;
	--series-other: #e34948;
	--not-significant: #c9c8c2;
	--good: #0ca30c;
	--shadow: 0 1px 2px rgba(11, 11, 11, 0.06), 0 4px 16px rgba(11, 11, 11, 0.05);
	--radius: 10px;
	--font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	--mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		color-scheme: dark;
		--page: #0d0d0d;
		--surface: #1a1a19;
		--surface-2: #232321;
		--ink: #f0efec;
		--ink-2: #c3c2b7;
		--muted: #9a988f;
		--grid: #2c2c2a;
		--baseline: #45453f;
		--border: rgba(255, 255, 255, 0.12);
		--accent: #8fc96b;
		--accent-soft: #22301b;
		--link: #86b6ef;
		--series-1: #3987e5;
		--series-2: #d95926;
		--series-3: #199e70;
		--series-4: #c98500;
		--series-other: #e66767;
		--not-significant: #55544f;
		--shadow: none;
	}
}

:root[data-theme="dark"] {
	color-scheme: dark;
	--page: #0d0d0d;
	--surface: #1a1a19;
	--surface-2: #232321;
	--ink: #f0efec;
	--ink-2: #c3c2b7;
	--muted: #9a988f;
	--grid: #2c2c2a;
	--baseline: #45453f;
	--border: rgba(255, 255, 255, 0.12);
	--accent: #8fc96b;
	--accent-soft: #22301b;
	--link: #86b6ef;
	--series-1: #3987e5;
	--series-2: #d95926;
	--series-3: #199e70;
	--series-4: #c98500;
	--series-other: #e66767;
	--not-significant: #55544f;
	--shadow: none;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
	margin: 0;
	background: var(--page);
	color: var(--ink);
	font: 16px/1.55 var(--font);
}

a { color: var(--link); }
a:hover { text-decoration-thickness: 2px; }

img { max-width: 100%; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 820px; }

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

/* Header -------------------------------------------------------------------------------------------------------- */

.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-header .wrap { display: flex; align-items: center; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 10px; color: var(--ink); text-decoration: none; }
.brand-mark {
	display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; align-self: center;
	background: var(--accent); color: var(--surface); font-weight: 700; font-size: 15px;
}
.brand strong { font-size: 17px; letter-spacing: -0.01em; }
.brand span { color: var(--muted); font-size: 14px; }
.site-header nav { margin-left: auto; display: flex; gap: 16px; font-size: 14px; }
.site-header nav a { color: var(--ink-2); text-decoration: none; }
.site-header nav a:hover { color: var(--ink); text-decoration: underline; }

.intro { padding: 36px 0 20px; }
.intro h1 { font-size: clamp(26px, 4vw, 36px); line-height: 1.15; margin: 0 0 10px; letter-spacing: -0.02em; }
.intro p { margin: 0; max-width: 760px; color: var(--ink-2); font-size: 17px; }

/* Filters ------------------------------------------------------------------------------------------------------- */

.filters {
	display: grid; grid-template-columns: minmax(200px, 2fr) repeat(4, minmax(130px, 1fr)) auto; gap: 10px;
	align-items: end; padding: 14px; background: var(--surface); border: 1px solid var(--border);
	border-radius: var(--radius); box-shadow: var(--shadow);
}
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.04em; }
.field input, .field select, .button {
	font: inherit; font-size: 15px; height: 40px; padding: 0 10px; border-radius: 8px; min-width: 0;
	border: 1px solid var(--border); background: var(--page); color: var(--ink);
}
.field input:focus, .field select:focus, .button:focus-visible, .chip:focus-visible, a:focus-visible, summary:focus-visible {
	outline: 2px solid var(--link); outline-offset: 2px;
}
.button { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; white-space: nowrap; }
.button:hover { background: var(--surface-2); }
.button.small { height: 32px; font-size: 14px; padding: 0 10px; }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); font-weight: 600; }
.button.primary:hover { filter: brightness(1.08); }

.count { margin: 18px 0 12px; color: var(--ink-2); font-size: 15px; }

/* Cards --------------------------------------------------------------------------------------------------------- */

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 18px; padding-bottom: 40px; }
.card {
	display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border);
	border-radius: var(--radius); overflow: hidden; color: inherit; text-decoration: none; box-shadow: var(--shadow);
	transition: transform 0.12s ease, border-color 0.12s ease;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card:hover h2 { text-decoration: underline; text-decoration-thickness: 1px; }
.thumb { position: relative; height: 190px; background: var(--surface-2); display: grid; place-items: center; }
.thumb img { position: absolute; inset: 10px; width: calc(100% - 20px); height: calc(100% - 20px); object-fit: contain; }
.thumb .none { color: var(--muted); font-size: 14px; }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.kicker { font-size: 13px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: 0.04em; }
.card h2 { font-size: 18px; line-height: 1.3; margin: 0; letter-spacing: -0.01em; }
.card p {
	margin: 0; color: var(--ink-2); font-size: 14.5px; display: -webkit-box; -webkit-line-clamp: 3;
	-webkit-box-orient: vertical; overflow: hidden;
}
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 6px; }
.chip {
	display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; line-height: 1; padding: 5px 8px;
	border-radius: 999px; background: var(--surface-2); color: var(--ink-2); border: 1px solid transparent; white-space: nowrap;
}
.chip.analysis { background: var(--accent-soft); color: var(--ink); }
.card-foot { font-size: 13px; color: var(--muted); }

.empty { padding: 40px 0; text-align: center; color: var(--ink-2); }

/* Report -------------------------------------------------------------------------------------------------------- */

.report-head { padding: 26px 0 8px; }
.back { display: inline-block; font-size: 14px; margin-bottom: 14px; }
.report-head h1 { font-size: clamp(25px, 4vw, 38px); line-height: 1.15; margin: 6px 0 14px; letter-spacing: -0.02em; }
.facts {
	display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 22px; margin: 0;
	padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.facts div { min-width: 0; }
.facts dt { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.facts dd { margin: 2px 0 0; font-size: 15px; overflow-wrap: anywhere; }

.lead {
	font-size: 19px; line-height: 1.5; margin: 22px 0 6px; padding: 16px 18px; border-left: 4px solid var(--accent);
	background: var(--accent-soft); border-radius: 0 var(--radius) var(--radius) 0;
}
.prose p { margin: 0 0 12px; }
.prose h2, .block > h2 { font-size: 22px; margin: 34px 0 10px; letter-spacing: -0.01em; }

.result {
	margin: 26px 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
	box-shadow: var(--shadow); overflow: hidden;
}
.result-head { padding: 16px 18px 6px; }
.result-head h2 { font-size: 19px; line-height: 1.3; margin: 0; letter-spacing: -0.01em; }
.result-head p { margin: 6px 0 0; color: var(--ink-2); font-size: 15px; }
.result-body { padding: 8px 18px 4px; }
.result-tools { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 18px 16px; align-items: center; }
.result-tools .spacer { flex: 1; }
details.call { padding: 0 18px 16px; font-size: 14px; }
details.call summary { cursor: pointer; color: var(--ink-2); }
details.call pre {
	margin: 8px 0 0; padding: 12px; background: var(--surface-2); border-radius: 8px; font: 12.5px/1.5 var(--mono);
	white-space: pre-wrap; overflow-wrap: anywhere; max-height: 320px; overflow: auto;
}
details.call p { margin: 8px 0 0; color: var(--ink-2); }

/* Map */
.map .ol-control button { background: var(--surface); color: var(--ink); }
.map .ol-control button:hover, .map .ol-control button:focus { background: var(--surface-2); color: var(--ink); }
.map .ol-scale-line { background: rgba(0, 0, 0, 0.45); }
.map .ol-attribution ul { color: #333; }
.map-controls { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: end; margin-bottom: 10px; }
.map-controls .field { min-width: 150px; }
.map-controls .field.grow { flex: 1 1 220px; }
.map-controls .check { display: flex; align-items: center; gap: 8px; font-size: 14px; height: 40px; color: var(--ink-2); }
.map-controls input[type="range"] { height: 40px; padding: 0; border: 0; background: none; accent-color: var(--accent); }
.map {
	position: relative; height: min(64vh, 560px); min-height: 320px; border-radius: 8px; overflow: hidden;
	border: 1px solid var(--border); background: var(--surface-2);
}
.map-note { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.map-error { padding: 20px; color: var(--ink-2); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; margin: 12px 0 2px; font-size: 13.5px; }
.legend-title { font-weight: 600; color: var(--ink-2); width: 100%; }
.legend-ramp { flex: 1 1 260px; max-width: 460px; }
.legend-bar { height: 12px; border-radius: 3px; border: 1px solid var(--border); }
.legend-ticks { display: flex; justify-content: space-between; color: var(--ink-2); font-variant-numeric: tabular-nums; margin-top: 3px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.swatch { width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--border); flex: none; }

.popup {
	background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 8px;
	box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18); padding: 10px 30px 10px 12px; font-size: 13.5px; min-width: 210px;
	max-width: 300px; position: relative;
}
.popup table { border-collapse: collapse; width: 100%; }
.popup td { padding: 2px 0; vertical-align: top; }
.popup td + td { text-align: right; padding-left: 12px; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.popup .where { color: var(--muted); font-size: 12px; margin-top: 6px; }
.popup .close {
	position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border: 0; background: none; color: var(--ink-2);
	cursor: pointer; font-size: 18px; line-height: 1;
}
.popup .current td { color: var(--ink); }
.popup tr:not(.current) td:first-child { color: var(--ink-2); }

/* Charts */
.chart { width: 100%; min-height: 120px; }
.chart .vega-embed { width: 100%; }
.chart .vega-embed summary { opacity: 0.6; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 6px 0 10px; }
.stat { padding: 12px 14px; background: var(--surface-2); border-radius: 8px; }
.stat .label { font-size: 12.5px; color: var(--ink-2); }
.stat .value { font-size: 24px; font-weight: 650; letter-spacing: -0.01em; line-height: 1.2; margin-top: 2px; }
.stat .sub { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.badge {
	display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; padding: 3px 8px;
	border-radius: 999px; background: var(--surface); border: 1px solid var(--border);
}
.badge.yes::before { content: "✓"; color: var(--good); }
.badge.no::before { content: "–"; color: var(--muted); }
.region-name { font-weight: 600; margin: 10px 0 0; }

.table-wrap { max-height: 360px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; margin: 4px 0 8px; }
table.data { border-collapse: collapse; width: 100%; font-size: 13.5px; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--grid); white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; color: var(--ink-2); }

/* Downloads */
.downloads { width: 100%; border-collapse: collapse; font-size: 15px; background: var(--surface); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.downloads td { padding: 10px 14px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
.downloads tr:last-child td { border-bottom: 0; }
.downloads td.type, .downloads td.size { color: var(--muted); white-space: nowrap; font-size: 14px; }
.downloads td.get { text-align: right; width: 1%; }
.downloads a { overflow-wrap: anywhere; }

/* Footer -------------------------------------------------------------------------------------------------------- */

.site-footer { margin-top: 48px; padding: 30px 0 40px; background: var(--surface); border-top: 1px solid var(--border); font-size: 14px; color: var(--ink-2); }
.site-footer h2 { font-size: 15px; color: var(--ink); margin: 0 0 6px; }
.site-footer p { margin: 0 0 12px; max-width: 900px; }
.logos { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; margin: 18px 0; padding: 14px; background: #fff; border-radius: 8px; max-width: 100%; }
.logos img { height: auto; max-height: 64px; max-width: 100%; }
.logos img + img { max-height: 40px; }
.logos img[src$="biodiversa.png"] { max-height: 56px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 18px; }

.loading { padding: 40px 0; color: var(--muted); }
.error { padding: 18px; border: 1px solid var(--series-other); border-radius: var(--radius); background: var(--surface); }

@media (max-width: 920px) {
	.filters { grid-template-columns: 1fr 1fr; }
	.filters .field.search { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
	body { font-size: 15.5px; }
	.filters { grid-template-columns: 1fr; }
	.site-header nav { margin-left: 0; }
	.lead { font-size: 17px; }
	.result-head, .result-body, .result-tools, details.call { padding-left: 12px; padding-right: 12px; }
	.map { height: 58vh; }
	.downloads td.type { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	.card { transition: none; }
	.card:hover { transform: none; }
}
