@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: #f9fafb;
  color: #111827;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Header ──────────────────────────────────────────────────────────── */
header {
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  padding: 12px 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #111827;
  text-align: center;
  letter-spacing: -0.02em;
}

#controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

#filters {
  display: flex;
  flex: 1;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

#year-inputs {
  display: flex;
  gap: 6px;
  flex: 1;
}

#year-inputs input {
  flex: 1;
  min-width: 70px;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  color: #111827;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 7px 10px;
  outline: none;
}

#year-inputs input:focus {
  border-color: #6b7280;
}

/* ── Custom dropdown ─────────────────────────────────────────────────── */
.custom-select {
  position: relative;
  flex: 2;
  min-width: 130px;
  user-select: none;
}

.custom-select-selected {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
  color: #111827;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
}

.custom-select-selected:after {
  content: "▾";
  margin-left: auto;
  color: #6b7280;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.custom-select-options {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
  z-index: 100;
  overflow-y: auto;
  max-height: 260px;
}

.custom-select-options.hidden {
  display: none;
}

.custom-option {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
  color: #111827;
  cursor: pointer;
}

.custom-option:hover {
  background: #f9fafb;
}

.custom-option + .custom-option {
  border-top: 1px solid #f3f4f6;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.12);
}

/* ── Locate button ───────────────────────────────────────────────────── */
#locate-btn {
  background: #111827;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 7px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s;
}

#locate-btn:active { opacity: 0.8; }
#locate-btn.active { background: #3b82f6; }

/* ── Map wrapper ─────────────────────────────────────────────────────── */
#map-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
}

/* ── Status pill ─────────────────────────────────────────────────────── */
#status {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.93);
  color: #374151;
  border: 1px solid #e5e7eb;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

#status.hidden { display: none; }

/* ── Popup card ──────────────────────────────────────────────────────── */
#popup-card {
  position: absolute;
  width: min(320px, calc(100vw - 32px));
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.13), 0 2px 8px rgba(0,0,0,0.07);
  overflow: hidden;
  z-index: 10;
  pointer-events: auto;
}

#popup-card.hidden { display: none; }

#popup-species {
  font-size: 1rem;
  font-weight: 700;
  color: #111827;
  padding: 14px 16px 10px;
  border-bottom: 1px solid #f3f4f6;
}

#popup-details { padding: 6px 0; }

.popup-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  gap: 12px;
}

.popup-row + .popup-row { border-top: 1px solid #f9fafb; }

.popup-label {
  font-size: 0.88rem;
  color: #6b7280;
  font-weight: 500;
  white-space: nowrap;
}

.popup-value {
  font-size: 0.95rem;
  color: #111827;
  font-weight: 600;
  text-align: right;
}

/* ── Mobile popup ────────────────────────────────────────────────────── */
@media (max-width: 767px) {
  #popup-card {
    bottom: 72px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    top: auto !important;
  }
}

/* ── Live location dot ───────────────────────────────────────────────── */
.location-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #3b82f6;
  border: 3px solid #ffffff;
  box-shadow: 0 0 0 2px rgba(59,130,246,0.4);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 2px rgba(59,130,246,0.4); }
  50%  { box-shadow: 0 0 0 6px rgba(59,130,246,0.15); }
  100% { box-shadow: 0 0 0 2px rgba(59,130,246,0.4); }
}
