/* =========================================================
   Northern Nevada Healthy Food Access Map
   Design: warm civic - sage green, terracotta, cream surfaces
   ========================================================= */

:root {
  /* Palette */
  --bg:        #faf7f1;    /* warm cream */
  --bg-elev:   #ffffff;
  --bg-sunk:   #f1ece1;
  --ink:       #1f2421;    /* near-black green-tinted */
  --ink-muted: #5b635c;
  --line:      #e3ddcf;
  --line-strong:#cdc6b5;

  --sage:      #3d5a3a;    /* primary brand */
  --sage-700:  #2c4329;
  --sage-100:  #e6ede2;
  --terra:     #c0593b;    /* accent */
  --terra-100: #f6e3da;
  --terra-700: #b5512f;
  --gold:      #c89b3c;
  --sky:       #4c7da3;

  /* Site type marker colors */
  --c-food_pantry:        #3d5a3a;
  --c-soup_kitchen:       #c0593b;
  --c-farmers_market:     #7f8a38;
  --c-mobile_pantry:      #6f7c41;
  --c-meal_site:          #b06b2a;
  --c-senior_meal_site:   #8a6daf;
  --c-grocery_assistance: #4c7da3;
  --c-wic_clinic:         #a87a24;
  --c-snap_office:        #4c5f70;
  --c-community_garden:   #5a8a3a;
  --c-tribal_food_program:#a13d3d;
  --c-school_pantry:      #6a4c93;

  /* Type */
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;

  --topbar-h: 60px;
  --filter-h: 132px;
  --footer-h: 56px;
  --shadow-sm: 0 1px 2px rgba(20,24,21,.06), 0 1px 1px rgba(20,24,21,.04);
  --shadow-md: 0 6px 18px rgba(20,24,21,.08), 0 2px 6px rgba(20,24,21,.05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; }
body {
  font-family: var(--font);
  font-feature-settings: "cv11", "ss01";
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--sage-700); }
a:hover { color: var(--terra); }
button { font-family: inherit; }

/* ---------- Topbar ---------- */
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
  position: relative; z-index: 20;
  gap: 12px;
}
.topnav { display: flex; align-items: center; flex-shrink: 0;}
.topnav a { white-space: nowrap; }
.brand {
  display: flex; align-items: center; gap: 12px;
  text-decoration: none; color: var(--sage);
}
.brand-mark { height: 30px; width: auto; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 14px; color: var(--ink); font-weight: 600; letter-spacing: -0.005em; }
.brand-text em { font-size: 12px; color: var(--ink-muted); font-style: normal; margin-top: 1px; }
.topnav a {
  margin-left: 18px; color: var(--ink-muted); text-decoration: none; font-size: 14px; font-weight: 500;
}
.topnav a:hover { color: var(--sage); }

/* ---------- App layout ---------- */
.app {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-h));
  background: var(--bg);
}
.filterbar {
  display: flex; flex-direction: column;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
  position: relative; z-index: 10;
}
.filterbar-top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
}
.filterbar-chips {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
}
.filterbar-chips[hidden] { display: none; }
.filters-toggle-btn { display: none; }
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--terra); color: #fff;
  border-radius: 9px;
  font-size: 11px; font-weight: 700;
  margin-left: 2px;
}
.badge[hidden] { display: none !important; }
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-sunk);
  padding: 0 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  min-width: 240px; flex: 1 1 280px; max-width: 360px;
}
.search:focus-within { border-color: var(--sage); background: var(--bg-elev); box-shadow: 0 0 0 3px rgba(61,90,58,.12);}
.search svg { color: var(--ink-muted); flex-shrink: 0; }
.search input {
  border: none; outline: none; background: transparent;
  font: inherit; color: var(--ink); width: 100%;
  padding: 9px 0;
}
.iconbtn {
  border: none; background: transparent; color: var(--ink-muted); cursor: pointer;
  font-size: 20px; line-height: 1; padding: 4px 8px; border-radius: var(--r-sm);
}
.iconbtn:hover { background: var(--bg-sunk); color: var(--ink); }
.chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-sunk);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, color 120ms;
}
.chip:hover { background: var(--sage-100); border-color: var(--sage); }
.chip.active {
  background: var(--sage); color: #fff; border-color: var(--sage);
}
.chip.active:hover { background: var(--sage-700); }
.chip-action { background: var(--terra-100); border-color: #e8c3b1; color: var(--terra); font-weight: 600;}
.chip-action:hover { background: #f0d2c2; }
.chip-action.active { background: var(--terra); color: #fff; border-color: var(--terra); }
.textbtn {
  border: none; background: transparent; color: var(--ink-muted);
  cursor: pointer; font-size: 13px; padding: 6px 8px; text-decoration: underline;
}
.textbtn:hover { color: var(--terra); }
.resultcount {
  margin-left: auto;
  font-size: 13px; color: var(--ink-muted); font-variant-numeric: tabular-nums;
}

/* mobile view toggle */
.viewtoggle { display: none; gap: 2px; background: var(--bg-sunk); padding: 3px; border-radius: var(--r-md); border: 1px solid var(--line);}
.vt {
  border: none; background: transparent; cursor: pointer;
  padding: 6px 14px; font: inherit; font-size: 13px; font-weight: 500;
  color: var(--ink-muted); border-radius: 7px;
}
.vt.active { background: var(--bg-elev); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ---------- Split ---------- */
.split {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: minmax(340px, 420px) 1fr;
}
.listpane {
  overflow-y: auto; border-right: 1px solid var(--line);
  background: var(--bg);
}
.results { list-style: none; padding: 0; margin: 0; }
.result {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  background: var(--bg);
  transition: background 120ms;
}
.result:hover { background: var(--bg-elev); }
.result.active { background: var(--sage-100); }
.result .marker {
  width: 12px; height: 12px; border-radius: 50%; margin-top: 5px;
  border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(20,24,21,.18);
}
.result .name { font-weight: 600; color: var(--ink); margin: 0; font-size: 14.5px; line-height: 1.3;}
.result .meta {
  margin: 4px 0 0; font-size: 12.5px; color: var(--ink-muted);
}
.result .tags {
  margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 4px;
}
.tag {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 2px 7px; border-radius: 4px;
  background: var(--bg-sunk); color: var(--ink-muted);
  text-transform: uppercase; letter-spacing: 0.03em;
}
.tag-snap { background: var(--sage-100); color: var(--sage-700); }
.tag-wic  { background: #fbf0d4; color: #876215;}
.tag-senior { background: #ede5f5; color: #6a4c93;}
.tag-delivery { background: #e0eaf3; color: #345a76;}
.tag-seasonal { background: #f6e3da; color: #8a3a1f;}

.empty { padding: 36px 18px; text-align: center; color: var(--ink-muted);}
.empty strong { display: block; color: var(--ink); margin-bottom: 6px;}
.empty p { margin: 0; font-size: 13px; }

/* ---------- Map ---------- */
.mappane {
  position: relative;
  min-height: 0;
  background: var(--bg-sunk);
}
#map { position: absolute; inset: 0; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.18);}
.dot-food_pantry        { background: var(--c-food_pantry); }
.dot-soup_kitchen       { background: var(--c-soup_kitchen); }
.dot-farmers_market     { background: var(--c-farmers_market); }
.dot-senior_meal_site   { background: var(--c-senior_meal_site); }
.dot-wic_clinic         { background: var(--c-wic_clinic); }
.dot-tribal_food_program{ background: var(--c-tribal_food_program); }
.dot-other              { background: var(--ink-muted); }

/* Maplibre popup */
.maplibregl-popup { max-width: 280px !important; }
.maplibregl-popup-content {
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-family: var(--font);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--line);
}
.maplibregl-popup-content .pop-name { font-weight: 600; font-size: 14px; line-height: 1.3; margin-bottom: 4px; }
.maplibregl-popup-content .pop-type { font-size: 11px; font-weight: 600; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px;}
.maplibregl-popup-content .pop-meta { font-size: 12.5px; color: var(--ink); margin-bottom: 8px;}
.maplibregl-popup-content .pop-more {
  display: inline-block; font-size: 12.5px; font-weight: 600;
  color: var(--sage-700); cursor: pointer; text-decoration: underline;
}
.maplibregl-popup-tip { border-top-color: #fff !important; }

/* Reset-view button (always visible top-left of map) */
.reset-view-btn {
  position: absolute; top: 12px; left: 12px; z-index: 5;
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 7px 12px;
  font: inherit; font-size: 12.5px; font-weight: 600;
  color: var(--ink); cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 120ms, color 120ms, border-color 120ms;
}
.reset-view-btn:hover { background: var(--sage); color: #fff; border-color: var(--sage);}
.reset-view-btn svg { flex-shrink: 0; }

/* Cluster count label */
.cluster-count-label {
  color: #fff;
  font: 600 13px/1 var(--font);
  text-shadow: 0 1px 2px rgba(0,0,0,.25);
  user-select: none;
  pointer-events: none;
}

/* Custom marker */
.marker-dot {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1.5px rgba(20,24,21,.25), 0 1px 4px rgba(20,24,21,.18);
  cursor: pointer;
  transition: transform 120ms;
}
.marker-dot:hover { transform: scale(1.18); }
.marker-dot.active { transform: scale(1.35); box-shadow: 0 0 0 3px rgba(192,89,59,.4), 0 0 0 1.5px rgba(20,24,21,.3);}

/* ---------- Detail drawer ---------- */
.detail {
  position: fixed; top: 0; right: 0; height: 100vh;
  width: min(420px, 100vw);
  background: var(--bg-elev);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  z-index: 50;
  transform: translateX(100%);
  transition: transform 240ms cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
}
.detail[aria-hidden="false"] { transform: translateX(0); }

/* On narrow desktops, when detail is open, collapse the list pane so the
   map has breathing room. Otherwise the map gets squeezed to a thin strip
   between the list and the drawer. */
@media (min-width: 901px) and (max-width: 1280px) {
  body.detail-open .listpane { display: none; }
  body.detail-open .mappane { grid-column: 1 / -1; }
}
.detail-close {
  position: absolute; top: 12px; right: 12px;
  font-size: 24px; padding: 2px 10px;
}
.detail-body {
  padding: 32px 28px 28px;
  overflow-y: auto;
}
.detail h2 { font-size: 20px; line-height: 1.25; margin: 0 0 6px; letter-spacing: -0.01em; }
.detail .d-org { font-size: 13px; color: var(--ink-muted); margin: 0 0 14px; }
.detail .d-type {
  display: inline-block; font-size: 11.5px; font-weight: 600;
  padding: 3px 10px; border-radius: 4px;
  background: var(--sage-100); color: var(--sage-700);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin-bottom: 18px;
}
.detail .d-row { display: grid; grid-template-columns: 22px 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); align-items: start;}
.detail .d-row svg { color: var(--ink-muted); margin-top: 3px;}
.detail .d-row a { color: var(--ink); text-decoration: underline; word-break: break-word;}
.detail .d-tags { margin: 14px 0; display: flex; flex-wrap: wrap; gap: 6px;}
.detail .d-actions { margin: 18px 0 10px; display: flex; flex-wrap: wrap; gap: 8px;}
.actionbtn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--sage); color: #fff; border: none;
  padding: 9px 14px; border-radius: var(--r-md);
  font: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer; text-decoration: none;
}
.actionbtn:hover { background: var(--sage-700); color: #fff; }
.actionbtn.secondary { background: var(--bg-sunk); color: var(--ink); border: 1px solid var(--line);}
.actionbtn.secondary:hover { background: var(--sage-100); color: var(--sage-700); border-color: var(--sage);}
.d-verified { margin-top: 18px; font-size: 12px; color: var(--ink-muted); padding-top: 12px; border-top: 1px solid var(--line);}

.scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(20,24,21,0.32);
  opacity: 0;
  transition: opacity 240ms;
  pointer-events: none;
}
.scrim.open { opacity: 1; pointer-events: auto; }

/* ---------- Footer ---------- */
.footer {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--footer-h);
  background: var(--bg-elev);
  border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--ink-muted); text-align: center;
  padding: 8px 18px;
  display: none; /* hidden on app pages; about/suggest re-enable */
}
.footer .xpdshn-link { color: var(--terra-700); font-weight: 600; text-decoration: none; }
.footer .xpdshn-link:hover { text-decoration: underline; color: var(--terra); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .topbar { padding: 0 14px;}
  .brand-text strong { font-size: 13px;}
  .brand-text em { font-size: 11px;}
  .topnav a { margin-left: 10px; font-size: 13px;}
}
@media (max-width: 560px) {
  .brand-text em { display: none;}
  .brand-text strong { font-size: 12.5px; line-height: 1.3;}
  .topnav a { margin-left: 8px; font-size: 12.5px;}
}
@media (max-width: 900px) {

  .filterbar { padding: 10px 12px; gap: 8px;}
  .filterbar-top { gap: 6px;}
  .search { min-width: 0; max-width: none; flex: 1 1 100%; order: -1;}
  .resultcount { width: 100%; order: 99; margin-left: 0; font-size: 12px;}
  .viewtoggle { display: inline-flex;}
  .filters-toggle-btn { display: inline-flex;}
  .filterbar-chips.collapsed { display: none;}

  .split { grid-template-columns: 1fr; position: relative;}
  .listpane, .mappane { grid-column: 1; grid-row: 1; }
  body.view-map .listpane { display: none; }
  body.view-list .mappane { display: none; }

  .detail { width: 100vw; }
}

/* very small screens: stack chip rows */
@media (max-width: 480px) {
  .chips { width: 100%; }
}

/* scrollbar polish */
.listpane::-webkit-scrollbar { width: 10px; }
.listpane::-webkit-scrollbar-track { background: transparent; }
.listpane::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px; border: 2px solid var(--bg);}

/* skeleton loader */
.skeleton {
  background: linear-gradient(90deg, var(--bg-sunk) 0%, #ede7d8 50%, var(--bg-sunk) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { 0% { background-position: 200% 0;} 100% { background-position: -200% 0;} }


/* ----- Accessibility & polish (added from pre-launch audit) ----- */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

.geo-status {
  width: 100%;
  margin-top: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--terra-700);
  background: var(--terra-100);
  border: 1px solid #e8c3b1;
  border-radius: var(--r-md);
}

/* Honor reduced-motion: neutralize CSS transitions/animations. (Map camera
   moves are gated separately in app.js via prefers-reduced-motion.) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Touch targets: keep interactive controls >= 44px tall on small screens. */
@media (max-width: 900px) {
  .chip, .vt { min-height: 44px; display: inline-flex; align-items: center; }
  .vt { justify-content: center; }
  #search { min-height: 44px; }
}

/* Donate button in top nav */
.topnav a.nav-donate {
  padding: 7px 15px; background: var(--terra); color: #fff;
  border-radius: var(--r-md, 8px); font-weight: 600;
}
.topnav a.nav-donate:hover { background: var(--terra-700); color: #fff; }
