.timeline-container {
    max-width: 100%;
    margin: 0 auto;
}

.timeline-title {
    text-align: center;
    margin-bottom: 80px;
}

.timeline-title h1 {
    color: #1a365d;
    margin-bottom: 15px;
    font-weight: 800;
}

.timeline-title p {
    color: #718096;
    max-width: 800px;
    margin: 0 auto;
}

/* 時間軸容器 */
.timeline {
    position: relative;
    padding: 0px 0 0px 0;
}

/* 主時間軸線 */
.main-timeline-line {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 4px;
    background: transparent;
    transform: translateX(-50%);
    z-index: 1;
}

/* 每個年份的時間軸項目 - 放慢動畫 */
.timeline-item {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
    margin-bottom: 20px;
    padding-top: 50px;
    position: relative;
    opacity: 0;
    transform: translateY(50px);
    transition: opacity 1.2s ease, transform 1.2s ease;
}

.timeline-item.active {
    opacity: 1;
    transform: translateY(0);
}

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

/* 每個年份自己的時間軸線段 - 放慢動畫 */
.item-timeline-line {
    position: absolute;
    left: 50%;
    top: 50px;
    width: 4px;
    height: calc(100% - 50px);
    transform: translateX(-50%);
    z-index: 3;
    opacity: 0;
    transition: opacity 1.5s ease 0.4s;
}

.timeline-item.active .item-timeline-line {
    opacity: 1;
}

/* 年份標記 - 放慢動畫 */
.year-marker {
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    color: #e53e3e;
    padding: 0;
    font-weight: bold;
    z-index: 4;
    min-width: auto;
    text-align: center;
    background: none;
    box-shadow: none;
    opacity: 0;
    transition: opacity 1.2s ease 0.3s, transform 1.2s ease 0.3s;
    transform: translateX(-50%) scale(0.8);
}

.timeline-item.active .year-marker {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* 時間軸節點 - 放慢動畫 */
.timeline-node {
    position: absolute;
    left: 50%;
    top: 50px;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    z-index: 4;
    border: 4px solid white;
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.1);
    opacity: 0;
    transition: opacity 1.2s ease 0.5s, transform 1.2s ease 0.5s;
    transform: translateX(-50%) scale(0);
}

.timeline-item.active .timeline-node {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* 內容區域 - 放慢動畫 */
.timeline-content {
    width: 45%;
    padding: 30px;
    border-radius: 15px;
    position: relative;
    opacity: 0;
    transform: translateX(-30px);
    transition: opacity 1.2s ease 0.6s, transform 1.2s ease 0.6s;
     box-sizing: border-box;  /* 添加這行 */
}

.timeline-item:nth-child(even) .timeline-content {
    transform: translateX(30px);
}

.timeline-item.active .timeline-content {
    opacity: 1;
    transform: translateX(0);
}

/* 左右交替佈局 - 調整間距避免超出 */
.timeline-item:nth-child(odd) .timeline-content {
    margin-right: 5%;
}

.timeline-item:nth-child(even) .timeline-content {
    margin-left: 5%;
    order: 2;
}

/* 內容標題 - 放慢動畫 */
.content-title {
    font-size: 25px;
    color: #e53e3e;
    padding-bottom: 10px;
    border-bottom: none;
    font-weight: 700;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1s ease 0.8s, transform 1s ease 0.8s;
}

.timeline-item.active .content-title {
    opacity: 1;
    transform: translateY(0);
}

/* 內容文字 - 放慢動畫 */
.content-text {
    color: #4a5568;
    margin-bottom: 15px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1s ease 0.9s, transform 1s ease 0.9s;
}

.timeline-item.active .content-text {
    opacity: 1;
    transform: translateY(0);
}

/* 圖片容器 - 調整寬度避免超出 */
.timeline-images {
    width: 45%;
    padding: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;  /* 添加這行 */
}

.timeline-item:nth-child(odd) .timeline-images {
    order: 2;
}

/* 圖片網格 - 保留原來的，但會被後面的覆蓋 */
.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 20px;
    width: 100%;
    
}

/* ========== 圖片區域 - 橫排顯示，調整間距避免超出 ========== */
.image-container {
    position: relative;
    border-radius: 12px;
    overflow: visible;
    height: auto;
    opacity: 0;
    transform: scale(0.8) translateY(30px);
    transition: opacity 1.5s ease 1s, transform 1.5s ease 1s;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: stretch;
    gap: 0px;
    padding: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin: 0 auto;  /* 確保居中 */
}

.image-box {
    overflow: hidden;
    border-radius: 12px;
    width: calc(33.333% - 17px);  /* 調整計算方式，配合加大間距 */
    min-width: 180px;  /* 最小寬度從200px減為180px */
    flex: 1 1 auto;
    position: relative;
    z-index: 9;
    background-color: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
   
    transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    aspect-ratio: 16/12;
    max-width: 100%;  /* 確保不超出 */
}

.image-box img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 12px;  /* 內邊距從15px減為12px */
    box-sizing: border-box;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Zoom in 動畫效果 */
.timeline-item.active .image-container {
    animation: gentleZoomIn 1.8s ease-out 1s forwards;
}

@keyframes gentleZoomIn {
    0% {
        transform: scale(0.9);
        opacity: 0.5;
    }
    60% {
        transform: scale(1.02);
        opacity: 0.9;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 根據圖片數量調整寬度 - 同時調整間距 */
/* 1張圖片 */
.image-container:has(.image-box:only-child) .image-box {
    width: 80%;
    max-width: 450px;  /* 從500px減為450px */
    aspect-ratio: 16/10;
}

/* 2張圖片 */
.image-container:has(.image-box:nth-child(2):last-child) .image-box {
    width: calc(50% - 13px);  /* 配合25px間距調整 */
    aspect-ratio: 4/3;
    max-width: 280px;  /* 增加最大寬度限制 */
}

/* 3張圖片 */
.image-container:has(.image-box:nth-child(3):last-child) .image-box {
    width: calc(33.333% - 17px);  /* 配合25px間距調整 */
    aspect-ratio: 1/1;
    max-width: 220px;  /* 增加最大寬度限制 */
}

/* 4張及以上圖片 */
.image-container:has(.image-box:nth-child(4)) .image-box {
    width: calc(25% - 19px);  /* 配合25px間距調整 */
    min-width: 140px;  /* 從160px減為140px */
    aspect-ratio: 1/1;
    max-width: 200px;  /* 增加最大寬度限制 */
}

/* 增強放大效果 - 更明顯的hover效果 */
.image-box:hover {
    transform: scale(1.08);
    z-index: 20;
    
}

.image-box:hover img {
    transform: scale(1.15);
}

/* 添加光暈效果 */
.image-box::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, rgba(255,255,255,0.8) 0%, rgba(255,255,255,0) 70%);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
    z-index: 10;
}

.image-box:hover::after {
    opacity: 0.3;
}

/* 響應式設計 */
@media (max-width: 992px) {
    .main-timeline-line {
        left: 40px;
    }
    
    .timeline-item {
        flex-direction: column;
        margin-bottom: 100px;
    }
    
    .item-timeline-line {
        left: 40px;
    }
    
    .year-marker {
        left: 40px;
    }
    
    .timeline-node {
        left: 40px;
    }
    
    .timeline-content,
    .timeline-images {
        width: calc(100% - 100px);
        margin-left: 100px !important;
        margin-right: 0 !important;
        order: 0 !important;
    }
    
    .timeline-images {
        margin-top: 30px;
        
    }

    .timeline-item:nth-child(even) .timeline-content {
        transform: translateX(0);
    }
    
    /* 圖片響應式 - 平板 */
    .image-container {
        gap: 20px;  /* 平板間距稍微縮小 */
    }
    
    .image-box {
        width: calc(33.333% - 14px) !important;
        min-width: 150px;
    }
}

@media (max-width: 768px) {
    .timeline-content,
    .timeline-images {
        width: calc(100% - 60px);
        margin-left: 60px !important;
    }
    
    /* 圖片響應式 - 手機 */
    .image-container {
        gap: 15px;  /* 手機間距再縮小 */
        padding: 8px;
    }
    
    .image-box {
        width: calc(50% - 8px) !important;
        min-width: 120px;
        aspect-ratio: 4/3;
    }
    
    .image-box:hover {
        transform: scale(1.05);
    }
}

@media (max-width: 576px) {
    .timeline-content,
    .timeline-images {
        width: calc(100% - 60px);
        margin-left: 60px !important;
    }
    
    .images-grid {
        grid-template-columns: 1fr;
    }
    
    /* 圖片響應式 - 小手機 */
    .image-container {
        gap: 12px;
        padding: 5px;
    }
    
    .image-box {
        width: 100% !important;
        aspect-ratio: 16/9;
        max-width: 100%;
    }
    
    .image-box:hover {
        transform: scale(1.03);
    }
}

/* 動畫效果 - 圖片進場 */
.timeline-item.active .image-container {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.timeline-item.active .image-box {
    animation: fadeInUp 0.8s ease forwards;
    opacity: 0;
    animation-fill-mode: forwards;
}

/* 為每個圖片設定不同的動畫延遲 */
.image-box:nth-child(1) { animation-delay: 0.2s; }
.image-box:nth-child(2) { animation-delay: 0.3s; }
.image-box:nth-child(3) { animation-delay: 0.4s; }
.image-box:nth-child(4) { animation-delay: 0.5s; }
.image-box:nth-child(5) { animation-delay: 0.6s; }
.image-box:nth-child(6) { animation-delay: 0.7s; }

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

/* 1200px以上超大屏幕 - 調整避免超出 */
@media (min-width: 1200px) {
    /* 調整左右間距避免圖片超出 */
    .timeline-item:nth-child(odd) .timeline-content {
        margin-right: 4%;
    }
    
    .timeline-item:nth-child(even) .timeline-content {
        margin-left: 4%;
    }
    
    /* 2個圖片時最大 - 加入最大寬度限制 */
    .image-container:has(.image-box:nth-child(2):last-child) .image-box img {
        max-height: 300px;  /* 從350px減為300px */
        max-width: 100%;
    }
    
    .image-container:has(.image-box:only-child) .image-box img {
        max-height: 350px;  /* 從380px減為350px */
        max-width: 100%;
    }
    
    /* 為所有圖片添加最大寬度限制 */
    .image-box {
        max-width: 280px;
    }
}

/* 單張圖片特殊處理 */
.image-container:has(.image-box:only-child) {
    justify-content: center;
}