/* ==================== Work Timeline 时间线布局样式 ==================== */

/* ===== CSS 变量：全局物理常量 ===== */
:root {
    --container-pad: 24px;
    /*
     * 时间轴「列」左缘 = .timeline-content 内容区左缘 = 每行栅格第一列左缘。
     * 圆心到该左缘的距离 = padding-left(.indicator-main-set) + 圆点半径
     *                    = (var(--dot-center) - var(--dot-half)) + var(--dot-half)
     *                    = var(--dot-center)
     * 竖线需向右偏移上述距离（再减 0.5px 使 1px 线几何中心过圆心）。
     */
    --dot-center: 24px;
    --dot-size: 12px;
    --dot-half: 6px;
    --indicator-col-width: 160px;
}

/* ===== 整体布局 ===== */
.work-timeline-section {
    /* padding 由 index.html 中 section#work.work 统一控制 */
    margin: 0;
    position: relative;
}

.timeline-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--container-pad);
    position: relative;
}

/* ===== 垂直时间线线条（相对 .timeline-content：left = 圆心到时间轴列左缘）===== */
.timeline-line-track {
    position: absolute;
    top: 0;
    bottom: 0;
    /* left 原点 = 时间轴列左缘；偏移量 = 圆心到左缘的距离 var(--dot-center)，再减半线宽对齐圆心 */
    left: calc(var(--dot-center) - 0.5px);
    width: 1px;
    background: transparent;
    pointer-events: none;
    z-index: 1;
}

.timeline-line-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: linear-gradient(
        to bottom,
        #111111 0%,
        #555555 40%,
        #aaaaaa 70%,
        #e0e0e0 100%
    );
    will-change: height;
    transition: height 0.05s linear;
}

.timeline-line-fade {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 80px;
    background: linear-gradient(
        to bottom,
        transparent,
        rgba(255, 255, 255, 0.6)
    );
    pointer-events: none;
}

/* ===== 时间线内容区：竖线 + 栅格共用本盒坐标系（position 参照）===== */
.timeline-content {
    padding-left: 0;
    border-left: none;
    position: relative;
    width: 100%;
}

/* 动态插入的年份行容器（与线条兄弟，避免 innerHTML 清空线条） */
#works-timeline {
    width: 100%;
}

/* ===== 时间线组 ===== */
.timeline-group {
    display: grid;
    grid-template-columns: var(--indicator-col-width) 1fr;
    gap: 0 20px;
    margin-bottom: var(--section-gap, 80px);
    opacity: 0;
    transform: translateY(40px);
    transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
    position: relative;
}

.timeline-group.revealed {
    opacity: 1;
    transform: translateY(0);
}

.timeline-group:last-child {
    margin-bottom: var(--section-gap, 80px);
}

/* ===== 指示器列（左侧）===== */
.timeline-indicator-col {
    position: relative;
    z-index: 2;
}

.sticky-indicator-wrapper {
    position: sticky;
    top: 120px;
    height: auto;
}

/* 核心 Flex 容器：圆点 + 年份，gap: 16px */
/* padding-left = 圆心 x - 圆点半径，与 .timeline-line-track 共用 --dot-center */
.indicator-main-set {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-left: calc(var(--dot-center) - var(--dot-half));
}

/* ===== 呼吸圆点 ===== */
.breathing-dot {
    position: relative;
    width: var(--dot-size);
    height: var(--dot-size);
    background: #e0e0e0;
    border: 1.5px solid #cccccc;
    border-radius: 50%;
    flex-shrink: 0;
    z-index: 300;
    transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Halo 光晕环 */
.halo {
    position: absolute;
    inset: -4px;
    border: 1.5px solid #111;
    border-radius: 50%;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ===== 年份标签 ===== */
.year-label {
    font-size: 36px;
    font-weight: 800;
    color: #999;
    line-height: 1;
    letter-spacing: -1px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.timeline-group.revealed .year-label {
    opacity: 1;
    transform: translateY(0);
}

/* ===== 激活状态（当前年份滚动到视口时）===== */
.timeline-group.is-active .breathing-dot {
    background: #111;
    border-color: #111;
}

.timeline-group.is-active .halo {
    opacity: 1;
    transform: scale(1);
    animation: haloPulse 2.5s ease-in-out infinite;
}

.timeline-group.is-active .year-label {
    color: #111;
}

/* ===== 作品卡片（隐式容器设计） - 浅色主题适配===== */
.timeline-card {
    background: #ffffff;
    border: 1px solid #f8fafc;
    border-radius: 16px;
    padding: var(--spacing-5); /* 24px，四周统一内边距 */
    cursor: pointer;
    transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.timeline-card:last-child {
    margin-bottom: 0;
}

.timeline-card:hover {
    background: #ffffff;
    border-color: #111111;
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

/* 封面图包装器 - 16:9 比例，圆角 16px */
.timeline-card-cover-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%;
    overflow: hidden;
    border-radius: 16px;
    margin-top: var(--spacing-5); /* 24px，与标题区保持间距 */
}

.timeline-card-cover {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border-radius: 16px;
}

.timeline-card-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 0;
}

.timeline-card-badge {
    position: absolute;
    top: 16px;
    right: 16px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    color: #111;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.timeline-card-title {
    font-size: var(--font-size-lg); /* 20px */
    font-weight: 600;
    color: #111111;
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.timeline-card-desc {
    font-size: var(--font-size-base); /* 16px */
    color: #666666;
    line-height: 1.6;
    margin: 0 0 12px 0;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.timeline-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.timeline-card-category {
    font-size: var(--font-size-sm); /* 14px */
    color: #999999;
    font-weight: 400;
    line-height: 1.5;
}

.timeline-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-2); /* 8px */
}

.timeline-card-tag {
    font-size: var(--font-size-xs); /* 12px */
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.06);
    color: #111111;
    border-radius: 12px;
    display: inline-block;
    font-weight: 500;
    line-height: 1;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.timeline-card:hover .timeline-card-tag {
    background: #111111;
    color: #ffffff;
}

/* 密码按钮 - 位于封面图下方 */
.timeline-password-btn {
    margin-top: var(--spacing-5); /* 24px，与封面图间距 */
}

/* ===== 作品卡片网格布局 ===== */
.timeline-cards-grid {
    display: flex;
    flex-direction: column;
    gap: var(--card-gap, 24px);
}

/* ===== 作品卡片（使用 WorkCard 组件样式）===== */
.timeline-cards-grid .work-card {
    margin-bottom: 0;
}

.timeline-cards-grid .work-card:last-child {
    margin-bottom: 0;
}

/* ===== 卡片入场动画（交错）===== */
.timeline-card {
    opacity: 0;
    transform: translateY(30px);
}

/* WorkCard 组件卡片的动画 */
.timeline-group.revealed .timeline-cards-grid .work-card {
    animation: cardReveal 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* WorkCard 组件卡片的 nth-child 动画延迟 */
.timeline-group.revealed .timeline-cards-grid .work-card:nth-child(1) { animation-delay: 0.1s; }
.timeline-group.revealed .timeline-cards-grid .work-card:nth-child(2) { animation-delay: 0.2s; }
.timeline-group.revealed .timeline-cards-grid .work-card:nth-child(3) { animation-delay: 0.3s; }
.timeline-group.revealed .timeline-cards-grid .work-card:nth-child(4) { animation-delay: 0.4s; }
.timeline-group.revealed .timeline-cards-grid .work-card:nth-child(5) { animation-delay: 0.5s; }
.timeline-group.revealed .timeline-cards-grid .work-card:nth-child(6) { animation-delay: 0.6s; }

/* 保留原有的 timeline-card 样式兼容 */
.timeline-group.revealed .timeline-card {
    animation: cardReveal 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.timeline-group.revealed .timeline-card:nth-child(1) { animation-delay: 0.1s; }
.timeline-group.revealed .timeline-card:nth-child(2) { animation-delay: 0.2s; }
.timeline-group.revealed .timeline-card:nth-child(3) { animation-delay: 0.3s; }
.timeline-group.revealed .timeline-card:nth-child(4) { animation-delay: 0.4s; }
.timeline-group.revealed .timeline-card:nth-child(5) { animation-delay: 0.5s; }
.timeline-group.revealed .timeline-card:nth-child(6) { animation-delay: 0.6s; }

@keyframes cardReveal {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== 滚动进度指示器 ===== */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, #111, #666);
    z-index: 1001;
    transition: width 0.1s linear;
}

/* ===== Halo 脉冲动画 ===== */
@keyframes haloPulse {
    0%, 100% {
        transform: scale(1.1);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.5);
        opacity: 0;
    }
}
/* ===== 平板端 & 移动端 - 横向时间线（年份 + 横线 + 圆点）===== */
.timeline-mobile-header {
    display: none;
    margin-bottom: 32px;
    position: relative;
}

.timeline-mobile-header-inner {
    display: flex;
    align-items: center;
    gap: 12px;
}

.timeline-mobile-year {
    font-size: 36px;
    font-weight: 800;
    color: #999;
    letter-spacing: -1px;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.5s ease;
}

.timeline-mobile-line-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    position: relative;
}

.timeline-mobile-line {
    width: 100%;
    height: 1px;
    background: #e0e0e0;
    position: relative;
    overflow: visible;
}

.timeline-mobile-dot {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translate(50%, -50%);
    width: var(--dot-size);
    height: var(--dot-size);
    background: #e0e0e0;
    border: 1.5px solid #cccccc;
    border-radius: 50%;
    z-index: 3;
    transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.timeline-mobile-dot .halo {
    position: absolute;
    inset: -4px;
    border: 1.5px solid #111;
    border-radius: 50%;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* 激活状态 */
.timeline-group.is-active .timeline-mobile-year {
    color: #111;
}

.timeline-group.is-active .timeline-mobile-dot {
    background: #111;
    border-color: #111;
}

.timeline-group.is-active .timeline-mobile-dot .halo {
    opacity: 1;
    transform: scale(1);
    animation: haloPulse 2.5s ease-in-out infinite;
}

/* ==================== 平板端适配（768px - 1023px）==================== */
/* 布局：页边距 | 时间轴 | gap | 卡片 | 页边距 */
/* 设计规范：页边距 24px */
@media (max-width: 1023px) {
    :root {
        --container-pad: 24px;
        --indicator-col-width: 120px; /* 平板端时间轴宽度 */
    }

    .timeline-container {
        padding: 0 0px;
    }

    /* 时间轴宽度 + 卡片自动充满 */
    .timeline-group {
        grid-template-columns: 120px 1fr;
        gap: 0 16px; /* gap: 16px */
        margin-bottom: var(--section-gap, 64px);
    }

    .timeline-group:last-child {
        margin-bottom: var(--section-gap, 64px);
    }

    /* 平板端年份：流体字号；与 HTML 中 <wbr> 配合折行 */
    .year-label {
        font-size: clamp(1.5rem, 2.5vw + 0.75rem, 1.75rem); /* 24px - 28px */
        letter-spacing: -0.5px;
        word-break: normal;
        overflow-wrap: break-word;
        white-space: normal;
        line-height: 1.2;
    }

    .indicator-main-set {
        gap: 12px;
    }

    .timeline-card {
        border-radius: 12px;
        padding: 24px;
    }

    .timeline-card-body {
        flex: 0 0 auto;
    }

    .timeline-card-tags {
        min-height: 1.5rem;
    }

    .timeline-card-title {
        font-size: 18px; /* 平板端 18px */
        font-weight: 600;
        line-height: 1.4;
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .timeline-card-desc {
        font-size: var(--font-size-base); /* 16px 平板端与 PC 相同 */
        font-weight: 400;
        line-height: 1.6;
    }

    .timeline-card-category {
        font-size: var(--font-size-sm); /* 14px 平板端与 PC 相同 */
        font-weight: 400;
        line-height: 1.5;
    }

    .timeline-card-tag {
        font-size: var(--font-size-xs); /* 12px 平板端与 PC 相同 */
        line-height: 1;
    }

    .timeline-card-cover-wrapper {
        border-radius: 12px;
    }

    .timeline-card-cover {
        border-radius: 12px;
    }
}

/* ==================== 移动端适配（≤767px）==================== */
/* 布局：页边距 | 时间轴（固定列宽=最长折行年份）| gap | 卡片 | 页边距 */
/* 设计规范：页边距 16px */
@media (max-width: 767px) {
    :root {
        --container-pad: 16px;
        --dot-center: 10px;          /* 圆心 x 坐标 */
        --dot-half: 5px;             /* 圆点半径 */
        /*
         * 时间轴列固定宽度：圆点 + gap + 「2020-<wbr>-2021」折行后所需宽度（各年份行对齐）
         * 10 + 8 + ~64 ≈ 82，留余量避免截断
         */
        --timeline-indicator-col-mobile: 5.75rem; /* 92px @16px */
    }

    .timeline-container {
        padding: 0 0px;
    }

    .timeline-group {
        grid-template-columns: var(--timeline-indicator-col-mobile) 1fr;
        gap: 0 12px;
        margin-bottom: var(--section-gap, 32px);
    }

    .timeline-group:last-child {
        margin-bottom: var(--section-gap, 32px);
    }

    .timeline-indicator-col {
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    /* 移动端年份：<wbr> 处折行，避免任意字符断开 */
    .year-label {
        font-size: clamp(1.25rem, 3vw + 0.5rem, 1.5rem); /* 20px - 24px */
        letter-spacing: 0;
        word-break: normal;
        overflow-wrap: break-word;
        white-space: normal;
        line-height: 1.2;
        display: block;
        min-width: 0;
        flex: 1;
    }

    .indicator-main-set {
        flex-wrap: nowrap;
        align-items: center;
        gap: 8px;
        padding-left: calc(var(--dot-center) - var(--dot-half));
        box-sizing: border-box;
    }

    .breathing-dot {
        width: 10px;
        height: 10px;
        flex-shrink: 0;
    }

    .timeline-card {
        border-radius: 12px;
        padding: 16px;
        /* 统一卡片骨架：正文区最小高度 + 封面固定比例 */
        min-height: 0;
    }

    .timeline-card-body {
        flex: 0 0 auto;
    }

    .timeline-card-title {
        font-size: 16px; /* 移动端 16px */
        font-weight: 600;
        line-height: 1.4;
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .timeline-card-tags {
        min-height: 1.5rem;
    }

    .timeline-card-desc {
        font-size: 15px; /* 移动端 15px */
        font-weight: 400;
        line-height: 1.5;
    }

    .timeline-card-category {
        font-size: 13px; /* 移动端 13px */
        font-weight: 400;
        line-height: 1.5;
    }

    .timeline-card-tag {
        font-size: 12px; /* 移动端 12px（保底线） */
        line-height: 1;
    }

    .timeline-mobile-year {
        font-size: clamp(1.5rem, 4vw + 0.75rem, 2.25rem); /* 24px - 36px */
    }

    /* 封面区：用 aspect-ratio 定高，去掉 padding-top 16:9 占位，与 4:3 一致 */
    .timeline-card-cover-wrapper {
        border-radius: 12px;
        padding-top: 0;
        aspect-ratio: 4 / 3;
        flex-shrink: 0;
    }

    .timeline-card-cover {
        border-radius: 12px;
    }
}

/* ===== 暗色模式适配（首页 body.dark-theme）===== */
body.dark-theme .timeline-group {
    opacity: 1;
    transform: none;
}

body.dark-theme .timeline-indicator-col {
    opacity: 0.4;
    transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

body.dark-theme .timeline-indicator-col.is-active {
    opacity: 1;
}

body.dark-theme .year-label {
    color: rgba(255, 255, 255, 0.3);
    transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

body.dark-theme .timeline-indicator-col.is-active .year-label,
body.dark-theme .timeline-group.is-active .year-label {
    color: #ffffff;
}

body.dark-theme .breathing-dot {
    background: rgba(255, 255, 255, 0.3);
}

body.dark-theme .timeline-indicator-col.is-active .breathing-dot,
body.dark-theme .timeline-group.is-active .breathing-dot {
    background: #ffffff;
}

body.dark-theme .breathing-dot .halo {
    background: rgba(255, 255, 255, 0.15);
}

body.dark-theme .timeline-indicator-col.is-active .breathing-dot .halo,
body.dark-theme .timeline-group.is-active .breathing-dot .halo {
    background: rgba(255, 255, 255, 0.3);
}

/* 暗色模式下线条渐变 */
body.dark-theme .timeline-line-fill {
    background: linear-gradient(
        to bottom,
        #ffffff 0%,
        #888888 40%,
        #444444 70%,
        #222222 100%
    );
}

body.dark-theme .timeline-line-fade {
    background: linear-gradient(
        to bottom,
        transparent,
        rgba(17, 17, 17, 0.6)
    );
}

/* 暗色模式下卡片样式 */
body.dark-theme .timeline-card {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark-theme .timeline-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.2);
}

body.dark-theme .timeline-card-title {
    color: rgba(255, 255, 255, 0.9);
}

body.dark-theme .timeline-card-tag {
    color: rgba(255, 255, 255, 0.5);
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
}

/* ==================== 骨架屏样式 ==================== */
/* 封面图骨架屏 - 浅色系 */
.timeline-card-cover-wrapper.skeleton-light {
    background: #f0f0f0;
}
