/* FULL MAP MODAL */

body.map-modal-open {
  overflow: hidden;
}

.map-modal {
  position: fixed;
  z-index: 1000;
  inset: 0;
  padding: 10px;
  display: grid;
  place-items: center;
  background: rgba(5, 19, 36, 0.84);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.18s ease,
    visibility 0.18s ease;
}

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

.map-modal.is-open {
  opacity: 1;
  visibility: visible;
}

.map-modal-panel {
  width: min(100%, 1200px);
  height: min(94dvh, 900px);
  min-height: 0;
  padding: 12px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
  transform: translateY(10px) scale(0.985);
  transition: transform 0.18s ease;
}

.map-modal.is-open .map-modal-panel {
  transform: translateY(0) scale(1);
}

.map-modal-header {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.map-modal-header h2 {
  margin: 0 0 2px;
  color: #102f57;
  font-size: 20px;
  line-height: 1.15;
}

.map-modal-header p {
  margin: 0;
  color: #607489;
  font-size: 12px;
  line-height: 1.35;
}

.map-modal-close {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #e7f1fa;
  color: #102f57;
  cursor: pointer;
  font-size: 34px;
  font-weight: 400;
  line-height: 1;
}

.map-modal-body {
  min-height: 0;
  padding: 1px 3px 3px 1px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.map-modal-stage {
  position: relative;
  height: min(54dvh, 560px);
  min-height: 240px;
  overflow: hidden;
  display: grid;
  place-items: center;
  border: 1px solid #dce9f4;
  border-radius: 10px;
  background: #eef4f8;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.map-modal-stage.is-dragging {
  cursor: grabbing;
}

.map-modal-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  pointer-events: none;
  transform-origin: center;
  will-change: transform;
}

.map-modal-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.map-modal-controls button {
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: #e7f1fa;
  color: #173d67;
  cursor: pointer;
  font: inherit;
  font-size: 20px;
  font-weight: 700;
}

.map-modal-controls button:disabled {
  opacity: 0.45;
  cursor: default;
}

.map-modal-controls .map-reset-button {
  font-size: 13px;
}

.map-zoom-level {
  min-width: 50px;
  color: #607489;
  font-size: 13px;
  text-align: center;
}

.map-modal-legend .map-legend {
  margin-top: 0;
}

@media (prefers-reduced-motion: reduce) {
  .map-modal,
  .map-modal-panel {
    transition: none;
  }
}

/* MAP LEGEND */

.map-legend {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.map-legend .legend-group {
  padding: 16px;
  background: white;
  border: 1px solid #dce9f4;
  border-radius: 10px;
}

.map-legend .legend-group h3 {
  margin-bottom: 10px;
  font-size: 18px;
  line-height: 1.2;
}

.map-legend .legend-group ul {
  list-style: none;
}

.map-legend .legend-group li {
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: #5f748a;
  font-size: 14px;
  line-height: 1.3;
}

.map-legend .stop-number {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #17558f;
  color: white;
  font-size: 12px;
  font-weight: 700;
}

/* Match the map colors where practical */
.map-legend .stop-1  { background: #f26a21; }
.map-legend .stop-2  { background: #d62b78; }
.map-legend .stop-3  { background: #3889c9; }
.map-legend .stop-4  { background: #72b52b; }
.map-legend .stop-5  { background: #a6003a; }
.map-legend .stop-6  { background: #777777; }
.map-legend .stop-7  { background: #2f2f2f; }
.map-legend .stop-8  { background: #e60012; }
.map-legend .stop-9  { background: #123f72; }
.map-legend .stop-10 { background: #777777; }
.map-legend .stop-11 { background: #087a38; }
.map-legend .stop-12 { background: #1d2430; }
.map-legend .stop-13 { background: #1366b3; }
.map-legend .stop-14 { background: #d96b4c; }

.map-legend .visitor-key {
  margin-top: 14px;
  padding-top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid #dce9f4;
}

.map-legend .visitor-key img {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  object-fit: contain;
}

.map-legend .visitor-key p {
  margin: 0;
  color: #5f748a;
  font-size: 14px;
}

.map-legend .map-note {
  margin-top: 14px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 24px 1fr;
  column-gap: 8px;
  align-items: start;
  background: #eaf4fb;
  border-radius: 9px;
}

.map-legend .note-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  grid-row: span 2;
}

.map-legend .map-note strong {
  margin-bottom: 4px;
  color: #102f57;
  font-size: 14px;
}

.map-legend .map-note p {
  margin: 0;
  color: #607489;
  font-size: 13px;
  line-height: 1.4;
}

@media (min-width: 768px) {
  .map-modal-body {
    gap: 14px;
  }

  .map-modal-stage {
    height: min(60dvh, 650px);
    min-height: 360px;
  }

  .map-modal {
    padding: 24px;
  }

  .map-modal-panel {
    padding: 18px;
    gap: 14px;
  }

  .map-modal-header h2 {
    font-size: 25px;
  }

  .map-modal-header p {
    font-size: 14px;
  }

  .map-legend {
    grid-template-columns: 1fr 1fr;
    gap: 18px;
  }

  .map-legend .legend-group {
    padding: 18px;
  }

  .map-legend .legend-group h3 {
    font-size: 20px;
  }

  .map-legend .legend-group li {
    font-size: 15px;
  }
}

.map-modal button:focus-visible,
.map-modal-stage:focus-visible {
  outline: 3px solid rgba(23, 85, 143, 0.35);
  outline-offset: 3px;
}
