/* Pages with map dialogs keep their scrollbar space through opening and closing. */
html:has(.singular-map-modal) {
  scrollbar-gutter: stable;
}

/* Shared theme colors and typography for the map and its detached native dialog. */
.singular-map,
.singular-map-modal {
  --map-ink: var(--color-dark, #1d1d1b);
  --map-paper: var(--color-light, #f6f4ec);
  color: var(--map-ink);
  font-family: var(--font-sans, "Open Sans", sans-serif);
  font-weight: 400;
}

.singular-map,
.singular-map *,
.singular-map-modal,
.singular-map-modal * {
  box-sizing: border-box;
}

/* Brizy owns the surrounding section, background and spacing. */
.singular-map {
  position: relative;
  isolation: isolate;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  background: transparent;
}

.singular-map__canvas {
  width: 100%;
  height: clamp(360px, 54vw, 580px);
  max-height: 70dvh;
  background: var(--map-paper);
  border: 0;
  font: inherit;
  z-index: 0;
}

/* Full embeds place the location sidebar to the left of the map. */
.singular-map--full .singular-map__layout {
  position: relative;
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
}

/* The header stays in place while only the category list scrolls beneath it. */
.singular-map__sidebar {
  order: -1;
  display: flex;
  flex-direction: column;
  height: clamp(360px, 54vw, 580px);
  max-height: 70dvh;
  min-height: 0;
  background: var(--map-paper);
  border-right: 1px solid #1d1d1b40;
}

.singular-map__sidebar-header {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 30px;
  padding: 0px 0 22px;
  border-bottom: 1px solid #1d1d1b40;
}

/* A thin square ink scrollbar; the reserved gutter keeps rows from shifting when it appears. */
.singular-map__sidebar-body {
  flex: 1;
  min-height: 0;
  /* The right padding plus the reserved gutter lines dividers up with the header rule. */
  padding: 0 20px 30px 30px;
  scrollbar-color: var(--map-ink) transparent;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Safari uses these; browsers with scrollbar-color ignore them. */
.singular-map__sidebar-body::-webkit-scrollbar {
  width: 4px;
}

.singular-map__sidebar-body::-webkit-scrollbar-track {
  background: transparent;
}

.singular-map__sidebar-body::-webkit-scrollbar-thumb {
  background: var(--map-ink);
  border-radius: 0;
}

.singular-map .singular-map__sidebar-title {
  margin: 0;
  padding: 0;
  color: var(--map-ink);
  font-family: inherit;
  font-size: 20px;
  font-weight: 300;
  letter-spacing: 0.05em;
  line-height: 1.2;
  text-transform: uppercase;
}

/* Open and close controls only appear while the sidebar is a panel on narrow screens. */
.singular-map .singular-map__sidebar-open,
.singular-map .singular-map__sidebar-close {
  display: none;
}

.singular-map__group + .singular-map__group {
  border-top: 1px solid #1d1d1b40;
}

.singular-map__group-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Square checkbox in the theme's ink: outlined when off, filled with a white tick when on. */
.singular-map .singular-map__group-header input {
  flex: none;
  width: 14px;
  height: 14px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--map-ink);
  border-radius: 0;
  background: transparent center / 10px 8px no-repeat;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.singular-map .singular-map__group-header input:checked {
  background-color: var(--map-ink);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 8'%3E%3Cpath d='M1 4L3.8 6.8L9 1' fill='none' stroke='%23fff' stroke-width='1.4'/%3E%3C/svg%3E");
}

/* Category headings share the modal's small uppercase category style. */
.singular-map .singular-map__group-button {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin: 0;
  padding: 16px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--map-ink);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
  line-height: 1.5;
  text-align: left;
  text-transform: uppercase;
  cursor: pointer;
}

.singular-map__group-chevron {
  flex: none;
  transition: transform 150ms;
}

.singular-map__group-button[aria-expanded="true"] .singular-map__group-chevron {
  transform: rotate(180deg);
}

/* The category icon sits in a small black disc, matching the map pins. */
.singular-map__group-icon {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #000;
}

.singular-map__group-icon img {
  display: block;
  width: 16px;
  height: 16px;
  margin: 0;
  object-fit: contain;
}

.singular-map__group-icon img[src$="/img/maps/location.svg"] {
  filter: brightness(0) invert(1);
}

.singular-map__group-label {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.singular-map__group-count {
  flex: none;
  font-weight: 400;
}

.singular-map .singular-map__group-list {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
  transition: opacity 150ms;
}

/* Theme list styles must not reveal a collapsed category. */
.singular-map .singular-map__group-list[hidden] {
  display: none;
}

/* Theme and Brizy list styles must not add bullets to the location list. */
.singular-map .singular-map__group-list li {
  margin: 0;
  padding: 0;
  list-style: none;
}

.singular-map .singular-map__group-list li::marker,
.singular-map .singular-map__group-list li::before,
.singular-map .singular-map__group-list li::after {
  content: none;
  display: none;
}

.singular-map__group.is-hidden .singular-map__group-list {
  opacity: 0.45;
}

.singular-map .singular-map__location {
  display: block;
  width: 100%;
  margin: 0;
  padding: 10px 0 10px 26px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--map-ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.singular-map__location-name,
.singular-map__location-address {
  display: block;
  overflow-wrap: anywhere;
}

.singular-map__location-name {
  font-size: 14px;
  line-height: 1.5;
}

.singular-map__location-address {
  font-size: 12px;
  line-height: 1.5;
  opacity: 0.7;
}

/* Light dividers separate locations; category dividers stay stronger. */
.singular-map .singular-map__group-list li + li .singular-map__location {
  border-top: 1px solid #1d1d1b1a;
}

.singular-map__location:hover .singular-map__location-name {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* The selected location carries an ink bar in the checkbox column. */
.singular-map .singular-map__location[aria-current] {
  box-shadow: inset 2px 0 0 var(--map-ink);
}

.singular-map__location[aria-current] .singular-map__location-name {
  font-weight: 600;
}

.singular-map .singular-map__location:focus-visible,
.singular-map .singular-map__group-header input:focus-visible,
.singular-map .singular-map__group-button:focus-visible,
.singular-map .singular-map__sidebar-open:focus-visible,
.singular-map .singular-map__sidebar-close:focus-visible {
  outline: 1px solid var(--map-ink);
  outline-offset: 2px;
}

/* Below this width the map uses the full width and the sidebar opens over it. */
@media (max-width: 900px) {
  /* Clip the closed panel so it never widens the page. */
  .singular-map--full .singular-map__layout {
    grid-template-columns: minmax(0, 1fr);
    overflow: hidden;
  }

  /* Tall enough for the panel and the map; small-viewport units ignore mobile toolbars. */
  .singular-map--full .singular-map__canvas {
    height: 420px;
    height: clamp(420px, 75svh, 600px);
  }

  /* Styled like the map's zoom controls, at the top left where no Mapbox control sits. */
  .singular-map .singular-map__sidebar-open {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 38px;
    margin: 0;
    padding: 0 14px;
    border: 1px solid var(--map-ink);
    border-radius: 0;
    background: var(--map-paper);
    color: var(--map-ink);
    font: inherit;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.09em;
    line-height: 1;
    text-transform: uppercase;
    cursor: pointer;
  }

  .singular-map .singular-map__sidebar-close {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin: -10px -10px -10px 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--map-ink);
    cursor: pointer;
  }

  /* Hidden panels leave the tab order through visibility, after the slide finishes. */
  .singular-map__sidebar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 3;
    width: min(100%, 360px);
    height: auto;
    border-right: 1px solid var(--map-ink);
    box-shadow: 0 18px 60px #0003;
    visibility: hidden;
    transform: translateX(-100%);
    transition: transform 250ms, visibility 0s 250ms;
  }

  .singular-map.is-sidebar-open .singular-map__sidebar {
    visibility: visible;
    transform: none;
    transition: transform 250ms;
  }

  .singular-map__sidebar-header {
    margin: 0 24px;
    padding: 0px 0 18px;
  }

  .singular-map__sidebar-body {
    padding: 0 14px 24px 24px;
  }
}

/* Minimal embeds keep the same height across desktop and mobile layouts. */
.singular-map--minimal .singular-map__canvas {
  height: 400px;
}

/* Category images sit inside a black pin; its tip anchors the exact coordinates.
   Only the drawn pin takes the pointer, so a tilted neighbor's empty box never
   covers another pin. Events from the shape still reach the marker's listeners. */
.singular-map .singular-map__marker {
  width: 44px;
  height: 60px;
  background: transparent;
  border: 0;
  cursor: pointer;
  pointer-events: none;
}

.singular-map__pin path,
.singular-map__pin img {
  pointer-events: auto;
}

/* Bring the hovered or focused marker above its neighbors. */
.singular-map .singular-map__marker:hover,
.singular-map .singular-map__marker:focus {
  z-index: 1;
}

/* Legs from the exact shared point to each fanned-out pin tip, with a dot at the point. */
.singular-map .singular-map__stack {
  width: 0;
  height: 0;
  pointer-events: none;
}

.singular-map__stack svg {
  display: block;
  overflow: visible;
}

.singular-map__stack line {
  stroke: var(--map-ink);
  stroke-width: 1.5;
}

.singular-map__stack circle {
  fill: var(--map-ink);
  stroke: var(--map-paper);
  stroke-width: 1.5;
}

/* The location selected in the sidebar grows from its tip and stays above its neighbors. */
.singular-map .singular-map__marker.is-selected {
  z-index: 2;
}

.singular-map__marker.is-selected .singular-map__pin {
  transform: rotate(var(--map-stack-angle, 0deg)) scale(1.25);
}

/* The SVG outline fills the 44×60 marker; its tip is the marker's bottom center. */
.singular-map__pin {
  position: relative;
  display: block;
  width: 44px;
  height: 60px;
  filter: drop-shadow(0 2px 4px #1d1d1b40);
  /* Pins fanned out from a shared point tilt around their tips. */
  transform: rotate(var(--map-stack-angle, 0deg));
  transform-origin: 50% 100%;
  transition: opacity 150ms, transform 150ms;
}

/* Nearby pins merge into a numbered circle in the pins' black and ink ring. */
.singular-map .singular-map__cluster {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--map-ink);
  border-radius: 50%;
  background: #000;
  box-shadow: 0 0 0 4px #00000033, 0 2px 4px #1d1d1b40;
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: opacity 150ms;
}

.singular-map .singular-map__cluster:hover,
.singular-map .singular-map__cluster:focus {
  z-index: 1;
  opacity: 0.8;
}

.singular-map .singular-map__cluster:focus-visible {
  outline: 1px solid var(--map-ink);
  outline-offset: 5px;
}


.singular-map__pin svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.singular-map__pin path {
  fill: #000;
  stroke: var(--map-ink);
  stroke-width: 1;
  stroke-linejoin: round;
}

/* Centered on the round head at (22, 22), and kept upright when the pin tilts. */
.singular-map__pin img {
  position: absolute;
  top: 10px;
  left: 10px;
  display: block;
  width: 24px;
  height: 24px;
  margin: 0;
  object-fit: contain;
  transform: rotate(calc(-1 * var(--map-stack-angle, 0deg)));
}

/* Only the theme's generic fallback is recolored; selected media retains its colors. */
.singular-map__pin img[src$="/img/maps/location.svg"] {
  filter: brightness(0) invert(1);
}

.singular-map__marker:hover .singular-map__pin,
.singular-map__marker:focus .singular-map__pin {
  opacity: 0.8;
}

.singular-map__marker:focus-visible {
  outline: none;
}

/* Mapbox controls use the theme's square borders. */
.singular-map .mapboxgl-ctrl-group {
  border: 1px solid var(--map-ink);
  border-radius: 0;
  box-shadow: none;
  background: var(--map-paper);
}

.singular-map .mapboxgl-ctrl-group button {
  width: 38px;
  height: 38px;
  background-color: var(--map-paper);
  border-radius: 0;
}

.singular-map .mapboxgl-ctrl-group button + button {
  border-top-color: var(--map-ink);
}

.singular-map .mapboxgl-ctrl-attrib {
  max-width: min(90vw, 600px);
  background: var(--map-paper);
  color: var(--map-ink);
  font-size: 10px;
  line-height: 1.5;
}

.singular-map .mapboxgl-ctrl-attrib:not(.mapboxgl-compact) {
  padding: 3px 7px;
}

.singular-map .mapboxgl-ctrl-attrib a {
  color: inherit;
  text-decoration: underline;
}

/* Tooltips never intercept the pointer, so hovering a marker does not flicker. */
.singular-map .singular-map__tooltip,
.singular-map .singular-map__tooltip .mapboxgl-popup-content {
  pointer-events: none;
}

.singular-map .singular-map__tooltip .mapboxgl-popup-content {
  border: 1px solid var(--map-ink);
  border-radius: 0;
  background: var(--map-paper);
  color: var(--map-ink);
  padding: 8px 12px;
  box-shadow: none;
  font: inherit;
  font-size: 12px;
  white-space: nowrap;
}

.singular-map .singular-map__tooltip .mapboxgl-popup-tip {
  border-top-color: var(--map-ink);
}

.singular-map .singular-map__status {
  margin: 0;
  padding: 8px 12px;
  background: var(--map-paper);
  font-size: 12px;
  line-height: 1.5;
}

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

/* Full mode uses one dialog per embed, with no empty description placeholder. */
.singular-map-modal {
  position: fixed;
  inset: 0;
  width: min(560px, calc(100% - 32px));
  max-width: none;
  max-height: calc(100dvh - 48px);
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 0;
  background: var(--map-paper);
  box-shadow: 0 18px 60px #0003;
  overscroll-behavior: contain;
}

.singular-map-modal:not([open]) {
  display: none;
}

.singular-map-modal::backdrop {
  background: #1d1d1b99;
}

.singular-map-modal .singular-map-modal__close {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--map-ink);
  font: inherit;
  line-height: 1;
  cursor: pointer;
}

.singular-map-modal__content {
    padding: 30px;
}

.singular-map-modal .singular-map-modal__category {
  margin: 0 48px 22px 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
  line-height: 1.5;
  text-transform: uppercase;
}

/* The original media file is cropped only for display, without creating another image. */
.singular-map-modal .singular-map-modal__image {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  margin: 0;
  object-fit: cover;
}

.singular-map-modal .singular-map-modal__title {
  margin: 0;
  padding: 0;
  color: var(--map-ink);
  font-family: inherit;
  font-size: clamp(20px, 3vw, 26px);
  font-weight: 300;
  letter-spacing: 0.05em;
  line-height: 1.2;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.singular-map-modal__media {
  position: relative;
}

/* Imported Wikimedia images keep their author, license and source on the photo itself.
   Only the background is translucent, so the credit text stays fully legible. */
.singular-map-modal .singular-map-modal__image-credit {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 4px 8px;
    background: rgb(255 255 255 / 64%);
    color: #000;
    font-size: 12px;
    line-height: 1.26;
    overflow-wrap: anywhere;
    text-align: justify;
}

.singular-map-modal__image-credit a {
  color: inherit;
  text-decoration: underline;
}

.singular-map-modal .singular-map-modal__address {
  margin: 0;
  color: var(--map-ink);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.singular-map-modal__description {
  margin-top: 22px;
  border-top: 1px solid #1d1d1b40;
  padding-top: 20px;
  font-size: 14px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.singular-map-modal__description p {
  margin: 0 0 12px;
}

.singular-map-modal__description p:last-child {
  margin-bottom: 0;
}

.singular-map-modal .singular-map-modal__website {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-top: 28px;
  padding: 10px 0 5px;
  border-bottom: 1px solid currentColor;
  color: var(--map-ink);
  font-size: 17px;
  font-weight: 300;
  letter-spacing: 0.07em;
  line-height: 1.5;
  text-decoration: none;
  text-transform: uppercase;
}

.singular-map-modal__website svg {
  margin-top: 1px;
  width: 15px;
  height: 15px;
}

/* Google Maps and Uber icons float to the right edge of the website link's row;
   their margin and height match that link, so both sit on the same baseline. */
.singular-map-modal .singular-map-modal__directions {
  display: flex;
  float: right;
  gap: 14px;
  margin: 28px -8px 0 16px;
}

.singular-map-modal__content::after {
  content: "";
  display: block;
  clear: both;
}

/* Each logo sits above a short caption in the modal's small uppercase style. */
.singular-map-modal .singular-map-modal__direction {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 40px;
  padding: 2px 4px;
  color: var(--map-ink);
  text-decoration: none;
  transition: opacity 150ms;
}

.singular-map-modal .singular-map-modal__direction:hover {
  opacity: 0.6;
}

.singular-map-modal .singular-map-modal__direction:focus-visible {
  outline: 1px solid var(--map-ink);
  outline-offset: -2px;
}

.singular-map-modal__direction svg {
  display: block;
}

/* Logos share a bottom line, so both captions start at the same height. */
.singular-map-modal__direction-icon {
  display: flex;
  align-items: flex-end;
  height: 24px;
}

.singular-map-modal .singular-map-modal__direction-caption {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.09em;
  line-height: 1.2;
  text-transform: uppercase;
}

/* The pin logo keeps its 92.3 × 132.3 proportions. */
.singular-map-modal__direction-google {
  width: 17px;
  height: 24px;
}

/* The wordmark keeps its cropped 24 × 8.4 proportions. It sits 2px up, because the
   pin's visual bottom is its body, not its narrow tip. */
.singular-map-modal__direction-uber {
  width: 50px;
  height: 17.5px;
  margin-bottom: 2px;
}

.singular-map-modal :focus-visible {
  outline: none;
}

@media (max-width: 600px) {
  .singular-map-modal__category {
    margin-right: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .singular-map__pin,
  .singular-map .singular-map__cluster,
  .singular-map .singular-map__group-list,
  .singular-map__group-chevron,
  .singular-map__sidebar,
  .singular-map.is-sidebar-open .singular-map__sidebar {
    transition: none;
  }
}
