/* 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;
}

/* Scrollbars in the same palette as everything else: a thin track that
   disappears into the panel and a thumb the colour of a border. The
   filter bar and the photo strip opt out entirely further down. */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 999px;
  border: 3px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: #5a5a6b; background-clip: content-box; }
::-webkit-scrollbar-corner { background: transparent; }

/* ---- 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; }

/* One thumb-scrollable row everywhere, exactly like a phone; the
   expand button at the end (desktop only) unfolds it into the old
   wrapped grid for anyone who prefers everything on screen at once. */
.filters {
  display: flex; align-items: flex-end; gap: 14px; flex-wrap: nowrap;
  flex: 1; min-width: 0;
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  padding: 10px 18px 12px; background: var(--bg-panel);
}
.filters::-webkit-scrollbar { display: none; }
.filters .f-field, .filters .btn { flex: 0 0 auto; }
@media (min-width: 761px) {
  .filters-wrap.f-open .filters { flex-wrap: wrap; overflow-x: visible; }
}
.f-expand {
  flex: 0 0 34px; align-self: stretch; border: 0; cursor: pointer;
  border-left: 1px solid var(--border);
  background: var(--bg-panel); color: var(--text-dim);
  display: grid; place-items: center; padding: 0;
}
.f-expand:hover { color: var(--text); background: var(--bg-raised); }
.f-expand-chev {
  width: 8px; height: 8px;
  border-left: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg) translate(1px, -1px);
}
.filters-wrap.f-open .f-expand-chev { transform: rotate(135deg) translate(1px, -1px); }
.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 ---- */

/* The map and the list sit side by side: opening the list makes the
   map narrower rather than covering it, so "near the centre of the
   map" keeps meaning what it says. */
.stage { flex: 1; min-height: 0; display: flex; position: relative; }
/* Gaps while tiles load read as blank map, not a black void. */
#map { flex: 1; min-width: 0; height: 100%; 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 {
  /* Above every Leaflet pane and above the pin canvas: a click on the
     card is a click on the card, never on the map behind it. */
  position: absolute; z-index: 1200; 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);
}
.pin-bubble * { pointer-events: auto; }
.bubble-close {
  position: absolute; top: 6px; right: 6px; z-index: 3;
  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 .shot-track img { height: 150px; }
.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; }

/* ---- the photo strip ----
   Every photo OLX published, swipeable. Native scroll-snap carries the
   gesture and its momentum; the arrows are the same thing for a mouse. */

.shots { position: relative; }
.shot-track {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
}
.shot-track::-webkit-scrollbar { display: none; }
.shot-track img {
  display: block; flex: 0 0 100%; width: 100%; height: 150px;
  object-fit: cover; scroll-snap-align: center; background: var(--bg-input);
}
.shot-nav {
  position: absolute; z-index: 2; top: 50%; transform: translateY(-50%);
  width: 26px; height: 36px; border: 0; border-radius: 8px; cursor: pointer;
  background: #101014aa; color: #fff; font-size: 17px; line-height: 1; padding: 0;
}
.shot-nav:hover:not(:disabled) { background: #101014dd; }
.shot-nav:disabled { opacity: .25; cursor: default; }
.shot-nav.prev { left: 6px; }
.shot-nav.next { right: 6px; }
.shot-dots {
  position: absolute; left: 50%; bottom: 7px; transform: translateX(-50%);
  display: flex; gap: 4px; pointer-events: none;
}
.shot-dots i { width: 5px; height: 5px; border-radius: 50%; background: #ffffff66; }
.shot-dots i.on { background: #fff; }

/* Posted within the last week. */
.badge-new {
  position: absolute; top: 8px; left: 8px;
  font-size: 10px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase;
  color: #052e16; background: #4ade80; border-radius: 999px; padding: 3px 8px;
}
.badge-new.inline { position: static; display: inline-block; }

/* ---- favorites ----
   The star on the card sits beside the close button; the one on a
   list row sits on the thumbnail. Both turn gold when saved. */

.bubble-fav {
  position: absolute; top: 6px; right: 34px; z-index: 3;
  width: 24px; height: 24px; border: 0; border-radius: 7px; cursor: pointer;
  background: #10101488; color: #ffffff99; font-size: 14px; line-height: 1; padding: 0;
}
.bubble-fav:hover { background: #101014cc; color: #fff; }
.bubble-fav.on { color: #fbbf24; }
.row-star {
  position: absolute; top: 4px; left: 4px; z-index: 2;
  width: 24px; height: 24px; border-radius: 7px; cursor: pointer;
  display: grid; place-items: center;
  background: #10101466; color: #ffffff88; font-size: 13px; line-height: 1;
}
.row-star:hover { background: #101014bb; color: #fff; }
.row-star.on { color: #fbbf24; }
/* A favorite whose listing has since expired. */
.row.gone .row-title { color: var(--text-faint); font-style: italic; }

.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; }
/* Never break "21 506 zł/m²" across two lines under the price. */
.pin-card .perm2 {
  font-size: 11px; color: var(--text-faint); font-weight: 500; white-space: nowrap;
}
/* 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 .added { margin-top: 5px; font-size: 11.5px; color: var(--text-faint); }
.pin-card .stops {
  margin-top: 7px; font-size: 11.5px; color: var(--text-dim); line-height: 1.4;
}
.pin-card .stops[hidden] { display: none; }
.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; }

/* ---- the sidebar ---- */

.side {
  flex: 0 0 340px; min-width: 0; display: none; flex-direction: column;
  background: var(--bg-panel); border-left: 1px solid var(--border);
}
.side-open .side { display: flex; }

.side-toggle {
  position: absolute; z-index: 700; top: 12px; right: 12px;
  display: flex; align-items: center; gap: 7px;
  border: 1px solid var(--border-strong); border-radius: 10px; cursor: pointer;
  background: var(--bg-panel); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 600; padding: 7px 11px;
  box-shadow: 0 6px 20px #0006;
}
.side-toggle:hover { background: var(--bg-raised); }
.side-open .side-toggle { right: 352px; }
/* A chevron pointing the way the panel will move. */
.side-chev {
  width: 7px; height: 7px; border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor; transform: rotate(45deg); margin-left: 1px;
}
.side-open .side-chev { transform: rotate(-135deg); margin: 0 1px 0 0; }
.side-open .side-toggle-label { display: none; }

.side-head {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
/* On a phone the list covers the map, so it carries its own way back;
   on a desktop the toggle beside it already does that job. */
.side-back { display: none; }
.side-title {
  font-size: 10.5px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-faint);
}
.side-sort { align-self: flex-start; }
.side-sort button { padding: 4px 10px; font-size: 12.5px; }

.side-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.side-empty { margin: 0; padding: 16px 12px; color: var(--text-dim); font-size: 12.5px; }

.row {
  position: relative; display: flex; gap: 10px; width: 100%; text-align: left;
  border: 0; border-bottom: 1px solid var(--border); cursor: pointer;
  background: none; color: var(--text); font: inherit; padding: 9px 12px;
}
.row:hover { background: var(--bg-raised); }
.row.on { background: #22c55e1f; box-shadow: inset 3px 0 0 #22c55e; }
.row.seen { color: var(--text-dim); }
.row.seen .row-shot img { opacity: .55; }
.row-shot {
  flex: 0 0 84px; height: 63px; border-radius: 8px; overflow: hidden;
  background: var(--bg-input); position: relative;
}
.row-shot img { display: block; width: 100%; height: 100%; object-fit: cover; }
.row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-title {
  font-size: 12.5px; line-height: 1.3; font-weight: 600;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
/* The NEW badge floats over the row's top-right corner; the title
   leaves it that corner instead of running underneath it. */
.row:has(.badge-new) .row-title { padding-right: 52px; }
.row-price { font-size: 13px; font-weight: 700; color: var(--accent); }
.row-meta { font-size: 11px; color: var(--text-faint); }
.row .badge-new { top: 9px; right: 12px; left: auto; padding: 2px 6px; font-size: 9px; }
/* Waiting on its card: the shape is there, the words are not. */
.row.pending .row-title, .row.pending .row-price {
  min-height: 11px; border-radius: 4px; background: var(--bg-raised);
  animation: pulse 1.2s ease-in-out infinite;
}
.row.pending .row-title { min-height: 26px; }
@keyframes pulse { 50% { opacity: .45; } }

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

/* On a phone there is no room to put a list beside the map, so it
   takes the whole map over instead: tap Lista, pick a listing, and the
   list hands you back to the map with that listing's card open. */
@media (max-width: 899px) {
  .side {
    position: absolute; inset: 0; z-index: 1300;
    border-left: 0;
  }
  /* The list is the whole surface, so the floating toggle would just be
     sitting on top of it. */
  .side-open .side-toggle { display: none; }
  .side-toggle { top: 10px; right: 10px; padding: 8px 13px; }
  .side-back {
    display: inline-flex; align-items: center; gap: 7px; align-self: flex-start;
    border: 0; background: none; cursor: pointer; padding: 2px 0;
    color: var(--accent); font: inherit; font-size: 14px; font-weight: 600;
  }
  .side-back::before {
    content: ''; width: 8px; height: 8px;
    border-left: 2px solid currentColor; border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
  }
  /* Thumb-sized rows, and a list that scrolls past the home indicator. */
  .row { padding: 11px 12px; }
  .row-shot { flex: 0 0 96px; height: 72px; }
  .row-title { font-size: 13.5px; }
  .row-price { font-size: 14px; }
  .side-list { padding-bottom: env(safe-area-inset-bottom); }
}

@media (max-width: 760px) {
  .data-note { display: none; }
  .topbar { padding: 8px 12px; }
  .brand { font-size: 14.5px; }
  /* The bar already scrolls in one row; phones just tighten it, and
     the expand button is a desktop affordance only. */
  .filters { gap: 10px; padding: 8px 12px 10px; }
  .f-expand { display: none; }
  .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; }
  .shot-track img { height: 128px; }
  .leaflet-control-zoom { display: none; }  /* pinch zoom does this on touch */
}
