/* ═══════════════════════════════════════
   THE LIVING MAP OF SCRIPTURE — Phase 2
   ═══════════════════════════════════════ */
:root {
  --bg-0: #080b10; --bg-1: #0d1117; --bg-2: #131920; --bg-3: #1a222d; --bg-4: #212b38;
  --bdr-0: rgba(96,212,240,0.06); --bdr-1: rgba(96,212,240,0.12); --bdr-2: rgba(96,212,240,0.25);
  --text: #e4e8ee; --sub: #8a95a8; --muted: #556070;
  --cyan: #60d4f0; --gold: #f0c060; --coral: #ff6b6b; --green: #77e6b3; --purple: #b48eff;
  --g-cyan: rgba(96,212,240,0.1); --g-gold: rgba(240,192,96,0.1); --g-coral: rgba(255,107,107,0.1);
  --font-d: 'Cormorant Garamond', Georgia, serif;
  --font-b: 'DM Sans', -apple-system, sans-serif;
  --top: 52px; --panel: 330px; --r: 8px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg-0); color: var(--text); font-family: var(--font-b); font-size: 13.5px; line-height: 1.5; -webkit-font-smoothing: antialiased; overflow: hidden; }
::-webkit-scrollbar { width: 4px; } ::-webkit-scrollbar-track { background: transparent; } ::-webkit-scrollbar-thumb { background: rgba(96,212,240,0.12); border-radius: 4px; }

/* Shell */
.app-shell { display: grid; grid-template-columns: var(--panel) 1fr var(--panel); grid-template-rows: var(--top) 1fr; grid-template-areas: "top top top" "left map right"; height: 100vh; }

/* ── Topbar ── */
.topbar { grid-area: top; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--bg-1); border-bottom: 1px solid var(--bdr-0); z-index: 1000; }
.topbar-brand { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.brand-icon { width: 24px; height: 24px; color: var(--cyan); }
.brand-text h1 { font-family: var(--font-d); font-size: 16px; font-weight: 600; line-height: 1.2; letter-spacing: 0.02em; }
.brand-sub { font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.topbar-nav { display: flex; gap: 1px; margin-left: auto; background: rgba(255,255,255,0.02); border-radius: 8px; padding: 3px; }
.nav-tab { background: none; border: none; padding: 5px 12px; border-radius: 6px; color: var(--sub); font-family: var(--font-b); font-size: 12px; font-weight: 500; cursor: pointer; transition: all 0.2s; white-space: nowrap; }
.nav-tab:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.nav-tab.active { color: var(--cyan); background: var(--g-cyan); }
.topbar-actions { display: flex; gap: 6px; margin-left: 8px; }
.action-btn { width: 32px; height: 32px; border-radius: 6px; background: rgba(255,255,255,0.03); border: 1px solid var(--bdr-0); color: var(--sub); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.action-btn:hover { background: var(--g-cyan); color: var(--cyan); }

/* ── Panels ── */
.panel { overflow: hidden; z-index: 500; background: var(--bg-1); }
.left-panel { grid-area: left; border-right: 1px solid var(--bdr-0); }
.right-panel { grid-area: right; border-left: 1px solid var(--bdr-0); }
.panel-inner { height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.panel-content { flex: 1; overflow-y: auto; padding: 12px 14px; }

/* Search */
.search-container { position: relative; padding: 10px 14px; flex-shrink: 0; }
.search-icon { position: absolute; left: 26px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-input { width: 100%; padding: 9px 12px 9px 34px; background: var(--bg-2); border: 1px solid var(--bdr-0); border-radius: var(--r); color: var(--text); font-family: var(--font-b); font-size: 12.5px; outline: none; transition: all 0.2s; }
.search-input::placeholder { color: var(--muted); }
.search-input:focus { border-color: var(--bdr-2); box-shadow: 0 0 0 3px var(--g-cyan); }

/* Filters */
.filter-row { display: flex; gap: 5px; margin-bottom: 12px; flex-wrap: wrap; }
.fbtn { padding: 4px 11px; border-radius: 16px; background: var(--bg-2); border: 1px solid var(--bdr-0); color: var(--sub); font-family: var(--font-b); font-size: 11px; font-weight: 500; cursor: pointer; transition: all 0.15s; }
.fbtn:hover { border-color: var(--bdr-1); color: var(--text); }
.fbtn.active { background: var(--g-cyan); border-color: rgba(96,212,240,0.25); color: var(--cyan); }

/* Section headers */
.sec-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; padding: 0 2px; }
.sec-head h3 { font-family: var(--font-d); font-size: 15px; font-weight: 600; }
.sec-ct { font-size: 10.5px; color: var(--muted); }
.era-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--gold); font-weight: 600; padding: 8px 2px 4px; }

/* ── Cards ── */
.clist { display: flex; flex-direction: column; gap: 4px; }
.card { padding: 10px 12px 10px 16px; background: var(--bg-2); border: 1px solid var(--bdr-0); border-radius: var(--r); cursor: pointer; transition: all 0.15s; position: relative; animation: fadeUp 0.2s ease both; }
.card:nth-child(2) { animation-delay: .02s; } .card:nth-child(3) { animation-delay: .04s; }
.card:hover { background: var(--bg-3); border-color: var(--bdr-1); transform: translateX(2px); }
.card.active { background: var(--bg-4); border-color: var(--bdr-2); box-shadow: 0 0 10px var(--g-cyan); }
.card-bar { position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 2px 2px 0; opacity: 0; transition: opacity 0.15s; }
.card:hover .card-bar, .card.active .card-bar { opacity: 1; }
.card-t { font-family: var(--font-d); font-size: 14.5px; font-weight: 600; line-height: 1.3; margin-bottom: 2px; }
.card-s { font-size: 11.5px; color: var(--sub); line-height: 1.4; margin-bottom: 5px; }
.card-m, .pill-row { display: flex; flex-wrap: wrap; gap: 4px; }
.pill { display: inline-block; padding: 2px 7px; font-size: 10px; font-weight: 500; border-radius: 8px; background: rgba(255,255,255,0.03); border: 1px solid var(--bdr-0); color: var(--sub); line-height: 1.5; }
.p-cyan { background: var(--g-cyan); color: var(--cyan); border-color: rgba(96,212,240,0.2); }
.p-gold { background: var(--g-gold); color: var(--gold); border-color: rgba(240,192,96,0.2); }
.p-coral { background: var(--g-coral); color: var(--coral); border-color: rgba(255,107,107,0.2); }

/* Route preview */
.route-prev { font-size: 10px; color: var(--muted); margin-top: 4px; line-height: 1.6; }
.wp-dot { display: inline-block; width: 4px; height: 4px; border-radius: 50%; margin-right: 2px; vertical-align: middle; }

/* ── Right panel details ── */
.detail-eye { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--cyan); font-weight: 600; margin-bottom: 4px; }
.detail-h { font-family: var(--font-d); font-size: 24px; font-weight: 700; line-height: 1.2; margin-bottom: 8px; }
.detail-p { font-size: 12.5px; color: var(--sub); line-height: 1.6; margin-bottom: 12px; }

/* Stats */
.stat-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; margin-bottom: 14px; }
.stat { text-align: center; padding: 10px 6px; background: var(--bg-2); border: 1px solid var(--bdr-0); border-radius: var(--r); }
.stat-v { font-family: var(--font-d); font-size: 20px; font-weight: 700; color: var(--cyan); line-height: 1; }
.stat-l { font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 3px; }

/* Sections */
.detail-sec { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--bdr-0); }
.detail-sec-t { font-family: var(--font-d); font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 8px; }

/* Inline cards */
.icard { padding: 8px 10px; background: var(--bg-2); border: 1px solid var(--bdr-0); border-radius: 6px; margin-bottom: 4px; cursor: pointer; transition: all 0.12s; }
.icard:hover { background: var(--bg-3); border-color: var(--bdr-1); }
.icard.active { border-color: var(--bdr-2); background: var(--bg-4); }
.icard-ref { font-size: 10px; color: var(--cyan); font-weight: 500; margin-bottom: 1px; }
.icard-n { font-family: var(--font-d); font-size: 13px; font-weight: 600; }
.icard-sub { font-size: 11px; color: var(--sub); margin-top: 1px; }

/* Selected item card */
.sel-card { padding: 14px; background: rgba(96,212,240,0.04); border: 1px solid rgba(96,212,240,0.12); border-radius: var(--r); margin-bottom: 14px; }
.sel-card .detail-eye { margin-bottom: 3px; }
.sel-card .detail-h { font-size: 19px; margin-bottom: 6px; }
.sel-meta { font-size: 12px; color: var(--sub); margin-top: 6px; }
.sub-sec { margin-top: 10px; }
.sub-sec-t { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 5px; font-weight: 600; }

/* Timeline list */
.timeline-list { position: relative; padding-left: 22px; }
.tl-stop { position: relative; padding: 6px 0 6px 8px; cursor: pointer; }
.tl-dot { position: absolute; left: -20px; top: 12px; width: 8px; height: 8px; border-radius: 50%; border: 2px solid; background: var(--bg-1); }
.tl-name { font-family: var(--font-d); font-size: 13px; font-weight: 600; color: var(--sub); transition: color 0.15s; }
.tl-stop:hover .tl-name { color: var(--text); }
.tl-sub { font-size: 10.5px; color: var(--muted); }

/* Story controls */
.story-ctrl { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: rgba(96,212,240,0.05); border: 1px solid rgba(96,212,240,0.12); border-radius: var(--r); margin-bottom: 8px; }
.story-btns { display: flex; gap: 4px; }
.sbtn { width: 26px; height: 26px; border-radius: 50%; background: rgba(96,212,240,0.08); border: 1px solid rgba(96,212,240,0.18); color: var(--cyan); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 10px; transition: all 0.12s; }
.sbtn:hover { background: rgba(96,212,240,0.18); }
.story-name { font-size: 12px; font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.story-ct { font-size: 10px; color: var(--muted); white-space: nowrap; }
.story-bar { height: 3px; background: rgba(255,255,255,0.05); border-radius: 2px; overflow: hidden; margin-bottom: 14px; }
.story-fill { height: 100%; background: var(--cyan); border-radius: 2px; transition: width 0.5s; }

/* Empty state */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px 20px; min-height: 180px; }
.empty-icon { color: var(--muted); margin-bottom: 14px; }
.empty-state h3 { font-family: var(--font-d); font-size: 17px; margin-bottom: 6px; }
.empty-state p { font-size: 12.5px; color: var(--sub); max-width: 240px; line-height: 1.5; }

/* ── Map ── */
.map-container { grid-area: map; position: relative; z-index: 1; }
#map { width: 100%; height: 100%; background: var(--bg-0); }
.leaflet-container { background: var(--bg-0) !important; font-family: var(--font-b) !important; }
.leaflet-control-zoom { border: 1px solid var(--bdr-0) !important; border-radius: 6px !important; overflow: hidden; }
.leaflet-control-zoom a { background: var(--bg-1) !important; color: var(--sub) !important; border-color: var(--bdr-0) !important; width: 30px !important; height: 30px !important; line-height: 30px !important; font-size: 15px !important; }
.leaflet-control-zoom a:hover { background: var(--bg-2) !important; color: var(--cyan) !important; }

.pin { border-radius: 50%; box-shadow: 0 0 6px currentColor, 0 0 14px currentColor; transition: transform 0.15s; }
.pin:hover { transform: scale(1.3); }
.pin-lg { border-radius: 50%; box-shadow: 0 0 8px currentColor, 0 0 18px currentColor; border: 2px solid rgba(255,255,255,0.25); }
.pin-pulse { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 6px currentColor; } 50% { box-shadow: 0 0 12px currentColor, 0 0 20px currentColor; } }

/* Tooltips */
.leaflet-tooltip.map-tt {
  background: rgba(13,17,23,0.96) !important;
  border: 1px solid rgba(96,212,240,0.18) !important;
  border-radius: 8px !important;
  padding: 0 !important;
  box-shadow: 0 10px 28px rgba(0,0,0,0.5) !important;
  color: var(--text) !important;
  max-width: none !important;
}
.leaflet-tooltip.map-tt::before,
.leaflet-tooltip-top.map-tt::before,
.leaflet-tooltip-bottom.map-tt::before {
  display: none !important;
}
.leaflet-tooltip.map-tt .leaflet-tooltip-content {
  margin: 0 !important;
  padding: 0 !important;
  min-width: 0 !important;
  font-family: var(--font-b) !important;
  font-size: 14px !important;
  line-height: 1.4 !important;
}
.leaflet-tooltip.map-tt .tt-inner {
  padding: 10px 12px 11px !important;
  min-width: 170px;
  max-width: 250px;
  white-space: normal !important;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.leaflet-tooltip.map-tt .tt-eye {
  display: block !important;
  margin: 0 0 5px 0 !important;
  font-family: var(--font-b) !important;
  font-size: 10px !important;
  line-height: 1.2 !important;
  font-weight: 700 !important;
  letter-spacing: 0.08em !important;
  text-transform: uppercase !important;
  color: var(--cyan) !important;
  opacity: 0.95;
}
.leaflet-tooltip.map-tt .tt-name {
  display: block !important;
  margin: 0 0 6px 0 !important;
  font-family: var(--font-d) !important;
  font-size: 20px !important;
  line-height: 1.05 !important;
  font-weight: 700 !important;
  color: #ffffff !important;
  letter-spacing: 0.01em;
}
.leaflet-tooltip.map-tt .tt-desc {
  display: block !important;
  margin: 0 !important;
  font-family: var(--font-b) !important;
  font-size: 13px !important;
  line-height: 1.45 !important;
  font-weight: 500 !important;
  color: #c6d2df !important;
}
.leaflet-tooltip.map-tt * {
  text-rendering: optimizeLegibility;
}

/* Legend */
.map-legend { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 6px 16px; background: rgba(13,17,23,0.92); border: 1px solid var(--bdr-0); border-radius: 18px; font-size: 10.5px; color: var(--sub); z-index: 800; backdrop-filter: blur(8px); }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dot-color); box-shadow: 0 0 5px var(--dot-color); display: inline-block; }

/* Timeline slider */
.timeline-slider-container { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 800; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 16px; background: rgba(13,17,23,0.92); border: 1px solid var(--bdr-0); border-radius: 10px; backdrop-filter: blur(8px); min-width: 340px; }
.timeline-bar { width: 100%; }
.timeline-range { width: 100%; -webkit-appearance: none; appearance: none; height: 6px; background: var(--bg-3); border-radius: 3px; outline: none; }
.timeline-range::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--cyan); cursor: pointer; box-shadow: 0 0 6px var(--cyan); }
.timeline-range::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--cyan); cursor: pointer; border: none; }
.timeline-label { font-family: var(--font-d); font-size: 14px; font-weight: 600; color: var(--cyan); }

/* Mobile toggles */
.mobile-toggle { display: none; position: absolute; z-index: 900; top: 10px; width: 36px; height: 36px; border-radius: 6px; background: var(--bg-1); border: 1px solid var(--bdr-0); color: var(--sub); cursor: pointer; align-items: center; justify-content: center; }
.mobile-toggle.left { left: 10px; }
.mobile-toggle.right { right: 10px; }

/* Leaflet popup */
.leaflet-popup-content-wrapper { background: var(--bg-1) !important; border: 1px solid var(--bdr-1) !important; border-radius: var(--r) !important; color: var(--text) !important; box-shadow: 0 6px 24px rgba(0,0,0,0.5) !important; }
.leaflet-popup-tip { background: var(--bg-1) !important; }
.leaflet-popup-close-button { color: var(--sub) !important; }

/* Mobile overlay */
.mob-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1050; opacity: 0; pointer-events: none; transition: opacity 0.3s; }
.mob-overlay.active { opacity: 1; pointer-events: auto; }

/* Animations */
@keyframes fadeUp { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ── Responsive ── */
@media (max-width: 1100px) { :root { --panel: 290px; } }
@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; grid-template-rows: var(--top) 1fr; grid-template-areas: "top" "map"; }
  .brand-sub { display: none; } .brand-text h1 { font-size: 14px; }
  .left-panel, .right-panel { position: fixed; top: var(--top); bottom: 0; width: 320px; z-index: 1100; transform: translateX(-100%); transition: transform 0.3s cubic-bezier(0.4,0,0.2,1); box-shadow: 4px 0 24px rgba(0,0,0,0.4); }
  .left-panel { left: 0; } .right-panel { right: 0; left: auto; transform: translateX(100%); }
  .left-panel.open { transform: translateX(0); } .right-panel.open { transform: translateX(0); }
  .mobile-toggle { display: flex; }
  .nav-tab { padding: 5px 8px; font-size: 11px; }
  .timeline-slider-container { min-width: 260px; }
}
@media (max-width: 600px) {
  .left-panel, .right-panel { width: 100%; }
  .brand-text h1 { font-size: 12px; }
  .topbar-actions { display: none; }
  .nav-tab { padding: 4px 6px; font-size: 10px; }
}
