@import url("https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=DM+Sans:wght@300;400;500&display=swap");

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

:root {
  /* --bg: #0e1117; */
  /* --surface: #161b26; */
  --bg: #7dc87d;
  --surface: #e5f6d1;
  --panel: #c7854b;
  --border: #2a3450;
  --muted: #e8eaf0;
  --text: #ffffff;
  /* --accent: #f0a500; */
  --accent: rgba(28, 35, 51, 0.92);
  --accent2: #e05a2b;

  /* Family colors */
  --niger-congo: #e05a2b;
  --afro-asiatic: #3b9ede;
  --nilo-saharan: #7dc87d;
  --ubangian: #b07fd4;
  --unclassified: #a0a0a0;
}

html,
body {
  height: 100%;
  font-family: "DM Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ── Header ── */
#header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1100;
  height: 56px;
  background: #c7854b;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  backdrop-filter: blur(12px);
}
#header .logo {
  font-family: "Playfair Display", serif;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
#header .subtitle {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 300;
  border-left: 1px solid var(--border);
  padding-left: 16px;
}
#header .counter {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 20px;
}
#header .counter span {
  color: var(--accent);
  font-weight: 600;
}

/* ── Map ── */
#map {
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
}

/* ── Search ── */
#search-wrap {
  position: fixed;
  top: 72px;
  left: 16px;
  margin-left: 36px;
  z-index: 1000;
  display: flex;
  gap: 8px;
}
#search-input {
  width: 220px;
  padding: 8px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: "DM Sans", sans-serif;
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.2s;
}
#search-input:focus {
  border-color: #f0a500;
}
#search-input::placeholder {
  color: var(--muted);
}

/* ── View switcher ── */
#view-switcher {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: min(720px, calc(100vw - 360px));
}
.view-btn {
  border: 1px solid var(--border);
  background: rgba(28, 35, 51, 0.92);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition:
    transform 0.18s,
    border-color 0.18s,
    color 0.18s,
    background 0.18s;
  backdrop-filter: blur(12px);
}
.view-btn:hover {
  transform: translateY(-1px);
  color: var(--text);
}
.view-btn.active {
  background: #f0a500;
  border-color: #f0a500;
  color: #0e1117;
  font-weight: 700;
}

/* ── Brand mark ── */
#brand-mark {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 1000;
  width: 204px;
  padding: 10px 10px 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  background: rgb(255, 255, 255);
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
}
#brand-mark img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

/* ── Legend ── */
#legend {
  position: fixed;
  bottom: 136px;
  left: 16px;
  z-index: 1000;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  min-width: 200px;
}
#legend h4 {
  font-family: "Playfair Display", serif;
  font-size: 0.8rem;
  color: var(--accent);
  margin-bottom: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 7px;
  font-size: 0.75rem;
  color: var(--text);
}
.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.15);
}
.legend-vitality {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.vit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 5px;
}
.vit-icon {
  font-size: 0.9rem;
}

/* ── Info Panel (sidebar) ── */
#info-panel {
  position: fixed;
  top: 56px;
  right: -360px;
  bottom: 0;
  width: 340px;
  z-index: 1050;
  background: rgba(28, 35, 51, 0.92);
  border-left: 1px solid var(--border);
  transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  padding: 28px 24px;
}
#info-panel.open {
  right: 0;
}

#info-panel .close-btn {
  position: absolute;
  top: 14px;
  right: 16px;
  background: var(--border);
  border: none;
  color: var(--text);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
#info-panel .close-btn:hover {
  background: var(--accent2);
}

#info-panel .lang-family-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 14px;
}
#info-panel h2 {
  font-family: "Playfair Display", serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
#info-panel .lang-iso {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 18px;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
.info-card {
  background: rgba(28, 35, 51, 0.92);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}
.info-card .label {
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 5px;
}
.info-card .value {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
}
.info-card.full {
  grid-column: 1 / -1;
}

.vitality-bar-wrap {
  margin-top: 2px;
}
.vitality-bar {
  height: 6px;
  border-radius: 3px;
  margin-top: 6px;
  background: var(--border);
  overflow: hidden;
}
.vitality-fill {
  height: 100%;
  border-radius: 3px;
}

.info-section-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
  margin-top: 4px;
}
.region-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.region-tag {
  background: rgba(28, 35, 51, 0.92);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 0.71rem;
  color: var(--muted);
}

/* ── Filter bar ── */
#filters {
  position: fixed;
  top: 72px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.filter-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-family: "DM Sans", sans-serif;
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.filter-btn .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}
.filter-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}
.filter-btn:not(.active) {
  opacity: 0.5;
}

/* ── Zoom hint ── */
#zoom-hint {
  position: fixed;
  bottom: 24px;
  right: 16px;
  z-index: 1000;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.7rem;
  color: var(--muted);
  pointer-events: none;
}

@media (max-width: 900px) {
  #view-switcher {
    top: 114px;
    left: 16px;
    transform: none;
    max-width: calc(100vw - 32px);
    justify-content: flex-start;
  }
  #filters {
    top: 114px;
  }
}

/* ──────────────────────────────────────────────────────────────────── */
/* MOBILE RESPONSIVE (max-width: 768px) */
/* ──────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Header — more compact */
  #header {
    height: 48px;
    padding: 0 12px;
    gap: 10px;
  }
  #header .logo {
    font-size: 1rem;
  }
  #header .subtitle {
    display: none;
  }
  #header .counter {
    font-size: 0.65rem;
    padding: 3px 8px;
  }

  /* Map — adjust top offset */
  #map {
    top: 48px;
  }

  /* Search — more mobile-friendly */
  #search-wrap {
    top: 58px;
    left: 8px;
    margin-left: 0;
    gap: 6px;
  }
  #search-input {
    width: 160px;
    padding: 6px 10px;
    font-size: 0.75rem;
    margin-left: 36px;
  }

  /* View switcher — stacked vertically on tight screens */
  #view-switcher {
    top: 58px;
    left: 50%;
    transform: translateX(-50%);
    flex-wrap: wrap;
    gap: 6px;
    max-width: calc(100vw - 32px);
  }
  .view-btn {
    padding: 6px 12px;
    font-size: 0.68rem;
  }

  /* Hide filters on mobile */
  #filters {
    display: none;
  }

  /* Hide legend on mobile */
  #legend {
    display: none;
  }

  /* Reduce brand mark logo size */
  #brand-mark {
    width: 140px;
    padding: 7px 7px 5px;
    bottom: 12px;
    left: 8px;
  }

  /* Info panel — full width on mobile */
  #info-panel {
    width: 100%;
    right: -100% !important;
    transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  }
  #info-panel.open {
    right: 0 !important;
  }
  #info-panel h2 {
    font-size: 1.25rem;
  }

  /* Hide zoom hint on small screens */
  #zoom-hint {
    display: none;
  }

  /* Adjust info grid for mobile */
  .info-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .info-card .label {
    font-size: 0.6rem;
  }
  .info-card .value {
    font-size: 0.85rem;
  }
}

/* Very small screens (max-width: 500px) */
@media (max-width: 500px) {
  #header .counter {
    display: none;
  }

  #search-wrap {
    top: 54px;
  }

  #search-input {
    width: 140px;
    padding: 5px 8px;
    font-size: 0.7rem;
  }

  #view-switcher {
    display: none;
  }

  #brand-mark {
    width: 120px;
    bottom: 8px;
    left: 4px;
    border-radius: 14px;
    padding: 5px 5px 3px;
  }

  #info-panel {
    padding: 20px 16px;
  }
  #info-panel .close-btn {
    width: 24px;
    height: 24px;
    font-size: 0.8rem;
  }
  #info-panel h2 {
    font-size: 1.1rem;
    margin-bottom: 8px;
  }
  #info-panel .lang-iso {
    margin-bottom: 12px;
  }
}

/* ── Custom cluster styles ── */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background: transparent !important;
}
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background: rgba(240, 165, 0, 0.92) !important;
  color: #0e1117 !important;
  font-family: "DM Sans", sans-serif !important;
  font-weight: 700 !important;
  font-size: 0.8rem !important;
  border: 2px solid rgba(255, 255, 255, 0.3) !important;
}

/* ── Leaflet overrides ── */
.leaflet-control-zoom a {
  background: var(--panel) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
.leaflet-control-zoom a:hover {
  background: var(--border) !important;
}
.leaflet-control-attribution {
  background: rgba(14, 17, 23, 0.8) !important;
  color: var(--muted) !important;
  font-size: 0.6rem !important;
}
.leaflet-control-attribution a {
  color: var(--accent) !important;
}

.leaflet-control-layers {
  background: rgba(22, 27, 38, 0.95) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: 12px !important;
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.22) !important;
}
.leaflet-control-layers-toggle {
  filter: brightness(0.98) contrast(1.05);
}

/* Custom marker pulse */
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(1.25);
  }
}

/* Scrollbar */
#info-panel::-webkit-scrollbar {
  width: 4px;
}
#info-panel::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}
