/* ==========================================================================
   《百年孤独》布恩迪亚家族图谱 - 交互画布与谱系分支样式 (tree.css)
   基于 ANTIGRAVITY_PROMPT 官方素材包视觉标准重构
   ========================================================================== */

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

#panel-tree.active {
  display: flex;
}

/* 画布主工作区 - 浸入式暗绿古典马孔多热带废墟中庭背景 */
.tree-canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  background-color: #061411;
  background-image: 
    linear-gradient(rgba(6, 20, 17, 0.40), rgba(6, 20, 17, 0.58)),
    url('../assets/cien-anos/bg_macondo.png');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  user-select: none;
  -webkit-user-select: none;
}

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

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

/* 悬浮关系连线图例 (Top-Left Discreet Floating Legend) */
.tree-floating-legend {
  position: absolute;
  top: 18px;
  left: 20px;
  background: rgba(6, 18, 15, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(201, 169, 97, 0.35);
  border-radius: 4px;
  padding: 10px 14px;
  z-index: 25;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  pointer-events: auto;
  min-width: 130px;
}

.legend-header {
  margin-bottom: 6px;
}

.legend-title {
  font-family: var(--font-serif);
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.5px;
}

.legend-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  color: var(--text-light);
  font-family: var(--font-serif);
  white-space: nowrap;
}

.legend-line {
  display: inline-block;
  width: 18px;
  height: 1.5px;
  border-radius: 1px;
  flex-shrink: 0;
}

.legend-line.blood { background-color: #c9a961; height: 1.5px; }
.legend-line.marriage { background: repeating-linear-gradient(90deg, #d8c89f 0, #d8c89f 4px, transparent 4px, transparent 7px); }
.legend-line.friendship { background: repeating-linear-gradient(90deg, #b59b63 0, #b59b63 3px, transparent 3px, transparent 5px); }
.legend-line.special { background: repeating-linear-gradient(90deg, #d49b55 0, #d49b55 4px, transparent 4px, transparent 6px); }
.legend-line.incest { background-color: #b84233; height: 2px; }

/* 悬浮画布控制器 (Bottom-Left Discreet Floating Controls) */
.tree-floating-controls {
  position: absolute;
  bottom: 24px;
  left: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 25;
  pointer-events: auto;
}

.tree-mode-group,
.tree-zoom-group {
  background: rgba(6, 18, 15, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(201, 169, 97, 0.35);
  border-radius: 4px;
  padding: 3px;
  display: flex;
  align-items: center;
  gap: 3px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
}

.tree-ctrl-btn {
  background: transparent;
  border: none;
  color: var(--text-light);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-family: var(--font-serif);
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.2s;
}

.tree-ctrl-btn.mode-btn {
  width: auto;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 600;
}

.tree-ctrl-btn.mode-btn.active {
  background: rgba(201, 169, 97, 0.25);
  color: var(--gold);
  border: 1px solid rgba(201, 169, 97, 0.45);
}

.tree-ctrl-btn:hover {
  background: rgba(201, 169, 97, 0.2);
  color: var(--gold);
}

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

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

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

.line-highlight {
  stroke: #ffd700 !important;
  stroke-width: 3.5px !important;
  opacity: 1 !important;
  filter: drop-shadow(0 0 8px rgba(212, 175, 55, 0.85));
}

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

/* 人物节点容器层 */
.tree-nodes-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 1750px;
  height: 1950px;
  z-index: 10;
}

/* ==========================================================================
   维多利亚复古羊皮纸卡片 (The Buendía Parchment Card)
   淡褪象牙羊皮纸底色 + 纸张纤维纹理 + 顶部铜质大头钉 + 竖版肖像 + 经典手写短语
   ========================================================================== */
.tree-node {
  position: absolute;
  background-color: var(--paper-light);
  background-image: 
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.6) 0%, transparent 60%),
    url('../assets/cien-anos/parchment_texture.png'),
    linear-gradient(180deg, #eae0cd 0%, #d8c6a0 100%);
  background-size: cover, cover, auto;
  border: 1px solid rgba(139, 111, 71, 0.5);
  border-radius: 3px;
  box-shadow: 
    0 6px 18px rgba(0, 0, 0, 0.6),
    0 1px 3px rgba(0, 0, 0, 0.35),
    inset 0 0 12px rgba(139, 111, 71, 0.2);
  cursor: pointer;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.28s ease, border-color 0.28s ease, filter 0.28s ease;
  overflow: visible;
}

.tree-node:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 
    0 12px 28px rgba(0, 0, 0, 0.75),
    0 0 20px rgba(201, 169, 97, 0.45);
  border-color: var(--gold);
  filter: brightness(1.02);
  z-index: 35 !important;
}

.tree-node.node-highlight,
.tree-node.node-selected {
  outline: 2px solid var(--gold) !important;
  box-shadow: 
    0 0 26px rgba(201, 169, 97, 0.7),
    0 12px 32px rgba(0, 0, 0, 0.85) !important;
  border-color: var(--gold) !important;
  filter: brightness(1.04);
  z-index: 40 !important;
}

.tree-node.node-dimmed {
  opacity: 0.22 !important;
  filter: grayscale(0.6) brightness(0.7);
}

/* 纪念已故状态 (Deceased State per 05_character_card_memorial) */
.tree-node.node-memorial .node-photo img {
  filter: grayscale(0.5) contrast(1.1) brightness(0.9);
}

/* 卡片顶部仿铜复古大头钉 (Vintage Pin) */
.vintage-pin {
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  background: radial-gradient(circle at 35% 35%, #d8c89f 0%, #8b6f47 70%, #2c1f14 100%);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.7);
  z-index: 5;
}

/* 垂直排布卡片内部 */
.node-card-body {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 8px 6px 8px;
  box-sizing: border-box;
}

/* 人物写真肖像：复古深绿金框，增大高度并顶部对齐以完整显示头部 */
.node-photo {
  width: 144px;
  height: 126px;
  border-radius: 2px;
  overflow: hidden;
  border: 1px solid rgba(139, 111, 71, 0.45);
  position: relative;
  flex-shrink: 0;
  background: #0b1f1a;
  box-shadow: 
    inset 0 0 10px rgba(0, 0, 0, 0.5),
    0 2px 5px rgba(0, 0, 0, 0.25);
}

.node-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center; /* 关键：顶部对齐，完整保留头部与面部，绝不上方受遮挡 */
  display: block;
  filter: contrast(1.05) saturate(0.95);
  transition: transform 0.3s ease;
}

.tree-node:hover .node-photo img {
  transform: scale(1.03);
}

/* 下方文字区域：两行紧凑布局 (名字加粗 + 中文短语介绍) */
.node-info-text {
  width: 100%;
  margin-top: 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-width: 0;
  gap: 2px;
}

/* 人物姓名：加粗 深褐色古典衬线体 */
.node-name-text {
  font-family: var(--font-serif);
  font-size: 13.5px;
  font-weight: 800; /* 加粗 */
  color: #2b1f14;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 144px;
  letter-spacing: 0.3px;
}

/* 西班牙原名 (隐藏，只保留中文名与中文短语介绍) */
.node-name-es {
  display: none !important;
}

/* 人物中文短语介绍 (单行精炼) */
.node-epigraph-text {
  font-family: var(--font-body);
  font-size: 10.5px;
  color: #5c4b37;
  line-height: 1.2;
  margin-top: 0;
  max-width: 144px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: italic;
  font-weight: 500;
}

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

body.mode-wireframe .node-card-body {
  justify-content: center !important;
  background: var(--paper-light) !important;
}

body.mode-wireframe .tree-node {
  border: 1.5px solid var(--earth) !important;
}

body.mode-wireframe .node-name-text {
  font-size: 15px !important;
  color: var(--text-dark) !important;
}
