/* map.css: the Home listings map (template-parts/home-map.php, assets/js/map.js). Front page only. */

.bd-map {
  --map-land: #FFFFFF;
  --map-land-live: #D3F1F9;
  --map-border: #C9DBE6;
  --map-pin: var(--sky-deep, #116E8D);
  --map-pin-on: var(--navy, #16293D);
  --pin: 40px;
  --dia: 27px;
  position: relative;
  max-width: 100%;
  background: var(--sky-tint, #EAF9FD);
  border: 1px solid var(--line, #E3EAF0);
  border-radius: var(--r-card-lg, 16px);
  padding: clamp(14px, 3vw, 40px);
  isolation: isolate;
}
/* the brand diamond, outlined, in the corner (the prototype's slot decoration), clipped to the box */
.bd-map-deco { position: absolute; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; border-radius: inherit; }
.bd-map-deco::before {
  content: ""; position: absolute; width: 300px; height: 300px; left: -130px; top: -120px;
  border: 1.5px solid rgba(17, 110, 141, .10); border-radius: 30px; transform: rotate(45deg);
}

.bd-map-stage { position: relative; width: 100%; max-width: 960px; margin: 0 auto; }
.bd-map-frame { position: relative; width: 100%; aspect-ratio: 975 / 610; }
.bd-map-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }

.bd-map-state {
  fill: var(--map-land); stroke: var(--map-border); stroke-width: .9; stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  transition: fill .3s var(--ease-smooth, ease);
}
.bd-map-state.has-listings { fill: var(--map-land-live); cursor: pointer; }
.bd-map-state.is-hot { fill: #B6E9F6; }
.bd-map-leaders line { stroke: var(--map-pin); stroke-width: 1; vector-effect: non-scaling-stroke; opacity: .7; }
.bd-map-leaders circle { fill: var(--map-pin); }

/* ---- markers: real buttons laid over the SVG, positioned by percentage ---- */
.bd-map-pins { list-style: none; margin: 0; padding: 0; position: absolute; inset: 0; pointer-events: none; } /* clicks between markers reach the state shapes */
.bd-map-pin-item { position: absolute; width: 0; height: 0; margin: 0; padding: 0; }
.bd-map .bd-map-pin {
  position: absolute; left: calc(var(--pin) / -2); top: calc(var(--pin) / -2);
  width: var(--pin); height: var(--pin); padding: 0; margin: 0;
  display: grid; place-items: center;
  background: transparent !important; border: 0; border-radius: 50%;
  cursor: pointer; color: #FFFFFF; font: inherit; pointer-events: auto;
  translate: var(--nx, 0px) var(--ny, 0px);
  -webkit-tap-highlight-color: transparent;
}
.bd-map-pin-dia { position: relative; display: grid; place-items: center; width: var(--dia); height: var(--dia); }
.bd-map-pin-dia::before {
  content: ""; position: absolute; inset: 0;
  background: var(--map-pin); border: 2px solid #FFFFFF; border-radius: 6px;
  transform: rotate(45deg);
  box-shadow: 0 0 0 6px rgba(17, 110, 141, .14), 0 6px 14px rgba(14, 29, 46, .20);
  transition: background-color .26s var(--ease-smooth, ease), box-shadow .34s var(--ease-smooth, ease), transform .34s var(--ease-smooth, ease);
}
.bd-map-pin-n {
  position: relative; font-family: var(--f-head, inherit); font-weight: 700; font-size: 13px; line-height: 1;
  letter-spacing: -.01em; color: #FFFFFF; font-variant-numeric: tabular-nums;
}
.bd-map .bd-map-pin:hover .bd-map-pin-dia::before,
.bd-map .bd-map-pin:focus-visible .bd-map-pin-dia::before {
  transform: rotate(45deg) scale(1.12);
  box-shadow: 0 0 0 8px rgba(17, 110, 141, .18), 0 8px 18px rgba(14, 29, 46, .24);
}
.bd-map .bd-map-pin[aria-expanded="true"] .bd-map-pin-dia::before {
  background: var(--map-pin-on);
  box-shadow: 0 0 0 7px rgba(105, 212, 237, .45), 0 8px 18px rgba(14, 29, 46, .26);
}
.bd-map .bd-map-pin:focus-visible { outline: 2px solid var(--sky-deep, #116E8D); outline-offset: 2px; border-radius: 50%; }

/* state name tag on hover and keyboard focus */
.bd-map .bd-map-pin::after {
  content: attr(data-tip);
  position: absolute; left: 50%; bottom: calc(100% + 4px);
  padding: 4px 9px; border-radius: 8px; white-space: nowrap;
  background: var(--navy, #16293D); color: #FFFFFF;
  font-family: var(--f-body, inherit); font-size: 12.5px; font-weight: 600; line-height: 1.3;
  opacity: 0; transform: translate(-50%, 4px); pointer-events: none;
  transition: opacity .2s var(--ease-smooth, ease), transform .26s var(--ease-smooth, ease);
}
.bd-map .bd-map-pin:hover::after,
.bd-map .bd-map-pin:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }
.bd-map .bd-map-pin[aria-expanded="true"]::after { opacity: 0; }
.bd-map-pin-item:has(.bd-map-pin:hover), .bd-map-pin-item:has(.bd-map-pin:focus-visible), .bd-map-pin-item:has([aria-expanded="true"]) { z-index: 3; }

/* small Northeast states: callout marker in the ocean with its abbreviation */
.bd-map-pin-abbr {
  position: absolute; left: calc(50% + var(--dia) / 2 + 9px); top: 50%; transform: translateY(-50%);
  font-family: var(--f-head, inherit); font-size: 12px; font-weight: 700; letter-spacing: .04em;
  color: var(--sky-deep, #116E8D); line-height: 1;
}
.bd-map-pin-item.is-callout .bd-map-pin::after { left: auto; right: calc(50% - 14px); transform: translate(0, 4px); }
.bd-map-pin-item.is-callout .bd-map-pin:hover::after,
.bd-map-pin-item.is-callout .bd-map-pin:focus-visible::after { transform: translate(0, 0); }

/* ---- pop-ups ---- */
.bd-map-pops { margin-top: 24px; display: grid; gap: 16px; align-items: start; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.bd-map-pop {
  position: relative; background: #FFFFFF; border: 1px solid var(--line, #E3EAF0);
  border-radius: 14px; box-shadow: var(--shadow, 0 1px 2px rgba(14, 29, 46, .06), 0 6px 18px rgba(14, 29, 46, .06));
  display: flex; flex-direction: column; min-width: 0;
}
.bd-map-pop:focus { outline: none; }
.bd-map-pop:focus-visible { outline: 2px solid var(--sky-deep, #116E8D); outline-offset: 2px; }
.bd-map-pop-nub { display: none; }
.bd-map-pop-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 16px 12px 12px 18px; border-bottom: 1px solid var(--line, #E3EAF0);
}
.bd-map .bd-map-pop-h {
  margin: 0; font-family: var(--f-head, inherit); font-size: 1.0625rem; font-weight: 600; line-height: 1.3;
  letter-spacing: -.01em; color: var(--navy, #16293D); max-width: none;
}
.bd-map .bd-map-close {
  flex: none; width: 36px; height: 36px; margin: -6px 0 -6px 0; display: grid; place-items: center;
  border: 0; border-radius: 10px; background: transparent; color: var(--text-light, #5E7488); cursor: pointer; padding: 0;
}
.bd-map .bd-map-close:hover { background: var(--sky-tint, #EAF9FD); color: var(--navy, #16293D); }
.bd-map .bd-map-close:hover svg { transform: none; }
.bd-map-close svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

.bd-map-list { list-style: none; margin: 0; padding: 6px; }
.bd-map-list li { margin: 0; padding: 0; }
.bd-map a.bd-map-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 10px; border-radius: 10px;
  color: var(--text, #24384A); text-decoration: none;
}
.bd-map a.bd-map-item:hover, .bd-map a.bd-map-item:focus-visible { background: var(--sky-tint, #EAF9FD); color: var(--text, #24384A); }
.bd-map-thumb {
  flex: none; width: 64px; height: 48px; border-radius: 8px; overflow: hidden; background: var(--sky-tint, #EAF9FD);
  display: grid; place-items: center;
}
.bd-map-thumb img { width: 100%; height: 100%; object-fit: cover; }
.bd-map-thumb-dia { width: 12px; height: 12px; border-radius: 2px; background: var(--sky-deep, #116E8D); transform: rotate(45deg); opacity: .55; }
.bd-map-item-body { flex: 1; min-width: 0; display: grid; gap: 3px; }
.bd-map-item-title { font-size: .9375rem; font-weight: 600; line-height: 1.35; color: var(--navy, #16293D); }
.bd-map-item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: .875rem; line-height: 1.35; color: var(--text-light, #5E7488); }
.bd-map-item-ask { font-weight: 600; color: var(--sky-deep, #116E8D); font-variant-numeric: tabular-nums; }
.bd-map-item-status { display: inline-flex; align-items: center; gap: 6px; }
.bd-map-item-status::before { content: ""; width: 6px; height: 6px; border-radius: 1px; background: currentColor; transform: rotate(45deg); opacity: .7; }
.bd-map-item-go { flex: none; fill: none; stroke: var(--sky-deep, #116E8D); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* without JavaScript the markers cannot open anything: the pop-ups stay a plain list below the map */
html:not(.bd-js) .bd-map-close { display: none; }

/* ---- with JavaScript: anchored pop-up next to its marker ---- */
.bd-js .bd-map-pops { margin: 0; display: block; }
.bd-js .bd-map-pop {
  display: none; position: absolute; z-index: 20; left: 0; top: 0;
  width: 340px; max-width: calc(100% - 24px); max-height: min(380px, calc(100% - 24px));
  box-shadow: var(--shadow-lg, 0 24px 60px rgba(14, 29, 46, .18), 0 4px 12px rgba(14, 29, 46, .08));
  opacity: 0; transform: scale(.86);
  transition: opacity .2s var(--ease-smooth, ease), transform .32s cubic-bezier(.2, .9, .3, 1.15);
}
.bd-js .bd-map-pop.is-open { display: flex; }
.bd-js .bd-map-pop.is-shown { opacity: 1; transform: none; }
.bd-js .bd-map-pop.is-closing { transition: opacity .16s var(--ease-smooth, ease), transform .2s var(--ease-smooth, ease); }
.bd-js .bd-map-list { overflow-y: auto; overscroll-behavior: contain; min-height: 0; flex: 1; scrollbar-width: thin; }
.bd-js .bd-map-pop-nub {
  display: block; position: absolute; width: 14px; height: 14px; background: #FFFFFF;
  border: 1px solid var(--line, #E3EAF0); border-radius: 3px; transform: rotate(45deg);
  top: var(--nub-y, 28px); margin-top: -7px;
}
.bd-js .bd-map-pop.at-right .bd-map-pop-nub { left: -8px; border-top-color: transparent; border-right-color: transparent; }
.bd-js .bd-map-pop.at-left .bd-map-pop-nub { right: -8px; border-bottom-color: transparent; border-left-color: transparent; }
.bd-js .bd-map-pop.is-docked .bd-map-pop-nub { display: none; }
.bd-js .bd-map-pop.is-docked {
  left: 8px !important; right: 8px; top: auto !important; bottom: 8px; width: auto; max-width: none;
  max-height: max(calc(100% - 16px), min(360px, 62vh));
}

@media (max-width: 900px) {
  .bd-map { --pin: 34px; --dia: 23px; }
  .bd-map-pin-n { font-size: 12px; }
  .bd-map-pin-dia::before { border-radius: 5px; box-shadow: 0 0 0 4px rgba(17, 110, 141, .14), 0 4px 10px rgba(14, 29, 46, .20); }
}

/* phones: smaller markers, the Northeast callouts dock in a row under the map, the pop-up docks to the bottom */
@media (max-width: 600px) {
  .bd-map { --pin: 32px; --dia: 20px; padding: 10px; }
  .bd-map-pin-n { font-size: 11px; }
  .bd-map-pin-dia::before { border-width: 1.5px; border-radius: 4px; box-shadow: 0 0 0 3px rgba(17, 110, 141, .14), 0 3px 8px rgba(14, 29, 46, .22); }
  .bd-map .bd-map-pin::after { display: none; }
  .bd-map-leaders { display: none; }
  .bd-map-stage.has-dock-1 { padding-bottom: 46px; }
  .bd-map-stage.has-dock-2 { padding-bottom: 88px; }
  .bd-map-stage.has-dock-3 { padding-bottom: 130px; }
  .bd-map-pin-item.is-callout {
    left: calc(var(--dc) * 25% + 2px) !important; top: calc(100% + 8px + var(--dr) * 42px) !important;
    width: calc(25% - 4px); height: 36px;
  }
  .bd-map-pin-item.is-callout .bd-map-pin {
    left: 0; top: 0; width: 100%; height: 36px; translate: none;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    background: #FFFFFF !important; border: 1px solid var(--line, #E3EAF0); border-radius: 10px;
  }
  .bd-map-pin-item.is-callout .bd-map-pin-abbr { position: static; transform: none; font-size: 12px; }
  .bd-map-pin-item.is-callout .bd-map-pin:focus-visible { border-radius: 10px; }
  .bd-map-thumb { width: 52px; height: 40px; }
  .bd-map a.bd-map-item { gap: 10px; padding: 9px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .bd-js .bd-map-pop, .bd-js .bd-map-pop.is-closing { transition: none; transform: none; }
  .bd-map-pin-dia::before, .bd-map .bd-map-pin::after, .bd-map-state { transition: none; }
  .bd-map .bd-map-pin:hover .bd-map-pin-dia::before, .bd-map .bd-map-pin:focus-visible .bd-map-pin-dia::before { transform: rotate(45deg); }
}
