/* ===== RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --parchment: #F5EDD8;
  --parchment-dark: #EDE0C4;
  --navy: #1B3A5C;
  --navy-light: #2C5F8A;
  --gold: #D4A843;
  --gold-dark: #C9A84C;
  --gold-muted: rgba(212, 168, 67, 0.45);
  --text-dark: #1A1A1A;
  --text-mid: #3D3D3D;
  --text-light: #F9F4EC;
  --epistle-blue: #2C5F8A;
  --epistle-blue-light: #4A86B8;
  --shadow: rgba(27, 58, 92, 0.18);
  --nav-height: 56px;

  /* Text size vars */
  --popup-font-size: 1rem;
  --popup-scripture-size: 0.92rem;
  --popup-meta-size: 0.84rem;
}

body {
  font-family: 'Crimson Pro', Georgia, serif;
  background: #2a2a2a;
  color: var(--text-dark);
  height: 100vh;
  overflow: hidden;
}

/* ===== NAVIGATION BAR ===== */
.nav-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--navy);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  z-index: 1000;
  box-shadow: 0 2px 12px rgba(0,0,0,0.35);
}

.nav-brand {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex-shrink: 0;
}

.nav-title {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.nav-subtitle {
  font-size: 0.7rem;
  color: rgba(249, 244, 236, 0.55);
  white-space: nowrap;
  letter-spacing: 0.03em;
}

.nav-sections {
  display: flex;
  gap: 4px;
  flex: 1;
  justify-content: center;
}

.section-tab {
  background: transparent;
  border: 1px solid rgba(201, 168, 76, 0.3);
  color: rgba(249, 244, 236, 0.7);
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 0.88rem;
  padding: 5px 14px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.section-tab:hover {
  background: rgba(201, 168, 76, 0.12);
  color: var(--text-light);
  border-color: rgba(201, 168, 76, 0.55);
}

.section-tab.active {
  background: var(--gold-dark);
  color: var(--navy);
  border-color: var(--gold-dark);
  font-weight: 600;
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* Layer toggle */
.layer-toggle {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  overflow: hidden;
  gap: 0;
}

.layer-btn {
  background: transparent;
  border: none;
  color: rgba(249, 244, 236, 0.65);
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 0.82rem;
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.layer-btn:hover { color: var(--text-light); }

.layer-btn.active {
  background: var(--gold-dark);
  color: var(--navy);
  font-weight: 600;
}

.toggle-divider {
  color: rgba(255,255,255,0.2);
  font-size: 0.8rem;
}

/* Language toggle */
.lang-toggle {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  overflow: hidden;
  gap: 0;
}

.lang-btn {
  background: transparent;
  border: none;
  color: rgba(249, 244, 236, 0.65);
  font-family: 'Noto Sans KR', 'Crimson Pro', Georgia, sans-serif;
  font-size: 0.78rem;
  padding: 4px 9px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.lang-btn:hover { color: var(--text-light); }

.lang-btn.active {
  background: var(--gold-dark);
  color: var(--navy);
  font-weight: 700;
}

/* Korean font override for the whole UI when lang-ko is active */
body.lang-ko .popup-location-name,
body.lang-ko .popup-modern-name,
body.lang-ko .popup-title,
body.lang-ko .popup-summary,
body.lang-ko .chapter-tab,
body.lang-ko .jump-list-btn,
body.lang-ko .jump-sub-btn,
body.lang-ko .jump-panel-title,
body.lang-ko .section-tab,
body.lang-ko .drawer-tab {
  font-family: 'Noto Sans KR', Georgia, sans-serif;
}

/* Mobile drawer language buttons */
.drawer-lang {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(249, 244, 236, 0.75);
  font-family: 'Noto Sans KR', 'Crimson Pro', Georgia, sans-serif;
  font-size: 0.92rem;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}

.drawer-lang.active {
  background: var(--gold-dark);
  color: var(--navy);
  border-color: var(--gold-dark);
  font-weight: 700;
}

/* Music button */
.music-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: background 0.2s;
}

.music-btn:hover { background: rgba(255,255,255,0.15); }

/* Text size buttons */
.text-size-control {
  display: flex;
  align-items: center;
  gap: 2px;
}

.size-btn {
  background: transparent;
  border: 1px solid transparent;
  color: rgba(249, 244, 236, 0.5);
  cursor: pointer;
  border-radius: 3px;
  padding: 2px 5px;
  transition: all 0.2s;
  font-family: 'Crimson Pro', Georgia, serif;
  line-height: 1;
}

.size-btn:nth-child(1) { font-size: 0.78rem; }
.size-btn:nth-child(2) { font-size: 0.96rem; }
.size-btn:nth-child(3) { font-size: 1.14rem; }

.size-btn:hover { color: var(--text-light); border-color: rgba(255,255,255,0.2); }
.size-btn.active { color: var(--gold); border-color: rgba(201,168,76,0.5); }

/* Hamburger (mobile only) */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: rgba(249, 244, 236, 0.8);
  border-radius: 2px;
  transition: all 0.25s;
}

/* ===== MOBILE DRAWER ===== */
.mobile-drawer {
  position: fixed;
  top: var(--nav-height);
  right: -280px;
  width: 260px;
  height: calc(100vh - var(--nav-height));
  background: var(--navy);
  z-index: 999;
  transition: right 0.3s ease;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-left: 1px solid rgba(255,255,255,0.1);
}

.mobile-drawer.open { right: 0; }

.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 998;
}

.drawer-overlay.visible { display: block; }

.drawer-section-label {
  font-size: 0.72rem;
  color: rgba(249, 244, 236, 0.4);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 8px;
}

.drawer-tab, .drawer-layer {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(249, 244, 236, 0.75);
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 0.95rem;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}

.drawer-tab.active, .drawer-layer.active {
  background: var(--gold-dark);
  color: var(--navy);
  border-color: var(--gold-dark);
  font-weight: 600;
}

.drawer-divider {
  height: 1px;
  background: rgba(255,255,255,0.1);
  margin: 8px 0;
}

/* ===== MAP ===== */
#map {
  position: fixed;
  top: var(--nav-height);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
}

/* ===== CUSTOM MARKERS ===== */
.marker-narrative {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gold);
  border: 2.5px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Crimson Pro', Georgia, serif;
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--navy);
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  cursor: pointer;
  transition: all 0.2s;
  position: absolute;
  /* Position pin to the east (right) to avoid covering city labels */
  right: -40px;
  top: -16px;
}

.marker-epistle-from,
.marker-epistle-to {
  width: 28px;
  height: 28px;
  background: var(--epistle-blue);
  border: 2.5px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Crimson Pro', Georgia, serif;
  font-weight: 700;
  font-size: 0.68rem;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  cursor: pointer;
  transform: rotate(45deg);
}

.marker-epistle-from .marker-inner,
.marker-epistle-to .marker-inner {
  transform: rotate(-45deg);
}

.marker-epistle-to {
  background: var(--epistle-blue-light);
}

/* Marker hover */
.leaflet-marker-icon:hover .marker-narrative {
  transform: scale(1.1);
  box-shadow: 0 0 0 3px rgba(212, 168, 67, 0.35), 0 3px 10px rgba(0,0,0,0.35);
}

/* Marker states */
.marker-visited .marker-narrative {
  opacity: 0.55;
  background: #a88a38;
}

.marker-active .marker-narrative {
  background: #D43030;
  border-color: #fff;
  transform: scale(1.3);
  box-shadow: 0 0 0 4px rgba(212, 60, 60, 0.45), 0 4px 14px rgba(0,0,0,0.4);
  z-index: 9999 !important;
  animation: markerPulse 1.8s ease-in-out infinite;
}

@keyframes markerPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(212, 60, 60, 0.45), 0 4px 14px rgba(0,0,0,0.4); }
  50% { box-shadow: 0 0 0 10px rgba(212, 60, 60, 0.18), 0 4px 14px rgba(0,0,0,0.4); }
}

.leaflet-marker-icon { background: transparent !important; border: none !important; }

/* ===== LOCKED SECTION TABS ===== */
.section-tab.locked {
  opacity: 0.52;
  cursor: default;
}
.section-tab.locked:hover {
  background: transparent;
  color: rgba(249, 244, 236, 0.7);
  border-color: rgba(201, 168, 76, 0.3);
}
.lock-badge { font-size: 0.72em; margin-left: 3px; }
.drawer-tab.locked { opacity: 0.45; cursor: default; }
.drawer-tab.locked:hover {
  background: transparent;
  color: rgba(249, 244, 236, 0.75);
  border-color: rgba(255,255,255,0.12);
}

/* ===== SETTINGS BUTTON ===== */
.settings-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  color: rgba(249, 244, 236, 0.65);
  font-size: 1rem;
  line-height: 1;
  transition: all 0.2s;
}
.settings-btn:hover { background: rgba(255,255,255,0.15); color: var(--text-light); }
.settings-btn.active { background: var(--gold-dark); color: var(--navy); }

/* ===== SETTINGS PANEL ===== */
.settings-panel {
  position: fixed;
  top: var(--nav-height);
  right: 0;
  z-index: 902;
  background: rgba(22, 45, 72, 0.99);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(201, 168, 76, 0.25);
  border-top: none;
  border-radius: 0 0 8px 8px;
  width: 280px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity 0.2s, transform 0.2s;
}
.settings-panel.visible {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(201, 168, 76, 0.18);
}
.settings-title {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 0.9rem;
  color: var(--gold);
  font-weight: 600;
  letter-spacing: 0.03em;
}
.settings-close {
  background: transparent;
  border: none;
  color: rgba(249, 244, 236, 0.4);
  font-size: 0.88rem;
  cursor: pointer;
  padding: 2px 4px;
  transition: color 0.15s;
}
.settings-close:hover { color: #fff; }
.settings-body {
  padding: 10px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.settings-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.settings-label {
  font-size: 0.75rem;
  color: rgba(249, 244, 236, 0.45);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.settings-opts {
  display: flex;
  gap: 6px;
}
.settings-opt {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(249, 244, 236, 0.65);
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 0.83rem;
  padding: 5px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.settings-opt:hover { color: var(--text-light); border-color: rgba(255,255,255,0.25); }
.settings-opt.active {
  background: var(--gold-dark);
  color: var(--navy);
  border-color: var(--gold-dark);
  font-weight: 600;
}

/* ===== DUAL POPUP PANELS ===== */
.popup-left,
.popup-right {
  position: fixed;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.45), 0 2px 10px rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px);
  transition: opacity 0.25s, transform 0.25s;
  overflow: hidden;
  max-height: calc(100vh - var(--nav-height) - 52px);
}
.popup-left.visible,
.popup-right.visible {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

/* Left panel — parchment summary */
.popup-left {
  left: 16px;
  top: calc(var(--nav-height) + 16px);
  width: 330px;
  background: rgba(245, 237, 216, 0.96);
  border: 1px solid rgba(201, 168, 76, 0.3);
}
/* Right panel — deep navy scripture */
.popup-right {
  right: 16px;
  top: calc(var(--nav-height) + 16px);
  width: 370px;
  background: rgba(20, 36, 58, 0.97);
  border: 1px solid rgba(201, 168, 76, 0.22);
}

/* Opacity modes */
body.opacity-opaque .popup-left { background: rgba(245, 237, 216, 1.0); }
body.opacity-opaque .popup-right { background: rgba(20, 36, 58, 1.0); }

/* Drag handle — pill indicator */
.popup-drag-handle {
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  flex-shrink: 0;
  user-select: none;
}
.popup-drag-handle:active { cursor: grabbing; }
.popup-drag-handle::before {
  content: '';
  width: 36px;
  height: 3px;
  background: rgba(201, 168, 76, 0.28);
  border-radius: 2px;
  transition: background 0.15s;
}
.popup-drag-handle:hover::before { background: rgba(201, 168, 76, 0.55); }

/* Shared popup header (left panel) */
.popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 10px;
  border-bottom: 1px solid rgba(201, 168, 76, 0.22);
  background: linear-gradient(135deg, var(--navy) 0%, #2c4f78 100%);
  flex-shrink: 0;
  gap: 8px;
}
.popup-header-text { flex: 1; min-width: 0; }
.popup-location-name {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--gold);
  line-height: 1.2;
}
.popup-modern-name {
  font-size: 0.8rem;
  color: rgba(249, 244, 236, 0.6);
  margin-top: 2px;
  font-style: italic;
}
.popup-close {
  background: transparent;
  border: none;
  color: rgba(249, 244, 236, 0.55);
  font-size: 1.05rem;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  transition: color 0.2s;
  flex-shrink: 0;
  margin-left: 8px;
}
.popup-close:hover { color: #fff; }

/* Chapter tabs */
.chapter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 12px 6px;
  background: rgba(27, 58, 92, 0.06);
  border-bottom: 1px solid rgba(201, 168, 76, 0.18);
  flex-shrink: 0;
}
.chapter-tab {
  background: transparent;
  border: 1px solid rgba(27, 58, 92, 0.22);
  color: var(--navy);
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 0.8rem;
  padding: 3px 9px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.chapter-tab:hover { background: rgba(201, 168, 76, 0.14); border-color: var(--gold-muted); }
.chapter-tab.active {
  background: var(--gold-dark);
  color: var(--navy);
  border-color: var(--gold-dark);
  font-weight: 600;
}

/* Left panel body */
.popup-body {
  flex: 1;
  overflow-y: auto;
  padding: 13px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.popup-title {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.3;
}
.popup-summary {
  font-size: var(--popup-font-size);
  color: var(--text-mid);
  line-height: 1.6;
}
.popup-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.popup-date {
  font-size: var(--popup-meta-size);
  color: rgba(60, 60, 60, 0.65);
  font-style: italic;
  flex: 1;
}
.popup-epistle-badge {
  display: inline-block;
  background: var(--epistle-blue);
  color: #fff;
  font-size: 0.74rem;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
  letter-spacing: 0.03em;
  margin-top: 2px;
}
.popup-epistle-badge.to { background: var(--epistle-blue-light); }

/* Left panel footer */
.popup-footer {
  border-top: 1px solid rgba(201, 168, 76, 0.22);
  padding: 9px 14px;
  flex-shrink: 0;
  background: rgba(245, 237, 216, 0.98);
}
.popup-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.popup-nav-btn {
  background: var(--navy);
  border: none;
  color: var(--text-light);
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 0.88rem;
  padding: 6px 13px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}
.popup-nav-btn:hover { background: #2c4f78; }
.popup-nav-btn:disabled { background: rgba(27,58,92,0.22); cursor: default; }
.popup-progress {
  font-size: 0.8rem;
  color: rgba(60,60,60,0.6);
  font-style: italic;
  text-align: center;
}

/* Right panel header */
.popup-right-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(201, 168, 76, 0.18);
  flex-shrink: 0;
  gap: 12px;
}
.popup-right-ref {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 0.88rem;
  color: var(--gold);
  font-weight: 600;
  letter-spacing: 0.02em;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.popup-right-close {
  color: rgba(201, 168, 76, 0.45);
  margin-left: auto;
  flex-shrink: 0;
}
.popup-right-close:hover { color: var(--gold); }

/* Right panel body — scripture on dark navy */
.popup-right-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.scripture-text {
  font-size: var(--popup-scripture-size);
  font-style: italic;
  color: rgba(245, 237, 216, 0.9);
  line-height: 1.78;
}
.scripture-ref {
  font-size: var(--popup-meta-size);
  color: rgba(201, 168, 76, 0.72);
  font-weight: 600;
  font-style: normal;
  padding-top: 6px;
  border-top: 1px solid rgba(201, 168, 76, 0.15);
}

/* Scripture pagination (on dark background) */
.scripture-page-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-top: 1px solid rgba(201, 168, 76, 0.15);
}
.scripture-page-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(201, 168, 76, 0.3);
  color: rgba(245, 237, 216, 0.75);
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 0.8rem;
  padding: 3px 10px;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s;
}
.scripture-page-btn:hover { background: rgba(255,255,255,0.14); }
.scripture-page-btn:disabled { opacity: 0.3; cursor: default; }
.scripture-page-num {
  font-size: 0.74rem;
  color: rgba(245, 237, 216, 0.4);
  font-style: italic;
}

/* Read Bible / See Summary buttons */
.popup-read-btn,
.popup-see-summary-btn {
  background: var(--gold-dark);
  border: none;
  color: var(--navy);
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
  flex-shrink: 0;
}
.popup-read-btn:hover,
.popup-see-summary-btn:hover {
  background: var(--gold);
  color: #000;
}

/* YouTube Watch Sermon button and dropdown */
.youtube-buttons-container {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}

.youtube-watch-btn,
.youtube-dropdown-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--navy);
  border: 1px solid rgba(201, 168, 76, 0.5);
  color: var(--gold);
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}
.youtube-watch-btn:hover,
.youtube-dropdown-btn:hover {
  background: #2c4f78;
  border-color: var(--gold);
  color: #fff;
}

/* Red SVG play icon inside YouTube button */
.youtube-play-icon {
  display: inline-block;
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.youtube-dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: rgba(22, 45, 72, 0.98);
  border: 1px solid rgba(201, 168, 76, 0.3);
  border-radius: 4px;
  z-index: 3005;
  min-width: 180px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.youtube-dropdown-menu.visible {
  display: block;
}

.youtube-dropdown-menu a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  color: rgba(245, 237, 216, 0.85);
  text-decoration: none;
  border-bottom: 1px solid rgba(201, 168, 76, 0.1);
  font-size: 0.8rem;
  transition: background 0.15s;
}

.youtube-dropdown-menu a:last-child {
  border-bottom: none;
}

.youtube-dropdown-menu a:hover {
  background: rgba(201, 168, 76, 0.2);
  color: var(--gold);
}

/* Resize handles on popup panels */
.popup-resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 18px;
  height: 18px;
  cursor: se-resize;
  z-index: 10;
  opacity: 0.5;
  transition: opacity 0.2s;
  background:
    linear-gradient(135deg,
      transparent 30%,
      rgba(201, 168, 76, 0.7) 30%, rgba(201, 168, 76, 0.7) 40%,
      transparent 40%,
      transparent 55%,
      rgba(201, 168, 76, 0.7) 55%, rgba(201, 168, 76, 0.7) 65%,
      transparent 65%,
      transparent 80%,
      rgba(201, 168, 76, 0.7) 80%, rgba(201, 168, 76, 0.7) 90%,
      transparent 90%
    );
}
.popup-resize-handle:hover { opacity: 1; }

/* Right-panel YouTube container — sits between scripture text and page nav */
#popup-right-footer-youtube:not(:empty) {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(201, 168, 76, 0.15);
  display: flex;
  justify-content: flex-end;
}

/* Mobile: hide resize handles (panels are full-width, no resize needed) */
@media (max-width: 600px) {
  .popup-resize-handle { display: none; }
}

/* Scrollbars */
.popup-body::-webkit-scrollbar,
.popup-right-body::-webkit-scrollbar { width: 5px; }
.popup-body::-webkit-scrollbar-track,
.popup-right-body::-webkit-scrollbar-track { background: transparent; }
.popup-body::-webkit-scrollbar-thumb { background: rgba(201, 168, 76, 0.35); border-radius: 3px; }
.popup-right-body::-webkit-scrollbar-thumb { background: rgba(201, 168, 76, 0.25); border-radius: 3px; }

/* ===== TEXT SIZE STATES ===== */
body.text-large {
  --popup-font-size: 1.12rem;
  --popup-scripture-size: 1.04rem;
  --popup-meta-size: 0.96rem;
  --map-label-scale: 1.3;
}

body.text-xlarge {
  --popup-font-size: 1.26rem;
  --popup-scripture-size: 1.16rem;
  --popup-meta-size: 1.06rem;
  --map-label-scale: 1.6;
}

:root {
  --map-label-scale: 1;
}

/* ===== ANCIENT MODE — sepia filter turns ESRI relief tiles into parchment ===== */
#map.ancient-mode .leaflet-tile-pane {
  filter: sepia(0.72) saturate(0.82) brightness(1.08) hue-rotate(-6deg) contrast(0.88);
}

/* ===== ANCIENT MAP LABELS ===== */

/* Leaflet clears background/border on divIcon containers */
.ancient-label-icon {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  overflow: visible !important;
}

/* Shared label base */
.ancient-label {
  font-family: 'EB Garamond', Georgia, serif;
  white-space: nowrap;
  pointer-events: none;
  display: block;
  line-height: 1.1;
  user-select: none;
}

/* Region names — large, italic, faded uppercase */
.ancient-label.region {
  font-size: calc(0.82rem * var(--map-label-scale));
  font-style: italic;
  color: rgba(70, 40, 8, 0.52);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-shadow:
    0 0 8px rgba(240, 218, 165, 0.95),
    0 0 4px rgba(240, 218, 165, 0.85),
    1px 1px 0 rgba(240, 218, 165, 0.7);
}

/* Sea / water body labels — blue-brown italic */
.ancient-label.sea {
  font-size: calc(0.72rem * var(--map-label-scale));
  font-style: italic;
  color: rgba(25, 50, 90, 0.48);
  letter-spacing: 0.09em;
  text-shadow:
    0 0 6px rgba(210, 230, 245, 0.9),
    0 0 3px rgba(210, 230, 245, 0.7);
}

/* River names — small, blue-brown */
.ancient-label.river {
  font-size: calc(0.65rem * var(--map-label-scale));
  font-style: italic;
  color: rgba(30, 60, 100, 0.42);
  letter-spacing: 0.04em;
  text-shadow:
    0 0 4px rgba(210, 230, 245, 0.85);
}

/* City labels — smallest, dark ink look */
.ancient-label.city {
  font-size: calc(0.65rem * var(--map-label-scale));
  color: rgba(45, 25, 8, 0.78);
  letter-spacing: 0.01em;
  text-shadow:
    0 0 5px rgba(240, 218, 165, 0.98),
    0 0 3px rgba(240, 218, 165, 0.9),
    1px 1px 0 rgba(240, 218, 165, 0.6);
  transition: all 0.2s;
}

/* Highlighted city label (when location is open) */
.ancient-label.city.highlighted {
  font-size: calc(0.65rem * var(--map-label-scale) * 1.5);
  font-weight: 700;
  color: #D43030;
  text-shadow:
    0 0 8px rgba(212, 48, 48, 0.95),
    0 0 4px rgba(240, 218, 165, 0.9),
    1px 1px 0 rgba(212, 48, 48, 0.8);
  z-index: 10;
}

/* ===== LEAFLET OVERRIDES ===== */
.leaflet-control-zoom {
  border: none !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
}

.leaflet-control-zoom a {
  background: var(--navy) !important;
  color: var(--gold) !important;
  border-color: rgba(255,255,255,0.15) !important;
  font-size: 16px !important;
  line-height: 26px !important;
}

.leaflet-control-zoom a:hover {
  background: #2c4f78 !important;
}

.leaflet-control-attribution {
  font-size: 0.7rem !important;
  background: rgba(245, 237, 216, 0.85) !important;
}

/* ===== SCROLLBAR STYLING ===== */
.popup-body::-webkit-scrollbar { width: 6px; }
.popup-body::-webkit-scrollbar-track { background: transparent; }
.popup-body::-webkit-scrollbar-thumb { background: rgba(201, 168, 76, 0.4); border-radius: 3px; }

/* ===== START & JUMP-TO BUTTONS ===== */
.start-btn {
  position: fixed;
  top: calc(var(--nav-height) + 8px);
  right: calc(100px + 14px); /* left of jump-toggle-btn */
  bottom: auto;
  z-index: 3000;
  background: #8B3A3A; /* dark red/maroon */
  border: 1px solid rgba(201, 168, 76, 0.45);
  border-radius: 5px;
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 0.82rem;
  padding: 6px 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  color: var(--gold);
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
  transition: background 0.2s, border-color 0.2s;
}

.start-btn:hover {
  background: #a84545;
  border-color: var(--gold);
}

.jump-toggle-btn {
  position: fixed;
  top: calc(var(--nav-height) + 8px); /* just below nav bar */
  right: 10px;
  bottom: auto;
  z-index: 3000;
  background: var(--navy);
  border: 1px solid rgba(201, 168, 76, 0.45);
  border-radius: 5px;
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 0.82rem;
  padding: 6px 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
  transition: background 0.2s, border-color 0.2s;
}

.jump-toggle-btn:hover {
  background: #2c4f78;
  border-color: var(--gold);
}

.jump-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.01em;
}

.jump-panel {
  position: fixed;
  top: calc(var(--nav-height) + 44px); /* just below the toggle button */
  right: 10px;
  bottom: auto;
  z-index: 3001;
  background: rgba(22, 45, 72, 0.98);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(201, 168, 76, 0.3);
  border-radius: 8px;
  width: 280px;
  max-height: calc(100vh - var(--nav-height) - 60px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 0.2s, transform 0.2s;
  overflow: hidden;
}

.jump-panel.visible {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.jump-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 13px;
  border-bottom: 1px solid rgba(201, 168, 76, 0.2);
  flex-shrink: 0;
}

.jump-panel-title {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 0.88rem;
  color: var(--gold);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.jump-panel-close {
  background: transparent;
  border: none;
  color: rgba(249, 244, 236, 0.45);
  font-size: 0.88rem;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  transition: color 0.15s;
}

.jump-panel-close:hover { color: #fff; }

/* Scrollable list */
.jump-list {
  list-style: none;
  overflow-y: auto;
  padding: 5px 6px;
  margin: 0;
  flex: 1;
}

.jump-list::-webkit-scrollbar { width: 4px; }
.jump-list::-webkit-scrollbar-thumb { background: rgba(201,168,76,0.3); border-radius: 2px; }

.jump-list-item { display: flex; }

.jump-list-btn {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 6px 8px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
  color: rgba(249, 244, 236, 0.82);
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 0.88rem;
  line-height: 1.3;
}

.jump-list-btn:hover { background: rgba(201, 168, 76, 0.14); }

.jump-list-btn.visited { color: rgba(249, 244, 236, 0.38); }

.jump-list-btn.active {
  background: rgba(201, 168, 76, 0.18);
  color: var(--gold);
}

.jump-list-num {
  font-weight: 700;
  color: rgba(201, 168, 76, 0.75);
  min-width: 22px;
  font-size: 0.78rem;
  flex-shrink: 0;
  padding-top: 1px;
}

.jump-list-btn.active .jump-list-num { color: var(--gold); }
.jump-list-btn.visited .jump-list-num { color: rgba(201, 168, 76, 0.32); }

.jump-list-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.jump-list-chapter-count {
  font-size: 0.74rem;
  color: rgba(201, 168, 76, 0.55);
  font-style: italic;
}

/* ===== FOOTER ===== */
.site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 500;
  background: rgba(27, 58, 92, 0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 5px 16px;
  text-align: center;
  border-top: 1px solid rgba(201, 168, 76, 0.18);
}

.footer-credit {
  font-size: 0.72rem;
  color: rgba(249, 244, 236, 0.55);
  letter-spacing: 0.02em;
}

.footer-link-btn {
  background: none;
  border: none;
  color: rgba(201, 168, 76, 0.75);
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 0.72rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer-link-btn:hover { color: var(--gold); }

/* Footer collapsed state */
.footer-collapsed {
  text-align: center;
  padding: 2px 0;
}

.footer-expand-hint {
  font-size: 0.65rem;
  color: rgba(201, 168, 76, 0.5);
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: color 0.2s;
}

.site-footer:hover .footer-expand-hint,
.site-footer.expanded .footer-expand-hint {
  color: var(--gold);
}

/* Footer expanded state */
.footer-expanded {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease, opacity 0.35s ease;
  opacity: 0;
}

.site-footer:hover .footer-expanded,
.site-footer.expanded .footer-expanded {
  max-height: 280px;
  opacity: 1;
}

/* Flip arrow when expanded */
.site-footer:hover .footer-expand-hint::before,
.site-footer.expanded .footer-expand-hint::before {
  content: '▼ Less';
}
.footer-expand-hint::before {
  content: '▲ More';
}
.footer-expand-hint {
  font-size: 0;
}
.footer-expand-hint::before {
  font-size: 0.65rem;
}

.footer-logo-row {
  display: flex;
  justify-content: center;
  margin: 6px 0 4px;
}

.footer-logo {
  height: 120px;
  width: auto;
  opacity: 0.88;
  transition: opacity 0.2s;
}

.footer-logo:hover {
  opacity: 1;
}

.footer-lines {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding-bottom: 6px;
}

.footer-line {
  font-size: 0.70rem;
  color: rgba(249, 244, 236, 0.55);
  letter-spacing: 0.02em;
  text-align: center;
}

.footer-link {
  color: rgba(201, 168, 76, 0.75);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.2s;
}

.footer-link:hover { color: var(--gold); }

/* Adjust map bottom to not hide under footer */
#map { bottom: 30px; }

/* ===== ABOUT MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(10, 20, 36, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.modal-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.modal-card {
  background: var(--parchment);
  border-radius: 8px;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 48px rgba(0,0,0,0.45);
  border: 1px solid rgba(201, 168, 76, 0.3);
  overflow: hidden;
  transform: translateY(10px);
  transition: transform 0.25s;
}

.modal-overlay.visible .modal-card { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--navy) 0%, #2c4f78 100%);
  flex-shrink: 0;
}

.modal-title {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--gold);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-mid);
}

.modal-body h3 {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--navy);
  margin-top: 4px;
  border-bottom: 1px solid rgba(201, 168, 76, 0.25);
  padding-bottom: 4px;
}

.modal-body a {
  color: var(--navy-light);
}

.modal-body a:hover { color: var(--navy); }

/* ===== JUMP LIST SUBHEADINGS ===== */
.jump-list-item { display: flex; flex-direction: column; }

.jump-sub-list {
  list-style: none;
  padding: 0 0 4px 30px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.jump-sub-btn {
  background: transparent;
  border: none;
  color: rgba(249, 244, 236, 0.5);
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 0.8rem;
  padding: 3px 8px;
  border-radius: 3px;
  cursor: pointer;
  text-align: left;
  line-height: 1.3;
  transition: all 0.12s;
  width: 100%;
}
.jump-sub-btn:hover {
  background: rgba(201, 168, 76, 0.1);
  color: rgba(249, 244, 236, 0.82);
}
.jump-sub-btn.active {
  color: var(--gold);
  background: rgba(201, 168, 76, 0.12);
}

/* ===== RESPONSIVE — MOBILE ===== */
@media (max-width: 768px) {
  .nav-sections { display: none; }
  .text-size-control { display: none; }
  .lang-toggle { display: none; }
  .hamburger { display: flex; }
  .nav-bar { gap: 8px; }

  /* Stack panels vertically at bottom on mobile */
  .popup-left,
  .popup-right {
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    border-radius: 12px 12px 0 0;
    max-height: 48vh;
  }
  .popup-left {
    bottom: 28px;
    top: auto !important;
    transform: translateY(20px);
    z-index: 2001;
  }
  .popup-left.visible { transform: translateY(0); }
  .popup-right {
    bottom: calc(48vh + 28px);
    top: auto !important;
    transform: translateY(20px);
    z-index: 2000;
    max-height: 40vh;
  }
  .popup-right.visible { transform: translateY(0); }

  .popup-nav-btn { padding: 7px 11px; font-size: 0.85rem; }

  /* Settings panel full-width on mobile */
  .settings-panel { width: 100%; border-radius: 0; }

  /* Jump panel: keep right side but narrower on small screens */
  .jump-panel { width: 260px; }
}

@media (max-width: 480px) {
  .nav-title { font-size: 0.95rem; }
  .nav-subtitle { display: none; }
  .layer-btn { padding: 4px 7px; font-size: 0.78rem; }
  .settings-btn { display: none; } /* in mobile drawer */
}
