/**
 * 新約地理互動地圖樣式表 (NT Geography Explorer Style)
 * 嚴格遵循品牌色彩規範：
 * 炭灰 Charcoal: #2B2B2B
 * 温暖白 Warm White: #F5F3EE
 * 古金 Antique Gold: #C8A96A
 * 靛藍 / 觬藍 Slate Blue: #4A5D73
 * 柔米 Ivory: #EAE6DC
 * 琥珀 Amber: #D6A84C
 */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;700&family=Inter:wght@300;400;500;600;700&family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,600;1,6..72,400&family=Noto+Sans+TC:wght@300;400;500;700&family=Noto+Serif+TC:wght@400;600;700&display=swap');

:root {
  /* 品牌核心色彩 */
  --brand-charcoal: #2B2B2B;
  --brand-warm-white: #F5F3EE;
  --brand-antique-gold: #C8A96A;
  --brand-slate-blue: #4A5D73;
  --brand-ivory: #EAE6DC;
  --brand-amber: #D6A84C;

  /* 語義化色彩配置 */
  --bg-primary: #2B2B2B;
  --bg-secondary: #222222;
  --bg-surface: #333333;
  --bg-card: #2B2B2B;
  --bg-parchment: #F5F3EE;
  --bg-ivory-tint: #EAE6DC;

  --text-primary: #F5F3EE;
  --text-secondary: #EAE6DC;
  --text-muted: #A8A29E;
  --text-dark: #2B2B2B;

  --accent-gold: #C8A96A;
  --accent-blue: #4A5D73;
  --accent-amber: #D6A84C;

  --border-gold: rgba(200, 169, 106, 0.35);
  --border-subtle: rgba(245, 243, 238, 0.12);
  --border-ivory: #EAE6DC;

  --font-serif: 'Newsreader', 'Noto Serif TC', Georgia, serif;
  --font-sans: 'Inter', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Cinzel', 'Noto Serif TC', serif;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --shadow-subtle: 0 4px 16px rgba(0, 0, 0, 0.25);
  --shadow-elevated: 0 10px 30px rgba(0, 0, 0, 0.4);
}

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

html, body {
  width: 100%;
  height: 100%;
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── 頂部導覽與標頭 HEADER ─────────────────────── */
header {
  background: linear-gradient(180deg, #1F1F1F 0%, #2B2B2B 100%);
  border-bottom: 1px solid var(--border-gold);
  padding: 22px 24px 18px;
  position: relative;
  z-index: 1000;
}

.header-top {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.brand-badge {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand-antique-gold);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.brand-badge::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  background-color: var(--brand-antique-gold);
  border-radius: 50%;
}

.title-area h1 {
  font-family: var(--font-serif);
  font-size: clamp(22px, 3.2vw, 34px);
  font-weight: 600;
  color: var(--brand-warm-white);
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.title-area h1 em {
  font-style: normal;
  color: var(--brand-antique-gold);
  font-family: var(--font-serif);
  font-weight: 400;
}

.title-area p {
  color: var(--brand-ivory);
  opacity: 0.85;
  font-size: 13px;
  max-width: 760px;
  margin-top: 5px;
  line-height: 1.6;
}

/* 控制器按鈕群 (語言、資訊開關) */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-pill {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border-gold);
  background: rgba(43, 43, 43, 0.8);
  color: var(--brand-warm-white);
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-pill:hover {
  background: var(--brand-antique-gold);
  color: var(--brand-charcoal);
  border-color: var(--brand-antique-gold);
}
.btn-pill.active {
  background: var(--brand-antique-gold);
  color: var(--brand-charcoal);
  font-weight: 600;
}

/* 展開介紹 (About Toggle) */
.about-details {
  max-width: 1440px;
  margin: 14px auto 0;
  background: rgba(34, 34, 34, 0.9);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 18px;
}
.about-details summary {
  font-size: 12px;
  color: var(--brand-antique-gold);
  cursor: pointer;
  font-weight: 500;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.about-details summary::-webkit-details-marker { display: none; }
.about-content {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  font-size: 13px;
  color: var(--brand-ivory);
  line-height: 1.7;
}

/* ── 視角切換器 VIEW TABS BAR ─────────────────── */
.view-nav-bar {
  background-color: #222222;
  border-bottom: 1px solid rgba(200, 169, 106, 0.2);
  padding: 10px 24px;
  position: sticky;
  top: 0;
  z-index: 999;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.view-tabs {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.view-tabs::-webkit-scrollbar { display: none; }

.vtab-btn {
  padding: 8px 16px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(245, 243, 238, 0.18);
  background: transparent;
  color: var(--brand-ivory);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 7px;
}
.vtab-btn:hover {
  border-color: var(--brand-antique-gold);
  color: var(--brand-warm-white);
  background: rgba(200, 169, 106, 0.1);
}
.vtab-btn.active {
  background: var(--brand-antique-gold);
  color: var(--brand-charcoal);
  border-color: var(--brand-antique-gold);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(200, 169, 106, 0.35);
}

.vtab-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
  color: inherit;
}

/* ── 歷時性時間軌 (TIMELINE BAR) ───────────────── */
.timeline-strip {
  background: #272727;
  border-bottom: 1px solid var(--border-subtle);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.timeline-strip::-webkit-scrollbar { display: none; }

.timeline-inner {
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
}

.timeline-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--brand-antique-gold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.era-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 2px 0;
}

.era-btn {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  background: #333333;
  color: var(--brand-ivory);
  border: 1px solid var(--border-subtle);
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.era-btn:hover {
  border-color: var(--brand-amber);
  color: var(--brand-warm-white);
}
.era-btn.active {
  background: var(--brand-amber);
  color: var(--brand-charcoal);
  border-color: var(--brand-amber);
  font-weight: 600;
}

.era-info-chip {
  margin-left: auto;
  font-size: 12px;
  color: var(--brand-ivory);
  background: rgba(0, 0, 0, 0.3);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  border-left: 2px solid var(--brand-antique-gold);
}

/* ── 主要工作區 APP LAYOUT ─────────────────────── */
.app-container {
  display: flex;
  position: relative;
  height: calc(100vh - 190px);
  min-height: 580px;
  width: 100%;
  background-color: var(--brand-charcoal);
}

/* 地圖主容器 */
#map-container {
  flex: 1;
  height: 100%;
  position: relative;
  z-index: 1;
  background-color: #1A1A1A;
}

#map {
  width: 100%;
  height: 100%;
  outline: none;
}

/* 浮動於地圖上的控制面板 */
.map-floating-overlay {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 800;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.map-floating-overlay > * {
  pointer-events: auto;
}

.quick-filter-card {
  background: rgba(43, 43, 43, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  box-shadow: var(--shadow-elevated);
  max-width: 320px;
}
.quick-filter-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand-antique-gold);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.quick-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.qp-btn {
  padding: 3px 8px;
  font-size: 11px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(245, 243, 238, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: var(--brand-warm-white);
  cursor: pointer;
  transition: all 0.15s ease;
}
.qp-btn:hover, .qp-btn.active {
  background: var(--brand-slate-blue);
  color: var(--brand-warm-white);
  border-color: var(--brand-slate-blue);
}

/* 右側側邊詳情抽屜 DETAIL DRAWER */
.detail-drawer {
  width: 440px;
  height: 100%;
  background: linear-gradient(180deg, #282828 0%, #202020 100%);
  border-left: 1px solid var(--border-gold);
  overflow-y: auto;
  z-index: 850;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.35);
}

.detail-drawer.collapsed {
  transform: translateX(100%);
  position: absolute;
  right: 0;
  top: 0;
}

.drawer-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(33, 33, 33, 0.8);
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.drawer-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brand-antique-gold);
}
.drawer-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  color: var(--brand-warm-white);
  margin-top: 2px;
}
.drawer-subtitle {
  font-size: 12px;
  color: var(--brand-muted);
}

.drawer-close {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--brand-ivory);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}
.drawer-close:hover {
  background: var(--brand-charcoal);
  border-color: var(--brand-antique-gold);
  color: var(--brand-warm-white);
}

.drawer-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1;
}

/* 抽屜內卡片元件 */
.d-card {
  background: rgba(43, 43, 43, 0.7);
  border: 1px solid rgba(200, 169, 106, 0.25);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}
.d-card h4 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand-antique-gold);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.d-card p {
  font-size: 13px;
  color: var(--brand-warm-white);
  line-height: 1.65;
}

.archeology-banner {
  background: rgba(74, 93, 115, 0.2);
  border-left: 3px solid var(--brand-slate-blue);
  padding: 10px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 12.5px;
  color: var(--brand-ivory);
}

.journey-step-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  padding-left: 18px;
}
.journey-step-list::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--border-gold);
}
.journey-step-item {
  position: relative;
  font-size: 12.5px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.journey-step-item:hover {
  background: rgba(200, 169, 106, 0.15);
}
.journey-step-item::before {
  content: "";
  position: absolute;
  left: -15px;
  top: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand-antique-gold);
  border: 2px solid var(--brand-charcoal);
}

/* ── 全書卷矩陣視圖 MASTER MATRIX VIEW ─────────── */
.matrix-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
  display: none;
  min-height: calc(100vh - 160px);
}
.matrix-container.active {
  display: block;
}

.matrix-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.matrix-search-input {
  background: #242424;
  border: 1px solid var(--border-gold);
  color: var(--brand-warm-white);
  padding: 8px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  outline: none;
  min-width: 260px;
}
.matrix-search-input:focus {
  border-color: var(--brand-antique-gold);
  box-shadow: 0 0 0 2px rgba(200, 169, 106, 0.2);
}

.matrix-table-wrap {
  background: #242424;
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-md);
  overflow-x: auto;
  box-shadow: var(--shadow-elevated);
}

.matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.matrix-table th {
  background: #1C1C1C;
  color: var(--brand-antique-gold);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border-gold);
  position: sticky;
  top: 0;
}

.matrix-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--brand-warm-white);
  vertical-align: middle;
}

.matrix-table tr:hover td {
  background: rgba(200, 169, 106, 0.08);
  cursor: pointer;
}

.badge-cat {
  display: inline-block;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
}
.badge-cat.gospel { background: rgba(74, 93, 115, 0.35); color: #8FA4BA; border: 1px solid #4A5D73; }
.badge-cat.paul { background: rgba(200, 169, 106, 0.25); color: #E5CFA0; border: 1px solid #C8A96A; }
.badge-cat.general { background: rgba(214, 168, 76, 0.25); color: #F0D08A; border: 1px solid #D6A84C; }
.badge-cat.revelation { background: rgba(185, 28, 28, 0.25); color: #FCA5A5; border: 1px solid #B91C1C; }

/* ── LEAFLET 自訂樣式與標記 ───────────────────── */
.custom-city-marker {
  background: var(--brand-charcoal);
  border: 2px solid var(--brand-antique-gold);
  color: var(--brand-warm-white);
  border-radius: 50%;
  width: 14px !important;
  height: 14px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.6), 0 0 12px rgba(200, 169, 106, 0.4);
  transition: transform 0.2s ease;
}
.custom-city-marker:hover, .custom-city-marker.highlighted {
  transform: scale(1.6);
  background: var(--brand-antique-gold);
  border-color: var(--brand-warm-white);
  color: var(--brand-charcoal);
  z-index: 1000 !important;
}

.custom-church-marker {
  background: var(--brand-amber);
  border: 2px solid var(--brand-warm-white);
  color: var(--brand-charcoal);
  border-radius: 50%;
  width: 22px !important;
  height: 22px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.leaflet-popup-content-wrapper {
  background: #282828 !important;
  color: var(--brand-warm-white) !important;
  border: 1px solid var(--border-gold) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-elevated) !important;
  padding: 4px;
}
.leaflet-popup-tip {
  background: #282828 !important;
  border-top: 1px solid var(--border-gold);
}

.popup-title {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 700;
  color: var(--brand-antique-gold);
  margin-bottom: 4px;
}
.popup-desc {
  font-size: 12px;
  color: var(--brand-ivory);
  line-height: 1.5;
}
.popup-link-btn {
  margin-top: 8px;
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--brand-antique-gold);
  color: var(--brand-charcoal);
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

/* 動態發射發送弧線的脈動與虛線流動動畫 */
@keyframes dashFlow {
  to {
    stroke-dashoffset: -40;
  }
}

.epistle-flow-line {
  animation: dashFlow 2s linear infinite;
}

/* ── 底部資訊列 FOOTER / STATUS ───────────────── */
footer {
  background: #1C1C1C;
  border-top: 1px solid rgba(200, 169, 106, 0.2);
  padding: 12px 24px;
  font-size: 12px;
  color: var(--brand-muted);
}
.footer-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

/* 響應式佈局 (Mobile / Tablet) */
@media (max-width: 960px) {
  .app-container {
    flex-direction: column;
    height: auto;
  }
  #map-container {
    height: 520px;
  }
  .detail-drawer {
    width: 100%;
    height: 480px;
    border-left: none;
    border-top: 1px solid var(--border-gold);
  }
  .detail-drawer.collapsed {
    display: none;
  }
}
