/* ==========================================================================
   Nearby explorer — category toggles + slide-in list over a Leaflet map.
   Lives inside the community location box (.wh-comm-map). Square corners,
   hairlines, olive on paper — same vocabulary as the rest of the site.
   ========================================================================== */

.wh-nearby {
  --wn-olive: var(--whh-olive, #494F25);
  --wn-ink: var(--text-heading, #23231E);
  --wn-muted: var(--text-muted, #6B6A5F);
  --wn-paper: #FBF8F2;
  --wn-paper-deep: #F3EEE6;
  --wn-line: rgba(35, 35, 30, 0.14);
  --wn-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --wn-panel-w: clamp(236px, 42%, 310px);
  --wn-chips-h: 34px;
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  background: #e8e4da;
  font-family: var(--font-sans, Montserrat, sans-serif);
  color: var(--wn-ink);
  /* the site's button reset leaks uppercase + nowrap; reset here, opt back in on chips */
  text-transform: none;
  white-space: normal;
  letter-spacing: normal;
}

.wh-nearby__map {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #e8e4da;
}
.wh-nearby__map.leaflet-container { font-family: inherit; }
.wh-nearby__map .leaflet-control-attribution {
  font-size: 10px;
  padding: 2px 6px;
  background: rgba(251, 248, 242, 0.85) !important;
  color: var(--wn-muted);
}
.wh-nearby__map .leaflet-control-attribution a { color: var(--wn-muted); }
.wh-nearby__map .leaflet-bar { border: 0; box-shadow: 0 6px 18px rgba(35, 35, 30, 0.14); }
.wh-nearby__map .leaflet-control-zoom a {
  width: 34px !important;
  height: 34px !important;
  line-height: 34px !important;
  border-radius: 0 !important;
  color: var(--wn-ink) !important;
  background: rgba(251, 248, 242, 0.96) !important;
  border-color: var(--wn-line) !important;
}
.wh-nearby__map .leaflet-control-zoom a:hover { background: #fff !important; }

/* Give the tiles the same warm, slightly quiet cast as the rest of the page. */
.wh-nearby__map .leaflet-tile-pane { filter: saturate(0.72) contrast(0.96) brightness(1.02); }

/* --- Category chips --------------------------------------------------- */

.wh-nearby__chips {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  pointer-events: none; /* let map drag through the gaps */
}
.wh-nearby__chips > * { pointer-events: auto; }

.wh-nearby .wh-nearby__chip {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex !important;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  margin: 0;
  padding: 0 12px 0 10px !important;
  border: 1px solid var(--wn-line) !important;
  border-radius: 0 !important;
  background: rgba(251, 248, 242, 0.94) !important;
  color: var(--wn-ink) !important;
  -webkit-text-fill-color: currentColor !important;
  font: 600 0.66rem/1 var(--font-sans, Montserrat, sans-serif) !important;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(35, 35, 30, 0.12);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition:
    background-color 220ms var(--wn-ease),
    color 220ms var(--wn-ease),
    border-color 220ms var(--wn-ease),
    box-shadow 220ms var(--wn-ease),
    transform 220ms var(--wn-ease);
}
.wh-nearby .wh-nearby__chip:hover {
  background: #fff !important;
  border-color: rgba(73, 79, 37, 0.45) !important;
}
.wh-nearby .wh-nearby__chip:active { transform: translateY(1px); }
.wh-nearby .wh-nearby__chip:focus-visible {
  outline: 2px solid var(--wn-olive);
  outline-offset: 2px;
}
.wh-nearby .wh-nearby__chip.is-on {
  background: var(--wn-olive) !important;
  border-color: var(--wn-olive) !important;
  color: var(--wn-paper) !important;
  box-shadow: 0 8px 20px rgba(73, 79, 37, 0.28);
}
.wh-nearby__chip-icon { display: inline-flex; color: var(--wn-olive); transition: color 220ms var(--wn-ease); }
.wh-nearby .wh-nearby__chip.is-on .wh-nearby__chip-icon { color: var(--wn-paper); }
.wh-nearby__chip-count {
  padding-left: 7px;
  border-left: 1px solid var(--wn-line);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--wn-muted);
  letter-spacing: 0.04em;
  transition: color 220ms var(--wn-ease), border-color 220ms var(--wn-ease);
}
.wh-nearby .wh-nearby__chip.is-on .wh-nearby__chip-count {
  color: rgba(251, 248, 242, 0.8);
  border-left-color: rgba(251, 248, 242, 0.3);
}

/* --- Empty hint ------------------------------------------------------- */

.wh-nearby__hint {
  position: absolute;
  left: 58px;
  bottom: 62px;
  z-index: 3;
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--wn-line);
  background: rgba(251, 248, 242, 0.94);
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--wn-muted);
  transition: opacity 260ms var(--wn-ease), transform 260ms var(--wn-ease);
}
.wh-nearby__hint.is-hidden { opacity: 0; transform: translateY(6px); pointer-events: none; }

/* --- Walk Score badge ------------------------------------------------- */

.wh-nearby .wh-nearby__walk {
  position: absolute;
  left: 58px;
  bottom: 14px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 5px 11px 5px 7px;
  border: 1px solid var(--wn-line);
  background: rgba(251, 248, 242, 0.94);
  color: var(--wn-ink) !important;
  text-decoration: none !important;
  box-shadow: 0 4px 14px rgba(35, 35, 30, 0.12);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition: background-color 200ms var(--wn-ease), border-color 200ms var(--wn-ease);
}
.wh-nearby .wh-nearby__walk:hover { background: #fff; border-color: rgba(73, 79, 37, 0.45); }
.wh-nearby .wh-nearby__walk:focus-visible { outline: 2px solid var(--wn-olive); outline-offset: 2px; }
.wh-nearby__walk-num {
  font-family: var(--font-serif, "Cormorant Garamond", Georgia, serif);
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1;
  padding-right: 9px;
  border-right: 1px solid var(--wn-line);
  color: var(--wn-olive);
  font-variant-numeric: tabular-nums;
}
.wh-nearby__walk-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  line-height: 1;
  text-transform: uppercase;
}
.wh-nearby__walk-label sup { font-size: 0.7em; line-height: 0; }
.wh-nearby__walk-sub {
  display: block;
  font-style: normal;
  font-weight: 500;
  font-size: 0.66rem;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--wn-muted);
}

/* --- Site mark -------------------------------------------------------- */

.wh-nearby__site { background: none; border: 0; }
.wh-nearby__site-dot {
  position: absolute;
  left: -16px;
  top: -16px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--wn-ink);
  color: var(--wn-paper);
  box-shadow: 0 0 0 3px rgba(251, 248, 242, 0.95), 0 10px 22px rgba(35, 35, 30, 0.35);
}
.wh-nearby__site-dot--logo {
  left: -18px;
  top: -18px;
  width: 36px;
  height: 36px;
  padding: 5px;
  box-sizing: border-box;
}
.wh-nearby__site-dot--logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}
.wh-nearby__site-label {
  position: absolute;
  left: 50%;
  top: 20px;
  transform: translateX(-50%);
  padding: 5px 9px;
  background: var(--wn-ink);
  color: var(--wn-paper);
  font: 600 0.62rem/1 var(--font-sans, Montserrat, sans-serif);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(35, 35, 30, 0.25);
}
.wh-nearby__site:has(.wh-nearby__site-dot--logo) .wh-nearby__site-label {
  top: 22px;
}

/* --- Place pins ------------------------------------------------------- */

.wh-nearby__pin-wrap { background: none; border: 0; }
.wh-nearby__pin {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--wn-olive);
  color: var(--wn-paper);
  box-shadow: 0 0 0 2px rgba(251, 248, 242, 0.95), 0 6px 14px rgba(35, 35, 30, 0.28);
  transform-origin: 50% 50%;
  transition: transform 260ms var(--wn-ease), box-shadow 260ms var(--wn-ease), background-color 260ms var(--wn-ease);
  animation: wh-nearby-pin-in 520ms var(--wn-ease) both;
}
.wh-nearby__pin-wrap.is-hover .wh-nearby__pin,
.wh-nearby__pin-wrap:hover .wh-nearby__pin { transform: scale(1.12); }
.wh-nearby__pin-wrap.is-active .wh-nearby__pin {
  transform: scale(1.22);
  background: var(--wn-ink);
  box-shadow: 0 0 0 2px rgba(251, 248, 242, 0.95), 0 0 0 7px rgba(73, 79, 37, 0.22), 0 10px 22px rgba(35, 35, 30, 0.32);
}
.wh-nearby__pin-wrap:focus-visible { outline: none; }
.wh-nearby__pin-wrap:focus-visible .wh-nearby__pin { box-shadow: 0 0 0 2px var(--wn-paper), 0 0 0 4px var(--wn-olive); }

@keyframes wh-nearby-pin-in {
  from { opacity: 0; transform: scale(0.35); }
  60%  { opacity: 1; }
  to   { opacity: 1; transform: scale(1); }
}

.wh-nearby__tip {
  padding: 6px 10px;
  border: 1px solid var(--wn-line);
  border-radius: 0;
  background: var(--wn-paper);
  color: var(--wn-ink);
  font: 500 0.78rem/1.3 var(--font-sans, Montserrat, sans-serif);
  box-shadow: 0 8px 20px rgba(35, 35, 30, 0.18);
}
.wh-nearby__tip::before { border-top-color: var(--wn-paper) !important; }
.wh-nearby__tip-dist { margin-left: 8px; color: var(--wn-olive); font-variant-numeric: tabular-nums; }

/* --- Slide-in panel --------------------------------------------------- */

.wh-nearby__panel {
  position: absolute;
  top: calc(var(--wn-chips-h) + 22px);
  right: 12px;
  bottom: 34px;
  z-index: 5;
  width: var(--wn-panel-w);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: rgba(251, 248, 242, 0.96);
  border: 1px solid var(--wn-line);
  box-shadow: 0 18px 44px rgba(35, 35, 30, 0.22);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  opacity: 0;
  transform: translateX(24px);
  transition: opacity 300ms var(--wn-ease), transform 420ms var(--wn-ease);
}
.wh-nearby__panel.is-open { opacity: 1; transform: none; }
.wh-nearby__panel:not(.is-open) { transition-duration: 220ms, 260ms; }

.wh-nearby__panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 12px 12px 16px;
  border-bottom: 1px solid var(--wn-line);
}
.wh-nearby__panel-title {
  margin: 0;
  font-family: var(--font-serif, "Cormorant Garamond", Georgia, serif);
  font-size: 1.45rem;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--wn-ink);
}
.wh-nearby__panel-sub {
  margin: 4px 0 0;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--wn-muted);
}
.wh-nearby .wh-nearby__close {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  display: grid !important;
  place-items: center;
  width: 32px;
  height: 32px;
  margin: -4px -4px 0 0;
  padding: 0 !important;
  border: 1px solid transparent !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: var(--wn-muted) !important;
  -webkit-text-fill-color: currentColor !important;
  text-transform: none !important;
  white-space: normal !important;
  cursor: pointer;
  transition: background-color 200ms var(--wn-ease), color 200ms var(--wn-ease), border-color 200ms var(--wn-ease);
}
.wh-nearby .wh-nearby__close:hover { background: var(--wn-paper-deep) !important; color: var(--wn-ink) !important; border-color: var(--wn-line) !important; }
.wh-nearby .wh-nearby__close:focus-visible { outline: 2px solid var(--wn-olive); outline-offset: 2px; }

.wh-nearby__list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(35, 35, 30, 0.25) transparent;
}
.wh-nearby__list li { margin: 0; padding: 0; }
.wh-nearby__list li + li .wh-nearby__item { border-top: 1px solid var(--wn-line); }

.wh-nearby .wh-nearby__item {
  appearance: none;
  -webkit-appearance: none;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "name dist" "meta meta";
  align-items: baseline;
  column-gap: 12px;
  row-gap: 2px;
  width: 100%;
  margin: 0;
  padding: 11px 16px 11px 16px !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: var(--wn-ink) !important;
  -webkit-text-fill-color: currentColor !important;
  font: inherit !important;
  text-transform: none !important;
  white-space: normal !important;
  letter-spacing: 0 !important;
  text-align: left;
  cursor: pointer;
  transition: background-color 180ms var(--wn-ease);
  animation: wh-nearby-item-in 420ms var(--wn-ease) both;
  animation-delay: calc(var(--i, 0) * 26ms);
}
.wh-nearby .wh-nearby__item:hover { background: var(--wn-paper-deep) !important; }
.wh-nearby .wh-nearby__item:focus-visible { outline: 2px solid var(--wn-olive); outline-offset: -3px; }
.wh-nearby .wh-nearby__item.is-active { background: rgba(73, 79, 37, 0.1) !important; }
.wh-nearby .wh-nearby__item.is-active .wh-nearby__item-name { color: var(--wn-olive); }

.wh-nearby__item-main { display: contents; }
.wh-nearby__item-name {
  grid-area: name;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.86rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--wn-ink);
  transition: color 180ms var(--wn-ease);
}
.wh-nearby__item-meta {
  grid-area: meta;
  font-size: 0.7rem;
  line-height: 1.35;
  color: var(--wn-muted);
}
.wh-nearby__item-dist {
  grid-area: dist;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--wn-olive);
  font-variant-numeric: tabular-nums;
}

@keyframes wh-nearby-item-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.wh-nearby__panel-foot {
  padding: 9px 16px 10px;
  border-top: 1px solid var(--wn-line);
  background: rgba(243, 238, 230, 0.7);
}
.wh-nearby__panel-foot p { margin: 0; font-size: 0.7rem; line-height: 1.45; color: var(--wn-muted); }
.wh-nearby__panel-foot p + p { margin-top: 6px; }
.wh-nearby__fine { opacity: 0.85; }

/* --- Narrow: chips scroll, panel becomes a bottom sheet -------------- */

@media (max-width: 767px) {
  .wh-nearby__chips {
    flex-wrap: nowrap;
    right: 0;
    left: 0;
    padding: 0 12px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, transparent, #000 12px, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to right, transparent, #000 12px, #000 calc(100% - 28px), transparent);
  }
  .wh-nearby__chips::-webkit-scrollbar { display: none; }
  .wh-nearby .wh-nearby__chip { flex: none; }

  .wh-nearby__panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    height: 50%;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    transform: translateY(100%);
    box-shadow: 0 -14px 40px rgba(35, 35, 30, 0.22);
  }
  .wh-nearby__panel.is-open { transform: none; }
  .wh-nearby__panel-head { padding: 12px 12px 10px 16px; }
  .wh-nearby__panel-title { font-size: 1.3rem; }
  .wh-nearby .wh-nearby__item { padding: 10px 14px 10px 16px !important; }
  .wh-nearby__hint { left: 12px; bottom: 60px; right: 12px; }
  .wh-nearby .wh-nearby__walk { left: 12px; bottom: 12px; }
  .wh-nearby[data-active]:not([data-active=""]) .wh-nearby__walk { bottom: calc(50% + 12px); }
  /* pinch-zoom does the job on touch; the buttons only sit on top of pins */
  .wh-nearby__map .leaflet-control-zoom { display: none; }
  .wh-nearby__fine { display: none; }
  .wh-nearby__panel-foot:empty, .wh-nearby__panel-foot:not(:has(p:not(.wh-nearby__fine))) { display: none; }
  .wh-nearby__map .leaflet-bottom.leaflet-left { bottom: 0; }
  .wh-nearby[data-active]:not([data-active=""]) .leaflet-bottom { bottom: 50%; }
}

/* The box that holds it: taller than the old county map so the sheet and
   the chips both have room. Must be positioned — .wh-nearby is absolute. */
.wh-comm-map.wh-comm-map--nearby {
  position: relative;
  height: min(72vh, 600px) !important;
  min-height: 520px !important;
  max-height: none !important;
  overflow: hidden;
}
/* Stacked Community section — taller, full-bleed frame (no letterbox gap). */
.wh-comm-map.wh-comm-map--nearby.wh-comm-map--wide {
  height: min(78vh, 680px) !important;
  min-height: 560px !important;
}
.wh-comm-map.wh-comm-map--nearby .wh-nearby,
.wh-comm-map.wh-comm-map--nearby .wh-nearby__map {
  width: 100%;
  height: 100%;
}
@media (max-width: 767px) {
  .wh-comm-map.wh-comm-map--nearby {
    height: 560px !important;
    min-height: 520px !important;
    max-height: none !important;
  }
  .wh-comm-map.wh-comm-map--nearby.wh-comm-map--wide {
    height: 620px !important;
    min-height: 560px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wh-nearby__pin,
  .wh-nearby .wh-nearby__item { animation: none; }
  .wh-nearby__panel,
  .wh-nearby__hint,
  .wh-nearby__pin,
  .wh-nearby .wh-nearby__chip { transition: none; }
}
