/**
 * MAi Cartographer — map styling.
 *
 * Layout rule: the detail panel and the list of points share ONE slot on the
 * right of the map and never show at the same time, the map controls stay on
 * the left, and the toolbar sits under the canvas. Nothing overlaps, so every
 * control keeps its click target.
 */

.mai-map {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.mai-map__stage {
  position: relative;
}

.mai-map__canvas {
  width: 100%;
  min-height: 320px;
  background: #eef7ff;
}

.mai-map__error {
  display: grid;
  place-items: center;
  height: 100%;
  margin: 0;
  padding: 20px;
  color: #4f5f84;
  text-align: center;
}

/* Overlays are toggled by the `hidden` attribute: keep it authoritative. */
.mai-map__panel[hidden],
.mai-map__list[hidden] {
  display: none !important;
}

/* Title overlaid on the map, clear of both the controls and the panel. The
   white plate keeps it readable above the map labels. */
.mai-map__heading {
  position: absolute;
  z-index: 2;
  top: 14px;
  left: 50%;
  margin: 0;
  padding: 7px 16px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 2px 10px rgba(9, 35, 92, .14);
  color: #041b62;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
}

/* Mapbox controls: left side, never under the cards. */
.mai-map__stage .mapboxgl-ctrl-top-left {
  margin: 12px 0 0 12px;
}

.mai-map__stage .mapboxgl-ctrl-bottom-left {
  margin: 0 0 12px 12px;
}

/* --------------------------------------------------------------------------
   Markers — circular badge, as in the reference project
   -------------------------------------------------------------------------- */

.mai-map-marker {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #007d8f;
  color: #fff;
  box-shadow: 0 2px 6px rgba(9, 35, 92, .35);
  cursor: pointer;
  transition: transform .15s ease;
}

.mai-map-marker:hover,
.mai-map-marker:focus-visible {
  transform: scale(1.12);
  outline: none;
}

.mai-map-marker svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  stroke: currentColor;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Detail panel
   -------------------------------------------------------------------------- */

.mai-map__panel {
  position: absolute;
  z-index: 4;
  top: 56px;
  right: 14px;
  width: min(318px, calc(100% - 28px));
  max-height: calc(100% - 74px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 18px 18px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(9, 35, 92, .22);
}

.mai-map__close {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 2px 8px rgba(9, 35, 92, .18);
  color: #00164f;
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}

.mai-map__close:hover,
.mai-map__close:focus-visible {
  background: #eef7ff;
}

/* A visitor photo is a hint, not the subject: cap it so the details stay
   readable without scrolling. */
.mai-map__image {
  display: block;
  width: 100%;
  height: 132px;
  margin: 0 0 12px;
  border-radius: 8px;
  object-fit: cover;
}

.mai-map__type {
  margin: 0 0 6px;
  color: #007d8f;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.mai-map__title {
  margin: 0 0 10px;
  padding-right: 26px;
  color: #041b62;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.25;
}

.mai-map__description {
  margin-bottom: 12px;
  color: #071d62;
  font-size: 12.5px;
  line-height: 1.5;
}

.mai-map__description p {
  margin: 0 0 8px;
}

.mai-map__facts {
  margin: 0 0 14px;
  font-size: 12px;
  line-height: 1.45;
}

.mai-map__facts dt {
  color: #007d8f;
  font-weight: 700;
}

.mai-map__facts dd {
  margin: 0 0 8px;
  color: #071d62;
}

.mai-map__tel {
  color: #041b62;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Actions — itinerary, booking
   -------------------------------------------------------------------------- */

.mai-map__actions {
  display: grid;
  gap: 8px;
}

.mai-map__action {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.mai-map__action--primary {
  background: #041b62;
  color: #fff;
}

.mai-map__action--primary:hover,
.mai-map__action--primary:focus-visible {
  background: #0b2a7a;
  color: #fff;
}

.mai-map__action--secondary {
  background: #fff;
  border-color: #cddcf0;
  color: #041b62;
}

.mai-map__action--secondary:hover,
.mai-map__action--secondary:focus-visible {
  background: #f2f8ff;
  border-color: #9dbbe0;
  color: #041b62;
}

.mai-map__action.is-disabled,
.mai-map__action[disabled] {
  background: #eef2f8;
  border-color: #dde5f0;
  color: #7a86a3;
  cursor: not-allowed;
}

/* Reason under a disabled action: small, red, unmistakable. */
.mai-map__note {
  margin: -2px 0 2px;
  color: #b3261e;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
}

/* --------------------------------------------------------------------------
   List of points — same slot as the panel
   -------------------------------------------------------------------------- */

.mai-map__list {
  position: absolute;
  z-index: 4;
  top: 56px;
  right: 14px;
  width: min(318px, calc(100% - 28px));
  max-height: calc(100% - 74px);
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(9, 35, 92, .22);
}

.mai-map__list-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #041b62;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.mai-map__list-button:hover,
.mai-map__list-button:focus-visible {
  background: #eef7ff;
}

.mai-map__list-label {
  flex: 1;
  font-weight: 700;
}

.mai-map__list-type {
  color: #6d79a5;
  font-size: 11px;
}

.mai-map__list .mai-marker-badge {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #fff;
}

.mai-map__list .mai-marker-badge svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
  stroke: currentColor;
}

/* --------------------------------------------------------------------------
   Toolbar under the map — never covered, never covering
   -------------------------------------------------------------------------- */

.mai-map__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid #e2ecf8;
  background: #fff;
}

.mai-map__legend,
.mai-map__list-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid #dbe7f5;
  border-radius: 999px;
  background: #f4f9ff;
  color: #041b62;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.mai-map__list-toggle {
  cursor: pointer;
}

.mai-map__list-toggle:hover,
.mai-map__list-toggle:focus-visible {
  background: #e6f1ff;
  border-color: #9dbbe0;
}

.mai-map__legend-icon {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #007d8f;
}

.mai-map__list-icon {
  position: relative;
  display: inline-block;
  width: 12px;
  height: 10px;
  vertical-align: middle;
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

.mai-map__list-icon::after {
  content: "";
  position: absolute;
  top: 2px;
  right: 0;
  left: 0;
  border-top: 2px solid currentColor;
}

/* --------------------------------------------------------------------------
   Responsive — under 768px the cards leave the map and flow beneath it
   -------------------------------------------------------------------------- */

@media (max-width: 767px) {
  .mai-map__canvas {
    min-height: 300px;
  }

  .mai-map__heading {
    top: 12px;
    max-width: calc(100% - 120px);
    overflow: hidden;
    font-size: 12.5px;
    text-overflow: ellipsis;
  }

  .mai-map__stage {
    display: flex;
    flex-direction: column;
  }

  .mai-map__stage .mai-map__canvas {
    order: 1;
  }

  .mai-map__stage .mai-map__list,
  .mai-map__stage .mai-map__panel {
    /* `relative`, not `static`: the close button must stay inside the card
       instead of jumping to the corner of the map. */
    position: relative;
    order: 2;
    width: 100%;
    max-height: 60vh;
    border-radius: 0;
    box-shadow: none;
    border-top: 1px solid #e2ecf8;
  }

  .mai-map__stage .mai-map__list {
    max-height: 280px;
  }

  .mai-map__close {
    top: 8px;
    right: 8px;
  }

  .mai-map__footer {
    flex-wrap: wrap;
  }
}
