/* ============================================================
   Property map (hub "Map" view) - see property-map.js
   ============================================================ */

/* -------------------- List / Map switch -------------------- */
.property-view {
  display: inline-flex;
  margin-left: auto;
  padding: 0.2rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-full);
}

.property-view[hidden] {
  display: none;
}

.property-view__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.5rem;
  padding: 0.4rem 1.1rem;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--gray-500);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 200ms ease, color 200ms ease;
}

.property-view__btn svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.property-view__btn:hover {
  color: var(--ink);
}

.property-view__btn[aria-pressed='true'] {
  background: var(--ink);
  color: var(--white);
}

/* With the switch in the row, centre the row's items instead of baseline. */
.property-filter__status:has(.property-view:not([hidden])) {
  align-items: center;
}

/* -------------------- Map frame -------------------- */
.property-map {
  position: relative;
  height: clamp(26rem, 72vh, 44rem);
  border-radius: 1.75rem;
  overflow: clip;
  background: #f2efe9;
  box-shadow: inset 0 0 0 1px var(--gray-300);
  /* a map link scrolls here: stay clear of the floating header */
  scroll-margin-top: 6rem;
}

.property-map[hidden] {
  display: none;
}

.property-filter__status {
  scroll-margin-top: 6rem;
}

/* In map view the photo grid steps aside; the "nothing matches" message still shows. */
.is-map-view > .property-grid {
  display: none;
}

/* Sized by width/height, not position: MapLibre's own stylesheet sets
   position: relative on this element and would collapse an inset box. */
.property-map__canvas {
  width: 100%;
  height: 100%;
  font-family: var(--font);
}

.property-map__status {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 2rem;
  color: var(--gray-500);
  text-align: center;
}

.property-map__status[hidden] {
  display: none;
}

/* shown above the list when the map cannot start on this device */
.property-map__note {
  margin: 0 0 1.25rem;
  color: var(--gray-500);
  font-size: 0.9rem;
}

.property-map__note[hidden] {
  display: none;
}

.property-map.is-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1.75rem;
  height: 1.75rem;
  margin: -0.875rem 0 0 -0.875rem;
  border: 2px solid var(--gray-300);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: property-map-spin 800ms linear infinite;
}

@keyframes property-map-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .property-map.is-loading::after {
    animation: none;
  }
}

/* -------------------- Drop pins -------------------- */
.map-pin {
  position: relative;
  display: block;
  width: 2rem;
  height: 2.625rem;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  /* MapLibre positions the element with its own transform, so the pin art scales inside it. */
}

.map-pin[hidden] {
  display: none;
}

.map-pin svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 3px 4px rgba(10, 10, 10, 0.28));
  transform-origin: 50% 100%;
  transition: transform 200ms var(--ease-out-quart);
}

.map-pin path {
  fill: var(--ink);
  stroke: var(--white);
  stroke-width: 1.5;
  transition: fill 200ms ease;
}

.map-pin circle {
  fill: var(--white);
}

.map-pin:hover svg,
.map-pin:focus-visible svg,
.map-pin.is-active svg {
  transform: scale(1.18);
}

.map-pin.is-active path {
  fill: var(--pair-cream, #9a4a2f);
}

.map-pin:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 0.5rem;
}

/* The name appears beside a pin on hover, keyboard focus, or when it is open. */
.map-pin__label {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.45rem);
  transform: translateX(-50%);
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-full);
  background: var(--ink);
  color: var(--white);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}

.map-pin:hover .map-pin__label,
.map-pin:focus-visible .map-pin__label,
.map-pin.is-active .map-pin__label {
  opacity: 1;
}

.maplibregl-marker:has(.map-pin:hover),
.maplibregl-marker:has(.map-pin.is-active) {
  z-index: 3;
}

.map-pin__count {
  position: absolute;
  top: 0.42rem;
  left: 0;
  width: 100%;
  color: var(--white);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
  text-align: center;
}

/* -------------------- Pin card -------------------- */
.map-card {
  position: absolute;
  left: 1rem;
  bottom: 1rem;
  z-index: 4;
  display: grid;
  width: min(21rem, calc(100% - 2rem));
  border-radius: 1.25rem;
  overflow: clip;
  background: var(--white);
  color: var(--ink);
  box-shadow: 0 18px 40px rgba(10, 10, 10, 0.22);
}

.map-card[hidden] {
  display: none;
}

.map-card__photo {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.map-card__body {
  display: grid;
  gap: 0.45rem;
  padding: 1rem 1.1rem 0;
}

.map-card__actions {
  display: grid;
  gap: 0.6rem;
  padding: 0.85rem 1.1rem 1rem;
}

.map-card__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.map-card__name {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.2;
}

.map-card__name:focus {
  outline: none;
}

.map-card__tenure {
  flex: none;
  color: var(--gray-500);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.map-card__facts {
  margin: 0;
  color: var(--gray-500);
  font-size: 0.9rem;
  line-height: 1.4;
}

.map-card__ask {
  --btn-ink: var(--white);
  --btn-contrast: var(--ink);
  width: 100%;
  border-color: var(--ink);
  background: var(--ink);
}

.map-card__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
}

.map-card__link {
  padding: 0.35rem 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--gray-300);
  text-underline-offset: 0.2em;
  cursor: pointer;
  transition: text-decoration-color var(--duration-base) var(--ease-out-quart);
}

.map-card__link:hover,
.map-card__link:focus-visible {
  text-decoration-color: currentColor;
}

.map-card__close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(23, 23, 23, 0.72);
  color: var(--white);
  cursor: pointer;
}

.map-card__close svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* Phones: the card runs along the bottom, with a small photo beside the text. */
@media (max-width: 640px) {
  .property-map {
    height: min(78svh, 38rem);
    border-radius: 1.25rem;
  }

  .map-card {
    left: 0.6rem;
    right: 0.6rem;
    bottom: 0.6rem;
    width: auto;
  }

  /* small photo beside the name and facts; the buttons run full width below */
  .map-card {
    grid-template-columns: 5.25rem minmax(0, 1fr);
    align-items: center;
  }

  .map-card__photo {
    width: 4.25rem;
    height: 4.25rem;
    margin: 0.85rem 0 0 1rem;
    aspect-ratio: auto;
    border-radius: 0.75rem;
  }

  .map-card__body {
    padding: 0.85rem 3rem 0 0.25rem;
  }

  .map-card__top {
    display: grid;
    gap: 0.15rem;
  }

  .map-card__actions {
    grid-column: 1 / -1;
    padding: 0.75rem 1rem 0.85rem;
  }

  .map-card__close {
    top: 0.25rem;
    right: 0.25rem;
    width: 2.75rem;
    height: 2.75rem;
    background: transparent;
    color: var(--ink);
  }

  .map-card__links {
    gap: 0 1.1rem;
  }

  .map-card__link {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
  }


  .property-view {
    margin-left: 0;
  }

  .property-view__btn {
    min-height: 2.75rem;
  }
}

/* -------------------- MapLibre's own controls, in the site's look -------------------- */
.property-map .maplibregl-ctrl-group {
  border-radius: 0.75rem;
  overflow: clip;
  box-shadow: 0 4px 14px rgba(10, 10, 10, 0.14);
}

.property-map .maplibregl-ctrl-group button {
  width: 2.5rem;
  height: 2.5rem;
}

.property-map .maplibregl-ctrl-attrib {
  font-family: var(--font);
  font-size: 0.7rem;
}

.property-map .maplibregl-cooperative-gesture-screen {
  font-family: var(--font);
  font-size: 1rem;
  padding: 2rem;
  text-align: center;
}

/* -------------------- Line legend -------------------- */
.map-legend {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 3;
  max-width: calc(100% - 5rem);
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  font-size: 0.8rem;
  box-shadow: 0 4px 14px rgba(10, 10, 10, 0.14);
}

.map-legend__toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  width: 100%;
  min-height: 2.5rem;
  padding: 0.4rem 0.8rem 0.4rem 0.9rem;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.map-legend__toggle svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 200ms var(--ease-out-quart);
}

.map-legend.is-open .map-legend__toggle svg {
  transform: rotate(180deg);
}

.map-legend__list {
  display: none;
  margin: 0;
  padding: 0 0.9rem 0.75rem;
  list-style: none;
}

.map-legend.is-open .map-legend__list {
  display: grid;
  gap: 0.32rem;
}

.map-legend__list li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  line-height: 1.25;
}

.map-legend__line {
  flex: none;
  width: 1.4rem;
  height: 0.28rem;
  border-radius: 1rem;
  background: currentColor;
}

/* a planned line: dashed, like on the map */
.map-legend__line--planned {
  border-radius: 0;
  background: repeating-linear-gradient(90deg, currentColor 0 0.4rem, transparent 0.4rem 0.65rem);
}

.map-legend__hub {
  flex: none;
  width: 0.7rem;
  height: 0.7rem;
  margin: 0 0.35rem;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--white);
  box-sizing: border-box;
}

.map-legend__list li:last-child {
  margin-top: 0.2rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--gray-300);
}

/* -------------------- Phones: tap sizes, and a map that fits a phone held sideways -------------------- */
@media (max-width: 640px) {
  .map-legend__toggle {
    min-height: 2.75rem;
  }

  .property-map .maplibregl-ctrl-group button {
    width: 2.75rem;
    height: 2.75rem;
  }
}

@media (max-height: 520px) {
  .property-map {
    height: 86svh;
  }

  /* the open card sits beside the pin, without its photo, so both fit */
  .map-card {
    width: min(19rem, 46%);
  }

  .map-card__photo {
    display: none;
  }

  .map-legend.is-open .map-legend__list {
    max-height: calc(86svh - 5rem);
    overflow-y: auto;
  }
}
