/* 南方王與北方王：但以理書 10–12 章的歷史地圖 — 樣式表（投影與手機雙適配） */
:root {
  --bg-page: #f7f3e8;
  --bg-card: #fffdf8;
  --bg-parchment: #f2e8cf;
  --bg-parchment-dark: #e5d6b5;
  --text-main: #231f1a;
  --text-muted: #5c5346;
  --border-warm: #d8cbb0;

  /* 南方王＝藍色、北方王＝紅色、女性與王室重點＝金色 */
  --south-primary: #1d4ed8;
  --south-bg: #dbeafe;
  --south-border: #3b82f6;
  --north-primary: #b91c1c;
  --north-bg: #fee2e2;
  --north-border: #ef4444;
  --gold-accent: #d4af37;
  --gold-bg: #fef9c3;
  --gold-dark: #926c08;

  /* 字體縮放倍率（供投影切換大字模式） */
  --font-scale: 1;
}

body.font-large {
  --font-scale: 1.18;
}

body.font-xlarge {
  --font-scale: 1.35;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-page);
  color: var(--text-main);
  font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.65;
  font-size: calc(16px * var(--font-scale));
  padding-bottom: 78px; /* 預留底部時間軸空間 */
}

/* 頂部導覽列 */
.top-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(35, 31, 26, 0.96);
  color: #f9f5eb;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(6px);
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.brand-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-sample {
  font-size: 0.78rem;
  background: #d4af37;
  color: #1f1912;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
}

.legend-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.pill-south {
  background: #1e40af;
  color: #fff;
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 600;
  border: 1px solid #60a5fa;
}

.pill-north {
  background: #991b1b;
  color: #fff;
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 600;
  border: 1px solid #f87171;
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.view-tabs {
  display: flex;
  background: #383129;
  padding: 3px;
  border-radius: 8px;
  gap: 4px;
}

.tab-btn {
  background: transparent;
  color: #e6dec8;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.18s;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.tab-btn.active {
  background: #f5efe0;
  color: #231f1a;
}

.font-btn {
  background: #383129;
  color: #f5efe0;
  border: 1px solid #5c5144;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
}

.font-btn:hover {
  background: #4d4338;
}

/* 主畫面：電腦／投影左右雙欄（左邊地圖固定，右邊經文往下捲） */
.main-split-layout {
  display: grid;
  grid-template-columns: 54% 46%;
  max-width: 1680px;
  margin: 0 auto;
  align-items: start;
}

/* 左側固定區：地圖＋迷你族譜切換 */
.left-sticky-pane {
  position: sticky;
  top: 56px;
  height: calc(100vh - 134px);
  padding: 16px 12px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.map-card {
  background: var(--bg-parchment);
  border: 2px solid #bda882;
  border-radius: 14px;
  box-shadow: inset 0 0 36px rgba(138, 108, 62, 0.18), 0 6px 20px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.map-header-bar {
  background: rgba(52, 42, 30, 0.9);
  color: #fcf8ee;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.map-era-title {
  font-weight: 800;
  font-size: 1.05rem;
  color: #fde68a;
}

.map-sub-panel-toggle {
  display: flex;
  gap: 6px;
}

.mini-toggle-btn {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.82rem;
  cursor: pointer;
  font-weight: 600;
}

.mini-toggle-btn.active {
  background: #fde68a;
  color: #231f1a;
  border-color: #fde68a;
}

.map-canvas-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  background: radial-gradient(circle at 50% 50%, #f7efda 0%, #ead9b5 100%);
}

#historical-map-svg {
  width: 100%;
  height: 100%;
  max-height: 100%;
  display: block;
}

/* 地圖上的動態箭頭動畫 */
@keyframes dashFlow {
  to {
    stroke-dashoffset: -40;
  }
}

.map-arrow-animated {
  stroke-dasharray: 10 6;
  animation: dashFlow 1.6s linear infinite;
}

.map-footer-bar {
  background: rgba(242, 232, 207, 0.95);
  border-top: 1px solid #cbb894;
  padding: 8px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  color: #4a3f31;
  flex-wrap: wrap;
  gap: 8px;
}

.map-summary-badge {
  font-weight: 700;
  color: #231f1a;
  background: rgba(255, 255, 255, 0.7);
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid #cbb894;
}

/* 右側捲動敘事區 */
.right-scroll-pane {
  padding: 16px 20px 60px 12px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.intro-banner {
  background: linear-gradient(135deg, #2b241d 0%, #43372b 100%);
  color: #f9f5eb;
  border-radius: 14px;
  padding: 18px 22px;
  border-left: 6px solid var(--gold-accent);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
}

.intro-banner h2 {
  margin: 0 0 6px 0;
  font-size: 1.25rem;
  color: #fde68a;
}

.intro-banner p {
  margin: 0;
  font-size: 0.95rem;
  opacity: 0.92;
}

/* 每一段經文敘事卡 */
.story-section-card {
  background: var(--bg-card);
  border: 2px solid var(--border-warm);
  border-radius: 16px;
  padding: 24px 26px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
  transition: border-color 0.25s, box-shadow 0.25s, transform 0.2s;
  scroll-margin-top: 76px;
}

.story-section-card.active-section {
  border-color: #b48a28;
  box-shadow: 0 8px 28px rgba(180, 138, 40, 0.22);
}

.section-top-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.step-badge {
  background: #231f1a;
  color: #fde68a;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.9rem;
}

.year-badge {
  background: #efe5ce;
  color: #4a3c2c;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.9rem;
  border: 1px solid #d5c39f;
}

.permalink-anchor {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-family: monospace;
  padding: 2px 8px;
  border-radius: 4px;
  background: #f3ede0;
}

.permalink-anchor:hover {
  background: #e5dac3;
  color: #000;
}

.section-title {
  margin: 0 0 16px 0;
  font-size: calc(1.45rem * var(--font-scale));
  line-height: 1.35;
  color: #1c1814;
}

/* 經文區塊（和合本，南方藍、北方紅同色標示） */
.scripture-box {
  background: #faf5e8;
  border: 1.5px solid #decfa8;
  border-left: 6px solid #8c6d32;
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 20px;
}

.scripture-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 700;
}

.scripture-text {
  font-size: calc(1.22rem * var(--font-scale));
  line-height: 1.8;
  font-weight: 600;
  color: #1f1a14;
}

.verse-num {
  display: inline-block;
  font-size: 0.8em;
  font-weight: 800;
  color: #8c6d32;
  background: #efe4c8;
  padding: 1px 7px;
  border-radius: 999px;
  margin-right: 4px;
  vertical-align: middle;
}

/* 經文關鍵字上色（南方王＝藍色、北方王＝紅色） */
.kw-south {
  background: var(--south-bg);
  color: var(--south-primary);
  border-bottom: 2.5px solid var(--south-primary);
  padding: 1px 6px;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 0.15s, background 0.15s;
}

.kw-south:hover {
  background: #bfdbfe;
}

.kw-south-female {
  background: var(--south-bg);
  color: var(--south-primary);
  border: 2px solid var(--gold-accent);
  padding: 1px 7px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.kw-north {
  background: var(--north-bg);
  color: var(--north-primary);
  border-bottom: 2.5px solid var(--north-primary);
  padding: 1px 6px;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 0.15s, background 0.15s;
}

.kw-north:hover {
  background: #fecaca;
}

.kw-danger {
  background: #fef2f2;
  color: #991b1b;
  border-bottom: 2px dashed #dc2626;
  padding: 1px 5px;
  cursor: pointer;
  font-weight: 700;
}

.kw-highlight {
  background: var(--gold-bg);
  color: #713f12;
  border-bottom: 2px solid var(--gold-accent);
  padding: 1px 5px;
  border-radius: 4px;
}

/* 本段出場人物頭像列 */
.cast-strip {
  margin-bottom: 20px;
}

.cast-strip-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 10px;
}

.cast-mini-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  text-align: left;
  background: #fff;
  border: 2px solid #e2d8c3;
}

.cast-mini-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.1);
}

.cast-mini-card.faction-south {
  border-left: 6px solid var(--south-primary);
  background: linear-gradient(90deg, #eff6ff 0%, #ffffff 45%);
}

.cast-mini-card.faction-north {
  border-left: 6px solid var(--north-primary);
  background: linear-gradient(90deg, #fef2f2 0%, #ffffff 45%);
}

.cast-mini-card.faction-neutral {
  border-left: 6px solid #d97706;
  background: linear-gradient(90deg, #fffbeb 0%, #ffffff 45%);
}

.cast-mini-card.is-female {
  border: 2.5px solid var(--gold-accent);
  box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.2);
}

.avatar-circle {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  border: 2.5px solid #cbb894;
  background: #f5ebd6;
  position: relative;
}

.faction-south .avatar-circle {
  border-color: var(--south-primary);
}

.faction-north .avatar-circle {
  border-color: var(--north-primary);
}

.is-female .avatar-circle {
  border-color: var(--gold-accent);
  border-width: 3px;
  border-radius: 14px; /* 女性醒目圓角金邊 */
}

.cast-info {
  min-width: 0;
  flex: 1;
}

.cast-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 1rem;
}

.cast-phrase {
  font-size: 0.85rem;
  font-weight: 700;
  color: #3b3228;
  margin-top: 2px;
}

.cast-role-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* 三層解說設計 */
.layer-one-box {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 2px solid #f59e0b;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 18px;
}

.layer-label {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 9px;
  border-radius: 6px;
  margin-bottom: 6px;
}

.layer-1-label {
  background: #d97706;
  color: #fff;
}

.layer-one-text {
  margin: 0;
  font-size: calc(1.26rem * var(--font-scale));
  font-weight: 800;
  color: #451a03;
  line-height: 1.5;
}

.layer-two-box {
  background: #ffffff;
  border: 1px solid #e6dec8;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 16px;
}

.layer-2-label {
  background: #3f362c;
  color: #fde68a;
}

.story-para {
  margin: 10px 0;
  font-size: calc(1.04rem * var(--font-scale));
  line-height: 1.78;
  color: #29231d;
}

.controversy-box {
  background: #fff7ed;
  border-left: 4px solid #ea580c;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.92rem;
  color: #7c2d12;
  margin-top: 12px;
}

/* 第三層：出處折疊區 */
.layer-three-details {
  background: #f5efe2;
  border: 1px solid #d8cbb0;
  border-radius: 10px;
  padding: 10px 16px;
}

.layer-three-details summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 0.92rem;
  color: #4a3f31;
  user-select: none;
}

.sources-list {
  margin: 10px 0 4px 0;
  padding-left: 20px;
  font-size: 0.88rem;
  color: #3d3429;
}

.sources-list li {
  margin-bottom: 8px;
}

/* 底部時間軸與跳段列 */
.bottom-timeline-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 95;
  background: rgba(28, 24, 20, 0.96);
  color: #f7f2e4;
  border-top: 2px solid #6e5a3b;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  backdrop-filter: blur(8px);
}

.timeline-steps {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: flex-start;
  overflow-x: auto;
  padding: 2px 6px;
}

.timeline-node-btn {
  background: #332c23;
  color: #d6cbb5;
  border: 1.5px solid #594c3c;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: all 0.2s;
}

.timeline-node-btn:hover {
  background: #473d31;
  color: #fff;
}

.timeline-node-btn.active {
  background: var(--gold-accent);
  color: #1c1814;
  border-color: #fef08a;
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.5);
}

.timeline-connector {
  width: 28px;
  height: 2px;
  background: #594c3c;
  flex-shrink: 0;
}

.step-nav-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-step-btn {
  background: #f5efe0;
  color: #1c1814;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: 800;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 0.15s;
}

.nav-step-btn:hover:not(:disabled) {
  background: #fde68a;
}

.nav-step-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* 獨立分頁檢視（完整族譜、人物圖鑑） */
.standalone-pane {
  display: none;
  max-width: 1380px;
  margin: 24px auto;
  padding: 0 20px 60px 20px;
}

.standalone-pane.active {
  display: block;
}

/* 族譜樣式（兩家並排、女性圓角金邊、通婚粗線、殺害虛線） */
.genealogy-board {
  background: var(--bg-parchment);
  border: 2px solid #bda882;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
}

.genealogy-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 14px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.65);
  border-radius: 10px;
  font-size: 0.88rem;
  align-items: center;
}

/* 人物圖鑑網格 */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 18px;
}

/* 人物卡彈窗 Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 12, 0.72);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal-backdrop.open {
  display: flex;
}

.char-modal-card {
  background: var(--bg-card);
  border: 3px solid #bda882;
  border-radius: 18px;
  max-width: 760px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  position: relative;
}

.char-modal-header {
  padding: 20px 24px;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.char-modal-header.south {
  background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 100%);
}

.char-modal-header.north {
  background: linear-gradient(135deg, #7f1d1d 0%, #b91c1c 100%);
}

.char-modal-header.neutral {
  background: linear-gradient(135deg, #78350f 0%, #b45309 100%);
}

.modal-close-btn {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  font-weight: 800;
}

.char-modal-body {
  padding: 24px;
}

.portrait-coin-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.compare-box {
  background: #f6efe0;
  border: 1.5px solid #d8cbb0;
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}

.compare-box h4 {
  margin: 0 0 10px 0;
  font-size: 0.92rem;
  color: #4a3f31;
}

.coin-img {
  max-width: 100%;
  height: 170px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  padding: 6px;
  border: 1px solid #d5c39f;
}

.site-footer {
  max-width: 1680px;
  margin: 20px auto 30px auto;
  padding: 16px 24px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-warm);
}

/* 手機與平板響應式：地圖在上，經文在下 */
@media (max-width: 1024px) {
  .main-split-layout {
    grid-template-columns: 1fr;
  }

  .left-sticky-pane {
    position: sticky;
    top: 52px;
    z-index: 40;
    height: 44vh;
    min-height: 300px;
    padding: 8px 12px;
    background: var(--bg-page);
    border-bottom: 2px solid #cbb894;
  }

  .right-scroll-pane {
    padding: 14px 14px 60px 14px;
  }

  .portrait-coin-compare {
    grid-template-columns: 1fr;
  }
}
