/* Map popups in the study preview: /static/maps.js builds the markup; these
   are styles.css's map rules on the preview's colors. */

.place-name {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  text-decoration: underline dotted var(--accent);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  border-radius: 3px;
}
.place-name:hover,
.place-name:focus-visible { color: var(--accent); text-decoration-style: solid; }

body.map-open { overflow: hidden; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 16, 40, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-backdrop[hidden] { display: none; }

.map-modal {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 760px;
  height: min(86vh, 780px);
  height: min(86dvh, 780px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  font-family: var(--body);
  color: var(--text);
}

.map-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
}
.map-place { font: 800 18px var(--body); color: var(--text); }
.map-title { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }

.map-close {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.map-close:hover { background: var(--selected); color: var(--text); }

.map-viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #e9e2cf; /* old-paper tone while the scan loads */
  cursor: grab;
  touch-action: none;
  user-select: none;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.map-viewport:active { cursor: grabbing; }
.map-canvas { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.map-image { display: block; width: 100%; height: 100%; pointer-events: none; }

.map-pin {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(214, 40, 40, 0.12);
  border: 3px solid #d62828;
  box-shadow: 0 0 0 2px #fff, 0 2px 8px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}
.map-pin::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: rgba(214, 40, 40, 0.85);
}

.map-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #5b5446;
  background: #e9e2cf;
}
.map-loading[hidden] { display: none; }

.map-zoom {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.map-zoom button,
.map-footer button {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(19, 32, 90, 0.15);
}
.map-zoom button:hover,
.map-footer button:hover:not(:disabled) { color: var(--accent); border-color: var(--fill); }
.map-footer button:disabled { opacity: 0.35; cursor: default; box-shadow: none; }

.map-footer { display: flex; align-items: center; gap: 12px; padding: 10px 16px 4px; }
.map-meta { flex: 1; text-align: center; min-width: 0; }
.map-count { font-size: 12.5px; font-weight: 700; color: var(--text); }

.map-credit {
  padding: 4px 16px 12px;
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--text-dim);
  text-align: center;
}
.map-credit a { color: inherit; }

@media (max-width: 600px) {
  .modal-backdrop { padding: 0; align-items: stretch; }
  .map-modal { max-width: none; height: 100%; border-radius: 0; border: none; }
}

/* Painted (watercolor) map mode — maps.js setMode/showModern. */
.map-zoom[hidden],
.map-footer[hidden],
.map-modes[hidden],
.map-leaflet[hidden],
.map-canvas[hidden] { display: none; }

.map-modes {
  display: inline-flex;
  margin-top: 8px;
  padding: 3px;
  border-radius: 999px;
  background: var(--selected);
}
.map-modes button {
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 4px 12px;
  font: 700 12.5px var(--body);
  color: var(--text-dim);
  cursor: pointer;
}
.map-modes button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(19, 32, 90, 0.15); }

.map-leaflet { position: absolute; inset: 0; cursor: grab; }
.map-leaflet.leaflet-container { background: #f3ead8; } /* paper, while tiles load */
.map-leaflet .leaflet-control-zoom { border: none; box-shadow: 0 2px 8px rgba(19, 32, 90, 0.18); border-radius: 10px; overflow: hidden; }
.map-leaflet .leaflet-control-zoom a { color: var(--text); font-family: var(--body); }

/* Each pin is a 44px touch target (maps.js iconSize) with the dot at its centre. */
.map-mark { position: relative; cursor: pointer; }
.map-dot {
  position: absolute;
  left: 16px;
  top: 16px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #16181d; /* other places: black with a white border */
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  box-sizing: border-box;
}
/* the selected place: blue with a white border */
.map-dot.main { left: 13px; top: 13px; width: 18px; height: 18px; background: #1f4fe0; border-width: 3px; }
.map-label {
  position: absolute;
  left: 32px;
  top: 22px;
  transform: translateY(-50%);
  white-space: nowrap;
  font: 800 12.5px var(--body);
  color: #13205a;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 4px #fff;
  padding: 6px 4px; /* a taller tap target for the name */
}
.map-label.main { left: 36px; font: 800 15.5px var(--body); }
/* Other sides for a name when the right is taken (maps.js declutterLabels). */
.map-label.at-left { left: auto; right: 32px; }
.map-label.main.at-left { right: 36px; }
.map-label.at-top { left: 22px; top: 16px; transform: translate(-50%, -100%); }
.map-label.at-bottom { left: 22px; top: 28px; transform: translateX(-50%); }

/* Coordinates under the pointer on the painted map (maps.js). */
.map-coords {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 500;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  color: #13205a;
  font: 700 11.5px var(--body);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(19, 32, 90, 0.15);
}
.map-coords[hidden],
.map-coords:empty { display: none; }

/* What the place is (maps.js renderInfo): type, one-line description, what
   it's identified with today, and the full article on request. */
.map-info { padding: 0 16px 10px; font-family: var(--body); }
.map-info[hidden] { display: none; }
.map-kind { font-size: 11.5px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-faint); }
.map-brief { margin: 3px 0 0; font-size: 14.5px; line-height: 1.4; color: var(--text); }
.map-today { margin: 2px 0 0; font-size: 12.5px; color: var(--text-dim); }
.map-brief[hidden], .map-today[hidden], .map-more[hidden] { display: none; }
.map-more { margin-top: 6px; padding: 0; border: none; background: none; font: 700 12.5px var(--body); color: var(--accent); cursor: pointer; }
.map-more:hover { text-decoration: underline; }
.map-article { max-height: 32vh; overflow-y: auto; margin-top: 6px; padding-right: 4px; font-size: 13.5px; line-height: 1.5; color: var(--text); }
.map-article[hidden] { display: none; }
.map-article p { margin: 0 0 8px; }
.map-article-credit { font-size: 11px; color: var(--text-faint); }

/* Credit line's "Sources & licenses" and the full credits it opens (maps.js setCredit). */
.map-sources-btn { padding: 0; border: none; background: none; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }
.map-sources { max-height: 30vh; overflow-y: auto; padding: 0 16px 12px; font: 11.5px/1.5 var(--body); color: var(--text-dim); }
.map-sources[hidden] { display: none; }
.map-sources p { margin: 0 0 6px; }
.map-sources a { color: inherit; }

/* Public-domain photos of the place (maps.js renderInfo) and the large view. */
.map-photos { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; scrollbar-width: none; }
.map-photos[hidden] { display: none; }
.map-photos button { flex: 0 0 auto; padding: 0; border: none; border-radius: 8px; overflow: hidden; cursor: pointer; background: var(--selected); }
.map-photos img { display: block; height: 64px; width: auto; max-width: 120px; object-fit: cover; }
.map-photo-view { position: absolute; inset: 0; z-index: 2000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 48px 14px 18px; background: rgba(10, 14, 32, 0.94); cursor: zoom-out; }
.map-photo-view[hidden] { display: none; }
.map-photo-img { max-width: 100%; max-height: calc(100% - 70px); object-fit: contain; border-radius: 6px; }
.map-photo-caption { max-width: 640px; text-align: center; font: 13px/1.45 var(--body); color: #e8edff; }
.map-photo-caption a { color: #8fb3ff; margin-left: 4px; }
.map-photo-close { position: absolute; top: 10px; right: 12px; width: 34px; height: 34px; border: none; border-radius: 10px; background: rgba(255, 255, 255, 0.12); color: #fff; font-size: 22px; cursor: pointer; }

/* Painted map tiles: at fractional zoom (and on iPhone Safari) the scaled
   tiles leave hairline seams where the background shows through as a grid.
   Our tiles join seamlessly, so overlapping each by a pixel hides it. */
.map-leaflet .leaflet-tile-container canvas.leaflet-tile {
  width: 257px !important;
  height: 257px !important;
}

/* Credited photographers under the photo strip (maps.js renderInfo). */
.map-photo-credits { margin-top: 4px; font-size: 11px; line-height: 1.35; color: var(--text-dim, #4b5886); }
.map-photo-credits[hidden] { display: none; }
.map-photo-caption a { color: #8fb3ff; }

/* ---- Pin layout, Google Maps style (maps.js layoutPins) ---- */
.map-mark { transition: opacity 0.2s ease; }
/* Hidden pins must not catch taps. Leaflet's stylesheet (loaded later) sets
   pointer-events: auto on every marker, so outrank it: otherwise an invisible
   Machpelah sat on top of Hebron and took its taps. */
.leaflet-marker-icon.map-mark.is-hidden { opacity: 0; pointer-events: none; }
.map-dot {
  left: 17px; top: 17px; width: 10px; height: 10px;
  background: #1d2433; border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.map-label {
  left: 30px; font-weight: 700; font-size: 12.5px; color: #1d2433; letter-spacing: 0.01em;
  text-shadow: -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff, 0 0 4px #fff, 0 0 6px rgba(255, 255, 255, 0.9);
}
.map-label.at-left { right: 30px; }
.map-label.at-top { top: 15px; }
.map-label.at-bottom { top: 29px; }
/* The selected place: a larger blue point on the spot, with a soft ring. */
.map-pin-sel {
  position: absolute; left: 13px; top: 13px; width: 18px; height: 18px;
  background: #1f4fe0; border: 3px solid #fff; box-sizing: border-box; border-radius: 50%;
  box-shadow: 0 0 0 5px rgba(31, 79, 224, 0.22), 0 1px 4px rgba(0, 0, 0, 0.4);
}
.map-label.main { left: 38px; font-size: 15.5px; font-weight: 800; color: #13205a; }
.map-label.main.at-left { left: auto; right: 38px; }
/* Regions, seas and peoples: a spaced, quieter name with no pin. */
.map-mark.area .map-label {
  left: 22px; top: 22px; transform: translate(-50%, -50%);
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: #5b4a3a;
}
.map-mark.area.water .map-label {
  font-style: italic; text-transform: none; letter-spacing: 0.06em; font-size: 12px; color: #1f5a8c;
}
/* A selected region: its name, larger and in the pin's blue, in place of a pin. */
.map-mark.area .map-label.main { font-size: 15px; font-weight: 800; letter-spacing: 0.12em; color: #1f4fe0; }
.map-mark.area.water .map-label.main { font-size: 17px; letter-spacing: 0.04em; }

/* Photo viewer: the thumbnail stands in, softly blurred, until the full photo arrives. */
.map-photo-img { transition: filter 0.25s ease; }
.map-photo-img.is-preview { filter: blur(6px); width: 100%; }

/* ---- Study preview: the place view docks over the Bible pane on wide
   screens (maps.js BIBLE_MAPS_HOST, set in study.js), so the conversation
   stays readable beside it. Phones keep the full-screen view. ---- */
.map-backdrop.docked { position: absolute; z-index: 20; padding: 0; background: none; align-items: stretch; }
.map-backdrop.docked .map-modal { max-width: none; height: 100%; border: 0; border-radius: 0; box-shadow: none; }
/* No latitude/longitude under the name or on the map: nobody studies by them. */
.map-title, .map-coords { display: none; }
/* Thumbnails all one size. */
.map-photos img { width: 96px; height: 64px; max-width: none; }
