/* ═══════════════════════════════════════════════════════════════════════════
   THE GEOGRAPHY OF THE BIBLE — STYLE
   Dark scholarly theme with warm gold accents
   ═══════════════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── CORE PALETTE ─────────────────────────────────────────────────────── */
  --bg:          #181c24;
  --bg-raised:   #1f2432;
  --bg-card:     #272d3c;
  --bg-input:    #32384a;
  --border:      #272b38;
  --border-lt:   #333848;
  --text:        #e8e0d4;
  --text-2:      #9a9080;
  --text-3:      #5e5a52;
  --accent:      #7e3232;
  --accent-lt:   #b04848;
  --gold:        #c49a2c;
  --gold-lt:     #e0b840;
  --gold-bg:     #1e1c12;
  --gold-border: rgba(196,154,44,0.25);

  /* ── SEMANTIC: TESTAMENT COLORS ───────────────────────────────────────── */
  --ot-color:    #4a7fa8;
  --ot-bg:       #0e1c28;
  --nt-color:    #b05555;
  --nt-bg:       #280e0e;
  --both-color:  #5a9a50;
  --both-bg:     #0e1c10;

  /* ── SHADOWS ──────────────────────────────────────────────────────────── */
  --shadow-xs:   0 1px 2px rgba(0,0,0,.35);
  --shadow-sm:   0 1px 4px rgba(0,0,0,.4);
  --shadow-md:   0 4px 16px rgba(0,0,0,.5);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.65);
  --shadow-gold: 0 0 20px rgba(196,154,44,0.12);

  /* ── RADIUS ──────────────────────────────────────────────────────────── */
  --radius-sm:   5px;
  --radius-md:   9px;
  --radius-lg:   14px;

  /* ── TYPOGRAPHY ───────────────────────────────────────────────────────── */
  --font-body:   'Crimson Pro', Georgia, serif;
  --font-ui:     'Inter', system-ui, sans-serif;
  --font-mono:   'JetBrains Mono', 'Fira Mono', monospace;

  /* ── LAYOUT ───────────────────────────────────────────────────────────── */
  --header-h:    62px;
  --sidebar-w:   320px;
}

/* ── BASE ────────────────────────────────────────────────────────────────── */
html { scroll-behavior: smooth; }

/* Mobile nav — hidden on desktop (enabled inside @media queries) */
#menu-toggle { display: none; }
#mobile-nav { display: none; }


@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* WCAG AA: text (#e8e0d4) on bg (#181c24) passes 7:1 contrast ratio */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

body {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── SKIP LINK (Task 7: Accessibility) ─────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -999px;
  left: 0;
  background: var(--gold);
  color: var(--bg);
  padding: 8px 16px;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  z-index: 9999;
  border-radius: 0 0 var(--radius-sm) 0;
  text-decoration: none;
}
.skip-link:focus {
  top: 0;
}

/* Screen-reader only (visually hidden but accessible) */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── HEADER ──────────────────────────────────────────────────────────────── */
#header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  height: var(--header-h);
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(0,0,0,.5);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.025'/%3E%3C/svg%3E");
}

.header-inner {
  max-width: 1600px; margin: 0 auto; padding: 0 20px;
  height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 24px;
}

.logo { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; cursor: pointer; }
.logo svg { color: var(--gold-lt); flex-shrink: 0; filter: drop-shadow(0 0 6px rgba(196,154,44,0.3)); }
.logo h1 { font-family: var(--font-ui); font-size: 15px; font-weight: 600; letter-spacing: .01em; color: var(--text); }
.logo p { font-size: 12px; color: var(--text-3); font-family: var(--font-ui); letter-spacing: .02em; }

.header-nav { display: flex; gap: 3px; flex-wrap: wrap; }

.nav-btn {
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: var(--font-ui); font-size: 13px; font-weight: 500;
  color: var(--text-2);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  transition: all .2s ease;
  letter-spacing: .01em;
}
.nav-btn:hover {
  background: rgba(255,255,255,.06);
  color: var(--text);
  border-color: var(--border);
}
.nav-btn.active {
  background: var(--bg-card);
  color: var(--gold-lt);
  border-color: var(--gold-border);
  box-shadow: var(--shadow-gold);
}

/* ── APP LAYOUT ──────────────────────────────────────────────────────────── */
#app { padding-top: var(--header-h); min-height: 100vh; }
.view { display: none; min-height: calc(100vh - var(--header-h)); }
.view.active { display: flex; }

/* ── MAP VIEW ────────────────────────────────────────────────────────────── */
#map-view { flex-direction: row; position: relative; }

/* ── SIDEBAR ─────────────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  overflow-y: auto; height: calc(100vh - var(--header-h));
  display: flex; flex-direction: column; gap: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.018'/%3E%3C/svg%3E");
}

/* ── SEARCH ──────────────────────────────────────────────────────────────── */
#search-box { padding: 14px; border-bottom: 1px solid var(--border); position: relative; }

.search-row {
  display: flex; align-items: center; gap: 8px;
}

#random-btn {
  background: var(--bg-input);
  border: 1px solid var(--border-lt);
  color: var(--gold);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: background .15s;
}
#random-btn:hover { background: var(--border); }

#search {
  flex: 1;
  width: 100%;
  padding: 9px 12px;
  font-family: var(--font-ui); font-size: 14px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  caret-color: var(--gold);
}
#search:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(196,154,44,.1);
}
#search::placeholder { color: var(--text-3); }

/* ── FILTERS ─────────────────────────────────────────────────────────────── */
#filter-tabs {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.filter-tab {
  background: var(--bg-input);
  border: 1px solid var(--border);
  font-family: var(--font-ui); font-size: 11px; font-weight: 500;
  padding: 4px 10px;
  border-radius: 20px;
  cursor: pointer;
  color: var(--text-2);
  transition: all .15s;
  letter-spacing: .02em;
}
.filter-tab:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--gold-bg);
}
.filter-tab.active {
  background: var(--gold-bg);
  border-color: var(--gold);
  color: var(--gold-lt);
}

#testament-filter {
  display: flex; gap: 14px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
}
#testament-filter label {
  font-family: var(--font-ui); font-size: 12px;
  cursor: pointer; display: flex; align-items: center; gap: 6px;
  color: var(--text-2); user-select: none;
}
#testament-filter input[type=checkbox] {
  accent-color: var(--gold);
  width: 14px; height: 14px;
}

/* ── PLACES LIST ─────────────────────────────────────────────────────────── */
#places-list { flex: 1; overflow-y: auto; padding: 8px; }

.place-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: 3px;
  transition: background .15s, border-color .15s, box-shadow .15s;
  display: flex; align-items: center; gap: 10px;
  border: 1px solid transparent;
  position: relative;
}
.place-item:hover {
  background: rgba(255,255,255,.07);
  border-color: rgba(51,56,72,.7);
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.place-item.active {
  background: var(--gold-bg);
  border-color: var(--gold);
  box-shadow: inset 3px 0 0 var(--gold);
}
.place-item:hover .place-name { color: #f0ebe0; }

.region-header {
  padding: 8px 12px 4px;
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  opacity: .85; position: sticky; top: 0; background: var(--bg); z-index: 1;
  border-bottom: 1px solid var(--border); margin-top: 4px;
}

/* ── MAP CONTAINER ──────────────────────────────────────────────────────── */
#map-container { flex: 1; position: relative; min-width: 0; }

#map {
  width: 100%; height: calc(100vh - var(--header-h));
  position: relative;
}
#map::after {
  content: '';
  position: absolute; inset: 0; pointer-events: none; z-index: 400;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(10,12,16,.35) 100%);
}

/* ── MAP LEGEND ─────────────────────────────────────────────────────────── */
#map-legend {
  position: absolute; bottom: 20px; left: 16px; z-index: 500;
  background: var(--bg-raised);
  border: 1px solid var(--border-lt);
  border-radius: var(--radius-md); padding: 12px 16px;
  display: flex; flex-direction: column; gap: 10px;
  font-family: var(--font-ui); font-size: 12px;
  color: var(--text-2);
  box-shadow: var(--shadow);
  min-width: 180px;
}

.legend-header {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; user-select: none;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.legend-header .legend-title {
  font-size: 10px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-2);
  border-bottom: none; margin-bottom: 0; padding-bottom: 0;
}
.legend-chevron { font-size: 10px; color: var(--text-3); transition: transform .2s; }
#map-legend.collapsed .legend-chevron { transform: rotate(0deg); }

#map-legend .legend-section { display: flex; }
#map-legend.collapsed .legend-section { display: none; }

.legend-section { display: flex; flex-direction: column; gap: 5px; }

.legend-title {
  font-size: 10px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-2);
  margin-bottom: 4px;
}

.legend-item {
  display: flex; align-items: center; gap: 9px;
  color: var(--text-2); padding: 2px 0;
  font-size: 12px; letter-spacing: .01em;
}

.legend-swatch {
  width: 13px; height: 13px; flex-shrink: 0;
  border: 2px solid;
}
.legend-swatch.city        { background: #c49a2c44; border-color: #c49a2c; border-radius: 50%; }
.legend-swatch.settlement  { background: #a8b04a44; border-color: #a8b04a; border-radius: 50%; }
.legend-swatch.landmark    { background: #88888822; border-color: #888888; border-radius: 2px; transform: rotate(45deg); width: 10px; height: 10px; }
.legend-swatch.mountain    { background: #8a6a4022; border-color: #8a6a40; border-radius: 5px; }
.legend-swatch.region      { background: #4a7a5033; border-color: #4a7a50; border-radius: 3px; }
.legend-swatch.river       { background: #3a8ab844; border-color: #3a8ab8; border-radius: 50%; }
.legend-swatch.sea         { background: #2a6a9a44; border-color: #2a6a9a; border-radius: 50%; }
.legend-swatch.valley      { background: #7a5a3044; border-color: #7a5a30; border-radius: 50%; }
.legend-swatch.route       { background: #8a5a8a33; border-color: #8a5a8a; border-radius: 2px; transform: rotate(45deg); width: 10px; height: 10px; }
.legend-swatch.battle-site { background: #a0302033; border-color: #a03020; border-radius: 2px; transform: rotate(45deg); width: 10px; height: 10px; }
.legend-swatch.island      { background: #3a8a7a44; border-color: #3a8a7a; border-radius: 50%; }
.legend-swatch.coastal     { background: #2a8a7a44; border-color: #2a8a7a; border-radius: 50%; }


.legend-dot {
  width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid rgba(0,0,0,.15);
}
.legend-dot.ot    { background: #4a7fa8; }
.legend-dot.nt    { background: #b05555; }
.legend-dot.both  { background: #5a9a50; }

/* ── MAP MARKERS (Task 2 & 11) ──────────────────────────────────────────── */
.bible-marker {
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  box-shadow: 0 3px 10px rgba(0,0,0,.4), 0 0 0 1px rgba(0,0,0,.2);
  transition: transform .2s, box-shadow .2s;
  cursor: pointer;
}
.bible-marker:hover {
  transform: scale(1.3) !important;
  z-index: 9999 !important;
}

  z-index: 1;
}

/* Water pulse animation (rivers / seas) */
@keyframes waterPulse {
  0%, 100% { box-shadow: 0 2px 8px rgba(0,0,0,0.5); }
  50% { box-shadow: 0 2px 16px rgba(58,138,184,0.6); }
}
.bible-marker.river { animation: waterPulse 2s ease-in-out infinite; }
.bible-marker.sea    { animation: waterPulse 3s ease-in-out infinite; }
.bible-marker.river:hover,
.bible-marker.sea:hover {
  animation: waterPulse 1s ease-in-out infinite;
}

/* Cluster icons */
.cluster-icon {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-ui); font-size: 13px; font-weight: 700;
  color: var(--bg);
}

/* Leaflet cluster skin */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background: rgba(196,154,44,0.2) !important;
}
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background: rgba(196,154,44,0.7) !important;
  color: var(--bg) !important;
  font-family: var(--font-ui) !important;
  font-weight: 700 !important;
}

/* Leaflet popup overrides */
.leaflet-popup-content-wrapper {
  background: var(--bg-card) !important;
  border: 1px solid var(--border-lt) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-lg) !important;
  color: var(--text) !important;
}
.leaflet-popup-tip { background: var(--bg-card) !important; }
.leaflet-popup-close-button { color: var(--text-2) !important; }
.leaflet-popup-close-button:hover { color: var(--text) !important; }
.leaflet-popup-content { margin: 14px 18px; font-family: var(--font-ui); }
.popup-title { font-size: 17px; font-weight: 600; margin-bottom: 4px; color: var(--text); }
.popup-region { font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.popup-badges { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.popup-badge { font-size: 11px; padding: 3px 9px; border-radius: 10px; font-weight: 500; }
.popup-badge.ot   { background: var(--bg-input); color: var(--ot-color);   border: 1px solid rgba(74,127,168,.3); }
.popup-badge.nt  { background: var(--bg-input); color: var(--nt-color);   border: 1px solid rgba(176,85,85,.3); }
.popup-badge.both { background: var(--bg-input); color: var(--both-color); border: 1px solid rgba(90,154,80,.3); }
.popup-badge.gray { background: var(--bg-input); color: var(--text-3);    border: 1px solid var(--border); }
.popup-view-btn {
  display: inline-block; margin-top: 8px;
  background: var(--accent); color: var(--text);
  padding: 7px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  text-decoration: none; cursor: pointer; border: none;
  transition: background .2s;
}
.popup-view-btn:hover { background: var(--accent-lt); }

/* ── VERSE MODAL ──────────────────────────────────────────────────────────── */
.verse-modal {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.verse-modal.hidden { display: none; }
.verse-modal-content {
  background: var(--bg-raised); border: 1.5px solid var(--border-lt);
  border-radius: var(--radius-lg); padding: 24px 28px;
  max-width: 600px; width: 100%; max-height: 80vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.verse-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border); padding-bottom: 10px;
}

/* ── DETAIL PANEL ───────────────────────────────────────────────────────── */
.detail-panel {
  position: fixed; top: var(--header-h); right: 0; bottom: 0; width: 440px;
  background: var(--bg-card);
  border-left: 2px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 900; overflow-y: auto;
  transform: translateX(0); transition: transform .3s ease;
}
.detail-panel.hidden { transform: translateX(100%); pointer-events: none; }

.close-btn {
  position: absolute; top: 40px; right: 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
  transition: all .2s;
  line-height: 1;
  font-family: var(--font-ui);
}
.close-btn:hover { background: var(--accent); color: var(--text); border-color: var(--accent); }

.detail-content { padding: 24px; }

/* ── DETAIL CONTENT ──────────────────────────────────────────────────────── */
.detail-header {
  margin-bottom: 20px; padding-bottom: 18px; border-bottom: 1px solid var(--border);
  position: relative;
}
.detail-header::after {
  content: '';
  position: absolute; bottom: -1px; left: 0; right: 60%;
  height: 1px; background: linear-gradient(to right, var(--gold), transparent);
}

.detail-title { font-size: 27px; font-weight: 600; margin-bottom: 6px; line-height: 1.2; color: var(--text); }
.detail-subtitle { font-size: 14px; color: var(--text-2); font-family: var(--font-ui); margin-bottom: 8px; }

/* Era badges (Task 6) */
.era-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.era-badge {
  font-family: var(--font-ui); font-size: 10px; font-weight: 500;
  padding: 2px 8px; border-radius: 10px;
  background: var(--gold-bg); color: var(--gold);
  border: 1px solid var(--gold-border);
  letter-spacing: .03em;
}

.section { margin-bottom: 22px; position: relative; }

.section-title {
  font-family: var(--font-ui); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-2); margin-bottom: 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border); position: relative;
}
.section-title::after {
  content: ''; position: absolute; bottom: -1px; left: 0;
  width: 24px; height: 1px; background: var(--gold);
}

.detail-description { font-size: 16px; line-height: 1.75; color: var(--text); max-width: 68ch; }

.events-list { list-style: none; }
.events-list li {
  padding: 7px 0; font-size: 15px; border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: 8px; line-height: 1.5;
}
.events-list li:last-child { border-bottom: none; }
.events-list .event-bullet { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; margin-top: 8px; }

.verses-list { display: flex; flex-wrap: wrap; gap: 6px; }
.verse-tag {
  font-family: var(--font-mono); font-size: 12px;
  background: var(--bg-input); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: var(--radius-sm); color: var(--text);
  cursor: pointer; letter-spacing: .02em;
  transition: border-color .15s, color .15s;
}
.verse-tag:hover { background: var(--gold-bg); border-color: var(--gold); color: var(--gold-lt); }

.neighbors-list { display: flex; flex-wrap: wrap; gap: 6px; }
.neighbor-tag {
  font-family: var(--font-ui); font-size: 12px;
  background: var(--bg-input); border: 1px solid var(--border);
  padding: 3px 10px; border-radius: var(--radius-sm); color: var(--text);
  transition: border-color .15s, color .15s; cursor: default;
}
.neighbor-tag:hover { border-color: var(--gold); color: var(--gold-lt); }

.ancient-names { display: flex; flex-wrap: wrap; gap: 6px; }
.ancient-tag {
  font-family: var(--font-ui); font-size: 12px;
  background: var(--bg-raised); border: 1px solid var(--border);
  padding: 3px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-style: italic;
}

.ext-link {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-input); border: 1px solid var(--border-lt);
  padding: 6px 14px; border-radius: var(--radius-sm);
  color: var(--gold); font-family: var(--font-ui); font-size: 13px;
  text-decoration: none; transition: background .15s, border-color .15s;
}
.ext-link:hover { background: var(--gold-bg); border-color: var(--gold); }

/* ── TIMELINE VIEW ──────────────────────────────────────────────────────── */
#timeline-view {
  flex-direction: column;
  padding: 28px 32px 24px;
  background: var(--bg);
}

.timeline-controls { margin-bottom: 20px; display: flex; align-items: flex-start; gap: 16px; }
.timeline-eras { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.era-btn {
  background: var(--bg-raised);
  border: 1.5px solid var(--border-lt);
  font-family: var(--font-ui); font-size: 13px; font-weight: 600;
  padding: 7px 16px;
  border-radius: 20px; cursor: pointer;
  color: var(--text);
  transition: all .15s;
  display: inline-flex; align-items: center; gap: 4px;
}
.era-btn:hover { border-color: var(--gold); color: var(--gold); }
.era-btn.active { background: var(--gold-bg); border-color: var(--gold); color: var(--gold-lt); }

.era-count { font-size: 11px; color: var(--text-2); }

#timeline-container {
  flex: 1; overflow-x: auto; overflow-y: auto;
  padding: 16px 0 24px;
  /* Custom scrollbar for horizontal timeline */
  scroll-behavior: smooth;
}
#timeline { min-width: 1000px; position: relative; }

/* Timeline event */
.tl-event {
  transition: transform .2s, box-shadow .2s;
  background: var(--bg-raised);
  border: 1.5px solid var(--border-lt);
}
.tl-event:hover { transform: translateX(-50%) scale(1.06) !important; box-shadow: 0 4px 16px rgba(0,0,0,.4), 0 0 0 1px var(--gold); }

/* ── PLACES GRID VIEW ────────────────────────────────────────────────────── */
#places-view { flex-direction: column; padding: 24px; background: var(--bg); }

.view-header {
  margin-bottom: 24px;
  display: flex; align-items: baseline; gap: 16px;
  padding-bottom: 16px; border-bottom: 1px solid var(--border);
}
.view-header h2 { font-size: 26px; font-weight: 600; color: var(--text); }
.view-header p { color: var(--text-2); font-family: var(--font-ui); font-size: 14px; }

#places-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

.place-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 18px; cursor: pointer;
  transition: all .2s ease; box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.place-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--gold); transform: scaleX(0); transition: transform .2s ease;
}
.place-card:hover {
  box-shadow: var(--shadow-md), var(--shadow-gold);
  border-color: var(--gold-border); transform: translateY(-2px);
}
.place-card:hover::before { transform: scaleX(1); }

/* ── REGIONS VIEW ────────────────────────────────────────────────────────── */
#regions-view { flex-direction: column; padding: 24px; background: var(--bg); }

#regions-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }

.region-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); overflow: hidden; cursor: pointer;
  transition: all .2s ease; box-shadow: var(--shadow-sm);
}
.region-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--border-lt); }

.region-card-header {
  height: 88px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, rgba(126,50,50,.18) 0%, rgba(126,50,50,.08) 100%);
  border-bottom: 1px solid var(--border); position: relative;
}
.region-card-header::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(to right, transparent, rgba(196,154,44,.2), transparent);
}
.region-card-header .emoji { font-size: 36px; }

.region-card-body { padding: 16px 18px; }
.region-card-title { font-size: 18px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.region-card-desc { font-size: 14px; color: var(--text-2); line-height: 1.55; }
.region-card-stats { display: flex; gap: 12px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }

/* ── BIBLE STORY VIEW (Task 12) ─────────────────────────────────────────── */
#story-view { flex-direction: column; padding: 24px; background: var(--bg); overflow-y: auto; }

#story-container { max-width: 800px; margin: 0 auto; }

#story-progress {
  height: 4px; background: var(--border);
  border-radius: 2px; margin-bottom: 32px;
  overflow: hidden;
}
#story-progress::after {
  content: '';
  display: block; height: 100%;
  background: linear-gradient(to right, var(--ot-color), var(--gold), var(--nt-color));
  width: 100%;
}

#story-timeline { display: flex; flex-direction: column; gap: 0; }

.story-section {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 0 20px;
  padding: 0 0 48px;
  position: relative;
}
/* Connecting timeline line */
.story-section:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 28px; top: 48px; bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, var(--gold), var(--border));
}

.story-section-num {
  font-size: 22px; text-align: center;
  color: var(--gold); font-weight: 700;
  font-family: var(--font-ui);
  position: relative; z-index: 1;
}

.story-section-content { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 20px; }

.story-section-title {
  font-family: var(--font-ui); font-size: 20px; font-weight: 600;
  color: var(--text); margin-bottom: 10px;
}

.story-section-desc {
  font-size: 15px; color: var(--text-2); line-height: 1.7;
  margin-bottom: 14px;
}

.story-verse {
  border-left: 3px solid var(--gold);
  padding: 8px 14px;
  background: var(--gold-bg);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-family: var(--font-body); font-size: 14px;
  color: var(--text-2); font-style: italic;
  margin-bottom: 14px;
  line-height: 1.6;
}

.story-map-btn {
  background: var(--bg-input); border: 1px solid var(--border-lt);
  color: var(--gold); padding: 6px 14px;
  border-radius: var(--radius-sm); font-family: var(--font-ui);
  font-size: 13px; cursor: pointer; transition: background .15s, border-color .15s;
}
.story-map-btn:hover { background: var(--gold-bg); border-color: var(--gold); }

/* ── UTILITY ────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.dot.ot   { background: var(--ot-color);   box-shadow: 0 0 5px rgba(74,127,168,.4); }
.dot.nt   { background: var(--nt-color);   box-shadow: 0 0 5px rgba(176,85,85,.4); }
.dot.both { background: var(--both-color); box-shadow: 0 0 5px rgba(90,154,80,.4); }

/* ── EMPTY STATE ────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 40px; color: var(--text-2); }
.empty-state svg { margin-bottom: 12px; opacity: .3; }
.empty-state p { font-family: var(--font-ui); font-size: 14px; }

/* ── LOADING ────────────────────────────────────────────────────────────── */
.loading { display: flex; align-items: center; justify-content: center; padding: 40px; color: var(--text-2); font-family: var(--font-ui); font-size: 14px; gap: 8px; }
.spinner { width: 18px; height: 18px; border:: 2px solid var(--border); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── SCROLLBAR ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-lt); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ── RESPONSIVE — MOBILE (Task 8) ──────────────────────────────────────── */

/* ── MOBILE (< 768px) ──────────────────────────────────────────────── */
@media (max-width: 768px) {

  /* ── HEADER + HAMBURGER ── */
  .header-inner { padding: 0 10px; gap: 6px; }
  .logo { gap: 8px; flex-shrink: 0; }
  .logo svg { width: 20px; height: 20px; }
  .logo h1 { font-size: 12px; }
  .logo p { display: none; }

  /* Hide desktop nav, show hamburger button */
  .header-nav { display: none; }
  /* Hamburger — compact but still 44px touch target */
  #menu-toggle {
    display: flex !important;
    align-items: center; justify-content: center;
    width: 36px; height: 36px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-2);
    font-size: 16px;
    flex-shrink: 0;
    transition: background .15s, border-color .15s;
  }
  #menu-toggle:hover { background: var(--border); color: var(--text); border-color: var(--border-lt); }
  #menu-toggle[aria-expanded=true] { background: var(--gold-bg); color: var(--gold); border-color: var(--gold); }

  /* Mobile nav drawer */
  #mobile-nav {
    display: none;
    position: fixed;
    top: var(--header-h); left: 0; right: 0;
    background: var(--bg-card);
    border-bottom: 2px solid var(--border);
    z-index: 999;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
  }
  #mobile-nav.open { display: flex; }
  .mobile-nav-btn {
    width: 100%;
    padding: 0 18px;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-2);
    cursor: pointer;
    text-align: right;
    transition: background .15s, color .15s;
    min-height: 50px;
    display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  }
  .mobile-nav-btn:last-child { border-bottom: none; }
  .mobile-nav-btn:hover { background: var(--bg-raised); color: var(--text); }
  .mobile-nav-btn.active { color: var(--gold-lt); background: var(--gold-bg); }
  .mobile-nav-btn.active::after { content: '←'; font-size: 12px; }

  /* ── SEARCH BOX ── */
  #search-box { padding: 10px 12px; border-bottom: 1px solid var(--border); position: relative; }
  #search { height: 44px; font-size: 15px; padding: 8px 12px; }
  #random-btn { width: 44px; height: 44px; flex-shrink: 0; font-size: 18px; padding: 0; display: flex; align-items: center; justify-content: center; }

  /* ── FILTER TABS — horizontal scroll row, separate from testament ── */
  #filter-tabs {
    display: flex;
    flex-wrap: nowrap;
    gap: 5px;
    padding: 10px 12px 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border-bottom: none; /* border is on #testament-filter */
  }
  #filter-tabs::-webkit-scrollbar { display: none; }
  .filter-tab {
    flex-shrink: 0;
    background: var(--bg-input);
    border: 1px solid var(--border);
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 500;
    padding: 7px 13px;
    border-radius: 20px;
    cursor: pointer;
    color: var(--text-2);
    transition: all .15s;
    letter-spacing: .02em;
    min-height: 36px;
    display: flex; align-items: center;
  }
  .filter-tab:hover { border-color: var(--gold); color: var(--text); }
  .filter-tab.active { background: var(--gold-bg); border-color: var(--gold); color: var(--gold-lt); }

  /* ── TESTAMENT FILTER — full-width row below tabs ── */
  #testament-filter {
    padding: 0 12px 10px;
    display: flex; gap: 12px;
    border-bottom: 1px solid var(--border);
  }
  #testament-filter label {
    font-size: 13px; color: var(--text-2);
    display: flex; align-items: center; gap: 6px;
    min-height: 36px; cursor: pointer;
  }
  #testament-filter input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--gold); cursor: pointer; }

  /* ── SIDEBAR → bottom drawer ── */
  #map-view { flex-direction: column; }
  #sidebar {
    width: 100%; height: auto; max-height: 50vh;
    border-right: none; border-top: 1px solid var(--border);
    flex-direction: column;
    overflow-y: auto;
    order: 2;
  }
  #sidebar.hidden { display: none; }

  /* Filter strip sticks to top so tabs are always visible */
  #sidebar > #filter-tabs {
    position: sticky; top: 0; z-index: 10;
    background: var(--bg-card);
  }
  #sidebar > #testament-filter {
    position: sticky; top: 0; z-index: 9;
    background: var(--bg-card);
  }
  #sidebar > #places-list { display: none; }

  /* ── MAP ── */
  #map-container { flex: 1; width: 100%; order: 1; display: flex; flex-direction: column; }
  #map { height: calc(50vh - var(--header-h)); width: 100%; flex: 1; }

  /* ── LEGEND ── */
  #map-legend { font-size: 11px; bottom: 12px; left: 8px; min-width: 155px; max-height: 40vh; overflow-y: auto; }

  /* ── DETAIL PANEL — full-screen sheet ── */
  .detail-panel {
    width: 100%; top: var(--header-h); bottom: 0;
    border-left: none; border-top: 2px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    z-index: 1000;
  }
  .detail-content { padding: 16px; }

  /* ── VERSE MODAL — bottom sheet ── */
  .verse-modal { align-items: flex-end; padding: 0; }
  .verse-modal-content {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 20px 20px 40px;
    max-height: 90vh; width: 100%;
  }
  .verse-modal-header { padding-bottom: 12px; margin-bottom: 12px; }

  /* ── TIMELINE ── */
  #timeline-view { padding: 16px 12px; }
  #timeline-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .timeline-controls { flex-direction: column; gap: 12px; }
  .timeline-eras { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; padding-bottom: 4px; scrollbar-width: none; }
  .timeline-eras::-webkit-scrollbar { display: none; }
  .era-btn { flex-shrink: 0; padding: 8px 14px; font-size: 12px; }

  /* ── PLACES GRID ── */
  #places-view { padding: 16px 12px; }
  #places-grid { grid-template-columns: 1fr; gap: 12px; }
  .place-card { padding: 16px; }

  /* ── REGIONS GRID ── */
  #regions-view { padding: 16px 12px; }
  #regions-grid { grid-template-columns: 1fr; gap: 12px; }

  /* ── BIBLE STORY ── */
  #story-view { padding: 16px 12px; overflow-y: auto; }
  .story-section { grid-template-columns: 48px 1fr; gap: 0 12px; padding: 0 0 40px; }
  .story-section-content { padding: 16px; }
  .story-section-title { font-size: 17px; }
  .story-section-desc { font-size: 14px; }
}

/* ── MOBILE (< 480px) ──────────────────────────────────────────────── */
@media (max-width: 480px) {
  :root { --header-h: 50px; }
  .header-inner { padding: 0 8px; }
  .logo h1 { font-size: 11px; }
  #menu-toggle { width: 28px; height: 28px; font-size: 14px; }
  #map { height: calc(50vh - 50px); min-height: 30vh; }
  #sidebar { max-height: 55vh; }
  .verse-modal-content { border-radius: 12px 12px 0 0; padding: 16px 16px 32px; }
  .place-card { padding: 14px; }
  .detail-content { padding: 14px; }
  .detail-title { font-size: 20px; }
}

/* ── LEAFLET MOBILE CONTROLS ──────────────────────────────────────── */
@media (max-width: 768px) {
  .leaflet-touch .leaflet-bar {
    border: 1px solid var(--border-lt) !important;
    border-radius: var(--radius-sm) !important;
    overflow: hidden;
    box-shadow: var(--shadow-md);
  }
  .leaflet-touch .leaflet-bar a {
    width: 36px !important; height: 36px !important;
    line-height: 36px !important;
    border-bottom: 1px solid var(--border-lt) !important;
    background: var(--bg-card) !important;
    color: var(--text-2) !important;
    display: flex !important; align-items: center; justify-content: center;
    filter: none !important;
  }
  .leaflet-touch .leaflet-bar a:last-child { border-bottom: none !important; }
  .leaflet-touch .leaflet-bar a:hover { background: var(--border) !important; color: var(--text) !important; }
  .leaflet-touch .leaflet-control-layers-toggle {
    width: 36px !important; height: 36px !important;
    background: var(--bg-card) !important;
    border: 1px solid var(--border-lt) !important;
    border-radius: var(--radius-sm) !important;
    filter: none !important;
  }
  .leaflet-touch .leaflet-control-layers {
    border: 1px solid var(--border-lt) !important;
    border-radius: var(--radius-sm) !important;
    overflow: hidden;
    box-shadow: var(--shadow-md);
  }
  .leaflet-touch .leaflet-control-layers-expanded {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-lt) !important;
    border-radius: var(--radius-sm) !important;
    box-shadow: var(--shadow-lg);
    padding: 8px;
  }
  .leaflet-control-layers-expanded label {
    color: var(--text-2) !important;
    font-family: var(--font-ui) !important;
    font-size: 12px !important;
  }
  .leaflet-control-layers-expanded .leaflet-control-layers-separator { border-color: var(--border) !important; }
}


/* Leaflet layer control (for tile switching) */
.leaflet-control-layers {
  background: rgba(14,16,20,.9) !important;
  border: 1px solid var(--border-lt) !important;
  border-radius: var(--radius-sm) !important;
  font-family: var(--font-ui) !important;
  font-size: 12px !important;
  color: var(--text-2) !important;
}
.leaflet-control-layers-toggle { filter: invert(0.7); }

/* ── ABOUT VIEW ───────────────────────────────────────────────────────── */
/* About view — full-page scrollable layout */
#about-view { flex-direction: column; background: var(--bg); overflow-y: auto; }

#about-view {
  padding: 0;
  overflow-y: auto;
  height: 100%;
  background: var(--bg);
}
.about-content {
  max-width: 680px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}
.about-hero {
  text-align: center;
  padding: 40px 0 32px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.about-hero h2 {
  font-family: var(--font-ui);
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}
.about-hero p {
  font-size: 16px;
  color: var(--text-2);
  line-height: 1.7;
  max-width: 520px;
  margin: 0 auto;
}
.about-section {
  padding: 28px 0;
  border-bottom: 1px solid var(--border);
}
.about-section:last-child { border-bottom: none; }
.about-section h3 {
  font-family: var(--font-ui);
  font-size: 17px;
  font-weight: 600;
  color: var(--gold-lt);
  margin-bottom: 12px;
  letter-spacing: .03em;
}
.about-section p {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.8;
  margin-bottom: 10px;
}
.about-section p:last-child { margin-bottom: 0; }
.about-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
}
.about-list li {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.65;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.about-list li:last-child { border-bottom: none; }

/* Marker swatches in the About marker legend */
.about-markers li {
  align-items: center;
  gap: 12px;
  padding: 7px 0;
}
.marker-circle {
  display: inline-block; width: 12px; height: 12px;
  background: var(--gold); border-radius: 50%; flex-shrink: 0;
  margin-top: 2px;
}
.marker-diamond {
  display: inline-block; width: 11px; height: 11px;
  background: #e8a040; transform: rotate(45deg); flex-shrink: 0;
}
.marker-square {
  display: inline-block; width: 12px; height: 12px;
  background: #4a9e5a; border-radius: 2px; flex-shrink: 0;
}
.marker-water {
  display: inline-block; width: 12px; height: 12px;
  background: #4a8fbf; border-radius: 50%; flex-shrink: 0;
}
.marker-star {
  display: inline-block; width: 12px; height: 12px;
  background: #9e4a9a; clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); flex-shrink: 0;
}
