/* ========== 全局重置 ========== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: #2c2418;
  background: #f5f1e8;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

/* ========== 顶部 ========== */
.app-header {
  flex: 0 0 auto;
  background: linear-gradient(180deg, #3d2817 0%, #2a1a0e 100%);
  color: #f0e4d0;
  padding: 14px 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 10;
}

.title-block h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 2px;
  margin-bottom: 2px;
}

.subtitle {
  font-size: 12px;
  color: #c8b89a;
  letter-spacing: 1px;
}

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

.zoom-controls,
.filter-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.zoom-controls button {
  width: 28px;
  height: 28px;
  background: #5a3d22;
  color: #f0e4d0;
  border: 1px solid #7a5a3a;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: background 0.15s;
}

.zoom-controls button:hover {
  background: #7a5a3a;
}

#zoom-level {
  min-width: 48px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: #c8b89a;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.15s;
}

.checkbox:hover {
  background: rgba(255, 255, 255, 0.08);
}

.checkbox input {
  cursor: pointer;
}

.toolbar-divider {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.15);
  margin: 0 4px;
}

.panel-toggle-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #f0e4d0;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  letter-spacing: 1px;
  transition: background 0.15s, border-color 0.15s;
}

.panel-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.4);
}

.region-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  flex-wrap: wrap;
  max-width: 100%;
}

.region-label {
  color: #c8b89a;
  margin-right: 4px;
  letter-spacing: 1px;
}

.region-controls .checkbox {
  padding: 2px 6px;
  font-size: 12px;
}

.region-clear-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #c8b89a;
  padding: 2px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
  margin-left: 8px;
  letter-spacing: 1px;
}

.region-clear-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #f0e4d0;
  border-color: rgba(255, 255, 255, 0.4);
}

/* ========== 主体 ========== */
.app-main {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

.timeline-container {
  flex: 1 1 auto;
  position: relative;
  overflow: auto;
  min-height: 0;
  min-width: 0;
  background:
    linear-gradient(180deg, #faf6ed 0%, #f0e8d4 100%);
  cursor: grab;
}

.timeline-container:active {
  cursor: grabbing;
}

.timeline-container svg {
  display: block;
  user-select: none;
}

/* ========== 信息面板 ========== */
.info-panel {
  flex: 0 0 360px;
  background: #fffaf0;
  border-left: 1px solid #d8c8a8;
  overflow-y: auto;
  position: relative;
  padding: 24px;
  box-shadow: -4px 0 12px rgba(0, 0, 0, 0.05);
}

.info-panel.collapsed {
  flex: 0 0 0;
  padding: 0;
  overflow: hidden;
}

.close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  font-size: 22px;
  color: #8a7a5a;
  cursor: pointer;
  border-radius: 4px;
  line-height: 1;
}

.close-btn:hover {
  background: #f0e4d0;
  color: #3d2817;
}

.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: #8a7a5a;
}

.empty-state h2 {
  font-size: 18px;
  margin-bottom: 12px;
  color: #5a4a2a;
}

.empty-state h3 {
  font-size: 14px;
  margin: 24px 0 8px;
  color: #5a4a2a;
  text-align: left;
}

.empty-state p {
  font-size: 13px;
  line-height: 1.7;
  text-align: left;
}

/* 朝代信息卡片 */
.dynasty-card .dynasty-name {
  font-size: 28px;
  font-weight: 600;
  color: #3d2817;
  margin-bottom: 4px;
  letter-spacing: 4px;
}

.dynasty-card .dynasty-subtitle {
  font-size: 13px;
  color: #8a7a5a;
  margin-bottom: 16px;
}

.dynasty-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  font-size: 13px;
  padding: 12px 0;
  border-top: 1px solid #e8dcc0;
  border-bottom: 1px solid #e8dcc0;
  margin-bottom: 16px;
}

.dynasty-meta dt {
  color: #8a7a5a;
}

.dynasty-meta dd {
  color: #2c2418;
}

.dynasty-section {
  margin-bottom: 18px;
}

.dynasty-section h4 {
  font-size: 13px;
  color: #5a4a2a;
  margin-bottom: 8px;
  padding-left: 8px;
  border-left: 3px solid currentColor;
}

.dynasty-section ul {
  list-style: none;
  font-size: 13px;
  line-height: 1.8;
}

.dynasty-section li::before {
  content: "·";
  color: #b89a6a;
  margin-right: 6px;
  font-weight: bold;
}

.dynasty-section .item-year {
  display: inline-block;
  min-width: 40px;
  color: #8a7a5a;
  font-variant-numeric: tabular-nums;
  margin-right: 6px;
}

/* ========== SVG 元素样式 ========== */
.dynasty-bar {
  cursor: pointer;
  transition: opacity 0.15s, filter 0.15s;
}

.dynasty-bar:hover {
  filter: brightness(1.15) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.dynasty-bar.selected {
  stroke: #3d2817;
  stroke-width: 2;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.3));
}

.dynasty-label {
  pointer-events: none;
  fill: rgba(255, 255, 255, 0.95);
  font-size: 12px;
  font-weight: 500;
  text-anchor: middle;
  dominant-baseline: central;
  letter-spacing: 1px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.dynasty-label.dark {
  fill: rgba(0, 0, 0, 0.75);
  text-shadow: none;
}

.dynasty-label-above {
  pointer-events: none;
  font-size: 11px;
  font-weight: 600;
  text-anchor: middle;
  letter-spacing: 1px;
  paint-order: stroke;
  stroke: rgba(250, 246, 237, 0.85);
  stroke-width: 3;
  stroke-linejoin: round;
}

.axis-tick {
  stroke: #b89a6a;
  stroke-width: 1;
}

.axis-line {
  stroke: #8a7a5a;
  stroke-width: 1.5;
}

.axis-label {
  fill: #5a4a2a;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.grid-line {
  stroke: rgba(184, 154, 106, 0.25);
  stroke-width: 1;
  stroke-dasharray: 2 4;
}

.era-marker {
  fill: #c83232;
  cursor: pointer;
  transition: r 0.15s;
}

.era-marker:hover {
  r: 6;
}

.event-marker {
  fill: #d4a64a;
  stroke: #8a6a1a;
  stroke-width: 1;
  cursor: pointer;
}

.person-marker {
  fill: #6a8a4a;
  stroke: #3a5a1a;
  stroke-width: 1;
  cursor: pointer;
}

/* ========== 提示框 ========== */
.tooltip {
  position: fixed;
  pointer-events: none;
  background: rgba(45, 30, 15, 0.95);
  color: #f0e4d0;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.tooltip.visible {
  opacity: 1;
}

.tooltip strong {
  color: #f5d089;
  margin-right: 4px;
}

/* ========== 响应式 ========== */
@media (max-width: 900px) {
  .app-main {
    flex-direction: column;
  }
  .info-panel {
    flex: 0 0 200px;
    border-left: none;
    border-top: 1px solid #d8c8a8;
  }
  .info-panel.collapsed {
    flex: 0 0 0;
  }
}

/* ========== GeaCron 地图链接（详情面板内） ========== */
.dynasty-map-links a {
  color: #c83232;
  text-decoration: none;
  display: block;
  padding: 4px 2px;
  border-radius: 3px;
  transition: background 0.12s;
}

.dynasty-map-links a:hover {
  background: rgba(200, 50, 50, 0.08);
  text-decoration: none;
}

/* ========== 地图弹窗 ========== */
.map-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: mapModalFade 0.18s ease-out;
}

@keyframes mapModalFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.map-modal-content {
  width: 92%;
  height: 85%;
  max-width: 1400px;
  background: #fff;
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.map-modal-content iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.map-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  transition: background 0.12s;
}

.map-modal-close:hover {
  background: rgba(0, 0, 0, 0.85);
}
