/* ========== 疆溯 Timarche 全局样式 ========== */

:root {
  --bg-main: #0a0e17;
  --bg-map: #0f151f;
  --bg-panel: #131b26;
  --bg-card: #1a2532;
  --gold: #c9a84c;
  --gold-light: #f5d98f;
  --gold-dark: #a6893a;
  --text-main: #e8edf2;
  --text-sub: #b0c4de;
  --text-aux: #8aa0b8;
  --line: #2a3a4a;
  --line-panel: #1f2d3a;
}

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

html, body {
  height: 100%;
  background: var(--bg-main);
  color: var(--text-main);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, sans-serif;
  overflow: hidden;
}

/* ---------- 加载遮罩 ---------- */
.loading-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: var(--bg-main);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; transition: opacity .5s;
}
.loading-overlay.fade-out { opacity: 0; pointer-events: none; }
.loading-ring {
  width: 56px; height: 56px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--gold);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--text-sub); font-size: 14px; letter-spacing: 2px; }

/* ---------- 品牌栏 ---------- */
.brand-bar {
  height: 52px; display: flex; align-items: center; padding: 0 20px;
  background: var(--bg-panel); border-bottom: 1px solid var(--line-panel);
}
.brand-name {
  font-size: 24px; font-weight: 600; color: var(--gold); letter-spacing: 4px;
}
.brand-sub {
  margin-left: 14px; font-size: 12px; font-weight: 300; color: var(--text-aux); letter-spacing: 1px;
}

/* ---------- 主布局 ---------- */
.layout {
  display: flex;
  height: calc(100% - 52px);
}

/* ---------- 地图区域 ---------- */
.map-area {
  position: relative;
  width: 70%;
  background: var(--bg-map);
}
#map { position: absolute; inset: 0; opacity: 0; transition: opacity .5s; }
#map.loaded { opacity: 1; }

.leaflet-container { background: var(--bg-map); font-family: inherit; }

/* 占位 / 错误提示 */
.geojson-placeholder {
  position: absolute; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 900; display: flex; align-items: center; gap: 8px;
  background: rgba(19, 27, 38, .92); border: 1px solid var(--line);
  color: var(--text-aux); font-size: 13px;
  padding: 8px 16px; border-radius: 6px; pointer-events: none;
}
.fatal-error {
  position: absolute; inset: 0; z-index: 950;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; color: var(--text-aux); font-size: 15px;
}
.fatal-error i { font-size: 36px; color: var(--gold-dark); }
.hidden { display: none !important; }

/* ---------- 首次访问提示 ---------- */
.first-visit-hint {
  position: absolute; left: 50%; bottom: 130px; transform: translateX(-50%) translateY(8px);
  z-index: 900; display: flex; align-items: center; gap: 8px;
  background: rgba(201, 168, 76, .95); color: var(--bg-main);
  font-size: 13px; font-weight: 500; letter-spacing: 1px;
  padding: 10px 20px; border-radius: 20px;
  opacity: 0; transition: opacity .5s, transform .5s;
  pointer-events: none; white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .4);
}
.first-visit-hint.hint-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 疆域弹窗 ---------- */
.territory-popup { text-align: center; }
.territory-popup b { font-size: 15px; color: var(--gold); display: block; }
.territory-popup span { font-size: 12px; color: var(--text-sub); }
.leaflet-popup-content-wrapper {
  background: var(--bg-panel); color: var(--text-main);
  border: 1px solid var(--line); border-radius: 8px;
}
.leaflet-popup-tip { background: var(--bg-panel); border: 1px solid var(--line); }
.leaflet-popup-close-button { color: var(--text-aux) !important; }


/* ---------- 时间轴 ---------- */
.timeline-panel {
  position: absolute; left: 24px; right: 24px; bottom: 20px; z-index: 800;
  background: rgba(19, 27, 38, .92);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 18px 8px;
  backdrop-filter: blur(6px);
}
.timeline-header { display: flex; justify-content: space-between; align-items: center; }
.current-dynasty { display: flex; align-items: baseline; gap: 10px; }
.timeline-emoji { font-size: 20px; }
.timeline-name { font-size: 20px; font-weight: 600; color: var(--gold); }
.timeline-year { font-size: 22px; font-weight: 300; color: var(--text-sub); }

.timeline-controls { display: flex; gap: 8px; }
.ctrl-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg-card);
  color: var(--text-sub); font-size: 14px; cursor: pointer;
  transition: all .2s;
}
.ctrl-btn:hover { border-color: var(--gold); color: var(--gold-light); }
.ctrl-btn.play { background: var(--gold); border-color: var(--gold); color: var(--bg-main); }
.ctrl-btn.play.playing { background: var(--gold-dark); border-color: var(--gold-dark); }

.timeline-slider {
  width: 100%; margin: 14px 0 4px;
  -webkit-appearance: none; appearance: none;
  height: 4px; border-radius: 2px;
  background: var(--line); outline: none; cursor: pointer;
}
.timeline-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--gold); border: 3px solid var(--gold-light);
  box-shadow: 0 0 8px rgba(201, 168, 76, .6); cursor: grab;
}
.timeline-slider::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--gold); border: 3px solid var(--gold-light);
  box-shadow: 0 0 8px rgba(201, 168, 76, .6); cursor: grab;
}

.timeline-marks { position: relative; height: 22px; }
.timeline-mark {
  position: absolute; transform: translateX(-50%);
  font-size: 13px; font-weight: 500; color: var(--text-aux);
  cursor: pointer; transition: color .15s; white-space: nowrap;
  padding: 6px 10px 4px; /* 扩大触控/点击区域 */
  margin: -6px -10px 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none;
}
.timeline-mark::before {
  content: ""; position: absolute; top: -6px; left: 50%; transform: translateX(-50%);
  width: 6px; height: 6px; border-radius: 50%; background: var(--line);
  transition: background .15s;
}
.timeline-mark:hover { color: var(--gold-light); }
.timeline-mark.minor {
  font-size: 0; /* 隐藏文字，仅保留圆点 */
}
.timeline-mark.minor:hover { font-size: 13px; }
.timeline-mark.active { color: var(--gold); font-weight: 600; font-size: 13px; }
.timeline-mark.active::before { background: var(--gold); }

/* ---------- 信息面板 ---------- */
.info-panel {
  width: 30%;
  background: var(--bg-panel);
  border-left: 1px solid var(--line-panel);
  overflow-y: auto;
  padding: 28px 26px 20px;
  display: flex; flex-direction: column; gap: 16px;
  transition: opacity .15s ease;
}
.info-panel.panel-fading { opacity: 0; }
.info-panel::-webkit-scrollbar { width: 6px; }
.info-panel::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.dynasty-title h1 {
  font-size: 44px; font-weight: 600; line-height: 1.1; color: var(--gold);
}
.panel-period {
  margin-top: 6px; font-size: 22px; font-weight: 300; line-height: 1.4; color: var(--text-sub);
}

.info-card {
  background: var(--bg-card); border: 1px solid var(--line-panel);
  border-radius: 8px; padding: 14px 16px;
}
.info-card h3 {
  font-size: 12px; font-weight: 400; line-height: 1.6;
  color: var(--text-aux); letter-spacing: 1px; margin-bottom: 8px;
}
.info-card h3 i { color: var(--gold); margin-right: 6px; }
.info-card p { font-size: 15px; font-weight: 400; line-height: 1.7; color: var(--text-main); }

.highlights { list-style: none; }
.highlights li {
  position: relative; padding-left: 18px; margin-bottom: 8px;
  font-size: 15px; line-height: 1.7; color: var(--text-main);
}
.highlights li::before {
  content: "◆"; position: absolute; left: 0; top: 2px;
  font-size: 9px; color: var(--gold);
}

.panel-footer {
  margin-top: auto; padding-top: 16px;
  font-size: 11px; font-weight: 300; line-height: 1.6;
  color: var(--text-aux); text-align: center; letter-spacing: 1px;
}

/* ---------- 都城标记 ---------- */
.fullscreen-btn {
  position: absolute; top: 42px; right: 12px; z-index: 850;
  width: 36px; height: 36px; border-radius: 6px;
  border: 1px solid var(--line); background: rgba(19, 27, 38, .92);
  color: var(--text-sub); font-size: 14px; cursor: pointer;
  transition: all .2s;
}
.fullscreen-btn:hover { border-color: var(--gold); color: var(--gold-light); }

.capital-marker {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(201, 168, 76, .18); border: 1px solid var(--gold);
  color: var(--gold); font-size: 13px;
  box-shadow: 0 0 10px rgba(201, 168, 76, .35);
}
.capital-label {
  background: rgba(19, 27, 38, .9); border: 1px solid var(--gold-dark);
  color: var(--gold-light); font-size: 12px; padding: 2px 8px;
  border-radius: 4px; white-space: nowrap;
}
.leaflet-tooltip.capital-tooltip { background: transparent; border: none; box-shadow: none; }

/* ---------- 著名城池标记 ---------- */
.city-marker {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--text-sub); border: 2px solid var(--bg-panel);
  box-shadow: 0 0 6px rgba(176, 196, 222, .5);
  transition: all .15s;
}
.city-marker:hover {
  background: var(--gold-light); transform: scale(1.4);
  box-shadow: 0 0 10px rgba(245, 217, 143, .8);
}
.leaflet-tooltip.city-tooltip {
  background: rgba(19, 27, 38, .92); border: 1px solid var(--line);
  color: var(--text-main); font-size: 12px; border-radius: 4px;
  box-shadow: none; padding: 2px 8px;
}
.leaflet-tooltip.city-tooltip::before { display: none; }
.city-popup { max-width: 240px; }
.city-popup b {
  font-size: 14px; color: var(--gold); display: block; margin-bottom: 4px;
}
.city-popup span { font-size: 12.5px; line-height: 1.6; color: var(--text-main); }

/* ---------- 平板端 768-1024px ---------- */
@media (min-width: 768px) and (max-width: 1023px) {
  .map-area { width: 60%; }
  .info-panel { width: 40%; }
  .dynasty-title h1 { font-size: 36px; }
  .panel-period { font-size: 18px; }
}

/* ---------- 移动端 <768px ---------- */
@media (max-width: 767px) {
  html, body { overflow: auto; }
  .brand-sub { display: none; }
  .layout { flex-direction: column; height: calc(100% - 52px); overflow: hidden; }
  .map-area { width: 100%; height: 60%; flex: none; }
  .info-panel { width: 100%; height: 40%; flex: none; border-left: none; border-top: 1px solid var(--line-panel); padding: 18px 16px; }
  .timeline-panel { left: 8px; right: 8px; bottom: 8px; padding: 8px 12px 4px; }
  .timeline-name { font-size: 16px; }
  .timeline-year { font-size: 15px; }
  .timeline-emoji { font-size: 16px; }
  .timeline-mark { font-size: 11px; }
  .timeline-marks { height: 18px; }
  .ctrl-btn { width: 32px; height: 32px; font-size: 12px; }
  .dynasty-title h1 { font-size: 30px; }
  .panel-period { font-size: 15px; }
  .first-visit-hint { bottom: 110px; font-size: 12px; padding: 8px 14px; }
}

/* ---------- 动效降级 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
