/* Bible Maps (Labs) */

/* The map itself stays light; the panel and loading note follow the site theme (see style.css). */

.maps-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.maps-main {
  flex: 1;
  min-height: 0;
  position: relative;
}

.maps-canvas {
  position: absolute;
  inset: 0;
}

/* Layer panel */

.maps-panel {
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  color: var(--text);
  left: 16px;
  max-height: calc(100% - 32px);
  overflow-y: auto;
  position: absolute;
  top: 16px;
  width: 280px;
  z-index: 2;
}

.maps-panel-toggle {
  align-items: center;
  background: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
  text-align: left;
  width: 100%;
}

.maps-panel-title {
  font-weight: 600;
}

.maps-labs {
  background: var(--light-yellow);
  border-radius: 4px;
  color: #333;
  font-size: 12px;
  letter-spacing: 0.05em;
  line-height: 13px;
  margin-left: 8px;
  padding: 1px 6px;
  text-transform: uppercase;
}

.maps-panel-chevron {
  border-bottom: 2px solid currentColor;
  border-right: 2px solid currentColor;
  height: 8px;
  transform: rotate(-135deg);
  transition: transform 150ms;
  width: 8px;
}

.maps-panel--collapsed .maps-panel-chevron {
  transform: rotate(45deg);
}

.maps-panel--collapsed .maps-panel-body {
  display: none;
}

.maps-panel-body {
  font-size: 16px;
  padding: 0 16px 16px;
}

.maps-panel-intro {
  margin: 0 0 12px;
}

.maps-group {
  margin: 0 0 12px;
}

.maps-group legend {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  opacity: 0.6;
  text-transform: uppercase;
}

.maps-group label {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 8px;
  padding: 2px 0;
}

.maps-group input {
  accent-color: var(--gray);
}

/* Every switch gets a 16px swatch so the labels line up; the shape echoes how the layer draws. */
.maps-swatch {
  align-items: center;
  display: inline-flex;
  flex: none;
  height: 12px;
  justify-content: center;
  width: 16px;
}

.maps-swatch::before {
  border-radius: 2px;
  content: '';
  display: block;
  width: 16px;
}

.maps-swatch--modern::before { border-top: 2px dotted var(--gray); }
.maps-swatch--place-major::before { background: var(--text); border-radius: 50%; height: 8px; width: 8px; }
.maps-swatch--place-minor::before { background: var(--text); border-radius: 50%; height: 5px; width: 5px; }
.maps-swatch--regions::before {
  background: linear-gradient(90deg, var(--blue), var(--violet), var(--fuchsia), var(--green), var(--yellow));
  height: 10px;
  opacity: 0.55;
}
.maps-swatch--regions-other::before {
  background: linear-gradient(90deg, var(--blue), var(--violet), var(--fuchsia), var(--green), var(--yellow));
  height: 10px;
  opacity: 0.25;
}
/* Journeys: a strip of the colors used in each group (the build script assigns them). */
.maps-swatch--jesus::before { background: linear-gradient(90deg, #4a3aa7 20%, #2a78d6 20% 40%, #e87ba4 40% 60%, #008300 60% 80%, #eda100 80%); height: 4px; }
.maps-swatch--paul::before { background: linear-gradient(90deg, #e87ba4 20%, #2a78d6 20% 40%, #4a3aa7 40% 60%, #eda100 60% 80%, #008300 80%); height: 4px; }

/* Journey legend under each journeys switch */

.maps-legend {
  font-size: 14px;
  list-style: none;
  margin: 2px 0 6px 21px;
  padding: 0;
}

.maps-legend[hidden] {
  display: none;
}

.maps-legend label {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 8px;
  padding: 1px 0;
}

.maps-legend input {
  accent-color: var(--gray);
}

.maps-legend-line {
  border-radius: 2px;
  box-shadow: 0 0 0 1px var(--surface);
  flex: none;
  height: 4px;
  width: 16px;
}
.maps-swatch--herod::before { background: var(--light-yellow); border: 1px solid var(--yellow); height: 10px; }
.maps-swatch--provinces::before { border-top: 2px dashed var(--red); opacity: 0.6; }
.maps-swatch--roads::before { background: #a0785a; height: 2px; }

/* Loading note, centered over the map until the first layers have drawn */

.maps-loading {
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  left: 50%;
  padding: 8px 16px;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
}

.maps-loading[hidden] {
  display: none;
}

/* Reset view button, styled like MapLibre's own zoom buttons */

.maps-reset {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 10.5 12 3l9 7.5'/%3E%3Cpath d='M5 9.5V21h14V9.5'/%3E%3C/svg%3E") center / 16px no-repeat;
}

/* Journey name on hover */

.maps-tooltip .maplibregl-popup-content {
  border-radius: 6px;
  color: #333; /* popups are part of the light map, not the themed page */
  font: 600 14px 'Source Sans Pro', sans-serif;
  padding: 4px 10px;
  pointer-events: none;
}

.maps-tooltip {
  pointer-events: none;
}

/* Distance units: a two-button segmented control */

.maps-units {
  align-items: center;
  border-top: 1px solid var(--divider);
  display: flex;
  font-size: 14px;
  gap: 8px;
  padding: 8px 0;
}

.maps-units-label {
  flex: auto;
  font-weight: 600;
}

.maps-units button {
  background: var(--surface);
  border: 1px solid var(--underline);
  cursor: pointer;
  min-width: 40px;
  padding: 2px 10px;
}

.maps-units button:first-of-type {
  border-radius: 6px 0 0 6px;
}

.maps-units button:last-of-type {
  border-left: none;
  border-radius: 0 6px 6px 0;
}

.maps-units button[aria-pressed="true"] {
  background: var(--gray);
  border-color: var(--gray);
  color: #fff;
}

/* Feedback link, a row like Distances and Sources */

.maps-feedback {
  border-top: 1px solid var(--divider);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 0;
}

.maps-feedback a:hover {
  text-decoration: underline;
}

/* Sources */

.maps-sources {
  border-top: 1px solid var(--divider);
  font-size: 14px;
  padding-top: 8px;
}

.maps-sources summary {
  cursor: pointer;
  font-weight: 600;
}

.maps-sources ul {
  margin: 8px 0 0;
  padding-left: 16px;
  list-style: disc;
}

.maps-sources li {
  margin-bottom: 6px;
}

.maps-sources a,
.maps-popup a {
  text-decoration: underline;
}

/* Popups */

.maps-popup .maplibregl-popup-content {
  /* Popup dividers run edge to edge (past the 16px side padding). The line between places marks a bigger
     break than the one above the external links, so it's darker. */
  --popup-divider-place: #c4c4c4;
  --popup-divider-links: #ebebeb;
  border-radius: 8px;
  color: #333;
  font: 400 15px 'Source Sans Pro', sans-serif;
  max-width: 280px;
  padding: 12px 16px;
}

.maps-popup .maplibregl-popup-close-button {
  border-radius: 50%;
  color: inherit;
  font-size: 22px;
  height: 28px;
  line-height: 1;
  opacity: 0.5;
  right: 8px;
  top: 8px;
  width: 28px;
}

.maps-popup .maplibregl-popup-close-button:hover {
  background: #f0f0f0;
  opacity: 1;
}

.maps-popup .maplibregl-popup-content {
  max-height: min(340px, 40vh);
  overflow-y: auto;
}

.maps-popup-item:first-child .maps-popup-meta {
  padding-right: 28px;
}

.maps-popup-item + .maps-popup-item {
  border-top: 2px solid var(--popup-divider-place);
  margin: 10px -16px 0;
  padding: 16px 16px 0;
}

.maps-popup h3 {
  font-size: 17px;
  text-transform: none;
}

.maps-popup-meta {
  font-size: 13px;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  opacity: 0.6;
  text-transform: uppercase;
}

.maps-popup p {
  margin: 4px 0;
}

/* External links block: the divider runs past the popup's 16px side padding to its edges. */
.maps-popup-links {
  border-top: 1px solid var(--popup-divider-links);
  margin: 16px -16px 0;
  padding: 6px 16px 0;
}

/* Secondary link: quieter than the verse references above it. */
.maps-popup-more {
  font-size: 13px;
  opacity: 0.6;
}

.maps-popup .maps-popup-more a {
  text-decoration: none;
}

.maps-popup .maps-popup-more a:hover {
  text-decoration: underline;
}

.maps-popup-refs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  margin: 6px 0;
}

/* Phone: panel becomes a bottom sheet, collapsed by default via JS */

@media (max-width: 640px) {
  .maps-panel {
    border-radius: 12px 12px 0 0;
    bottom: 0;
    left: 0;
    max-height: 60%;
    top: auto;
    width: 100%;
  }

  /* Keep the scale bar and map credits above the collapsed sheet. */
  .maps-main .maplibregl-ctrl-bottom-right {
    bottom: 48px;
  }
}
