/* Map block. Leaflet's own styles come first (vendor/leaflet/leaflet.css). */
.map__canvas {
  display: none;
  isolation: isolate; /* Leaflet uses high z-index values inside; they must not cover menus */
  width: 100%;
  border-radius: var(--radius);
  background: var(--surface);
}
.map--live .map__canvas {
  display: block;
}
.map--small .map__canvas {
  height: 240px;
}
.map--medium .map__canvas {
  height: 380px;
}
.map--large .map__canvas {
  height: 560px;
}
/* With the map working, the list of places is for screen readers only; without it, it is the content. */
.map--live .map__places {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.map__places {
  margin: calc(var(--space) * 0.5) 0;
  padding-left: calc(var(--space) * 1.2);
}
.map-pin span {
  display: block;
  box-sizing: border-box;
  background: var(--primary);
  box-shadow: var(--shadow-1);
}
.map-pin--accent span {
  background: var(--accent);
}
.map-pin--dark span {
  background: var(--text);
}
.map-pin--dot span {
  width: 24px;
  height: 24px;
  border: 3px solid #ffffff;
  border-radius: 50%;
}
/* The classic pin: a rounded square turned so one corner points down, with a white dot in it. */
.map-pin--drop span {
  position: relative;
  width: 30px;
  height: 30px;
  border: var(--line-strong) solid #ffffff;
  border-radius: 50% 50% 50% 0;
  transform: translateY(2px) rotate(-45deg);
}
.map-pin--drop span::after {
  content: '';
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: #ffffff;
}
/* Three styles are the standard map recoloured here, so they need no other map service. */
.map--style-grayscale .leaflet-tile-pane {
  filter: grayscale(1);
}
.map--style-light .leaflet-tile-pane {
  filter: grayscale(1) brightness(1.25) contrast(0.6);
}
.map--style-dark .leaflet-tile-pane {
  filter: invert(1) hue-rotate(180deg) grayscale(0.4) brightness(0.9) contrast(0.95);
}
.map--style-sage .leaflet-tile-pane {
  filter: grayscale(1) sepia(0.28) hue-rotate(62deg) saturate(0.75) brightness(1.06) contrast(0.82);
}
.map--style-sage .map__canvas {
  background: #d8e1d4;
  border: var(--line) solid #e4ddd0;
  border-radius: var(--radius-2xl);
}
.map--style-sage .map-pin span {
  background: #a14a33;
}
.map--style-dark .map__canvas {
  background: #262626;
}
.leaflet-container a {
  color: var(--link);
}

/* In the admin's preview (no scripts run there) a map is drawn as a placeholder: it must look like a map, not like a plain list. */
[data-preview] .map:not(.map--live) {
  position: relative;
  overflow: hidden;
  border: 2px dashed var(--line-strong, #9aa5a0);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgb(0 0 0 / 6%) 1px, transparent 1px) 0 0 / 48px 48px,
    linear-gradient(0deg, rgb(0 0 0 / 6%) 1px, transparent 1px) 0 0 / 48px 48px,
    var(--surface);
}
[data-preview] .map:not(.map--live)::before {
  content: '\1F4CD  Map: drawn on the live page. The places are listed here.';
  display: block;
  padding: calc(var(--space) * 0.5) var(--space);
  background: var(--primary);
  color: var(--on-primary, #fff);
  font-weight: 700;
  font-size: var(--label-size);
}
[data-preview] .map:not(.map--live) .map__places {
  margin: 0;
  padding: var(--space) var(--space) var(--space) calc(var(--space) * 2.4);
  list-style: none;
}
[data-preview] .map:not(.map--live) .map__places li {
  position: relative;
  padding: 0.15rem 0;
}
[data-preview] .map:not(.map--live) .map__places li::before {
  content: '\1F4CD';
  position: absolute;
  left: -1.6em;
}

/* The editor's map: a mosaic of map pictures with pins; a picture that does not load leaves the drawn grid. */
.map__mosaic {
  position: relative;
  overflow: hidden;
  width: 100%;
  background:
    linear-gradient(90deg, rgb(0 0 0 / 8%) 1px, transparent 1px) 0 0 / 25% 100%,
    linear-gradient(0deg, rgb(0 0 0 / 8%) 1px, transparent 1px) 0 0 / 100% 42%,
    var(--surface);
}
.map__mosaic img {
  position: absolute;
  display: block;
  max-width: none;
}
.map__mosaic .map-pin {
  position: absolute;
  transform: translate(-50%, -50%);
}
.map--style-grayscale .map__mosaic img {
  filter: grayscale(1);
}
.map--style-light .map__mosaic img {
  filter: grayscale(1) brightness(1.25) contrast(0.6);
}
.map--style-dark .map__mosaic img {
  filter: invert(1) hue-rotate(180deg) grayscale(0.4) brightness(0.9) contrast(0.95);
}
.map--style-sage .map__mosaic img {
  filter: grayscale(1) sepia(0.28) hue-rotate(62deg) saturate(0.75) brightness(1.06) contrast(0.82);
}
