/* =============================================================================
   Kilifi Atlas — walterland.app
   Sahara-fieldwork theme: cream backgrounds, burnt-umber accents,
   structured typography, polished cards.
   ============================================================================= */

:root {
  --bg-app:        #F3ECDD;
  --bg-panel:      #F7EFE0;
  --bg-panel-alt:  #EDE3CC;
  --border:        #D0BD96;
  --border-soft:   #E4D6B8;
  --text:          #211C12;
  --text-soft:     #4A4232;
  --text-faint:    #8A7C60;
  --brand:         #211C12;
  --brand-soft:    #4A4232;
  --accent:        #C2641E;
  --accent-deep:   #B14A22;
  --ochre:         #E8A53A;
  --shadow-card:   0 1px 2px rgba(33, 28, 18, 0.06), 0 6px 16px rgba(33, 28, 18, 0.10);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: 'Hanken Grotesk', -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  display: flex;
  background: var(--bg-app);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* =============================================================================
   SIDEBAR
   ============================================================================= */

#sidebar {
  width: 340px;
  flex-shrink: 0;
  padding: 20px 22px 24px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#sidebar::-webkit-scrollbar { width: 6px; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
#sidebar > * { flex-shrink: 0; }

/* ---- Hero / brand ---- */
.hero { padding-bottom: 4px; }
.brand-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}
.brand-mark {
  font-size: 16px;
  color: var(--accent);
  line-height: 1;
}
.brand {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--text-faint);
}
.hero h1 {
  font-family: 'Archivo', sans-serif;
  font-size: 24px;
  font-weight: 800;
  color: var(--brand);
  margin-bottom: 6px;
  letter-spacing: -0.6px;
}
.tagline {
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.5;
}

/* ---- CTA card ---- */
.cta {
  display: block;
  text-decoration: none;
  color: inherit;
  background: linear-gradient(135deg, #2A2417 0%, #1A160E 100%);
  color: #F3ECDD;
  padding: 16px 18px;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.cta::before {
  content: '';
  position: absolute;
  top: 0; right: 0; width: 70px; height: 100%;
  background: linear-gradient(90deg, transparent 0%, rgba(232, 165, 58, 0.22) 100%);
  pointer-events: none;
}
.cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(91, 58, 29, 0.1), 0 8px 18px rgba(91, 58, 29, 0.14);
}
.cta-eyebrow {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--ochre);
  margin-bottom: 8px;
}
.cta-title {
  font-family: 'Archivo', sans-serif;
  font-size: 19px;
  font-weight: 800;
  line-height: 1.04;
  margin-bottom: 8px;
  letter-spacing: -0.4px;
}
.cta-sub {
  font-size: 11.5px;
  color: rgba(243, 236, 221, 0.74);
  line-height: 1.5;
  margin-bottom: 12px;
}
.cta-arrow {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--ochre);
  letter-spacing: 0.2px;
}

/* ---- Start-here block ---- */
.start-here {
  background: var(--bg-panel-alt);
  border-left: 3px solid var(--accent);
  padding: 12px 14px 12px 16px;
  border-radius: 0 6px 6px 0;
}
.start-here h2 {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--accent-deep);
  margin-bottom: 8px;
}
.start-here ol {
  margin: 0;
  padding-left: 18px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text-soft);
}
.start-here li { margin-bottom: 3px; }
.start-here strong { color: var(--brand); font-weight: 600; }

/* ---- Layer groups ---- */
.group h2, .legend h2 {
  font-family: 'Space Mono', monospace;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.3px;
  color: var(--text-faint);
  margin-bottom: 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border-soft);
}

.group label {
  display: block;
  font-size: 11.5px;
  padding: 3px 6px 3px 4px;
  margin: 0 -6px 0 -4px;
  cursor: pointer;
  color: var(--text);
  line-height: 1.35;
  border-radius: 4px;
  transition: background 0.1s ease;
}
.group label:hover {
  background: var(--bg-panel-alt);
}
.group input {
  margin-right: 8px;
  vertical-align: -1px;
  accent-color: var(--accent);
  cursor: pointer;
}
.muted {
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 400;
  margin-left: 3px;
}

/* ---- Layers disclosure (collapsed by default — keeps landing page clean) ---- */
.layers-panel {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-panel);
  overflow: hidden;
}
.layers-panel summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 14px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.3px;
  color: var(--text-soft);
  background: var(--bg-panel-alt);
  transition: background 0.15s ease;
}
.layers-panel summary::-webkit-details-marker { display: none; }
.layers-panel summary:hover { background: #efe4cc; }
.layers-panel summary::after {
  content: '+';
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
  color: var(--accent);
  transition: transform 0.2s ease;
}
.layers-panel[open] summary::after { transform: rotate(45deg); }
.layers-panel[open] summary { border-bottom: 1px solid var(--border-soft); }
.layers-count {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-faint);
  letter-spacing: 0.4px;
  text-transform: none;
  margin-left: auto;
  margin-right: 10px;
}
.layers-label { flex: 0 0 auto; }
.layers-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---- Legend ---- */
.legend ul { list-style: none; }
.legend li {
  display: flex;
  align-items: center;
  font-size: 10.5px;
  padding: 3px 0;
  color: var(--text-soft);
  line-height: 1.3;
}
.legend .swatch {
  width: 13px;
  height: 13px;
  border-radius: 2px;
  margin-right: 8px;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.2);
}

/* ---- Footer ---- */
#sidebar footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#sidebar footer small {
  font-size: 10px;
  color: var(--text-faint);
  line-height: 1.55;
}
#sidebar footer small strong { color: var(--brand); font-weight: 600; }

/* =============================================================================
   MAP
   ============================================================================= */

#map { flex: 1; height: 100vh; position: relative; }

/* =============================================================================
   POPUP CARDS — restructured as definition lists with type pills
   ============================================================================= */

.maplibregl-popup { z-index: 50; }

.maplibregl-popup-content {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  padding: 0;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(91, 58, 29, 0.18), 0 1px 3px rgba(91, 58, 29, 0.1);
  border: 1px solid var(--border);
  max-width: 290px;
  overflow: hidden;
}

.popup-card { font-size: 12px; line-height: 1.5; color: var(--text); }

.popup-card .pill {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--accent-deep);
  background: rgba(196, 109, 61, 0.13);
  padding: 3px 8px;
  border-radius: 3px;
  margin: 12px 14px 0;
}

.popup-card h3 {
  margin: 6px 14px 2px;
  font-size: 14px;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: -0.1px;
  line-height: 1.3;
}

.popup-card .subtitle {
  margin: 0 14px 10px;
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.4;
}

.popup-card dl {
  margin: 0;
  padding: 10px 14px 12px;
  background: var(--bg-panel-alt);
  border-top: 1px solid var(--border-soft);
  display: grid;
  grid-template-columns: minmax(0, auto) 1fr;
  gap: 4px 14px;
  font-size: 11.5px;
}
.popup-card dt {
  color: var(--text-faint);
  font-weight: 500;
  font-size: 11px;
}
.popup-card dd {
  margin: 0;
  color: var(--text);
  font-weight: 500;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.popup-card dd b { color: var(--brand); font-weight: 700; }

.popup-card .status {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  text-align: left;
}
.popup-card .yes { color: #2d6a31; background: #e0eedb; }
.popup-card .no  { color: #8b3000; background: #f3dccb; }

.maplibregl-popup-close-button {
  font-size: 18px;
  padding: 4px 8px;
  color: var(--text-faint);
  border-radius: 0 0 0 4px;
}
.maplibregl-popup-close-button:hover {
  background: transparent;
  color: var(--brand);
}

/* =============================================================================
   MAP CONTROLS
   ============================================================================= */

.maplibregl-ctrl-group {
  border-radius: 6px !important;
  box-shadow: var(--shadow-card) !important;
  overflow: hidden;
}
.maplibregl-ctrl-group button {
  background: var(--bg-panel) !important;
  border-bottom: 1px solid var(--border-soft) !important;
}
.maplibregl-ctrl-scale {
  background: rgba(255, 251, 240, 0.85) !important;
  border-color: var(--border) !important;
  font-size: 10px !important;
  color: var(--text-soft) !important;
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

@media (max-width: 720px) {
  body { flex-direction: column; }
  #sidebar { width: 100%; height: auto; max-height: 60vh; }
  #map { height: 40vh; }
}
