/* ── Explore-page overrides for shared site.css ─────────────── */
/* site.css is loaded first; these rules win on the explore page only */
:root { --accent: var(--active-accent); }   /* so site-brand SVG tracks region colour */

.site-nav {
    position: absolute !important;
    top: 0; left: 0; right: 0;
    z-index: 20;
}

/* ── Design tokens ───────────────────────────────────────────── */
:root {
    --active-accent: #002868;
    --navbar-h:      52px;
    --panel-w:       320px;
    --panel-bg:      #ffffff;
    --page-bg:       #f0f4f8;
    --border:        #cdd3d9;
    --border-light:  #e8ecef;
    --text:          #1f2328;
    --text-2:        #57606a;
    --text-3:        #8b949e;
    --shadow:        0 4px 16px rgba(0,0,0,0.13);
    --r:             6px;
}

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

body, html {
    margin: 0; padding: 0;
    width: 100%; height: 100%;
    font-family: 'Source Sans 3', system-ui, sans-serif;
    font-size: 14px;
    color: var(--text);
    overflow: hidden;
}

/* ── Map ─────────────────────────────────────────────────────── */
#map { position: absolute; inset: 0; }

/* ── Loading ─────────────────────────────────────────────────── */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(240,244,248,0.75);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    z-index: 100;
    color: var(--text-2);
    font-size: 0.85rem;
}
.loading-overlay[hidden] { display: none !important; }
.loading-spinner {
    width: 28px; height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--active-accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    transition: border-top-color 0.3s;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-msg { margin: 0; }

/* ── Navbar ──────────────────────────────────────────────────── */
.navbar {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: var(--navbar-h);
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 16px;
    z-index: 20;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-shrink: 0;
    text-decoration: none;
}

.navbar-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.navbar-tagline {
    font-size: 0.7rem;
    color: var(--text-3);
    border-left: 1px solid var(--border);
    padding-left: 10px;
    margin-left: 2px;
    white-space: nowrap;
}

/* Search */
.navbar-search {
    flex: 1;
    position: relative;
    max-width: 480px;
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-3);
    pointer-events: none;
}

.search-input {
    width: 100%;
    height: 34px;
    padding: 0 32px 0 32px;
    border: 1px solid var(--border);
    border-radius: 17px;
    font-family: inherit;
    font-size: 0.85rem;
    color: var(--text);
    background: var(--page-bg);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input:focus {
    border-color: var(--active-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--active-accent) 12%, transparent);
    background: #fff;
}
.search-input::placeholder { color: var(--text-3); }

.search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-3);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    padding: 2px 5px;
    border-radius: 3px;
}
.search-clear:hover { color: var(--text); background: var(--page-bg); }
.search-clear[hidden] { display: none; }

.search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: var(--shadow);
    z-index: 50;
    overflow: hidden;
    max-height: 280px;
    overflow-y: auto;
}
.search-results[hidden] { display: none; }

.search-result-item {
    width: 100%;
    background: none;
    border: none;
    padding: 9px 12px;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.82rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 1px;
    transition: background 0.1s;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--page-bg); }

.result-main { color: var(--text); font-weight: 500; }
.result-sub  { color: var(--text-3); font-size: 0.72rem; }

.navbar-meta {
    margin-left: auto;
    flex-shrink: 0;
}
.navbar-src {
    font-size: 0.7rem;
    color: var(--text-3);
    white-space: nowrap;
}

.navbar-links {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}
.navbar-links a {
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.82rem;
    font-weight: 500;
    text-decoration: none;
    color: var(--text-2);
    transition: all 0.13s;
    white-space: nowrap;
}
.navbar-links a:hover  { background: var(--page-bg); color: var(--text); }
.navbar-links a.active { background: var(--active-accent); color: white; }

/* ── Right panel ─────────────────────────────────────────────── */
.right-panel {
    position: absolute;
    top: calc(var(--navbar-h) + 12px);
    right: 12px;
    width: var(--panel-w);
    max-height: calc(100vh - var(--navbar-h) - 24px);
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: var(--shadow);
    z-index: 10;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Panel sections */
.rp-section {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}
.rp-section.rp-cats {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.rp-hd {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.rp-title {
    font-size: 0.67rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--text-3);
    display: block;
    margin-bottom: 8px;
}
.rp-hd .rp-title { margin-bottom: 0; }

.rp-badge {
    font-family: 'Source Code Pro', monospace;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--active-accent);
    background: color-mix(in srgb, var(--active-accent) 10%, white);
    padding: 1px 6px;
    border-radius: 3px;
    transition: color 0.3s, background 0.3s;
}

.text-btn {
    background: none;
    border: none;
    padding: 0;
    color: #0074d9;
    font-family: inherit;
    font-size: 0.73rem;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.text-btn:hover { color: #005099; }

/* ── Dataset list — horizontal scroll pills ──────────────────── */
.dataset-list {
    display: flex;
    gap: 5px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
}
.dataset-list::-webkit-scrollbar { display: none; }

.dataset-card {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 11px 5px 7px;
    border-radius: 100px;
    border: 1px solid var(--border);
    background: var(--page-bg);
    color: var(--text-2);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.15s;
}
.dataset-card:hover:not(:disabled) {
    border-color: var(--active-accent);
    color: var(--active-accent);
    background: color-mix(in srgb, var(--active-accent) 6%, white);
}
.dataset-card.active {
    background: var(--active-accent);
    color: white;
    border-color: transparent;
    font-weight: 600;
    transition: background 0.3s;
}
.dataset-card:disabled {
    opacity: 0.38;
    cursor: default;
}

/* ── Segmented controls ──────────────────────────────────────── */
.seg-ctrl {
    display: flex;
    gap: 4px;
}

.seg-btn {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--page-bg);
    color: var(--text-2);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    transition: all 0.13s;
    white-space: nowrap;
}
.seg-btn:hover {
    border-color: var(--active-accent);
    color: var(--active-accent);
    background: color-mix(in srgb, var(--active-accent) 7%, white);
}
.seg-btn.active {
    background: var(--active-accent);
    color: #fff;
    border-color: transparent;
    font-weight: 600;
    transition: background 0.3s;
}

/* ── Confidence slider ───────────────────────────────────────── */
.slider-wrap {
    position: relative;
    height: 22px;
    display: flex;
    align-items: center;
    margin-bottom: 5px;
}
.slider-bg {
    position: absolute;
    left: 0; right: 0;
    height: 5px;
    background: var(--border-light);
    border-radius: 3px;
    pointer-events: none;
}
.slider-fill {
    position: absolute;
    left: 0;
    height: 5px;
    background: var(--active-accent);
    border-radius: 3px;
    pointer-events: none;
    transition: width 0.06s, background 0.3s;
}
input[type=range] {
    position: relative; z-index: 2;
    -webkit-appearance: none; appearance: none;
    width: 100%; background: transparent;
    margin: 0; outline: none; cursor: pointer; height: 22px;
}
input[type=range]::-webkit-slider-runnable-track { background: transparent; height: 5px; }
input[type=range]::-moz-range-track              { background: transparent; height: 5px; }
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: white;
    border: 2px solid var(--active-accent);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: border-color 0.3s;
    margin-top: -4.5px;
}
input[type=range]::-moz-range-thumb {
    width: 14px; height: 14px; border-radius: 50%;
    background: white; border: 2px solid var(--active-accent);
    cursor: pointer; box-sizing: border-box;
}
.slider-ends {
    display: flex;
    justify-content: space-between;
    font-size: 0.63rem;
    color: var(--text-3);
}

/* ── Visualisation tools ─────────────────────────────────────── */
.viz-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 4px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-2);
    transition: background 0.1s;
}
.viz-row:hover { background: var(--page-bg); }
.viz-row input[type=checkbox] {
    width: 13px; height: 13px;
    cursor: pointer;
    accent-color: var(--active-accent);
    margin: 0; flex-shrink: 0;
}
.viz-icon  { font-size: 0.9rem; flex-shrink: 0; opacity: 0.7; }
.viz-label { flex: 1; }

/* ── Category tree ───────────────────────────────────────────── */
.cat-tree {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.cat-tree::-webkit-scrollbar       { width: 4px; }
.cat-tree::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.t1-group { border-bottom: 1px solid var(--border-light); }

.t1-row {
    display: flex; align-items: center; gap: 7px;
    padding: 5px 4px; cursor: pointer; user-select: none;
    border-radius: 4px; transition: background 0.1s;
}
.t1-row:hover { background: var(--page-bg); }

.t1-cb {
    flex-shrink: 0; width: 13px; height: 13px;
    cursor: pointer; accent-color: var(--active-accent);
    margin: 0; transition: accent-color 0.3s;
}
.t1-dot  { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.t1-name { flex: 1; font-size: 0.82rem; font-weight: 600; color: var(--text); }
.t1-caret {
    font-size: 0.7rem; color: var(--text-3);
    transition: transform 0.15s; flex-shrink: 0; line-height: 1;
}
.t1-group.open .t1-caret { transform: rotate(90deg); }

.t2-list {
    display: none;
    padding: 1px 4px 4px 26px;
    columns: 2; column-gap: 0;
}
.t1-group.open .t2-list { display: block; }

.t2-row {
    display: flex; align-items: center; gap: 5px;
    padding: 3px 4px; border-radius: 3px;
    cursor: pointer; transition: background 0.1s;
    break-inside: avoid;
}
.t2-row:hover { background: var(--page-bg); }
.t2-cb {
    flex-shrink: 0; width: 11px; height: 11px;
    cursor: pointer; accent-color: var(--active-accent); margin: 0;
}
.t2-name { font-size: 0.75rem; color: var(--text-2); line-height: 1.2; }

/* ── Stats bar ───────────────────────────────────────────────── */
.stats-bar {
    position: absolute;
    bottom: 12px; left: 12px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
    z-index: 10;
    display: flex;
    align-items: stretch;
    overflow: hidden;
}
.stat-cell {
    display: flex; flex-direction: column; align-items: center;
    padding: 7px 14px;
}
.stat-cell dt {
    font-size: 0.58rem; text-transform: uppercase;
    letter-spacing: 0.07em; color: var(--text-3);
    margin-bottom: 2px; white-space: nowrap;
}
.stat-cell dd {
    margin: 0;
    font-family: 'Source Code Pro', monospace;
    font-size: 0.85rem; font-weight: 600; color: var(--text);
    font-variant-numeric: tabular-nums; white-space: nowrap;
}
.stat-sep { width: 1px; background: var(--border-light); flex-shrink: 0; }

/* ── Popups ──────────────────────────────────────────────────── */
.maplibregl-popup-content {
    font-family: 'Source Sans 3', system-ui, sans-serif;
    font-size: 13px;
    padding: 0;
    border-radius: var(--r);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    max-width: 290px;
    overflow: hidden;
    color: var(--text);
}
.maplibregl-popup-close-button {
    top: 7px; right: 9px;
    font-size: 1rem; color: var(--text-3); line-height: 1;
}

.pop-name {
    font-size: 0.93rem; font-weight: 700;
    padding: 10px 28px 4px 12px;
    color: var(--text); line-height: 1.25;
}
.pop-crumb {
    display: flex; align-items: center; gap: 5px;
    padding: 0 12px 9px;
    font-size: 0.72rem; color: var(--text-2);
    border-bottom: 1px solid var(--border-light);
}
.pop-crumb-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.pop-crumb-sep { color: var(--text-3); }

.pop-conf {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
}
.pop-conf-label {
    font-size: 0.68rem; text-transform: uppercase;
    letter-spacing: 0.07em; color: var(--text-3); flex-shrink: 0;
}
.conf-bar-bg {
    flex: 1; height: 5px;
    background: var(--border-light);
    border-radius: 3px; overflow: hidden;
}
.conf-bar-fill { height: 100%; border-radius: 3px; }
.pop-conf-val {
    font-family: 'Source Code Pro', monospace;
    font-size: 0.78rem; font-weight: 600;
    min-width: 38px; text-align: right; flex-shrink: 0;
}

.pop-sources {
    display: flex; flex-wrap: wrap; gap: 5px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
}
.src-badge {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 0.67rem; font-weight: 700;
    padding: 3px 8px; border-radius: 3px; border: 1px solid;
    text-transform: uppercase; letter-spacing: 0.03em;
}
.src-osm      { background: #fff7ed; color: #92400e; border-color: #fcd34d; }
.src-overture { background: #f0fdf4; color: #166534; border-color: #86efac; }
.src-merged   { background: #eff6ff; color: #1d4ed8; border-color: #93c5fd; }
.src-wikidata { background: #fdf4ff; color: #6b21a8; border-color: #d8b4fe; }

.pop-attrs {
    padding: 8px 12px 11px;
    display: flex; flex-direction: column; gap: 4px;
}
.attr-row { display: flex; gap: 8px; font-size: 0.75rem; }
.attr-key {
    color: var(--text-3); min-width: 46px; flex-shrink: 0;
    font-size: 0.67rem; text-transform: uppercase;
    letter-spacing: 0.05em; padding-top: 1px;
}
.attr-val { color: var(--text); }
.attr-link { color: #0074d9; text-decoration: none; }
.attr-link:hover { text-decoration: underline; }
