/* ==========================================================================
   《百年孤独》布恩迪亚家族图谱 - 交互画布与谱系分支样式 (tree.css)
   ========================================================================== */

/* 谱系树面板容器 */
#panel-tree {
  overflow: hidden;
  height: calc(100vh - 65px);
  position: relative;
}

/* 顶部操作次级导航 */
.tree-subnav {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 20;
  overflow-x: auto;
  flex-shrink: 0;
}

/* 世代快速定位胶囊 */
.gen-jumps-group {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.gen-jumps-label {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 700;
  margin-right: 2px;
}

.gen-jump-pill {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s;
}

.gen-jump-pill:hover {
  border-color: var(--accent-gold);
  color: var(--text-primary);
  transform: translateY(-1px);
}

/* 画布控制工具条 (模式切换、放大缩小、居中) */
.tree-controls-group {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.mode-toggle-group {
  display: flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.mode-toggle-btn {
  background: transparent;
  border: none;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 4px 9px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-toggle-btn.active {
  background: var(--accent-gold);
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.zoom-ctrls-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.zoom-btn {
  background: transparent;
  border: none;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  border-radius: 4px;
}

.zoom-btn:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

.zoom-indicator-text {
  font-size: 11px;
  font-family: monospace;
  color: var(--text-muted);
  padding: 0 6px;
  min-width: 44px;
  text-align: center;
}

.btn-center-view {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-center-view:hover {
  border-color: var(--accent-gold);
  color: var(--text-primary);
}

/* 图例关系说明条 */
.tree-legend-strip {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 11px;
  color: var(--text-muted);
  overflow-x: auto;
  z-index: 15;
  white-space: nowrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-line {
  display: inline-block;
  width: 14px;
  height: 2.5px;
  border-radius: 2px;
}

.legend-line.marriage { background-color: #64748b; }
.legend-line.parent-child { background-color: #3b82f6; }
.legend-line.adoption { background: repeating-linear-gradient(90deg, #10b981 0, #10b981 4px, transparent 4px, transparent 7px); }
.legend-line.affair { background: repeating-linear-gradient(90deg, #f59e0b 0, #f59e0b 5px, transparent 5px, transparent 8px); }
.legend-line.incest { background-color: #ef4444; height: 3px; }

.legend-hint {
  margin-left: auto;
  color: var(--accent-gold);
}

/* 画布主工作区 */
.tree-canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  background-color: var(--bg-primary);
  background-image: radial-gradient(rgba(245, 158, 11, 0.05) 1px, transparent 1px);
  background-size: 24px 24px;
  user-select: none;
  -webkit-user-select: none;
}

.tree-canvas-container.is-dragging {
  cursor: grabbing;
}

/* 硬件加速视口 */
.tree-canvas-viewport {
  position: absolute;
  top: 0;
  left: 0;
  width: 1450px;
  height: 1220px;
  transform-origin: 0 0;
  will-change: transform;
}

/* SVG 连线层 */
.tree-svg-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 1450px;
  height: 1220px;
  pointer-events: none;
  z-index: 1;
}

.tree-line {
  transition: stroke 0.25s, stroke-width 0.25s, opacity 0.25s;
}

.line-highlight {
  stroke: #f59e0b !important;
  stroke-width: 4px !important;
  opacity: 1 !important;
  filter: drop-shadow(0 0 6px rgba(245, 158, 11, 0.7));
}

.line-dimmed {
  opacity: 0.12 !important;
}

/* 人物节点容器与卡片 */
.tree-nodes-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 1450px;
  height: 1220px;
  z-index: 10;
}

.tree-node {
  position: absolute;
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s, border-color 0.2s, opacity 0.2s;
  overflow: hidden;
}

.tree-node:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: var(--shadow-md);
  border-color: var(--accent-gold);
}

.node-highlight {
  outline: 3px solid #f59e0b !important;
  box-shadow: 0 0 24px rgba(245, 158, 11, 0.45) !important;
  border-color: #f59e0b !important;
  z-index: 40 !important;
}

.node-dimmed {
  opacity: 0.22 !important;
  filter: grayscale(0.8);
}

/* 卡片内部网飞剧照模式 */
.node-card-body {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 8px 10px;
  gap: 10px;
}

.node-photo {
  width: 58px;
  height: 58px;
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 2px solid var(--accent-gold);
  position: relative;
  flex-shrink: 0;
  background: #000;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.node-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.node-photo-badge {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.8);
  color: #f59e0b;
  font-size: 7.5px;
  font-weight: 900;
  text-align: center;
  padding: 1px 0;
  letter-spacing: 0.5px;
}

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

.node-gen-badge {
  font-size: 9.5px;
  font-weight: 800;
  color: var(--accent-gold);
  text-transform: uppercase;
  letter-spacing: 0.2px;
}

.node-name-text {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.node-name-es {
  font-size: 10px;
  color: var(--text-muted);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.node-role-text {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* 极简原图拓扑线框模式 (Wireframe Mode) */
body.mode-wireframe .node-photo {
  display: none !important;
}

body.mode-wireframe .node-card-body {
  padding: 10px 8px !important;
  text-align: center;
  justify-content: center !important;
  background: var(--bg-card) !important;
  border-radius: var(--radius-sm) !important;
}

body.mode-wireframe .tree-node {
  border: 2px solid #475569 !important;
  border-radius: var(--radius-sm) !important;
}

body.mode-wireframe .node-name-text {
  font-size: 14px !important;
  font-weight: 800 !important;
  color: var(--text-primary) !important;
}

body.mode-wireframe .node-gen-badge,
body.mode-wireframe .node-name-es,
body.mode-wireframe .node-role-text {
  display: none !important;
}
