/* Dewble map demo. Shares Taki's design tokens: same palette, same
   type, dark panels, one sky-blue accent. */

:root {
  --bg-canvas: #141419;
  --bg-page: #1a1a21;
  --bg-panel: #22222b;
  --bg-raised: #2a2a35;
  --bg-input: #16161c;
  --border: #32323e;
  --border-strong: #43434f;
  --text: #e8e8ee;
  --text-dim: #a3a3b2;
  --text-faint: #6d6d7c;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --accent-soft: #38bdf822;
  --radius: 12px;
  --font: -apple-system, "Segoe UI", Roboto, "Hiragino Sans", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
/* Panel color behind everything, so a phone's notch and home-indicator
   safe areas blend with the top bar instead of flashing another shade. */
html { background: var(--bg-panel); }
body {
  margin: 0; display: flex; flex-direction: column;
  background: var(--bg-panel); color: var(--text);
  font: 14px/1.5 var(--font);
  padding-bottom: env(safe-area-inset-bottom);
  /* Page zoom belongs to the map alone: no double-tap or pinch zoom
     on the chrome around it. */
  touch-action: manipulation;
}

/* ---- chrome ---- */

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px; background: var(--bg-panel);
  padding-top: calc(10px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
}
/* Pinch gestures starting on the chrome must never zoom the page;
   pan-x keeps the filter bar's sideways scroll working. */
.topbar, .statusbar { touch-action: pan-x; }
.filters { touch-action: pan-x; }
.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 700; font-size: 16px; color: var(--text); text-decoration: none;
}
.brand .byline { font-weight: 500; font-size: 12px; color: var(--text-faint); margin-left: 2px; }
.dewble-mark {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(160deg, var(--accent), #2563eb);
  color: #0b1220; font-size: 15px; font-weight: 800;
}
.demo-chip {
  font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft);
  border: 1px solid #38bdf855; border-radius: 999px; padding: 3px 10px;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.data-note { color: var(--text-faint); font-size: 12.5px; }

/* Language switch: the Offer filter's segmented control, sized down to
   sit in the top bar. It stays when the data note drops on phones. */
.lang-toggle { flex: 0 0 auto; }
.lang-toggle button {
  padding: 4px 9px; font-size: 12px; font-weight: 700; letter-spacing: .04em;
}

/* ---- filter bar ---- */

.filters-wrap {
  display: flex; align-items: stretch;
  background: var(--bg-panel); border-bottom: 1px solid var(--border);
}
.f-arrow {
  flex: 0 0 26px; border: 0; cursor: pointer;
  background: var(--bg-panel); color: var(--text-dim);
  font-size: 18px; line-height: 1; padding: 0;
}
.f-arrow:first-child { border-right: 1px solid var(--border); }
.f-arrow:last-child { border-left: 1px solid var(--border); }
.f-arrow:hover:not(:disabled) { color: var(--text); background: var(--bg-raised); }
.f-arrow:disabled { opacity: .3; cursor: default; }
.f-arrow[hidden] { display: none; }

.filters {
  display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap;
  flex: 1; min-width: 0;
  padding: 10px 18px 12px; background: var(--bg-panel);
}
.f-field { display: flex; flex-direction: column; gap: 4px; }
.f-field > span {
  font-size: 10.5px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-faint);
}
.filters select, .filters input {
  background: var(--bg-input); color: var(--text);
  border: 1px solid var(--border); border-radius: 9px;
  padding: 7px 10px; font: inherit; font-size: 13.5px;
}
.filters select:focus, .filters input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.f-price input { width: 110px; }
#fCity { width: 150px; }
/* Dynamic per-category dropdowns flow as normal bar items. */
.f-extra { display: contents; }
.f-extra select { max-width: 190px; }

.segmented { display: flex; background: var(--bg-input); border: 1px solid var(--border); border-radius: 9px; padding: 2px; }
.segmented button {
  border: 0; background: none; color: var(--text-dim); cursor: pointer;
  font: inherit; font-size: 13px; padding: 5px 12px; border-radius: 7px;
}
.segmented button[aria-pressed="true"] { background: var(--bg-raised); color: var(--text); font-weight: 600; }
.segmented button:disabled { opacity: .35; cursor: default; }

.btn {
  border: 0; cursor: pointer; font: inherit; font-weight: 600; font-size: 13.5px;
  background: var(--accent); color: #08222e;
  border-radius: 9px; padding: 8px 16px;
}
.btn:hover { background: var(--accent-strong); }
.btn:disabled { opacity: .5; cursor: default; }

.statusbar {
  padding: 6px 18px; background: var(--bg-canvas);
  border-bottom: 1px solid var(--border); min-height: 30px;
}
.status { color: var(--text-dim); font-size: 12.5px; }
.status[data-busy="1"]::before {
  content: ''; display: inline-block; width: 10px; height: 10px; margin-right: 7px;
  border: 2px solid var(--accent); border-top-color: transparent; border-radius: 50%;
  animation: spin .8s linear infinite; vertical-align: -1px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- map ---- */

/* Gaps while tiles load read as blank map, not a black void. */
#map { flex: 1; min-height: 0; background: #d9d5cf; }
.leaflet-container { background: #d9d5cf; }

/* Dark-friendly OSM: dim the raster a touch so pins pop. */
.leaflet-tile-pane { filter: brightness(.92) saturate(.9); }


.leaflet-container { font: 13px/1.45 var(--font); }
.leaflet-control-attribution {
  background: #1a1a21dd !important; color: var(--text-faint) !important;
}
.leaflet-control-attribution a { color: var(--text-dim) !important; }
.leaflet-control-zoom a {
  background: var(--bg-panel) !important; color: var(--text) !important;
  border-color: var(--border) !important;
}
.leaflet-control-zoom a:hover { background: var(--bg-raised) !important; }

/* ---- listing bubble (our own element, always above the pins) ---- */

.pin-bubble {
  position: absolute; z-index: 900; width: min(262px, calc(100vw - 20px));
  transform: translate(-50%, calc(-100% - 10px));
  background: var(--bg-panel); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: 0 12px 40px #000a; overflow: hidden;
  pointer-events: auto;
}
.pin-bubble::after {
  content: ''; position: absolute; left: 50%; bottom: -7px;
  width: 12px; height: 12px; transform: translateX(-50%) rotate(45deg);
  background: var(--bg-panel);
  border-right: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border-strong);
}
/* Flipped under the pin when there is no headroom above it. */
.pin-bubble.below { transform: translate(-50%, 0); }
.pin-bubble.below::after {
  bottom: auto; top: -7px;
  transform: translateX(-50%) rotate(225deg);
}
.bubble-close {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  width: 24px; height: 24px; border: 0; border-radius: 7px; cursor: pointer;
  background: #10101488; color: #fff; font-size: 15px; line-height: 1;
}
.bubble-close:hover { background: #101014cc; }

/* ---- listing bubble ---- */

.pin-bubble .pin-card img { height: 140px; }
.leaflet-popup-content-wrapper {
  background: var(--bg-panel); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: 0 12px 40px #000a; padding: 0; overflow: hidden;
}
.leaflet-popup-content { margin: 0; width: 260px !important; }
.leaflet-popup-tip { background: var(--bg-panel); border: 1px solid var(--border-strong); }
.leaflet-popup-close-button { color: var(--text-dim) !important; font-size: 18px !important; padding: 6px 8px 0 0 !important; }

.pin-card img {
  display: block; width: 100%; height: 150px; object-fit: cover;
  background: var(--bg-input);
}
.pin-card .body { padding: 10px 12px 12px; }
.pin-card .title {
  font-weight: 600; font-size: 13px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.pin-card .price { font-size: 16px; font-weight: 700; color: var(--accent); margin-top: 5px; }
.pin-card .meta { color: var(--text-dim); font-size: 12px; margin-top: 3px; }
.pin-card .perm2 { font-size: 11px; color: var(--text-faint); font-weight: 500; }
/* OLX gives an exact address for only a small minority of listings,
   so a dot is usually a point inside a district, not a doorstep. */
.pin-card .approx {
  margin-top: 6px; display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--text-faint);
}
.pin-card .approx::before {
  content: ''; flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%;
  border: 1px solid currentColor;
}
.pin-card .stops {
  margin-top: 7px; font-size: 11.5px; color: var(--text-dim); line-height: 1.4;
}
.pin-card .stops span {
  display: block; font-size: 10px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-faint); margin-bottom: 1px;
}
.pin-card .loading { padding: 14px 12px; color: var(--text-dim); font-size: 13px; }
.pin-card a.go {
  display: inline-block; margin-top: 9px; font-size: 12.5px; font-weight: 600;
  color: var(--accent); text-decoration: none;
}
.pin-card a.go:hover { text-decoration: underline; }

/* ---- small screens ---- */

@media (max-width: 760px) {
  .data-note { display: none; }
  .topbar { padding: 8px 12px; }
  .brand { font-size: 14.5px; }
  /* One thumb-scrollable row: labels shrink, nothing wraps under the map. */
  .filters {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    gap: 10px; padding: 8px 12px 10px; scrollbar-width: none;
  }
  .filters::-webkit-scrollbar { display: none; }
  .f-field { flex: 0 0 auto; }
  .f-price input { width: 90px; }
  .btn { flex: 0 0 auto; padding: 8px 14px; }
  .statusbar { padding: 5px 12px; }
  .leaflet-popup-content { width: min(250px, calc(100vw - 70px)) !important; }
  .pin-card img { height: 120px; }
  .leaflet-control-zoom { display: none; }  /* pinch zoom does this on touch */
}
