/* --- Timeline Container Styles --- */
#timeline-container {
    width: 100%;
    max-width: 900px;
    margin: 3rem auto;
    padding: 0 1rem;
    box-sizing: border-box;
}

/* --- Timeline Container Styles --- */
#main-timeline-container { /* Changed from #timeline-container to #main-timeline-container */
    width: 100%;
    max-width: 900px;
    margin: 3rem auto;
    padding: 0 1rem;
    box-sizing: border-box;
    position: relative; /* For the central line */
}

#main-timeline-container::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: var(--separator-color);
    transform: translateX(-50%);
}

.timeline-group {
    margin-bottom: 3rem;
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

/* Odd groups (1st, 3rd, ...) start from the left */
.timeline-group:nth-child(odd) {
    flex-direction: row;
}
.timeline-group:nth-child(odd) .timeline-date-info {
    text-align: right;
    padding-right: 3.5rem; /* Space between date/description and line */
}
.timeline-group:nth-child(odd) .timeline-date::before {
    right: calc(-11px - 1.5rem); /* Position on the right side of the date for odd groups, aligned with center line */
    left: auto;
}
.timeline-group:nth-child(odd) .timeline-photos-grid {
    text-align: left;
    padding-left: 2rem; /* Space between line and photos */
}

/* Even groups (2nd, 4th, ...) start from the right */
.timeline-group:nth-child(even) {
    flex-direction: row-reverse; /* Reverse order for right side */
}
.timeline-group:nth-child(even) .timeline-date-info {
    text-align: left;
    padding-left: 3.5rem; /* Space between date/description and line */
}
.timeline-group:nth-child(even) .timeline-date::before {
    left: calc(-11px - 1.5rem); /* Position on the left side of the date for even groups, aligned with center line */
    right: auto;
}
.timeline-group:nth-child(even) .timeline-photos-grid {
    text-align: right;
    padding-right: 2rem; /* Space between line and photos */
}

.timeline-date-info {
    flex: 0 0 45%; /* Take 45% width */
    box-sizing: border-box;
    display: flex;
    flex-direction: column; /* Stack date and description vertically */
    align-items: inherit; /* Inherit alignment from parent for odd/even */
}

.timeline-group:nth-child(odd) .timeline-date-info {
    align-items: flex-end; /* Align content to the right for odd groups */
}

.timeline-group:nth-child(even) .timeline-date-info {
    align-items: flex-start; /* Align content to the left for even groups */
}

.timeline-date {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 0.5rem; /* Space between date and description */
    position: relative;
    box-sizing: border-box;
}

.timeline-overall-description {
    font-size: 1rem;
    color: var(--text-color);
    line-height: 1.5;
    margin-top: 0;
    margin-bottom: 1.5rem; /* Space below overall description */
    box-sizing: border-box;
}

.timeline-date::before {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    background-color: var(--accent-color);
    border-radius: 50%;
    border: 3px solid var(--bg-color);
    box-shadow: 0 0 0 2px var(--accent-color);
    z-index: 1;
}

.timeline-photos-grid {
    flex: 0 0 45%; /* Take 45% width */
    display: flex; /* Change to flex for horizontal layout */
    flex-wrap: wrap; /* Allow images to wrap to the next line */
    gap: 1.5rem; /* Space between images */
    box-sizing: border-box;
    justify-content: flex-start; /* Align items to the start */
}

/* Remove .timeline-photo-item styles as it's no longer used */
/*
.timeline-photo-item {
    background-color: #fff;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.timeline-photo-item:hover {
    transform: translateY(-5px);
}
*/

.timeline-photo-image { /* New class for direct image styling */
    width: calc(50% - 0.75rem); /* Two images per row with gap */
    max-height: 300px; /* Set a max-height to prevent excessively tall images */
    height: auto; /* Allow height to adjust based on aspect ratio */
    object-fit: contain; /* Ensure the entire image is visible, letterboxing if necessary */
    display: block;
    /* background-color: #f0f0f0; */ /* Add a background for contain mode */
    /* border-radius: 12px; */ /* Apply border-radius directly to image */
    /* box-shadow: 0 10px 30px rgba(0,0,0,0.15); */ /* 移除阴影 */
    transition: transform 0.3s ease; /* 移除 box-shadow 的 transition */
}

.timeline-photo-image:hover {
    transform: translateY(-5px);
    /* box-shadow: 0 15px 40px rgba(0,0,0,0.2); */ /* 移除阴影 */
}

.timeline-description { /* This class is not used in the timeline, but keeping it for other potential uses */
    padding: 1rem;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-color);
    margin: 0;
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

@media (max-width: 768px) {
    /* 通用调整 */
    .gallery-header h1 {
        font-size: 1.8rem; /* 减小标题字体大小 */
    }
    .back-link {
        padding: 0.4rem 1.2rem; /* 调整返回链接内边距 */
        font-size: 0.9rem; /* 调整返回链接字体大小 */
    }

    /* 相册封面容器调整 */
    #covers-container {
        gap: 1rem; /* 减小封面间距 */
        padding: 1rem 0.5rem; /* 调整内边距 */
    }
    .album-cover-item {
        width: 95%; /* 封面宽度更大 */
        max-width: 300px; /* 限制最大宽度 */
    }
    .album-cover-item img {
        height: 150px; /* 统一封面高度 */
    }

    /* 主时间线容器调整 */
    #main-timeline-container {
        margin: 1.5rem auto;
        padding: 0 0.5rem;
    }
    #main-timeline-container::before {
        left: 15px; /* 调整中心线位置 */
        transform: translateX(0);
    }
    .timeline-group {
        flex-direction: column; /* 强制单列布局 */
        align-items: flex-start; /* 所有内容左对齐 */
        margin-bottom: 1.5rem;
        padding-left: 25px; /* 调整左侧内边距，为竖线留出空间 */
    }
    .timeline-group:nth-child(odd) { /* 移除奇偶行的特殊布局 */
        flex-direction: column;
    }
    .timeline-group:nth-child(odd) .timeline-date-info {
        text-align: left; /* 强制左对齐 */
        padding-right: 0;
    }
    .timeline-group:nth-child(even) { /* 移除奇偶行的特殊布局 */
        flex-direction: column;
    }
    .timeline-group:nth-child(even) .timeline-date-info {
        text-align: left; /* 强制左对齐 */
        padding-left: 0;
    }
    .timeline-date-info {
        padding-left: 0;
        padding-right: 0;
        flex: none;
        width: auto;
        align-items: flex-start !important; /* 强制左对齐 */
    }
    .timeline-date {
        font-size: 1.3rem; /* 调整日期字体大小 */
        margin-bottom: 0.3rem;
        text-align: left !important; /* 强制左对齐 */
    }
    .timeline-overall-description {
        font-size: 0.9rem; /* 调整描述字体大小 */
        margin-bottom: 1rem;
    }
    .timeline-date::before {
        display: none; /* 移动端隐藏圆点 */
    }
    .timeline-photos-grid {
        flex-direction: row;
        justify-content: flex-start; /* 图片左对齐 */
        gap: 0.8rem; /* 调整图片间距 */
        flex: none;
        width: 100%;
        padding: 0;
    }
    .timeline-photo-image {
        width: calc(50% - 0.4rem); /* 两张图片每行 */
        max-height: 160px; /* 调整图片最大高度 */
        padding: 5px; /* 调整图片内边距 */
    }

    /* 相册内容平铺图片调整 */
    #tiled-images-container {
        max-width: 100%;
        margin: 1rem 0;
        gap: 1rem;
    }
    .tiled-image-item {
        padding: 5px; /* 调整平铺图片内边距 */
        max-height: 200px; /* 调整平铺图片最大高度 */
    }
}

@media (max-width: 480px) {
    /* 更小的手机屏幕调整 */
    .gallery-header h1 {
        font-size: 1.5rem; /* 进一步减小标题字体大小 */
    }
    .back-link {
        padding: 0.3rem 1rem; /* 进一步调整返回链接内边距 */
        font-size: 0.8rem; /* 进一步调整返回链接字体大小 */
    }

    #covers-container {
        gap: 0.8rem; /* 进一步减小封面间距 */
        padding: 0.8rem 0.3rem;
    }
    .album-cover-item {
        width: 98%; /* 封面宽度几乎占满 */
        max-width: 280px;
    }
    .album-cover-item img {
        height: 120px; /* 进一步统一封面高度 */
    }

    #main-timeline-container {
        margin: 1rem auto;
        padding: 0 0.3rem;
    }
    #main-timeline-container::before {
        left: 10px; /* 进一步调整中心线位置 */
    }
    .timeline-group {
        margin-bottom: 1rem;
        padding-left: 20px; /* 进一步调整左侧内边距 */
    }
    .timeline-date {
        font-size: 1.1rem; /* 进一步调整日期字体大小 */
    }
    .timeline-overall-description {
        font-size: 0.8rem; /* 进一步调整描述字体大小 */
        margin-bottom: 0.8rem;
    }
    .timeline-date::before {
        display: none; /* 移动端隐藏圆点 */
    }
    .timeline-photos-grid {
        gap: 0.5rem; /* 进一步调整图片间距 */
    }
    .timeline-photo-image {
        width: calc(100% - 0.5rem); /* 单张图片占据整行 */
        max-height: 120px; /* 进一步调整图片最大高度 */
        padding: 3px;
    }

    #tiled-images-container {
        margin: 0.8rem 0;
        gap: 0.8rem;
    }
    .tiled-image-item {
        padding: 3px;
        max-height: 150px;
    }
}

/* New styles for album covers */
.album-cover-item {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.album-cover-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.album-cover-item img {
    width: 100%;
    height: 200px; /* 统一封面高度 */
    object-fit: cover;
    display: block;
    border-radius: 8px;
}

.album-title {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 10px;
    font-size: 1.1em;
    text-align: center;
    box-sizing: border-box;
    opacity: 0;
    transform: translateY(100%);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.album-cover-item:hover .album-title {
    opacity: 1;
    transform: translateY(0);
}

#covers-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

#album-content {
    display: none; /* 默认隐藏 */
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    flex-direction: column; /* 确保内容垂直排列 */
    align-items: center; /* 居中对齐 */
    padding: 20px;
    box-sizing: border-box;
    width: 100%;
}

#album-content.visible {
    display: flex; /* 显示 */
    opacity: 1;
}
