/* =======================================================================
   BIBLE ATLAS — interactive map
   ======================================================================= */
#mapPageContainer {
  position: fixed;
  top: 64px; left: 0; right: 0; bottom: 0;
  z-index: 95;
  background: var(--bg-main);
  font-family: var(--font-ui);
}
.bm-root { position: absolute; inset: 0; display: flex; flex-direction: column; }
.bm-stage { position: relative; flex: 1; min-height: 0; }
.bm-map { position: absolute; inset: 0; background: #cfd8dc; }
.bm-error { padding: 3rem; text-align: center; color: var(--text-muted); }

/* ---------- toolbar ---------- */
.bm-toolbar {
  position: absolute; top: 12px; left: 12px; right: 380px; z-index: 500;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.bm-title { pointer-events: auto; display: inline-flex; flex-direction: column; align-self: flex-start;
  background: color-mix(in srgb, var(--bg-card) 92%, transparent); backdrop-filter: blur(6px);
  border: 1px solid var(--border-subtle); border-radius: 10px; padding: 6px 12px; box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.bm-title-main { font-family: var(--font-serif); font-weight: 700; font-size: 1.15rem; color: var(--text-main); }
.bm-title-sub { font-size: .72rem; color: var(--text-muted); }
.bm-presets { pointer-events: auto; display: flex; flex-wrap: wrap; gap: 6px; }
.bm-chip {
  border: 1px solid var(--border-subtle); background: color-mix(in srgb, var(--bg-card) 92%, transparent);
  backdrop-filter: blur(6px); color: var(--text-main); font-size: .78rem; font-weight: 600;
  padding: 5px 11px; border-radius: 999px; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.06);
  transition: background .15s, color .15s, border-color .15s;
}
.bm-chip:hover { border-color: var(--accent-primary); }
.bm-chip.active { background: var(--accent-primary); border-color: var(--accent-primary); color: #fff; }

.bm-layers {
  position: absolute; bottom: 14px; left: 58px; z-index: 500;
  display: flex; gap: 10px; align-items: center;
  background: color-mix(in srgb, var(--bg-card) 92%, transparent); backdrop-filter: blur(6px);
  border: 1px solid var(--border-subtle); border-radius: 8px; padding: 5px 10px;
  font-size: .74rem; font-weight: 600; color: var(--text-main); box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.bm-layers label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.bm-map .leaflet-bottom.leaflet-left { margin-bottom: 0; }

/* ---------- side panel ---------- */
.bm-panel {
  position: absolute; top: 12px; right: 12px; bottom: 12px; width: 352px; z-index: 600;
  display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--bg-card) 96%, transparent); backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.12);
  overflow: hidden;
}
.bm-panel-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border-subtle); }
.bm-panel-toggle { display: none; border: none; background: none; font-size: 1rem; color: var(--text-muted); cursor: pointer; }
.bm-panel-era { font-size: .82rem; font-weight: 700; color: var(--text-main); display: flex; align-items: center; gap: 8px; flex: 1; }
.bm-panel-era span { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.bm-panel-era em { margin-left: auto; font-style: normal; font-weight: 600; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.bm-panel-body { flex: 1; overflow-y: auto; padding: 8px 10px 12px; overscroll-behavior: contain; }
.bm-panel-foot { border-top: 1px solid var(--border-subtle); padding: 8px 14px 10px; }
.bm-legend { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: .68rem; color: var(--text-muted); }
.bm-legend span { display: inline-flex; align-items: center; gap: 4px; }
.bm-legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.bm-disclaimer { margin: 6px 0 0; font-size: .66rem; line-height: 1.35; color: var(--text-muted); }

.bm-list-h { font-size: .66rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); margin: 10px 4px 4px; }
.bm-empty { padding: 1.5rem .75rem; text-align: center; font-size: .85rem; color: var(--text-muted); line-height: 1.5; }
.bm-item {
  display: grid; grid-template-columns: 14px 1fr; column-gap: 8px; width: 100%; text-align: left;
  border: none; background: transparent; padding: 7px 6px; border-radius: 8px; cursor: pointer; color: var(--text-main);
  animation: bmFadeIn .35s ease;
}
.bm-item:hover { background: var(--accent-primary-light); }
.bm-item-t { font-size: .86rem; font-weight: 650; line-height: 1.25; }
.bm-item-d { grid-column: 2; font-size: .72rem; color: var(--text-muted); margin-top: 1px; }
.bm-pin { grid-row: span 2; width: 10px; height: 10px; margin-top: 4px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 25%, transparent); }
.bm-line { grid-row: span 2; width: 14px; height: 0; margin-top: 8px; border-top: 3px dashed var(--c); }
@keyframes bmFadeIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.bm-back { border: none; background: none; color: var(--accent-primary); font-size: .8rem; font-weight: 600; cursor: pointer; padding: 4px 4px 8px; }
.bm-detail { padding: 2px 6px; animation: bmFadeIn .3s ease; }
.bm-cat { display: inline-block; font-size: .66rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); padding: 2px 8px; border-radius: 999px; }
.bm-detail h3 { font-family: var(--font-serif); font-size: 1.3rem; line-height: 1.2; margin: 8px 0 6px; color: var(--text-main); }
.bm-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .78rem; color: var(--text-muted); margin-bottom: 8px; }
.bm-note { font-size: .74rem; line-height: 1.4; color: #92400e; background: #fffbeb; border: 1px solid #fde68a; border-radius: 6px; padding: 6px 8px; margin: 6px 0; }
[data-theme="dark"] .bm-note { color: #fcd34d; background: rgba(245,158,11,.1); border-color: rgba(245,158,11,.3); }
.bm-summary { font-family: var(--font-serif); font-size: 1rem; line-height: 1.55; color: var(--text-main); margin: 10px 0; }
.bm-context { background: var(--accent-primary-light); border-left: 3px solid var(--accent-primary); border-radius: 0 6px 6px 0; padding: 8px 10px; margin: 10px 0; }
.bm-context-h { font-size: .66rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-primary); margin-bottom: 3px; }
.bm-context p { margin: 0; font-size: .84rem; line-height: 1.5; color: var(--text-main); }
.bm-refs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.bm-ref, .bm-replay {
  border: 1px solid var(--accent-primary-border); background: var(--bg-card); color: var(--accent-primary);
  font-size: .78rem; font-weight: 650; padding: 5px 10px; border-radius: 6px; cursor: pointer;
}
.bm-ref:hover, .bm-replay:hover { background: var(--accent-primary); color: #fff; }
.bm-replay { margin: 4px 0 6px; }

/* ---------- map markers & labels ---------- */
.bm-event-icon { background: none; border: none; }
.bm-dot {
  display: block; width: 14px; height: 14px; margin: 2px; border-radius: 50%;
  background: var(--c); border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.25), 0 2px 6px rgba(0,0,0,.3);
  transition: transform .2s ease;
}
.bm-dot.bm-uncertain { border-style: dashed; }
.bm-event-icon:hover .bm-dot { transform: scale(1.3); }
.bm-event-icon.bm-selected .bm-dot { transform: scale(1.35); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 45%, transparent), 0 2px 8px rgba(0,0,0,.35); }
.bm-event-icon:not(.bm-faint) .bm-dot::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--c);
  animation: bmPulse 2.4s ease-out infinite; pointer-events: none;
}
@keyframes bmPulse { 0% { transform: scale(1); opacity: .7; } 100% { transform: scale(2.6); opacity: 0; } }
.bm-dot { position: relative; }

.bm-tip { font-family: var(--font-ui); font-size: .78rem; line-height: 1.35; border-radius: 6px; }
.bm-tip span { color: #475569; font-size: .72rem; }

.bm-region-label { background: none; border: none; pointer-events: none; }
.bm-region-label span {
  display: inline-block; transform: translate(-50%, -50%); white-space: nowrap;
  font-family: var(--font-serif); font-weight: 700; font-size: .82rem; letter-spacing: .04em;
  color: color-mix(in srgb, var(--c) 80%, #000);
  text-shadow: 0 0 3px #fff, 0 0 6px #fff, 0 0 8px rgba(255,255,255,.9);
}
.bm-region-label.bm-kind-empire span { font-size: .95rem; text-transform: uppercase; letter-spacing: .12em; }
.bm-region-label.bm-kind-people span { font-style: italic; font-size: .74rem; }

.bm-geo-label { background: none; border: none; pointer-events: none; }
.bm-geo-label span {
  display: inline-block; transform: translate(-50%, -50%); white-space: nowrap; text-align: center;
  font-family: var(--font-serif); font-style: italic; color: #1e3a5f; font-size: .85rem;
  text-shadow: 0 0 4px rgba(255,255,255,.85);
}
.bm-geo-label small { display: block; font-size: .62rem; font-style: normal; opacity: .7; }
.bm-geo-sea span { font-size: 1.05rem; letter-spacing: .2em; color: #2b5a84; }
.bm-geo-river span { color: #2563eb; font-size: .72rem; }
.bm-geo-land span { color: #6b5a3c; letter-spacing: .25em; text-transform: uppercase; font-size: .7rem; font-style: normal; }

/* ---------- time bar ---------- */
.bm-timebar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 14px;
  padding: 10px 22px 12px 14px; background: var(--bg-card); border-top: 1px solid var(--border-subtle);
  box-shadow: 0 -6px 20px rgba(0,0,0,.06); user-select: none; -webkit-user-select: none;
}
.bm-play {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--accent-primary); color: #fff; font-size: .9rem; box-shadow: 0 4px 12px rgba(30,64,175,.3);
}
.bm-play:hover { background: var(--accent-primary-hover); }
.bm-readout { flex: 0 0 132px; }
.bm-year { font-family: var(--font-serif); font-size: 1.35rem; font-weight: 700; color: var(--text-main); font-variant-numeric: tabular-nums; line-height: 1.1; }
.bm-era-name { font-size: .72rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }

.bm-track-wrap { position: relative; flex: 1; height: 62px; cursor: pointer; touch-action: none; }
.bm-eras { position: absolute; left: 0; right: 0; top: 0; height: 18px; }
.bm-era-band {
  position: absolute; top: 0; height: 18px; overflow: hidden;
  background: color-mix(in srgb, var(--c) 16%, transparent); border-left: 1px solid var(--bg-card);
  border-bottom: 2px solid var(--c);
}
.bm-era-band span { display: block; padding: 2px 5px; font-size: .62rem; font-weight: 700; color: color-mix(in srgb, var(--c) 75%, #000); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
[data-theme="dark"] .bm-era-band span { color: color-mix(in srgb, var(--c) 70%, #fff); }
.bm-ticks { position: absolute; left: 0; right: 0; top: 23px; height: 8px; pointer-events: none; }
.bm-ticks i { position: absolute; top: 0; width: 2px; height: 8px; margin-left: -1px; border-radius: 1px; opacity: .55; }
.bm-track { position: absolute; left: 0; right: 0; top: 34px; height: 6px; border-radius: 3px; background: var(--border-subtle); }
.bm-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: linear-gradient(90deg, #d97706, #9333ea 45%, #e11d48 75%, #2563eb); }
.bm-handle {
  position: absolute; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent-primary); box-shadow: 0 2px 8px rgba(0,0,0,.25);
  cursor: grab; outline: none; transition: transform .12s ease;
}
.bm-handle:focus-visible { box-shadow: 0 0 0 4px var(--accent-primary-border); }
.bm-track-wrap.bm-dragging .bm-handle { cursor: grabbing; transform: scale(1.15); }
.bm-track-wrap.bm-dragging { cursor: grabbing; }
.bm-scale { position: absolute; left: 0; right: 0; top: 46px; height: 14px; pointer-events: none; }
.bm-scale span { position: absolute; transform: translateX(-50%); font-size: .62rem; color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- dark theme ---------- */
[data-theme="dark"] .bm-map .leaflet-tile-pane { filter: brightness(.62) saturate(.75) contrast(1.05); }
[data-theme="dark"] .bm-region-label span { text-shadow: 0 0 3px #000, 0 0 6px #000; color: color-mix(in srgb, var(--c) 55%, #fff); }
[data-theme="dark"] .bm-geo-label span { color: #9cc3e6; text-shadow: 0 0 4px #000; }
[data-theme="dark"] .bm-geo-land span { color: #cbb68a; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .bm-toolbar { right: 12px; }
  .bm-title-sub { display: none; }
  .bm-presets { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
  .bm-chip { flex: 0 0 auto; }
  .bm-panel { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 46%; }
  .bm-panel-toggle { display: block; }
  .bm-panel.bm-panel-collapsed .bm-panel-body, .bm-panel.bm-panel-collapsed .bm-panel-foot { display: none; }
  .bm-panel.bm-panel-collapsed .bm-panel-toggle { transform: rotate(180deg); }
  .bm-panel-foot { display: none; }
  .bm-layers { display: none; }
  .bm-readout { flex-basis: 92px; }
  .bm-year { font-size: 1.05rem; }
  .bm-era-band span { display: none; }
  .bm-timebar { gap: 10px; padding: 8px 14px 10px 10px; }
}
@media (max-width: 600px) {
  .bm-panel { max-height: 34%; }
  .bm-map .leaflet-control-zoom, .bm-map .leaflet-control-scale { display: none; }
  .bm-scale span:nth-child(even) { display: none; }
  .bm-scale span { font-size: .56rem; }
  .bm-play { width: 34px; height: 34px; }
}
