/* ============================================================
   SPREAD-OF-CHRISTIANITY MAP
   The map is an image (radius 12px, no frame); only the panels
   floating over it carry a shadow.
   ============================================================ */

.map-section { padding: 2rem 0 1rem; }

/* ── Era colours (data; mirror map-spread.js) ── */
[data-era-dot="apostolic"]    { background: #b8860b; }
[data-era-dot="antenicene"]   { background: #185FA5; }
[data-era-dot="imperial"]     { background: #854F0B; }
[data-era-dot="earlymedieval"]{ background: #3B6D11; }
[data-era-dot="highmedieval"] { background: #534AB7; }
[data-era-dot="earlymodern"]  { background: #A32D2D; }
[data-era-dot="modern"]       { background: #1D9E75; }

/* ── Map canvas + overlay shell ── */
.map-wrap {
  position: relative;
  margin-bottom: 3rem;
  border-radius: 12px;
  overflow: hidden;
}
.map-canvas {
  width: 100%;
  height: clamp(460px, 74vh, 720px);
  /* The sea: there is no tile layer, so this IS the basemap ground.
     A basemap colour (like the land fill in map-spread.js), not a UI token. */
  background: #f8f9fb;
  z-index: 1;
}
.leaflet-container { font-family: var(--font-ui); }
/* Lift the zoom buttons clear of the bottom timeline band */
.map-wrap .leaflet-bottom.leaflet-right { bottom: 96px; }
.map-wrap .leaflet-bar {
  border: none;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(28,40,51,.12);
}
.map-wrap .leaflet-bar a {
  color: var(--ink);
  background: var(--paper);
  border-bottom-color: var(--rule);
}
.map-wrap .leaflet-bar a:hover { background: var(--wash); }
/* Attribution sits over the timeline band, so keep it quiet and out of the way */
.map-wrap .leaflet-control-attribution {
  background: color-mix(in srgb, var(--paper) 85%, transparent);
  font-size: 12px;
  color: var(--slate);
}
.map-wrap .leaflet-control-attribution a { color: var(--lapis); }

/* Generic floating panel on the map */
.map-overlay {
  position: absolute;
  z-index: 1000;
  background: color-mix(in srgb, var(--paper) 96%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(28,40,51,.12);
  pointer-events: auto;
}

/* Top-left: current era */
.map-overlay--era {
  top: 14px;
  left: 14px;
  max-width: min(310px, calc(100% - 28px));
  padding: 0.85rem 1rem 0.9rem;
}
.map-era__label {
  font-family: var(--font-text);
  font-size: 20px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--ink);
}
.map-era__range {
  margin-top: 0.15rem;
  font-family: var(--font-ui);
  font-size: 14px;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--slate);
}
.map-era__blurb {
  margin: 0.45rem 0 0;
  font-family: var(--font-text);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink-2);
}
.map-era__blurb:empty { display: none; }

/* Top-right: legend */
.map-overlay--legend {
  top: 14px;
  right: 14px;
  padding: 0.5rem;
}
.map-legend__toggle {
  display: none;
  align-items: center;
  min-height: 24px; /* WCAG 2.5.8 target size */
  gap: 6px;
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  padding: 2px 8px;
}
.map-legend__toggle i { color: var(--slate); font-size: 16px; }
.map-legend {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.map-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--ink);
  background: none;
  border: none;
  border-radius: 8px;
  padding: 4px 8px;
  min-height: 28px;
  cursor: pointer;
  text-align: left;
  transition: background-color 120ms, color 120ms, opacity 120ms;
  opacity: 0.55;
}
.map-legend__item:hover { background: var(--wash); opacity: 1; }
.map-legend__item.is-active { opacity: 1; }
.map-legend__dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.map-legend__count {
  margin-left: auto;
  padding-left: 0.75rem;
  font-size: 13px;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--slate);
}

/* Bottom: timeline scrubber with clickable era stops */
.map-timeline {
  position: absolute;
  z-index: 1000;
  left: 14px;
  right: 14px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1rem 0.55rem;
  background: color-mix(in srgb, var(--paper) 96%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(28,40,51,.12);
  pointer-events: auto;
}
.map-play {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 40px;
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 500;
  color: var(--paper);
  background: var(--ink);
  border: none;
  border-radius: 8px;
  padding: 0.5rem 1.1rem;
  cursor: pointer;
  transition: background-color 120ms;
  flex-shrink: 0;
}
.map-play:hover { background: var(--ink-2); }
.map-play i { font-size: 14px; }

.map-timeline__track { flex: 1; min-width: 0; }
.map-range {
  display: block;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  /* The visible track is 3px, but the input itself is 24px tall so there is a
     real finger-sized area to grab on a touch screen. */
  height: 24px;
  background-color: transparent;
  background-image: linear-gradient(90deg, var(--ink) 0%, var(--rule) 0%);
  background-size: 100% 3px;
  background-position: center;
  background-repeat: no-repeat;
  outline: none;
  cursor: pointer;
}
.map-range:focus-visible { outline: 2px solid var(--rubric); outline-offset: 2px; border-radius: 4px; }
.map-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ink);
  border: 3px solid var(--paper);
  box-shadow: 0 0 0 1px var(--rule-strong);
  cursor: pointer;
}
.map-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ink);
  border: 3px solid var(--paper);
  box-shadow: 0 0 0 1px var(--rule-strong);
  cursor: pointer;
}

.map-timeline__stops {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  padding: 0 1px;
}
.map-stop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  border-radius: 6px;
  padding: 2px 2px 0;
  /* Stops sit flush against each other, so each needs the full 24px itself —
     in both axes, since the row compresses on narrow screens. */
  min-height: 26px;
  min-width: 26px;
  cursor: pointer;
  flex: 0 0 auto;
}
.map-stop__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  opacity: 0.35;
  transition: opacity 120ms;
}
.map-stop__year {
  font-family: var(--font-ui);
  font-size: 13px;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--slate);
  white-space: nowrap;
  transition: color 120ms;
}
.map-stop:hover .map-stop__dot { opacity: 0.75; }
.map-stop:hover .map-stop__year { color: var(--ink); }
.map-stop.is-active .map-stop__dot { opacity: 1; }
.map-stop.is-active .map-stop__year { color: var(--ink); font-weight: 500; }

@media (max-width: 720px) {
  .map-canvas { height: clamp(420px, 70vh, 620px); }
  .map-overlay--era { max-width: calc(100% - 28px - 120px); padding: 0.6rem 0.8rem; }
  .map-era__blurb { display: none; }
  .map-legend__toggle { display: inline-flex; }
  .map-overlay--legend .map-legend { display: none; margin-top: 6px; }
  .map-overlay--legend.is-open .map-legend { display: flex; }
  .map-timeline { flex-wrap: wrap; gap: 0.5rem; padding: 0.6rem 0.75rem 0.5rem; left: 10px; right: 10px; bottom: 10px; }
  .map-timeline__track { flex-basis: 100%; order: 2; }
  /* The timeline panel wraps to two rows here, so lift the zoom buttons and
     the attribution further clear of it. */
  .map-wrap .leaflet-bottom.leaflet-right { bottom: 150px; }
}

/* ── Spread arcs ── */
.spread-arc { stroke-linecap: round; pointer-events: none; }

/* ── Hover tooltip (floats, so it keeps a shadow) ── */
.map-tip.leaflet-tooltip {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  background: var(--paper);
  border: none;
  border-radius: 8px;
  padding: 3px 9px;
  box-shadow: 0 8px 24px rgba(28,40,51,.12);
}
.map-tip.leaflet-tooltip-top::before { border-top-color: var(--paper); }

/* ── Popups ── */
.map-wrap .leaflet-popup-content-wrapper {
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(28,40,51,.12);
}
.map-wrap .leaflet-popup-tip { box-shadow: none; }
.map-wrap .leaflet-popup-content { margin: 0.8rem 1.6rem 0.9rem 1rem; }
.map-wrap a.leaflet-popup-close-button { color: var(--slate); }
.map-popup { width: min(250px, 62vw); }
.map-popup__name { font-family: var(--font-text); font-size: 18px; font-weight: 500; line-height: 1.25; color: var(--ink); }
.map-popup__year { font-family: var(--font-ui); font-size: 14px; font-variant-numeric: lining-nums tabular-nums; color: var(--slate); margin: 1px 0 6px; }
.map-wrap .map-popup__note { font-family: var(--font-text); font-size: 15px; color: var(--ink-2); line-height: 1.5; margin: 0; }

/* ── Server-rendered list (fallback + search source) ── */
.map-list { margin-bottom: 2rem; max-width: 760px; }
.map-list__title {
  font-family: var(--font-text);
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.005em;
  color: var(--ink);
  margin-bottom: 0.4rem;
}
.map-list__hint {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-ui);
  font-size: 15px;
  color: var(--slate);
  margin: 0 0 2rem;
}
.map-list__hint i { color: var(--slate); font-size: 16px; }
.map-list__era { margin-bottom: 2.25rem; }
.map-list__era-label {
  font-family: var(--font-text);
  font-size: 1.3rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--ink);
  margin-bottom: 0.2rem;
}
.map-list__era-range {
  margin-left: 0.4rem;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 400;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--slate);
}
.map-list__era-blurb {
  font-family: var(--font-text);
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink-2);
  margin-bottom: 0.75rem;
  max-width: 64ch;
  font-variant-numeric: oldstyle-nums;
}
.map-list__places { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--rule); }
.map-list__place {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-text);
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink-2);
}
.map-list__place strong { color: var(--ink); font-weight: 500; }
.map-list__note { display: block; }
/* These behave as buttons (the script gives them role + tabindex), so they get
   a 24px hit area like any other control. */
.map-list__place[data-map-place] {
  cursor: pointer;
  margin: 0 -0.6rem;
  padding: 0.55rem 0.6rem;
  transition: background-color 120ms;
}
.map-list__place[data-map-place]:hover,
.map-list__place[data-map-place]:focus-visible { background: var(--wash); outline: none; }
.map-list__place[data-map-place]:focus-visible { box-shadow: inset 0 0 0 2px var(--rubric); border-radius: 8px; }
.map-list__year {
  font-family: var(--font-ui);
  font-size: 14px;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--slate);
}

.map-source {
  font-family: var(--font-text);
  font-size: 15px;
  font-style: italic;
  color: var(--slate);
  line-height: 1.55;
  max-width: 72ch;
  margin-bottom: 3rem;
}

@media (prefers-reduced-motion: reduce) {
  .map-play, .map-legend__item, .map-stop__dot, .map-stop__year, .map-list__place[data-map-place] { transition: none; }
}

/* Mobile readability: see the note in pistizo.css.
   Prose 18px, secondary 16px, labels at least 13px, 44px tap targets. */
@media (max-width: 768px) {
  .map-list__era-blurb,
  .map-list__place { font-size: 16px; }
  .map-popup__note,
  .map-list__hint,
  .map-source,
  .map-legend__toggle,
  .map-play { font-size: 15px; }
  .map-legend__toggle,
  .map-play,
  .map-list__place[data-map-place] { min-height: 44px; }
  .map-legend__item { min-height: 44px; font-size: 15px; }
  .map-era__label { font-size: 18px; }
  .map-wrap .leaflet-control-zoom a { width: 44px; height: 44px; line-height: 44px; }
  .map-era__range,
  .map-tip.leaflet-tooltip,
  .map-popup__year,
  .map-list__era-range,
  .map-list__year { font-size: 14px; }
  .map-legend__count,
  .map-stop__year,
  .map-wrap .leaflet-control-attribution { font-size: 13px; }
}
