/* ---------- Cards ---------- */
.card { border-radius: var(--radius); cursor: pointer; transition: transform .2s ease, box-shadow .2s ease; background: var(--surface); }
.card:hover, .card.active { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(0,0,0,.12); }
.card.selected { box-shadow: 0 0 0 2px var(--brand), 0 10px 24px rgba(13,124,102,.22); }

/* Photo carousel */
.photos { position: relative; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 10; background: var(--skel); }
.track { display: flex; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.track::-webkit-scrollbar { display: none; }
.track img { flex: 0 0 100%; width: 100%; height: 100%; object-fit: cover; scroll-snap-align: start; display: block; }
.nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border-radius: 50%; border: none;
  background: rgba(255,255,255,.92); color: #1d1d1f; font-size: 18px; line-height: 1; cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,.2); opacity: 0; transition: opacity .15s, transform .15s; display: grid; place-items: center;
}
.nav.prev { left: 10px; } .nav.next { right: 10px; }
.nav:hover { transform: translateY(-50%) scale(1.08); }
.card:hover .nav { opacity: 1; }
.dots { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); display: flex; gap: 5px; pointer-events: none; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.6); transition: background .2s, transform .2s; }
.dots i.on { background: var(--surface); transform: scale(1.2); }
.badges { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; flex-wrap: wrap; pointer-events: none; }
.badge { background: rgba(255,255,255,.95); color: #1d1d1f; font-size: 11px; font-weight: 600; padding: 4px 8px; border-radius: 6px; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.badge.new { background: var(--brand); color: #fff; }
.badge.drop { background: #fff4e5; color: #9a4b00; }
.fav {
  position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; border: none; background: none; cursor: pointer;
  display: grid; place-items: center; transition: transform .15s;
}
.fav:hover { transform: scale(1.1); }
.fav svg { width: 24px; height: 24px; fill: rgba(0,0,0,.35); stroke: #fff; stroke-width: 2; transition: fill .15s; }
.fav.on svg { fill: #e0245e; }
.fav.pulse { animation: heart .35s ease-out; }
@keyframes heart { 40% { transform: scale(1.35); } }

.card .info { padding: 10px 2px 2px; }
.price { font-weight: 700; font-size: 18px; letter-spacing: -.01em; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.price small { font-weight: 500; font-size: 13px; color: var(--muted); }
.price s { font-weight: 500; font-size: 13px; color: var(--muted); }
.addr { font-size: 14px; color: var(--ink); margin-top: 2px; }
.meta { color: var(--muted); font-size: 13px; margin-top: 3px; }
.meta .dist { color: var(--brand-text); font-weight: 500; }

/* Skeletons while "searching" */
.skel { pointer-events: none; }
.skel .sk { background: linear-gradient(90deg, var(--skel) 0%, var(--skel-2) 40%, var(--skel) 80%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; }
.skel .photos .sk { position: absolute; inset: 0; border-radius: 0; }
.skel .sk.l1 { height: 18px; width: 40%; margin-top: 4px; }
.skel .sk.l2 { height: 13px; width: 65%; margin-top: 8px; }
.skel .sk.l3 { height: 13px; width: 50%; margin-top: 6px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* Empty states */
.empty { text-align: center; padding: 48px 24px; color: var(--muted); display: grid; justify-items: center; gap: 10px; animation: rise .3s ease-out; }
.empty .ico { width: 64px; height: 64px; border-radius: 50%; background: var(--brand-soft); display: grid; place-items: center; }
.empty .ico svg { width: 30px; height: 30px; color: var(--brand-text); }
.empty h3 { font-size: 16px; color: var(--ink); font-weight: 600; }
.empty p { font-size: 14px; max-width: 280px; }
.btn { margin-top: 6px; padding: 10px 18px; border: none; border-radius: 10px; background: var(--brand); color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; transition: background .15s, transform .1s; }
.btn:hover { background: var(--brand-dark); }
.btn:active { transform: scale(.97); }

/* ---------- Map pins ---------- */
.leaflet-div-icon, .me-icon { background: none; border: none; }
.pin-wrap { position: absolute; transform: translate(-50%, -100%); padding-bottom: 7px; }
.price-pin {
  position: relative; background: var(--surface); color: var(--ink); font-weight: 700; font-size: 13px; white-space: nowrap;
  padding: 5px 10px; border-radius: 999px; box-shadow: 0 2px 6px rgba(0,0,0,.25);
  transform-origin: 50% calc(100% + 7px); transition: transform .15s, background .15s, color .15s;
  animation: pop .3s cubic-bezier(.34,1.56,.64,1);
}
/* Small arrow pointing at the exact place */
.price-pin::after {
  content: ''; position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%);
  border: 6px solid transparent; border-bottom: 0; border-top-color: var(--surface); transition: border-color .15s;
}
.pin-heart { color: #e0245e; margin-right: 3px; }
@keyframes pop { from { opacity: 0; transform: scale(.3); } }
/* Seen: soft gray (like Airbnb) */
.price-pin.seen { background: var(--pin-seen-bg); color: var(--pin-seen-ink); }
.price-pin.seen::after { border-top-color: var(--pin-seen-bg); }
/* Hover from the list */
.price-pin.active { background: var(--ink); color: var(--on-ink); transform: scale(1.1); }
.price-pin.active::after { border-top-color: var(--ink); }
/* Selected: brand color + bounce */
.price-pin.selected { background: var(--brand); color: #fff; transform: scale(1.18); animation: bounce .45s ease-out; }
.price-pin.selected::after { border-top-color: var(--brand); }
.price-pin.selected .pin-heart { color: #fff; }
@keyframes bounce { 0% { transform: scale(1); } 40% { transform: scale(1.3) translateY(-6px); } 70% { transform: scale(1.12); } 100% { transform: scale(1.18); } }
/* Bubbles with the number of listings */
.cl-wrap { position: absolute; transform: translate(-50%, -50%); }
.cluster {
  display: grid; place-items: center; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 700; font-size: 13px;
  border: 3px solid var(--surface); box-shadow: 0 2px 8px rgba(0,0,0,.3); cursor: pointer; transition: transform .15s, background .15s;
  animation: pop .3s cubic-bezier(.34,1.56,.64,1);
}
.cluster:hover { transform: scale(1.1); }
.cluster.active { background: var(--ink); transform: scale(1.12); }
.list-more { text-align: center; color: var(--muted); font-size: 13px; padding: 8px 12px 16px; line-height: 1.5; }

/* Mini card when hovering a pin */
#hovercard {
  position: absolute; left: 0; top: 0; z-index: 1000; width: 230px; background: var(--surface); border-radius: 12px; overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,.22); pointer-events: none; opacity: 0; transition: opacity .12s;
}
#hovercard.show { opacity: 1; }
#hovercard img { width: 100%; height: 128px; object-fit: cover; display: block; background: var(--skel); }
#hovercard .info { padding: 8px 10px 10px; }
#hovercard .price { font-size: 16px; }
#hovercard .addr, #hovercard .meta { font-size: 12px; }

/* Custom map buttons (Center on me, Draw zone) */
.map-btn {
  display: flex; align-items: center; gap: 6px; background: var(--surface); color: var(--ink); border: none; cursor: pointer;
  border-radius: 10px; box-shadow: 0 1px 6px rgba(0,0,0,.25); font-family: var(--font); font-size: 13px; font-weight: 600;
  transition: background .15s;
}
.map-btn:hover { background: var(--hover); }
.map-btn.round { width: 40px; height: 40px; justify-content: center; }
.map-btn.round svg { width: 20px; height: 20px; color: #1a73e8; }
.map-btn.pill { padding: 9px 12px; }
.map-btn.pill svg { width: 16px; height: 16px; }
.map-btn.on { background: var(--ink); color: var(--on-ink); }

/* Drawing mode */
#drawlayer { position: absolute; inset: 0; z-index: 950; cursor: crosshair; touch-action: none; display: none; }
body.drawing #drawlayer { display: block; }
#drawbar {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1001; display: none; align-items: center; gap: 12px;
  background: var(--ink); color: var(--on-ink); padding: 10px 10px 10px 16px; border-radius: 999px; font-size: 13px; font-weight: 500;
  box-shadow: 0 4px 14px rgba(0,0,0,.3); white-space: nowrap;
}
body.drawing #drawbar { display: flex; animation: drop .25s ease-out; }
body.drawing #searchhere, body.drawing #autosearch { display: none; }
#drawbar button { border: none; background: rgba(127,127,127,.25); color: var(--on-ink); padding: 6px 12px; border-radius: 999px; font: inherit; font-weight: 600; cursor: pointer; }
#drawbar button:hover { background: rgba(127,127,127,.4); }

.halo { animation: halo 1.6s ease-in-out infinite; }
@keyframes halo { 50% { stroke-opacity: .25; fill-opacity: .05; } }
.me-dot { width: 16px; height: 16px; border-radius: 50%; background: #1a73e8; border: 3px solid #fff; box-shadow: 0 0 0 0 rgba(26,115,232,.4); animation: me 2s infinite; }
@keyframes me { 0% { box-shadow: 0 0 0 0 rgba(26,115,232,.45); } 70% { box-shadow: 0 0 0 12px rgba(26,115,232,0); } 100% { box-shadow: 0 0 0 0 rgba(26,115,232,0); } }
.leaflet-popup-content { font-family: var(--font); }

/* ---------- Mobile only ---------- */
#toggle, #preview { display: none; }

@media (max-width: 800px) {
  header { padding: 8px 12px; gap: 8px; }
  .logo small, .logo b, #locate span { display: none; }
  #searchbox { margin-left: 0; }
  #locate { padding: 9px; }
  #locate svg { width: 18px; height: 18px; }
  main { position: relative; }
  /* The list slides up over the map */
  #side {
    position: absolute; inset: 0; width: 100%; z-index: 1100; background: var(--surface); border: none;
    transform: translateY(100%); visibility: hidden; transition: transform .3s cubic-bezier(.2,.8,.2,1), visibility .3s;
  }
  body.show-list #side { transform: none; visibility: visible; }
  #list { padding-bottom: 90px; }
  .nav { display: none; }
  .card:hover { transform: none; box-shadow: none; }
  .card.selected { box-shadow: 0 0 0 2px var(--brand); }
  #toggle {
    display: flex; align-items: center; gap: 6px; position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
    transform: translateX(-50%); z-index: 1200; background: var(--ink); color: var(--on-ink); border: none; border-radius: 999px;
    padding: 12px 20px; font-size: 14px; font-weight: 600; box-shadow: 0 4px 14px rgba(0,0,0,.3); cursor: pointer; transition: transform .1s;
  }
  #toggle:active { transform: translateX(-50%) scale(.96); }
  /* Preview when tapping a pin */
  #preview.show {
    display: flex; position: absolute; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 1000;
    background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: 0 6px 20px rgba(0,0,0,.25); cursor: pointer;
    animation: rise .25s ease-out;
  }
  #preview > img { width: 120px; min-height: 104px; object-fit: cover; }
  #preview .info { padding: 10px 40px 10px 12px; min-width: 0; }
  #preview .x { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%; border: none; background: var(--hover); cursor: pointer; }
  #status { top: 10px; bottom: auto; left: 54px; right: 10px; }
  #autosearch { display: none; }
  #hovercard { display: none; }
  #drawbar { top: auto; bottom: calc(24px + env(safe-area-inset-bottom)); left: 12px; right: 12px; transform: none; justify-content: space-between; }
  body.drawing #toggle { display: none; }
  #searchhere { top: 10px; }
  /* Full-screen detail, slides up from below */
  #detail { position: fixed; inset: 0; width: auto; z-index: 1300; border: none; box-shadow: none; transform: translateY(100%); }
  body.show-detail #toggle { display: none; }
  /* More compact detail buttons and the modal as a rising sheet */
  .d-cta { padding-left: 16px; padding-right: 16px; }
  .d-cta .price { font-size: 16px; }
  .d-cta .btn { padding: 12px 14px; font-size: 14px; }
  .d-pager span { display: none; }
  .m-card {
    left: 0; right: 0; top: auto; bottom: 0; width: auto; transform: none; max-height: 92dvh;
    border-radius: 20px 20px 0 0; padding-bottom: env(safe-area-inset-bottom); animation: sheetIn .3s cubic-bezier(.2,.8,.2,1);
  }
  #toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
  #filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 8px 12px;
    -webkit-mask-image: linear-gradient(to right, #000 80%, transparent); mask-image: linear-gradient(to right, #000 80%, transparent); }
  #filters.at-end { -webkit-mask-image: none; mask-image: none; }
  #filters::-webkit-scrollbar { display: none; }
  #filters > * { flex-shrink: 0; }
}

/* ---------- Accessibility: visible focus when using the keyboard ---------- */
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--brand-text); outline-offset: 2px; }
.card:focus-visible { outline-offset: 4px; }
.leaflet-marker-icon:focus-visible { outline: none; }
.leaflet-marker-icon:focus-visible .price-pin,
.leaflet-marker-icon:focus-visible .cluster { outline: 3px solid var(--brand-text); outline-offset: 3px; }
.card:focus-within .nav { opacity: 1; }
.skip {
  position: fixed; left: 12px; top: -80px; z-index: 5000; background: var(--ink); color: var(--on-ink);
  padding: 12px 18px; border-radius: 10px; font-weight: 600; text-decoration: none; transition: top .15s;
}
.skip:focus { top: 12px; }

/* ---------- 44 px touch targets on touch screens ---------- */
@media (pointer: coarse) {
  #locate { min-width: 44px; min-height: 44px; justify-content: center; }
  #theme-btn { width: 44px; height: 44px; }
  #q { min-height: 44px; }
  #q-clear { width: 32px; height: 32px; }
  #filters select, #sort, .chips button, #f-more, .achip, #active .link { min-height: 44px; }
  #f-clear { min-height: 44px; padding: 0 8px; }
  .achip { padding-left: 14px; }
  .leaflet-touch .leaflet-bar a { width: 44px; height: 44px; line-height: 44px; }
  .map-btn.round { width: 44px; height: 44px; }
  .map-btn.pill { min-height: 44px; }
  .fav { width: 44px; height: 44px; top: 4px; right: 4px; }
  .d-icon, .d-icon.sm, .m-x { width: 44px; height: 44px; }
  .d-back { min-height: 44px; }
  #preview .x { width: 44px; height: 44px; top: 0; right: 0; background: none; font-size: 15px; }
  .slot, .seg button, .opt { min-height: 44px; }
  .price-pin { padding: 7px 11px; } /* ~34 px tall: the WCAG AA minimum is 24 px */
  #drawbar button { min-height: 36px; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Bolivia: operation, dual currency, agent and WhatsApp ---------- */
.op { display: flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.op button { padding: 6px 14px; border: none; border-radius: 999px; background: none; color: var(--ink-2); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s, color .15s; }
.op button:hover { color: var(--ink); }
.op button.on { background: var(--brand); color: #fff; }
.price .eq { flex-basis: 100%; font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-top: -2px; }
.addr b { font-weight: 600; color: var(--ink); }
.d-eq { font-size: 14px; font-weight: 500; color: var(--ink-2); margin-top: 2px; }
.d-eq span { color: var(--muted); font-weight: 400; font-size: 13px; }
.d-small { font-size: 13px; color: var(--muted); margin-top: 10px; }
.d-small b { color: var(--ink); font-weight: 600; }
.agent { display: flex; align-items: center; gap: 12px; margin-top: 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.agent .av { width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); font-weight: 700; font-size: 14px; }
.agent > div:nth-child(2) { flex: 1; min-width: 0; }
.agent b { display: block; font-size: 14px; }
.agent small { display: block; font-size: 12.5px; color: var(--muted); }
.btn.wa { background: #17814a; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.btn.wa:hover { background: #126b3c; }
.btn.wa svg { width: 18px; height: 18px; }
.wa-chat { background: var(--surface-2); border-radius: 12px; padding: 12px; }
.wa-label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.wa-chat textarea { width: 100%; border: none; border-radius: 10px 10px 2px 10px; padding: 10px 12px; background: #d9fdd3; color: #111; font: inherit; font-size: 14px; line-height: 1.45; resize: vertical; }
html.dark .wa-chat textarea { background: #144d37; color: #e9edef; }
.wa-check { background: #17814a !important; color: #fff; }
.wa-check svg { width: 28px; height: 28px; }
.wa-bubble { background: #d9fdd3; color: #111; line-height: 1.5; }
html.dark .wa-bubble { background: #144d37; color: #e9edef; }
/* Paperwork and services */
.badge.ok { background: #e6f5ec; color: #16653a; }
h3 .badge { vertical-align: middle; margin-left: 6px; font-size: 11px; box-shadow: none; }
.docs { list-style: none; padding: 0; display: grid; gap: 10px; font-size: 14px; }
.docs li { display: flex; gap: 10px; align-items: flex-start; }
.docs li::before { content: '✓'; flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: #e6f5ec; color: #16653a; }
.docs li.n::before { content: '!'; background: #fff4e5; color: #9a4b00; }
.docs b, .docs li > div { font-weight: 500; }
.docs small { display: block; font-size: 12.5px; color: var(--muted); font-weight: 400; }
.d-tip { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--brand-soft); color: var(--brand-ink); font-size: 13.5px; line-height: 1.5; }
.svc { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; font-size: 14px; }
.svc li { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.svc li.n { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.svc li.n span { filter: grayscale(1); opacity: .6; }
.svc small { flex-basis: 100%; margin-left: 24px; margin-top: -6px; font-size: 12px; color: #9a4b00; text-decoration: none; display: inline-block; }
html.dark .badge.ok, html.dark .docs li::before { background: #173d29; color: #7fdca5; }
html.dark .docs li.n::before { background: #46300f; color: #ffc77a; }
html.dark .svc small { color: #ffc77a; }
/* Price per m² versus the area */
.badge.deal { background: #eef3ff; color: #1f4fbf; }
.m2 { margin-top: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.m2-head { font-size: 13.5px; color: var(--ink-2); line-height: 1.4; }
.m2-head b { color: var(--ink); }
.m2-head b.good { color: #16653a; } .m2-head b.high { color: #9a4b00; }
html.dark .m2-head b.good { color: #7fdca5; } html.dark .m2-head b.high { color: #ffc77a; }
.m2-bar { position: relative; height: 6px; margin: 12px 0 6px; border-radius: 999px; background: linear-gradient(90deg, #2e9e5b, #d8d8d8 50%, #e08a2b); }
.m2-bar i { position: absolute; top: 50%; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--ink); transform: translate(-50%, -50%); }
.m2-legend { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--muted); }
/* Calculators */
.calc { display: grid; gap: 14px; padding: 14px; border-radius: 12px; background: var(--surface-2); }
.c-range { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; font-size: 13.5px; color: var(--ink-2); }
.c-range output { font-weight: 600; color: var(--ink); }
.c-range input { grid-column: 1 / -1; width: 100%; height: 24px; margin: 0; accent-color: var(--brand); }
.c-check { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: 13.5px; font-weight: 500; }
.c-check input { accent-color: var(--brand); transform: translateY(1px); }
.c-check small { color: var(--muted); font-weight: 400; }
.c-result { display: grid; gap: 2px; padding: 12px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); }
.c-result small { font-size: 12.5px; color: var(--muted); }
.c-result b { font-size: 24px; letter-spacing: -.02em; color: var(--brand-text); }
.c-result.bad b { color: #b3261e; }
.c-result span { font-size: 12.5px; color: var(--muted); }
.c-rows { display: grid; gap: 6px; font-size: 13.5px; }
.c-rows div { display: flex; justify-content: space-between; gap: 12px; }
.c-rows span { color: var(--ink-2); } .c-rows b { font-weight: 600; text-align: right; }
.c-note { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.c-note:empty { display: none; }
/* WhatsApp on the card */
.card-body { position: relative; }
.card-body .info { padding-right: 52px; }
.card-wa { position: absolute; right: 2px; top: 12px; width: 40px; height: 40px; border-radius: 50%; border: none; display: grid; place-items: center; background: #17814a; color: #fff; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.15); transition: transform .12s, background .15s; }
.card-wa:hover { background: #126b3c; transform: scale(1.06); }
.card-wa svg { width: 20px; height: 20px; }
@media (max-width: 800px) { .op button { padding: 10px 14px; min-height: 38px; } .card-wa { width: 44px; height: 44px; } }
