/* ============================================================
 * 世系表专用样式 (lineage_table.css)
 * 复用 theme.css 的 CSS 变量,保持书卷风视觉连贯
 * 布局:横向滚动表格,行=世次,父亲用colspan合并子女列
 * ============================================================ */

/* 页面容器 */
.lineage-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-md);
}

/* 顶部标题栏 */
.lineage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--line);
}

.lineage-header h1 {
    color: var(--ink);
    font-family: var(--font-display);
    font-size: var(--fs-title);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
}

.lineage-header-actions {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
    flex-shrink: 0;
}

/* 返回按钮 */
.lineage-btn {
    padding: 8px 16px;
    text-decoration: none;
    border: 1px solid var(--ink-faint);
    border-radius: var(--radius-sm);
    color: var(--ink);
    font-size: var(--fs-body);
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    transition: all 0.25s ease;
    min-height: 40px;
    white-space: nowrap;
}

.lineage-btn:hover {
    background: var(--paper-deep);
    border-color: var(--ink);
}

/* 说明栏 */
.lineage-tip {
    background: var(--paper-deep);
    border-left: 3px solid var(--gold);
    padding: var(--space-sm) var(--space-md);
    margin-bottom: var(--space-md);
    border-radius: var(--radius-sm);
    color: var(--ink-soft);
    font-size: var(--fs-caption);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.lineage-tip .fa-info-circle {
    color: var(--gold-deep);
    flex-shrink: 0;
}

/* ===== 横向滚动容器 ===== */
.lineage-scroll {
    overflow-x: auto;
    overflow-y: visible;
    padding: var(--space-sm) 0 var(--space-lg);
    /* 滚动条美化(书卷风) */
    scrollbar-color: var(--gold) var(--paper-deep);
    scrollbar-width: thin;
}

.lineage-scroll::-webkit-scrollbar {
    height: 12px;
}

.lineage-scroll::-webkit-scrollbar-track {
    background: var(--paper-deep);
    border-radius: var(--radius-sm);
}

.lineage-scroll::-webkit-scrollbar-thumb {
    background: var(--gold);
    border-radius: var(--radius-sm);
}

.lineage-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--gold-deep);
}

/* ===== 世系表 ===== */
.lineage-table {
    border-collapse: collapse;
    table-layout: fixed;
    /* min-width 由模板内联 style 动态设置(列数 × 70px) */
    background: var(--paper-light);
}

/* 每行高度固定,便于对齐 */
.lineage-table tr.gen-row {
    height: 60px;
}

/* 世次标签列:sticky 固定,滚动时始终可见 */
.lineage-table .gen-label {
    position: sticky;
    left: 0;
    z-index: 10;
    background: var(--gold);
    color: var(--paper);
    font-family: var(--font-display);
    font-size: var(--fs-body);
    font-weight: 700;
    text-align: center;
    padding: var(--space-sm) var(--space-xs);
    border: 1px solid var(--gold-deep);
    min-width: 80px;
    width: 80px;
    max-width: 80px;
    letter-spacing: 0.05em;
    box-shadow: 2px 0 4px rgba(74, 60, 40, 0.1);
}

/* 无世次标签特殊色 */
.lineage-table .gen-label.zero-gen {
    background: var(--ink-faint);
    border-color: var(--ink-soft);
}

/* 人员单元格 */
.lineage-table .person-cell {
    border: 1px solid var(--line);
    padding: 4px 2px;
    text-align: center;
    vertical-align: middle;
    background: var(--paper);
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
    min-width: 70px;
}

.lineage-table .person-cell:hover {
    background: var(--paper-deep);
    transform: scale(1.05);
    z-index: 5;
    box-shadow: 0 2px 8px rgba(74, 60, 40, 0.15);
}

/* 占位空单元格 */
.lineage-table .empty-cell {
    border: 1px dashed var(--line-soft);
    background: transparent;
    min-width: 70px;
}

/* 姓名:大字加粗,墨色 */
.cell-name {
    font-family: var(--font-display);
    font-size: var(--fs-body);
    font-weight: 700;
    color: var(--ink);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 配偶:小字,朱砂色调,另起一行 */
.cell-spouse {
    font-size: 11px;
    color: var(--cinnabar);
    line-height: 1.2;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* colspan 较大的单元格(多子女的父亲)强调显示 */
.lineage-table .person-cell[colspan] {
    background: var(--paper-light);
}

.lineage-table .person-cell[colspan]:hover {
    background: var(--paper-deep);
}

/* ===== 移动端适配 ===== */
@media (max-width: 768px) {
    .lineage-header {
        flex-wrap: wrap;
    }

    .lineage-header h1 {
        font-size: var(--fs-sub);
    }

    /* 移动端缩小单元格和字号(min-width 由模板内联设置) */
    .lineage-table tr.gen-row {
        height: 50px;
    }

    .lineage-table .gen-label {
        min-width: 60px;
        width: 60px;
        max-width: 60px;
        font-size: var(--fs-caption);
    }

    .lineage-table .person-cell {
        min-width: 60px;
    }

    .cell-name {
        font-size: var(--fs-caption);
    }

    .cell-spouse {
        font-size: 10px;
    }
}

/* ============================================================
 * 族人信息弹窗(与 family_tree_book.css 共用样式,此处复制保持独立)
 * ============================================================ */

/* 遮罩层 */
.person-modal-mask {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 26, 26, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}
.person-modal-mask.show {
    opacity: 1;
    visibility: visible;
}

/* 弹窗主体 */
.person-modal {
    background: var(--paper-light);
    border: 1px solid var(--gold);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(74, 60, 40, 0.3);
    width: 90%;
    max-width: 720px;
    max-height: 88vh;
    overflow-y: auto;
    position: relative;
    transform: scale(0.92);
    transition: transform 0.25s ease;
}
.person-modal-mask.show .person-modal {
    transform: scale(1);
}

/* 关闭按钮 */
.modal-close-btn {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--paper-deep);
    color: var(--ink);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s ease;
}
.modal-close-btn:hover {
    background: var(--cinnabar);
    color: var(--paper);
}

/* 加载中 */
.modal-loading {
    padding: var(--space-xl);
    text-align: center;
    color: var(--ink-soft);
    font-size: var(--fs-body);
}

/* 弹窗内容:左右两栏 */
.modal-body {
    display: flex;
    gap: var(--space-md);
    padding: var(--space-lg);
}

/* 左栏:照片 + 姓名 + 世次徽章 */
.modal-left {
    flex: 0 0 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--space-sm);
    padding-top: var(--space-sm);
}

.modal-photo-box {
    width: 150px;
    height: 180px;
    border: 2px solid var(--line);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--paper-deep);
    color: var(--ink-faint);
}
.modal-photo-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.modal-name {
    font-family: var(--font-display);
    font-size: var(--fs-sub);
    color: var(--ink);
    margin: 0;
    font-weight: 700;
}

.modal-gen-badge {
    background: var(--gold);
    color: var(--paper);
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-size: var(--fs-caption);
    font-family: var(--font-display);
    font-weight: 700;
}

/* 右栏:详细信息 */
.modal-right {
    flex: 1;
    min-width: 0;
}

.modal-section {
    margin-bottom: var(--space-md);
}
.modal-section:last-child {
    margin-bottom: 0;
}
.modal-section h3 {
    font-family: var(--font-display);
    font-size: var(--fs-body-lg);
    color: var(--ink);
    border-bottom: 1px solid var(--line);
    padding-bottom: var(--space-xs);
    margin-bottom: var(--space-sm);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

/* 信息行:标签 + 值 */
.modal-info-row {
    display: flex;
    margin-bottom: 6px;
    font-size: var(--fs-body);
    line-height: 1.6;
}
.modal-info-label {
    flex: 0 0 80px;
    color: var(--ink-faint);
    font-weight: 500;
}
.modal-info-value {
    flex: 1;
    color: var(--ink);
    word-break: break-all;
}

/* 配偶照片预览 */
.modal-photo-preview img {
    max-width: 150px;
    max-height: 180px;
    border: 2px solid var(--line);
    border-radius: var(--radius-md);
    object-fit: cover;
}

/* 弹窗移动端:左右栏改上下 */
@media (max-width: 600px) {
    .modal-body {
        flex-direction: column;
    }
    .modal-left {
        flex: none;
    }
}
