/* ───────────────── Reset & base ───────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0b0f17;
  --panel: rgba(17, 22, 33, 0.92);
  --panel-solid: #111621;
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #e7ecf3;
  --text-dim: #a1adbe;
  --text-mute: #6c7689;
  --accent: #4cc2ff;
  --accent-dim: rgba(76, 194, 255, 0.15);

  --built: #22c55e;        /* green */
  --construction: #f59e0b; /* amber */
  --proposed: #ef4444;     /* red */
  --scouted: #e879f9;      /* magenta — scouted / marketed */
  --defeated: #38bdf8;     /* bright sky blue — community victory */
  --opposition: #c084fc;   /* purple — active opposition ring */

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-lg: 0 20px 50px -10px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255,255,255,0.04);
  --shadow-md: 0 8px 24px -6px rgba(0, 0, 0, 0.4);
}

html, body {
  height: 100%;
  width: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ───────────────── Map ───────────────── */
#map {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #0a0d14;
}

.leaflet-container {
  font-family: inherit;
  background: #0a0d14;
}

/* Tone down attribution */
.leaflet-control-attribution {
  background: rgba(11, 15, 23, 0.7) !important;
  color: var(--text-mute) !important;
  font-size: 10px !important;
  backdrop-filter: blur(6px);
}
.leaflet-control-attribution a { color: var(--text-dim) !important; }

.leaflet-control-zoom a {
  background: var(--panel-solid) !important;
  color: var(--text) !important;
  border: 1px solid var(--panel-border) !important;
  border-radius: 8px !important;
  margin-bottom: 4px !important;
  width: 32px !important;
  height: 32px !important;
  line-height: 30px !important;
  box-shadow: var(--shadow-md);
}
.leaflet-control-zoom a:hover {
  background: #1a2233 !important;
  color: var(--accent) !important;
}
.leaflet-control-zoom {
  border: none !important;
  margin-bottom: 30px !important;
  margin-right: 16px !important;
}

/* ───────────────── Map pins ───────────────── */
.pin {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid #0b0f17;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.1);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
}
.pin:hover { transform: scale(1.25); }
.pin-built { background: var(--built); }
.pin-construction { background: var(--construction); }
.pin-proposed { background: var(--proposed); }
.pin-scouted {
  background: var(--scouted);
  position: relative;
}
.pin-scouted::before {
  content: '?';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #0b0f17;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}
.pin-defeated {
  background: var(--defeated);
  position: relative;
}
/* Checkmark overlay on defeated pins */
.pin-defeated::before {
  content: '';
  position: absolute;
  inset: 3px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'><polyline points='20 6 9 17 4 12'/></svg>");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

/* Pulsing ring for proposed/construction */
.pin-pulse {
  position: relative;
}
.pin-pulse::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid currentColor;
  opacity: 0;
  animation: pulse 2s ease-out infinite;
}
.pin-construction.pin-pulse { color: var(--construction); }
.pin-proposed.pin-pulse { color: var(--proposed); }
.pin-scouted.pin-pulse { color: var(--scouted); }

/* Opposition ring: persistent purple ring around any pin where
   organized community resistance is active. */
.pin-opposition::before {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2.5px dashed var(--opposition);
  pointer-events: none;
  opacity: 0.95;
  animation: spin 14s linear infinite;
}
.pin {
  position: relative;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes pulse {
  0%   { transform: scale(0.7); opacity: 0.8; }
  100% { transform: scale(1.8); opacity: 0; }
}

.pin-selected {
  transform: scale(1.4);
  box-shadow: 0 0 0 4px rgba(76, 194, 255, 0.35), 0 4px 14px rgba(0,0,0,0.7);
}

/* Popup styling */
.leaflet-popup-content-wrapper {
  background: var(--panel-solid) !important;
  color: var(--text) !important;
  border-radius: 10px !important;
  box-shadow: var(--shadow-md) !important;
  border: 1px solid var(--panel-border);
  padding: 0;
}
.leaflet-popup-tip { background: var(--panel-solid) !important; border: 1px solid var(--panel-border); }
.leaflet-popup-content { margin: 12px 14px !important; min-width: 200px; }
.leaflet-popup-content h4 { font-size: 14px; margin-bottom: 4px; }
.leaflet-popup-content p { color: var(--text-dim); font-size: 12px; }
.leaflet-popup-content .popup-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 5px 10px;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
}
.leaflet-popup-close-button { color: var(--text-mute) !important; }

/* ───────────────── Top bar ───────────────── */
.top-bar {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
}

.title-block {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.logo-dot {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent) 0%, #2563eb 100%);
  box-shadow: 0 0 16px rgba(76, 194, 255, 0.4);
  position: relative;
}
.logo-dot::after {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 4px;
  background: var(--bg);
}
.logo-dot::before {
  content: '';
  position: absolute;
  inset: 10px;
  border-radius: 2px;
  background: var(--accent);
  z-index: 1;
}

.title-block h1 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.subtitle { font-size: 11px; color: var(--text-mute); margin-top: 1px; }

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-mute);
  pointer-events: none;
}
#search {
  padding: 8px 12px 8px 32px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 8px;
  font-size: 13px;
  width: 240px;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}
#search:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(76, 194, 255, 0.05);
}
#search::placeholder { color: var(--text-mute); }

.filter-group {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.04);
  padding: 3px;
  border-radius: 9px;
  border: 1px solid var(--panel-border);
}
.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.filter-btn:hover { color: var(--text); }
.filter-btn.active {
  background: var(--panel-solid);
  color: var(--text);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.count {
  background: rgba(255,255,255,0.07);
  color: var(--text-mute);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 600;
}
.filter-btn.active .count {
  background: var(--accent-dim);
  color: var(--accent);
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-built { background: var(--built); box-shadow: 0 0 6px rgba(34,197,94,0.4); }
.dot-construction { background: var(--construction); box-shadow: 0 0 6px rgba(245,158,11,0.4); }
.dot-proposed { background: var(--proposed); box-shadow: 0 0 6px rgba(239,68,68,0.4); }
.dot-scouted { background: var(--scouted); box-shadow: 0 0 6px rgba(232,121,249,0.5); }
.dot-defeated { background: var(--defeated); box-shadow: 0 0 6px rgba(56,189,248,0.5); }
.dot-opposition { background: var(--opposition); box-shadow: 0 0 6px rgba(192,132,252,0.5); }

.opp-ring {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px dashed var(--opposition);
  flex-shrink: 0;
}
.legend-check { color: var(--defeated); font-weight: 700; margin-left: 4px; }
.legend-note { font-size: 12px; color: var(--text-mute); margin-top: 4px; }

/* ───────────────── Sidebar ───────────────── */
.sidebar {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  max-width: 92vw;
  z-index: 999;
  background: var(--panel);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-left: 1px solid var(--panel-border);
  box-shadow: -20px 0 50px -10px rgba(0,0,0,0.6);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
  padding: 88px 0 0 0;
}

.sidebar.collapsed { transform: translateX(100%); }

.sidebar-toggle {
  position: absolute;
  left: -32px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 56px;
  background: var(--panel-solid);
  border: 1px solid var(--panel-border);
  border-right: none;
  border-radius: 8px 0 0 8px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: -4px 0 12px rgba(0,0,0,0.3);
  transition: background 0.15s;
}
.sidebar-toggle:hover { background: #1a2233; color: var(--accent); }
.sidebar-toggle svg { transition: transform 0.3s; }
.sidebar.collapsed .sidebar-toggle svg { transform: rotate(180deg); }

.sidebar-empty,
.sidebar-details {
  padding: 20px 22px 24px;
  overflow-y: auto;
  flex: 1;
}

/* Scrollbar */
.sidebar-empty::-webkit-scrollbar,
.sidebar-details::-webkit-scrollbar { width: 8px; }
.sidebar-empty::-webkit-scrollbar-thumb,
.sidebar-details::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.08);
  border-radius: 4px;
}
.sidebar-empty::-webkit-scrollbar-thumb:hover,
.sidebar-details::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.15);
}

/* Empty state */
.empty-illustration {
  color: var(--text-mute);
  opacity: 0.4;
  margin: 8px 0 12px;
}
.sidebar-empty h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
}
.sidebar-empty > p {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 20px;
}

.legend {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 20px;
}
.legend h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-mute);
  margin-bottom: 10px;
  font-weight: 600;
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-dim);
  padding: 4px 0;
}

.featured-list h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-mute);
  margin-bottom: 10px;
  font-weight: 600;
}
.featured-list ul { list-style: none; }
.featured-list li {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
}
.featured-list li:hover {
  background: rgba(255,255,255,0.04);
  border-color: var(--panel-border);
}
.featured-list .li-name { flex: 1; color: var(--text); font-weight: 500; }
.featured-list .li-loc { color: var(--text-mute); font-size: 11px; }

/* Details */
.sidebar-header { margin-bottom: 18px; }
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}
.status-built { background: rgba(34,197,94,0.12); color: #4ade80; }
.status-built::before { content: '●'; }
.status-construction { background: rgba(245,158,11,0.12); color: #fbbf24; }
.status-construction::before { content: '●'; }
.status-proposed { background: rgba(239,68,68,0.12); color: #f87171; }
.status-proposed::before { content: '●'; }
.status-scouted { background: rgba(232,121,249,0.13); color: #f0abfc; }
.status-scouted::before { content: '?'; font-size: 13px; }
.status-defeated { background: rgba(56,189,248,0.15); color: #7dd3fc; }
.status-defeated::before { content: '✓'; font-size: 13px; }

#detail-name {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.muted { color: var(--text-mute); font-size: 13px; }

.county-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 3px 9px;
  background: rgba(76, 194, 255, 0.08);
  color: var(--accent);
  border: 1px solid rgba(76, 194, 255, 0.18);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.county-tag::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* ─── Victory block (defeated projects) ─── */
.victory-block {
  background: linear-gradient(135deg, rgba(56,189,248,0.12) 0%, rgba(56,189,248,0.02) 100%);
  border: 1px solid rgba(56,189,248,0.40);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  box-shadow: 0 0 20px rgba(56,189,248,0.10), inset 0 1px 0 rgba(255,255,255,0.04);
}
.victory-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #7dd3fc;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}
.victory-row {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 10px;
  padding: 4px 0;
  font-size: 13px;
  line-height: 1.45;
}
.victory-row .label {
  color: var(--text-mute);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  padding-top: 2px;
}
.victory-row .value { color: var(--text); }

/* ─── Opposition card ─── */
.opposition-section h3 svg { color: var(--opposition); }
.opposition-card {
  background: linear-gradient(135deg, rgba(192,132,252,0.07) 0%, rgba(192,132,252,0.02) 100%);
  border: 1px solid rgba(192,132,252,0.28);
  border-radius: 10px;
  padding: 12px 14px;
}
.opposition-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text) !important;
  text-decoration: none !important;
  margin-bottom: 6px;
}
.opposition-group:hover { color: #c084fc !important; }
.opposition-group .arrow { color: var(--opposition); margin-left: auto; }
.opposition-meta {
  font-size: 11px;
  color: var(--text-mute);
  margin-bottom: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.opposition-meta span {
  background: rgba(255,255,255,0.04);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
}
.opposition-focus {
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 8px;
}
.opposition-wins {
  list-style: none;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px dashed rgba(192,132,252,0.25);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.opposition-wins li {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.45;
  padding-left: 18px;
  position: relative;
}
.opposition-wins li::before {
  content: '✓';
  position: absolute;
  left: 0;
  top: 0;
  color: #7dd3fc;
  font-weight: 700;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.detail-cell {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.detail-cell .label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-mute);
  font-weight: 600;
}
.detail-cell .value {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}

.summary {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-dim);
  margin-bottom: 22px;
  padding: 12px 14px;
  background: rgba(76, 194, 255, 0.04);
  border-left: 2px solid var(--accent);
  border-radius: 0 8px 8px 0;
}

.section { margin-bottom: 22px; }
.section h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-mute);
  margin-bottom: 10px;
  font-weight: 600;
}

.article-list,
.forum-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.article-list a,
.forum-list a {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  transition: all 0.15s;
  font-size: 13px;
  line-height: 1.4;
}
.article-list a:hover,
.forum-list a:hover {
  background: rgba(76, 194, 255, 0.07);
  border-color: rgba(76, 194, 255, 0.3);
  text-decoration: none;
  transform: translateX(-2px);
}
.article-list .arrow,
.forum-list .arrow {
  color: var(--text-mute);
  flex-shrink: 0;
  margin-top: 2px;
  transition: color 0.15s, transform 0.15s;
}
.article-list a:hover .arrow,
.forum-list a:hover .arrow {
  color: var(--accent);
  transform: translate(2px, -2px);
}
.article-list .article-title { flex: 1; font-weight: 500; }
.article-list .article-outlet {
  display: block;
  color: var(--text-mute);
  font-size: 11px;
  margin-top: 2px;
  font-weight: 400;
}
.forum-list .forum-title { flex: 1; }

.disclaimer {
  margin-top: 18px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.02);
  border: 1px dashed var(--panel-border);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-mute);
  line-height: 1.5;
}

/* Footer credit */
.footer-credit {
  position: absolute;
  bottom: 6px;
  left: 16px;
  z-index: 500;
  font-size: 10px;
  color: var(--text-mute);
  background: rgba(11, 15, 23, 0.7);
  padding: 4px 10px;
  border-radius: 6px;
  backdrop-filter: blur(6px);
}
.footer-credit a { color: var(--text-dim); }

/* ───────────────── Responsive ───────────────── */
@media (max-width: 900px) {
  .top-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 10px 12px;
  }
  .controls { width: 100%; flex-wrap: wrap; }
  #search { width: 100%; min-width: 0; flex: 1; }
  .filter-group { width: 100%; justify-content: space-between; }
  .filter-btn { flex: 1; justify-content: center; }
  .sidebar { width: 100vw; padding-top: 140px; }
  .sidebar-toggle { left: 50%; top: 0; transform: translate(-50%, -100%); border-radius: 8px 8px 0 0; border: 1px solid var(--panel-border); border-bottom: none; width: 56px; height: 28px; }
  .sidebar.collapsed .sidebar-toggle svg { transform: rotate(-90deg); }
  .sidebar-toggle svg { transform: rotate(90deg); }
  .footer-credit { display: none; }
}

@media (max-width: 500px) {
  .title-block h1 { font-size: 14px; }
  .subtitle { display: none; }
  .filter-btn { font-size: 11px; padding: 6px 8px; }
  .count { display: none; }
}
