/* Buyers' map page. Leaflet's own stylesheet is loaded before this one. Colors come from tokens.css. */

.mappage {
  padding-block: var(--space-4) var(--space-12);
}

.mappage__lead {
  margin-bottom: var(--space-4);
  color: var(--color-text-secondary);
  font: var(--type-body);
}

/* The map opens only on a tap (hidden until then); the list below is the no-JS version. */
.mapbox {
  height: min(58vh, 28rem);
  margin-bottom: var(--space-6);
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-variant);
  box-shadow: var(--shadow-sm);
}

.mapbox[hidden] {
  display: none;
}

/* Buttons and city chips need JavaScript. */
.mapbar,
.mapchips {
  display: none;
}

.js .mapbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.js .mapbar .btn {
  flex: 1 1 12rem;
}

.js .mapchips {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-1);
  overflow-x: auto;
  scrollbar-width: none;
}

.mapchips .chip {
  flex: none;
  cursor: pointer;
}

.mapstatus {
  margin: 0 0 var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-primary-container);
  color: var(--color-on-primary-container);
  font: var(--type-body);
}

.mapstatus[hidden],
.mapcard[hidden],
.mapcity[hidden],
.maplist[hidden] {
  display: none;
}

.mapcard__dist {
  color: var(--color-primary);
  font-weight: 700;
}

.mapbox.leaflet-container {
  font: var(--type-caption);
}

.mappin {
  background: none;
  border: 0;
}

.mappin span {
  display: block;
  width: 30px;
  height: 30px;
  border: 3px solid var(--color-on-primary);
  border-radius: 50% 50% 50% 0;
  background: var(--color-primary);
  box-shadow: var(--shadow-md);
  rotate: -45deg;
}

.mappin span::after {
  content: "";
  display: block;
  width: 10px;
  height: 10px;
  margin: 7px;
  border-radius: 50%;
  background: var(--color-on-primary);
}

.leaflet-popup-content-wrapper {
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
}

.leaflet-popup-tip {
  background: var(--color-surface);
}

.mappop p {
  margin: 2px 0 0;
  color: var(--color-text-secondary);
}

/* Leaflet colors every link in the container; ours must keep the readable brand color in both themes. */
.leaflet-container .mappop__title {
  color: var(--color-primary);
  font: var(--type-body-strong);
  overflow-wrap: anywhere;
}

.mapcity {
  margin-top: var(--space-6);
}

.mapcity h2 {
  margin-bottom: var(--space-3);
  font: var(--type-subtitle);
}

.maplist {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.mapcard {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.mapcard__body {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.mapcard__title {
  color: inherit;
  font: var(--type-body-strong);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.mapcard__place,
.mapcard__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--color-text-secondary);
  font: var(--type-caption);
}

.mapcard__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.mapcard__actions .btn {
  flex: 1 1 8rem;
}

.mapempty {
  display: grid;
  justify-items: center;
  gap: var(--space-3);
  padding: var(--space-10) var(--space-4);
  text-align: center;
}

.mapempty .icon {
  width: 2.5rem;
  height: 2.5rem;
  color: var(--color-primary);
}

@media (min-width: 900px) {
  .mappage {
    max-width: 56rem;
  }

  .mapcard {
    grid-template-columns: 1fr auto;
    align-items: center;
  }
}
