/* Vital City tokens */
:root {
  --vc-bg: #faf8f3;
  --vc-ink: #1a1a1a;
  --vc-muted: #666;
  --vc-rule: #e5e0d6;
  --vc-accent: #b8312f;
  --liquor: #b8312f;
  --cannabis: #2e7d4f;
  --tobacco: #c97a1f;
  --beer: #b8860b;
  --serif: 'Georgia', 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--vc-ink);
  background: var(--vc-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  padding: 18px 24px 12px;
  border-bottom: 1px solid var(--vc-rule);
  background: var(--vc-bg);
}
.wordmark {
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: 0.18em;
  font-size: 13px;
  color: var(--vc-accent);
  margin-bottom: 8px;
}
.title-block h1 {
  font-family: var(--serif);
  font-size: clamp(22px, 3.2vw, 32px);
  margin: 0 0 4px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.title-block .dek {
  margin: 0;
  color: var(--vc-muted);
  font-size: 14px;
  max-width: 70ch;
}
.methodology-link {
  position: absolute;
  top: 22px;
  right: 24px;
  font-size: 12px;
  color: var(--vc-muted);
  text-decoration: none;
  border-bottom: 1px solid var(--vc-muted);
}
.methodology-link:hover { color: var(--vc-ink); border-bottom-color: var(--vc-ink); }

#controls {
  padding: 12px 24px;
  background: #fff;
  border-bottom: 1px solid var(--vc-rule);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
}
.cat-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}
.cat-toggle input {
  accent-color: var(--vc-ink);
  width: 16px; height: 16px;
}
.cat-toggle .dot {
  display: inline-block;
  width: 11px; height: 11px;
  border-radius: 50%;
  border: 1.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
}
.cat-liquor   .dot { background: var(--liquor);   }
.cat-cannabis .dot { background: var(--cannabis); }
.cat-tobacco  .dot { background: var(--tobacco);  }
.cat-beer     .dot { background: var(--beer);     }
.cat-toggle .count {
  color: var(--vc-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.view-toggle {
  display: inline-flex;
  border: 1px solid var(--vc-rule);
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
}
.view-btn {
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  border: none;
  background: #fff;
  cursor: pointer;
  color: var(--vc-muted);
  border-right: 1px solid var(--vc-rule);
}
.view-btn:last-child { border-right: none; }
.view-btn.active {
  background: var(--vc-ink);
  color: #fff;
}

#borough-filter, #search {
  font: inherit;
  font-size: 14px;
  padding: 6px 10px;
  border: 1px solid var(--vc-rule);
  border-radius: 4px;
  background: #fff;
}
.search-wrap {
  position: relative;
  flex: 1;
  min-width: 180px;
  max-width: 360px;
}
#search { width: 100%; }
.suggestions {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--vc-rule);
  border-radius: 4px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
  max-height: 320px;
  overflow-y: auto;
  z-index: 1000;
}
.suggestion {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--vc-rule);
  font-size: 13px;
  line-height: 1.3;
}
.suggestion:last-child { border-bottom: none; }
.suggestion:hover, .suggestion.active { background: var(--vc-bg); }
.suggestion .s-dot {
  flex: 0 0 9px;
  width: 9px; height: 9px;
  border-radius: 50%;
}
.suggestion .s-text { min-width: 0; flex: 1; }
.suggestion .s-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.suggestion .s-addr {
  color: var(--vc-muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.suggestion mark { background: #fff3a0; color: inherit; padding: 0; }
#reset-btn {
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  border: 1px solid var(--vc-rule);
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
}
#reset-btn:hover { background: var(--vc-bg); }
.visible-count {
  font-size: 12px;
  color: var(--vc-muted);
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

#map {
  width: 100%;
  height: 60vh;
  min-height: 420px;
  position: relative;
}

.nearby-panel {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 500;
  width: 300px;
  max-height: calc(100% - 24px);
  background: #fff;
  border: 1px solid var(--vc-rule);
  border-radius: 6px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.nearby-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--vc-rule);
  background: var(--vc-bg);
}
.nearby-panel h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.3;
  font-weight: 700;
}
#nearby-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--vc-muted);
  padding: 0 4px;
}
#nearby-close:hover { color: var(--vc-ink); }
.nearby-summary {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--vc-muted);
  border-bottom: 1px solid var(--vc-rule);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
}
.nearby-summary .ns-cat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--vc-ink);
}
.nearby-summary .ns-cat .ns-dot {
  width: 8px; height: 8px; border-radius: 50%;
}
.nearby-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}
.nearby-list li {
  padding: 8px 12px;
  border-bottom: 1px solid var(--vc-rule);
  cursor: pointer;
  font-size: 13px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.nearby-list li:hover { background: var(--vc-bg); }
.nearby-list li:last-child { border-bottom: none; }
.nearby-list .nl-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex: 0 0 9px;
  margin-top: 4px;
}
.nearby-list .nl-text { min-width: 0; flex: 1; }
.nearby-list .nl-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nearby-list .nl-meta {
  font-size: 11px;
  color: var(--vc-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nearby-list .nl-dist {
  font-size: 11px;
  color: var(--vc-muted);
  font-variant-numeric: tabular-nums;
  margin-left: 6px;
  flex-shrink: 0;
}

@media (max-width: 700px) {
  .nearby-panel { width: calc(100% - 24px); max-height: 50%; top: auto; bottom: 12px; }
}

#table-section {
  padding: 24px;
  background: #fff;
  border-top: 1px solid var(--vc-rule);
}
#table-section h2 {
  font-family: var(--serif);
  font-size: 20px;
  margin: 0 0 12px;
}
#table { font-size: 13px; }

.site-footer {
  padding: 20px 24px 40px;
  border-top: 1px solid var(--vc-rule);
  font-size: 12px;
  color: var(--vc-muted);
  background: var(--vc-bg);
}
.site-footer p { margin: 0 0 6px; max-width: 80ch; }
.site-footer a { color: var(--vc-muted); }
.site-footer .meta { font-size: 11px; }

/* Popup styling */
.leaflet-popup-content {
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  margin: 10px 14px;
}
.leaflet-popup-content .pop-name {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 2px;
}
.leaflet-popup-content .pop-cat {
  display: inline-block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 1px 6px;
  border-radius: 3px;
  color: #fff;
  margin-bottom: 6px;
}
.pop-cat.liquor   { background: var(--liquor);   }
.pop-cat.cannabis { background: var(--cannabis); }
.pop-cat.tobacco  { background: var(--tobacco);  }
.pop-cat.beer     { background: var(--beer);     }
.leaflet-popup-content .pop-addr { color: var(--vc-muted); margin-bottom: 4px; }
.leaflet-popup-content .pop-meta { font-size: 11px; color: var(--vc-muted); }
.leaflet-popup-content a { color: var(--vc-accent); }

/* Tabulator overrides */
.tabulator { background: #fff; border: 1px solid var(--vc-rule); border-radius: 4px; }
.tabulator .tabulator-header { background: var(--vc-bg); }
.tabulator-row .tabulator-cell { padding: 8px 10px; }
.tabulator .cat-pill {
  display: inline-block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 6px;
  border-radius: 3px;
  color: #fff;
}
.cat-pill.liquor   { background: var(--liquor);   }
.cat-pill.cannabis { background: var(--cannabis); }
.cat-pill.tobacco  { background: var(--tobacco);  }
.cat-pill.beer     { background: var(--beer);     }

@media (max-width: 700px) {
  .topbar { padding: 14px 16px 10px; }
  .methodology-link { top: 16px; right: 16px; }
  #controls { padding: 10px 16px; }
  #map { height: 55vh; min-height: 360px; }
  #table-section { padding: 16px; }
}

/* Methodology page */
.prose {
  max-width: 72ch;
  padding: 24px;
  line-height: 1.6;
}
.prose h1, .prose h2 {
  font-family: var(--serif);
}
.prose h1 { font-size: 28px; margin: 0 0 6px; }
.prose h2 { font-size: 18px; margin: 24px 0 8px; }
.prose table {
  width: 100%; border-collapse: collapse; font-size: 13px; margin: 12px 0;
}
.prose th, .prose td {
  text-align: left; padding: 8px; border-bottom: 1px solid var(--vc-rule);
  vertical-align: top;
}
.prose th { background: var(--vc-bg); }
.prose code {
  font-size: 12px; background: var(--vc-bg);
  padding: 1px 4px; border-radius: 3px;
}
.prose ul { padding-left: 22px; }
.prose li { margin-bottom: 6px; }
