/* MNHBP hemp business directory.
   Layout: a locator console. Search and filters in a left rail with the results list,
   the map fills the rest. On phones the map stacks above the list.
   Colors follow the existing mnhbp.org palette; category colors match the PDF maps. */
:root {
  --bg: #f4f8ff;
  --bg-alt: #eaf2ff;
  --panel: #ffffff;
  --text: #0f254d;
  --muted: #4b5b73;
  --faint: #7a889c;
  --navy: #1d3b86;
  --navy-ink: #16306f;
  --sky: #4fb3e7;
  --border: #d6e3f5;
  --chip: #eef4ff;
  --focus: #4fb3e7;
  --map-bg: #e9eef6;

  --c-liquor: #2a78d6;
  --c-grocery: #1baf7a;
  --c-convenience: #eb6834;
  --c-bar: #eda100;
  --c-smoke: #6250d6;
  --c-hemp: #008300;
  --c-other: #9a9a95;
  --c-mfr: #e34948;
  --c-whl: #111111;

  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --radius: 10px;
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--navy); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- app shell ---------- */
.dir {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 8px 18px rgba(13, 40, 90, 0.08);
  height: min(780px, calc(100vh - 120px));
  min-height: 560px;
}
.dir.no-list { grid-template-columns: minmax(0, 1fr); }
.dir.no-map { grid-template-columns: minmax(0, 1fr); }
.dir.no-list .rail { display: none; }
.dir.no-map .mapwrap { display: none; }

.rail { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--border); }
.controls { display: flex; flex-direction: column; gap: 10px; padding: 14px 14px 10px; border-bottom: 1px solid var(--border); }
.searchrow { display: flex; gap: 8px; }
.search {
  flex: 1; min-width: 0;
  font: inherit; font-size: 15px; color: var(--text); background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px;
}
.search::placeholder { color: var(--faint); }
.btn {
  font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
  border-radius: 8px; border: 1px solid var(--navy); background: var(--navy); color: #fff;
  padding: 8px 12px; white-space: nowrap;
}
.btn:hover { background: var(--navy-ink); }
.btn.ghost { background: var(--panel); color: var(--navy); border-color: var(--border); }
.btn.ghost:hover { border-color: var(--navy); }
.btn.small { font-size: 13px; padding: 5px 9px; }

.filters > summary {
  display: flex; align-items: center; gap: 7px; cursor: pointer; list-style: none;
  font-size: 13px; font-weight: 700; color: var(--navy); padding: 2px 0;
}
.filters > summary::-webkit-details-marker { display: none; }
.filters > summary::before {
  content: ""; width: 0; height: 0; border-left: 6px solid currentColor;
  border-top: 4px solid transparent; border-bottom: 4px solid transparent; transition: transform 0.15s ease;
}
.filters[open] > summary::before { transform: rotate(90deg); }
.fsum { font-weight: 400; color: var(--muted); }
.fbody { display: flex; flex-direction: column; gap: 10px; padding-top: 10px; }
.filterlabel { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); margin: 2px 0 -2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: 13px; color: var(--text); cursor: pointer;
  background: var(--chip); border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px 4px 7px;
}
.chip[aria-pressed="false"] { background: var(--panel); color: var(--faint); }
.chip[aria-pressed="false"] svg { opacity: 0.35; }
.chip .ct { color: var(--muted); font-size: 12px; }
.chip[aria-pressed="false"] .ct { color: var(--faint); }
.toggles { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); }
.toggles label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.toggles input { accent-color: var(--navy); }

.status { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 8px; padding: 8px 14px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--border); background: var(--bg); }
.status strong { color: var(--text); }
.origin { display: inline-flex; align-items: center; gap: 6px; order: 3; flex-basis: 100%; }
.linkbtn { font: inherit; font-size: 13px; color: var(--navy); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; }

.results { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; }
.result { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 4px 10px; padding: 11px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.result:hover, .result.active { background: var(--bg-alt); }
.result .mk { padding-top: 3px; }
.result .name { font-weight: 700; font-size: 15px; line-height: 1.3; color: var(--text); overflow-wrap: anywhere; }
.result .meta { grid-column: 2 / 4; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.result .dist { font-size: 13px; color: var(--muted); white-space: nowrap; }
.tags { grid-column: 2 / 4; display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 11px; font-weight: 700; letter-spacing: 0.02em; color: var(--navy); background: var(--chip); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; }
.tag.approx { color: var(--muted); }
.more { padding: 12px 14px 16px; }
.empty { padding: 28px 18px; color: var(--muted); font-size: 14px; }
.empty strong { color: var(--text); display: block; margin-bottom: 4px; }

.mapwrap { position: relative; min-width: 0; min-height: 0; background: var(--map-bg); }
#map { position: absolute; inset: 0; background: var(--map-bg); }
/* Mute the full-color base map so the business markers carry the color */
#map .leaflet-tile-pane { filter: grayscale(0.9) brightness(1.06) contrast(0.88); }
.legend {
  position: absolute; z-index: 500; left: 10px; bottom: 22px;
  background: rgba(255, 255, 255, 0.95); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; color: var(--text); display: grid; gap: 3px; max-width: calc(100% - 20px);
}
.legend .row { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.legend .note { color: var(--muted); font-size: 11px; margin-top: 2px; }
.legend-toggle { display: none; }
.maptools { position: absolute; z-index: 500; right: 10px; top: 10px; display: flex; flex-direction: column; gap: 6px; }
.loading { position: absolute; inset: 0; z-index: 600; display: grid; place-items: center; color: var(--muted); font-size: 14px; background: var(--map-bg); }

/* popups */
.leaflet-popup-content { margin: 12px 14px; font-family: var(--font); color: var(--text); font-size: 13px; line-height: 1.45; min-width: 220px; }
.pop h3 { margin: 0 0 4px; font-size: 15px; color: var(--navy); line-height: 1.25; }
.pop .kind { color: var(--muted); margin-bottom: 6px; }
.pop .row { margin: 2px 0; }
.pop .lic { color: var(--faint); font-size: 12px; margin-top: 6px; }
.pop .acts { display: flex; gap: 12px; margin-top: 8px; font-weight: 700; }
.pop .warn { margin-top: 6px; font-size: 12px; color: var(--muted); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 5px 7px; }
.leaflet-container { font-family: var(--font); }
.leaflet-control-attribution { font-size: 10px; }

/* ---------- embed mode ---------- */
body.embed { background: var(--panel); height: 100%; }
html.embed { height: 100%; }
.embedbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--panel); }
.embedbar .t { font-weight: 700; color: var(--navy); font-size: 14px; }
.embedbar a { font-size: 12px; color: var(--muted); text-decoration: none; white-space: nowrap; }
.embedbar a:hover { color: var(--navy); }
body.embed .dir { border: 0; border-radius: 0; box-shadow: none; height: calc(100% - 41px); min-height: 0; }
body.embed .wrap-embed { height: 100%; }

/* ---------- phones ---------- */
@media (max-width: 760px) {
  .dir { grid-template-columns: minmax(0, 1fr); grid-template-rows: 46vh minmax(0, 1fr); height: auto; min-height: 0; }
  .dir .mapwrap { grid-row: 1; height: 46vh; }
  .dir .rail { grid-row: 2; border-right: 0; border-top: 1px solid var(--border); }
  .dir .results { max-height: 70vh; }
  .dir.no-list { grid-template-rows: 70vh; }
  .dir.no-map { grid-template-rows: auto; }
  .dir.no-map .rail { grid-row: 1; }
  .legend { display: none; }
  .legend.open { display: grid; }
  .legend-toggle { display: inline-block; }
  body.embed .dir { height: auto; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
