:root {
  --ink: #1b1b1b;
  --muted: #666;
  --accent: #2e7d32;
  --bg: #fafaf7;
  --border: #ddd;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

header {
  padding: 1.25rem 1.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.subtitle a {
  color: var(--accent);
}

main {
  padding: 0;
}

#map-wrap {
  position: relative;
  height: 78vh;
  width: 100%;
  overflow: hidden;
}

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

/* Detail panel */
.detail-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(400px, 92%);
  height: 100%;
  background: #fff;
  box-shadow: -2px 0 10px rgba(0,0,0,0.25);
  transform: translateX(100%);
  transition: transform 0.2s ease-out;
  z-index: 1000;
  overflow-y: auto;
  padding: 1rem 1.25rem 1.5rem;
}

.detail-panel.open {
  transform: translateX(0);
}

.detail-close {
  position: sticky;
  top: 0;
  float: right;
  margin-top: -0.25rem;
  border: none;
  background: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0.25rem 0.4rem;
}

.detail-close:hover {
  color: var(--ink);
}

footer {
  padding: 0.75rem 1.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

footer a {
  color: var(--accent);
}

/* Year controls */
#controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.5rem;
  background: #fff;
  border-top: 1px solid var(--border);
}

#play-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  border-radius: 50%;
  width: 2rem;
  height: 2rem;
  flex: 0 0 auto;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
}

#play-btn:hover {
  background: #f2f2f0;
}

#year-slider {
  flex: 1 1 auto;
  accent-color: var(--accent);
}

#year-label {
  flex: 0 0 auto;
  min-width: 3rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--muted);
}

/* Marker */
.ge-marker span {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.25);
}

/* Marker hover label: crop name on top, innovation name as a smaller
   subtitle underneath, so two pins sharing a crop (e.g. two rice
   varieties) are still distinguishable without clicking. */
.ge-label {
  text-align: center;
}

.ge-label .tooltip-subtitle {
  display: block;
  font-size: 0.75em;
  color: var(--muted);
  font-weight: 400;
}

/* Legend */
.legend {
  background: #fff;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  font-size: 0.8rem;
  line-height: 1.6;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-item[title] {
  cursor: help;
}

.legend .swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.25);
  flex: 0 0 auto;
}

.legend-title {
  font-weight: 600;
  margin-bottom: 0.2rem;
}

/* Filter control + its description sit side by side in the top-right corner */
.leaflet-top.leaflet-right {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.filter-description {
  display: none;
  background: #fff;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  font-size: 0.8rem;
  color: var(--muted);
  max-width: 220px;
}

.filter-description.visible {
  display: block;
}

.filter-control {
  background: #fff;
  padding: 0.5rem;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.filter-title {
  font-weight: 600;
  padding: 0 0.2rem;
}

.filter-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  border-radius: 4px;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  text-align: left;
  cursor: pointer;
}

.filter-btn:hover {
  background: #f2f2f0;
}

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Detail content (reused inside the side panel) */
.popup h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--accent);
  word-break: break-word;
}

.popup .section {
  margin-bottom: 0.6rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.popup .section:last-of-type {
  border-bottom: none;
}

.popup h3 {
  margin: 0 0 0.3rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.popup .row {
  display: flex;
  gap: 0.5rem;
  font-size: 0.85rem;
  margin-bottom: 0.15rem;
}

.popup .row.notes {
  flex-direction: column;
  gap: 0.1rem;
}

.popup .label {
  flex: 0 0 auto;
  min-width: 8.5rem;
  font-weight: 600;
  color: var(--muted);
}

.popup .value {
  flex: 1 1 auto;
}

.popup .loc-note {
  margin: 0.4rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  font-style: italic;
}
