/* ============================================================================
   Grillable — theming
   Two earthy themes driven by CSS variables.
   :root            = light  (warm oat / terracotta)
   [data-theme=dark] = dark  (charcoal & ember)
   ========================================================================== */

:root {
  /* Access categories (legend, markers, card spines) */
  --open: #3f8f5c;
  --discount: #be7a1e;
  --resident: #c0392b;
  --none: #8a8275;

  /* Surfaces & text */
  --bg: #f4f0e8;        /* warm oat */
  --panel: #fcfaf5;     /* warm white */
  --panel-2: #efe9dd;   /* recessed warm sand */
  --ink: #2b2620;       /* espresso */
  --muted: #786e60;     /* taupe */
  --line: #e4dcce;      /* sand hairline */

  /* Brand */
  --accent: #c2541c;        /* terracotta / ember */
  --accent-strong: #a6451a; /* pressed */
  --on-accent: #fff5ec;     /* text on ember */
  --sage: #6e7a45;          /* olive secondary (info / near-me) */

  /* States */
  --ring: rgba(194, 84, 28, 0.35);
  --card-shadow: 0 3px 12px rgba(60, 40, 20, 0.10);
  --marker-ring: #ffffff;

  /* Sage-tinted "info" surface (near-me active, distance pill) */
  --info-bg: #e7ecd9;
  --info-ink: #4f5a2e;
  --info-line: #d2dcb8;

  /* Badges */
  --yes-bg: #e4efe4;  --yes-ink: #2f6b43;  --yes-line: #cadfca;
  --no-bg:  #f6e3df;  --no-ink:  #a53a2c;  --no-line:  #ecc9c1;
  --par-bg: #f4e9d2;  --par-ink: #8a5e16;  --par-line: #e6d2a8;

  /* Map cluster bubbles */
  --cl-out: rgba(194, 84, 28, 0.22);
  --cl-in:  rgba(194, 84, 28, 0.85);
}

[data-theme="dark"] {
  --open: #5fb47a;
  --discount: #e0a23c;
  --resident: #e0726a;
  --none: #a89a88;

  --bg: #1a1613;        /* warm near-black */
  --panel: #241f1a;     /* raised charcoal */
  --panel-2: #2e2820;   /* recessed charcoal */
  --ink: #ede4d6;       /* warm cream */
  --muted: #9a8e7e;     /* taupe */
  --line: #3a332b;      /* hairline brown */

  --accent: #d2691e;        /* ember */
  --accent-strong: #e07d33;
  --on-accent: #1a1613;
  --sage: #8a9a5b;

  --ring: rgba(210, 105, 30, 0.45);
  --card-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  --marker-ring: #ffffff;

  --info-bg: #2a301e;
  --info-ink: #b6c57f;
  --info-line: #3d4628;

  --yes-bg: #233026;  --yes-ink: #8fc79f;  --yes-line: #34493a;
  --no-bg:  #3a2622;  --no-ink:  #e59488;  --no-line:  #5a352e;
  --par-bg: #352b1b;  --par-ink: #dcb263;  --par-line: #4d3f24;

  --cl-out: rgba(214, 105, 30, 0.26);
  --cl-in:  rgba(214, 105, 30, 0.86);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

/* Smooth, scoped theme cross-fade (map redraws itself, so it's excluded) */
#sidebar, .brand, .filters, .legend, .disclaimer, .card, .badge, .dist,
.search-row input, .search-row button, .filter-row select, .reset, .theme-toggle {
  transition: background-color .25s ease, color .25s ease, border-color .25s ease;
}

#app { display: flex; height: 100vh; width: 100vw; }

/* ───────── Sidebar ───────── */
#sidebar {
  width: 380px;
  min-width: 320px;
  height: 100%;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.brand {
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.brand h1 {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}
.brand .sub { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.45; }

/* Theme toggle */
.theme-toggle {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  font-size: 15px; line-height: 1;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background-color .15s, border-color .15s, transform .2s ease;
}
.theme-toggle:hover { border-color: var(--accent); transform: rotate(-18deg); }
.theme-toggle:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.filters { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.search-row { display: flex; gap: 8px; margin-bottom: 12px; }
.search-row input {
  flex: 1; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; background: var(--panel); color: var(--ink);
}
.search-row input::placeholder { color: var(--muted); opacity: .8; }
.search-row input:focus { outline: 2px solid var(--ring); outline-offset: 0; border-color: var(--accent); }
.search-row button {
  white-space: nowrap; padding: 8px 10px; border: 1px solid var(--line);
  background: var(--panel); border-radius: 8px; font-size: 12.5px; cursor: pointer; color: var(--ink);
}
.search-row button:hover { background: var(--bg); border-color: var(--accent); }
.search-row button.active { background: var(--info-bg); border-color: var(--info-line); color: var(--info-ink); }
.dist {
  font-size: 10.5px; font-weight: 700; color: var(--info-ink);
  background: var(--info-bg); border: 1px solid var(--info-line); border-radius: 20px; padding: 2px 7px;
}
.filter-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.filter-row label { width: 92px; font-size: 12px; color: var(--muted); font-weight: 600; }
.filter-row select {
  flex: 1; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; background: var(--panel); color: var(--ink);
}
.filter-row select:focus { outline: 2px solid var(--ring); border-color: var(--accent); }
.dist-row input[type="range"] { flex: 1; accent-color: var(--accent); cursor: pointer; }
.dist-row input[type="range"]:disabled { cursor: not-allowed; opacity: .5; }
.dist-val { font-size: 12px; color: var(--muted); font-weight: 600; min-width: 78px; text-align: right; }
.filter-row.checks { flex-wrap: wrap; gap: 10px; }
.chk { width: auto !important; display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; color: var(--ink); font-weight: 500; cursor: pointer; }
.chk input { accent-color: var(--accent); }
.reset {
  margin-top: 2px; width: 100%; padding: 7px; border: 1px solid var(--line);
  background: var(--panel); border-radius: 8px; font-size: 12.5px; color: var(--muted);
  cursor: pointer;
}
.reset:hover { background: var(--bg); border-color: var(--accent); color: var(--ink); }

.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.lg { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 2px rgba(0,0,0,.06); }
.dot.open { background: var(--open); }
.dot.discount { background: var(--discount); }
.dot.resident { background: var(--resident); }
.dot.none { background: var(--none); }

.count {
  padding: 12px 18px 4px; font-size: 11px; color: var(--muted);
  font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
}

.list { list-style: none; margin: 0; padding: 6px 12px 12px; overflow-y: auto; flex: 1; }
.list::-webkit-scrollbar { width: 10px; }
.list::-webkit-scrollbar-thumb {
  background: var(--line); border-radius: 8px; border: 2px solid var(--panel);
}
.list::-webkit-scrollbar-thumb:hover { background: var(--muted); }
.card {
  background: var(--panel);
  border: 1px solid var(--line); border-left: 4px solid var(--none);
  border-radius: 10px; padding: 11px 12px; margin-bottom: 9px; cursor: pointer;
  transition: box-shadow .12s, transform .12s, border-color .12s, background-color .25s;
}
.card:hover { box-shadow: var(--card-shadow); transform: translateY(-1px); }
.card.open { border-left-color: var(--open); }
.card.discount { border-left-color: var(--discount); }
.card.resident { border-left-color: var(--resident); }
.card.none { border-left-color: var(--none); }
.card h3 { margin: 0 0 3px; font-size: 14px; line-height: 1.25; }
.card .meta { font-size: 11.5px; color: var(--muted); margin-bottom: 7px; }
.badges { display: flex; flex-wrap: wrap; gap: 5px; }
.badge {
  font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 20px;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--line);
}
.badge.yes { background: var(--yes-bg); color: var(--yes-ink); border-color: var(--yes-line); }
.badge.no { background: var(--no-bg); color: var(--no-ink); border-color: var(--no-line); }
.badge.partial { background: var(--par-bg); color: var(--par-ink); border-color: var(--par-line); }

.disclaimer {
  padding: 10px 18px; font-size: 10.5px; color: var(--muted);
  border-top: 1px solid var(--line); line-height: 1.45;
}

/* ───────── Map ───────── */
#map { flex: 1; height: 100%; background: var(--bg); }

/* Popups */
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; line-height: 1.45; }
.pop h3 { margin: 0 0 2px; font-size: 14.5px; color: var(--ink); }
.pop .meta { color: var(--muted); font-size: 11.5px; margin-bottom: 8px; }
.pop table { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.pop td { padding: 3px 0; vertical-align: top; font-size: 12px; color: var(--ink); }
.pop td.k { color: var(--muted); width: 96px; padding-right: 8px; }
.pop .notes { font-size: 11.5px; color: var(--muted); margin: 0 0 9px; }
.pop a.site {
  display: inline-block; background: var(--accent); color: var(--on-accent); text-decoration: none;
  padding: 6px 11px; border-radius: 7px; font-size: 12px; font-weight: 600;
}
.pop a.site:hover { background: var(--accent-strong); }

/* Dark-mode Leaflet chrome: popups, controls, attribution */
[data-theme="dark"] .leaflet-popup-content-wrapper,
[data-theme="dark"] .leaflet-popup-tip {
  background: var(--panel); color: var(--ink);
  box-shadow: 0 3px 18px rgba(0, 0, 0, 0.6);
}
[data-theme="dark"] .leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
[data-theme="dark"] .leaflet-container a.leaflet-popup-close-button:hover { color: var(--ink); }
[data-theme="dark"] .leaflet-bar a,
[data-theme="dark"] .leaflet-bar a:hover {
  background: var(--panel); color: var(--ink); border-bottom-color: var(--line);
}
[data-theme="dark"] .leaflet-bar a:hover { background: var(--panel-2); }
[data-theme="dark"] .leaflet-control-attribution {
  background: rgba(36, 31, 26, 0.82); color: var(--muted);
}
[data-theme="dark"] .leaflet-control-attribution a { color: var(--sage); }

/* Cluster bubbles tinted to the ember theme */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large { background: var(--cl-out); }
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div { background: var(--cl-in); color: #fff; }

/* Responsive */
@media (max-width: 760px) {
  #app { flex-direction: column; }
  #sidebar { width: 100%; min-width: 0; height: 46%; }
  #map { height: 54%; }
}
