/* ============================================================
   世系图 - 现代简约风格
   ============================================================ */

.gene-desc {
    font-size: 13px;
    color: var(--color-text-light);
    margin-top: 2px;
}
.gene-desc strong {
    color: var(--color-accent);
}

/* --- 树容器 --- */
.tree-container {
    width: 100%;
    margin: 0;
    padding: 20px 0 0;
    overflow-x: auto;
    overflow-y: visible;
    /* Firefox 滚动条 */
    scrollbar-width: thin;
    scrollbar-color: #d4b8a0 #f5f0eb;
}
/* WebKit 滚动条（Chrome / Edge / Safari） */
.tree-container::-webkit-scrollbar {
    height: 8px;
}
.tree-container::-webkit-scrollbar-track {
    background: #f5f0eb;
    border-radius: 4px;
}
.tree-container::-webkit-scrollbar-thumb {
    background: #d4b8a0;
    border-radius: 4px;
    border: 1px solid #f5f0eb;
}
.tree-container::-webkit-scrollbar-thumb:hover {
    background: #b8835a;
}

/* ============================================================
   核心树结构
   ============================================================ */

.tree {
    text-align: center;
    padding: 20px 0 60px;
}

.tree ul {
    padding-top: 20px;
    position: relative;
    margin: 0;
    padding-left: 0;
    list-style: none;
    display: flex;
    justify-content: center;
    white-space: nowrap;
    transition: all 0.5s;
}

/* 顶层 UL — 宽度由内容决定，窄时居中，宽时左对齐 */
.tree > ul {
    padding-top: 0;
    width: max-content;
    margin-left: auto;
    margin-right: auto;
}

/* ┃ 父到子的竖线 */
.tree ul::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 0;
    height: 20px;
    border-left: 2px solid #c9b99a;
}

/* 顶层 UL 不需要竖线 */
.tree > ul::before {
    display: none;
}

/* LI - 每个节点 */
.tree li {
    display: inline-block;
    text-align: center;
    position: relative;
    padding: 20px 5px 0 5px;
    list-style: none;
    vertical-align: top;
    transition: all 0.5s;
    flex-shrink: 0;
}

/* ───┬─── 兄弟间横线 ────────────────
   方案说明：
   ::after 承载右半横线 + 中心竖线（border-left）+ 左圆角
   ::before 承载左半横线 + 中心竖线（border-right）+ 右圆角（非老大）
   中心竖线只画一次，用 border-right 统一处理，
   border-left 只做圆角不补竖线避免重叠
   ─────────────────────────────── */
.tree li::before,
.tree li::after {
    content: '';
    position: absolute;
    top: 0;
    height: 20px;
    box-sizing: border-box;
}
.tree li::before {
    right: 50%;
    width: 50%;
    border-top: 2px solid #c9b99a;
}
.tree li::after {
    left: 50%;
    width: 50%;
    border-top: 2px solid #c9b99a;
}

/* 老大 - 无左边横线 */
.tree li:first-child::before {
    border: 0 none;
}

/* 老幺 - 无右边横线 */
.tree li:last-child::after {
    display: none;
}

/* 所有节点加中心竖线 + 圆角 */
/* ::after 画左圆角 + 中心竖线 */
.tree li::after {
    border-left: 2px solid #c9b99a;
    border-radius: 4px 0 0 0;
}
/* ::before 画右圆角 + 中心竖线（老大不画，避免左边漏出） */
.tree li:not(:first-child)::before {
    border-right: 2px solid #c9b99a;
    border-radius: 0 4px 0 0;
}

/* 独子 - 无横线 */
.tree li:only-child::before,
.tree li:only-child::after {
    display: none;
}
.tree li:only-child {
    padding-top: 0;
}

/* ===== 节点卡片 ===== */
.tree li a {
    border: 1.5px solid #d4b8a0;
    padding: 5px 14px;
    text-decoration: none;
    color: #5a4a3a;
    font-size: 11px;
    font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
    display: inline-block;
    border-radius: 8px;
    position: relative;
    z-index: 2;
    background: #ffffff;
    line-height: 1.5;
    transition: all 0.25s ease;
    text-align: center;
    min-width: 44px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.tree li a:hover {
    background: #fdf8f4;
    border-color: #b8835a;
    box-shadow: 0 3px 12px rgba(184,131,90,0.15);
    transform: translateY(-1px);
}

.tree li a h1 {
    font-size: 14px;
    font-weight: 600;
    color: #5a3e2b;
    margin: 0;
    padding: 0;
    line-height: 1.5;
    letter-spacing: 1px;
    white-space: nowrap;
}

/* 备注文本 */
.note-text {
    font-size: 11px;
    color: #8a7a6a;
    line-height: 1.5;
    margin-top: 3px;
    text-align: center;
}

/* ===== Tooltip 传记浮窗 ===== */
.tooltips {
    position: relative;
    z-index: 2;
}
.tooltips:hover {
    z-index: 3;
    background: none;
}
.tooltips span {
    display: none;
}
.tooltips:hover span {
    display: block;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 16em;
    border: 1px solid #d4b8a0;
    background-color: #fdf8f4;
    padding: 8px 10px;
    color: #4a3a2a;
    font-size: 12px;
    line-height: 1.6;
    text-align: left;
    white-space: normal;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(90,62,43,0.12);
    z-index: 999;
    margin-top: 6px;
}

/* 最底一排的浮窗显示在卡片上方 */
.leaf-tip:hover span {
    top: auto;
    bottom: 100%;
    margin-top: 0;
    margin-bottom: 8px;
}

/* ===== 隐藏备注 ===== */
.tree.hide-notes .note-text {
    display: none;
}

/* ===== 切换按钮 ===== */
.btn-toggle-note {
    background: #fff;
    color: #8a7a6a;
    border: 1.5px solid #d4b8a0;
    border-radius: 8px;
    cursor: pointer;
    font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
    transition: all 0.25s ease;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.btn-toggle-note:hover {
    background: #fdf8f4;
    border-color: #b8835a;
    color: #5a3e2b;
    box-shadow: 0 3px 12px rgba(184,131,90,0.15);
    transform: translateY(-1px);
}

/* ===== 世系缩放按钮 ===== */
.tree-zoom {
    position: fixed;
    right: 24px;
    bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 90;
}
.zoom-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1.5px solid #d4b8a0;
    background: #fff;
    color: #5a3e2b;
    font-size: 20px;
    font-weight: 300;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(90,62,43,0.1);
    transition: all 0.2s;
    user-select: none;
    line-height: 1;
}
.zoom-btn:hover {
    background: #fdf8f4;
    border-color: #b8835a;
    box-shadow: 0 3px 12px rgba(184,131,90,0.2);
    transform: scale(1.08);
}
.zoom-btn:active {
    transform: scale(0.95);
}
.zoom-label {
    font-size: 12px;
    color: #8a7a6a;
    background: rgba(255,255,255,0.85);
    padding: 2px 8px;
    border-radius: 10px;
    border: 1px solid #d4b8a0;
    white-space: nowrap;
}
.zoom-note {
    font-size: 15px;
    cursor: pointer;
}
.zoom-note-off {
    opacity: 0.45;
}

/* ===== SVG 图标在圆形按钮中居中 ===== */
.zoom-btn svg {
    display: block;
}

/* ===== 导出加载旋转动画 ===== */
.zoom-btn-loading {
    pointer-events: none;
    opacity: 0.7;
}
.zoom-btn-loading svg {
    display: none;
}
.zoom-btn-loading::after {
    content: '';
    display: block;
    width: 16px;
    height: 16px;
    border: 2px solid #e8ddd4;
    border-top-color: #5a3e2b;
    border-radius: 50%;
    animation: zoom-spin 0.7s linear infinite;
    box-sizing: border-box;
}
@keyframes zoom-spin {
    to { transform: rotate(360deg); }
}

/* ===== 响应式 ===== */
@media (max-width: 900px) {
    .tree ul {
        padding-top: 15px;
    }
    .tree li {
        padding: 15px 3px 0 3px;
    }
    .tree li a {
        padding: 3px 8px;
        font-size: 10px;
    }
    .tree li a h1 {
        font-size: 12px;
    }
    .tree ul::before { height: 15px; }
    .tree li::before,
    .tree li::after { height: 15px; }
}
