/* 垂直时间轴专用样式 */
#timeline {
    position: relative;
    padding: 0 4rem;
}

/* 时间轴中心线 */
#timeline::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, #d4af37 0%, #8b6f47 50%, #d4af37 100%);
    transform: translateX(-50%);
    border-radius: 2px;
}

/* 时间刻度 */
.timeline-markers {
    position: absolute;
    left: 50%;
    top: 0;
    height: 100%;
    width: 0;
}

.marker-year {
    position: absolute;
    transform: translateY(-50%);
    font-weight: 600;
    color: #8b6f47;
    font-size: 0.9rem;
    width: 100px;
}

.marker-year::before {
    content: '';
    position: absolute;
    height: 2px;
    width: 20px;
    background: #8b6f47;
    top: 50%;
    transform: translateY(-50%);
}

.marker-year.left {
    right: 20px;
    text-align: right;
}

.marker-year.left::before {
    right: -20px;
}

.marker-year.right {
    left: 20px;
    text-align: left;
}

.marker-year.right::before {
    left: -20px;
}

.marker-year.major::before {
    width: 30px;
    background: #d4af37;
}

.marker-year.major {
    color: #d4af37;
    font-weight: 700;
    font-size: 1rem;
}

/* 人物节点 */
.person-node {
    position: absolute;
    left: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
}

.person-node.male {
    transform: translateX(-100%);
    margin-left: -20px;
}

.person-node.female {
    transform: translateX(0);
    margin-left: 20px;
}

.person-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #d4af37;
    border: 4px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    position: relative;
    transition: all 0.3s ease;
}

.person-node:hover .person-dot {
    transform: scale(1.5);
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.6);
}

.person-node.active .person-dot {
    transform: scale(1.8);
    background: #e67e22;
    box-shadow: 0 4px 20px rgba(230, 126, 34, 0.7);
}

.person-label {
    position: absolute;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.95);
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    top: 50%;
    transform: translateY(-50%);
}

.person-node.male .person-label {
    right: 30px;
}

.person-node.female .person-label {
    left: 30px;
}

.person-node:hover .person-label {
    background: #d4af37;
    color: #fff;
}

/* 生卒年连线（矩形） */
.person-lifespan {
    position: absolute;
    width: 10px;
    opacity: 0.7;
    transition: all 0.3s ease;
    z-index: 5;
}

.person-lifespan.male {
    background: linear-gradient(180deg, #3498db, #2980b9);
    border-radius: 2px;
}

.person-lifespan.female {
    background: linear-gradient(180deg, #e84393, #c0392b);
    border-radius: 2px;
}

/* 生卒年端点标记短线 */
.person-lifespan::before,
.person-lifespan::after {
    content: '';
    position: absolute;
    height: 2px;
    background: inherit;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
}

.person-lifespan::before {
    top: 0;
}

.person-lifespan::after {
    bottom: 0;
}

/* 男性人物连线偏移样式 */
.person-lifespan.male.offset-0 {
    left: calc(50% - 40px);
}

.person-lifespan.male.offset-1 {
    left: calc(50% - 60px);
}

.person-lifespan.male.offset-2 {
    left: calc(50% - 80px);
}

.person-lifespan.male.offset-3 {
    left: calc(50% - 100px);
}

/* 女性人物连线偏移样式 */
.person-lifespan.female.offset-0 {
    left: calc(50% + 32px);
}

.person-lifespan.female.offset-1 {
    left: calc(50% + 52px);
}

.person-lifespan.female.offset-2 {
    left: calc(50% + 72px);
}

.person-lifespan.female.offset-3 {
    left: calc(50% + 92px);
}

/* 人物节点偏移样式 */
.person-node.male.offset-0 {
    transform: translateX(-100%);
    margin-left: -40px;
}

.person-node.male.offset-1 {
    transform: translateX(-100%);
    margin-left: -60px;
}

.person-node.male.offset-2 {
    transform: translateX(-100%);
    margin-left: -80px;
}

.person-node.male.offset-3 {
    transform: translateX(-100%);
    margin-left: -100px;
}

.person-node.female.offset-0 {
    transform: translateX(0);
    margin-left: 32px;
}

.person-node.female.offset-1 {
    transform: translateX(0);
    margin-left: 52px;
}

.person-node.female.offset-2 {
    transform: translateX(0);
    margin-left: 72px;
}

.person-node.female.offset-3 {
    transform: translateX(0);
    margin-left: 92px;
}

.person-lifespan:hover {
    opacity: 1;
    width: 12px;
}

.person-lifespan.active {
    opacity: 1;
    width: 12px;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.7);
}

/* 朝代分区 */
.dynasty-section {
    position: absolute;
    left: 0;
    width: 100%;
    border-top: 2px dashed rgba(139, 111, 71, 0.3);
    padding: 1rem 0;
}

.dynasty-name {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    font-weight: 700;
    color: rgba(139, 111, 71, 0.6);
    letter-spacing: 2px;
}

/* 故事线高亮 */
.storyline-highlight .person-lifespan {
    opacity: 0.3;
}

.storyline-highlight .person-lifespan.storyline-active {
    opacity: 1;
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.8);
}

.storyline-highlight .person-node {
    opacity: 0.4;
}

.storyline-highlight .person-node.storyline-active {
    opacity: 1;
}

/* 移除容器内滚动，使用页面滚动 */
.timeline-container {
    overflow: visible;
    max-height: none;
}

/* 响应式调整 */
/* 平板端适配 */
@media (max-width: 1199px) {
    #timeline {
        padding: 0 3rem;
    }
    
    .person-label {
        font-size: 0.8rem;
        padding: 0.25rem 0.5rem;
        max-width: 120px;
    }
    
    .marker-year {
        font-size: 0.85rem;
        width: 80px;
    }
    
    .dynasty-name {
        font-size: 1.1rem;
        left: 15px;
    }
}

/* 移动端适配 */
@media (max-width: 768px) {
    #timeline {
        padding: 0 1rem;
    }
    
    .person-label {
        font-size: 0.75rem;
        padding: 0.2rem 0.4rem;
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .marker-year {
        font-size: 0.8rem;
        width: 70px;
    }
    
    .dynasty-name {
        font-size: 1rem;
        left: 10px;
        writing-mode: vertical-rl;
    }

    .timeline-container {
        overflow: visible;
        max-height: none;
        padding: 1rem !important;
    }
    
    /* 移动端优化触摸点击区域 */
    .person-node {
        padding: 10px;
        margin: -10px;
    }
    
    .person-dot {
        width: 24px;
        height: 24px;
    }
    
    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }
}
