/* styles.css */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', sans-serif;
    background-color: #f0f2f5;
    padding: 20px;
}

.waterfall-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px; /* 增大列间距为标题留出空间 */
    max-width: 1400px;
    margin: 0 auto;
}

.image-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    cursor: pointer;
    transition: transform 0.3s ease;
    background: #fff; /* 标题背景色与图片容器统一 */
    display: flex; /* 新增flex布局 */
    flex-direction: column; /* 子元素垂直排列 */
}

.image-wrapper {
    flex: 1; /* 图片区域占据剩余空间 */
    overflow: hidden; /* 防止图片溢出 */
}

.image-item img {
    width: 100%;
    /*height: 100%;*/ /* 填充父容器高度 */
    object-fit: contain; /* 保持比例填充 */
    display: block;
    transition: transform 0.3s ease;
}

.image-item:hover img {
    transform: scale(1.03); /* 悬停时图片轻微放大 */
}

/* 新增标题样式 */
.image-title {
    padding: 12px 16px;
    font-size: 14px;
    color: #333;
    line-height: 1.4;
    background: #ffffff;
    border-top: 1px solid #f0f0f0;
    transition: all 0.3s ease;
}

/* 悬停时标题样式变化（可选） */
.image-item:hover .image-title {
    background: #f8f8f8;
    color: #222;
}

/* 模态框样式（保持不变，仅调整标题字体） */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
    padding: 40px;
    overflow: auto;
}

.modal-content {
    position: relative;
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 90vh;
    animation-name: zoom;
    animation-duration: 0.3s;
}

#expandedImg {
    width: 100%;
    height: auto;
    border-radius: 4px;
}

#imgTitle {
    color: white;
    text-align: center;
    padding: 15px 0;
    font-size: 1.3em;
    font-weight: 500;
}

/* 控制按钮（保持不变） */
.close-btn, .nav-btn {
    position: absolute;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    transition: 0.3s;
    padding: 20px;
}

.close-btn {
    top: 20px;
    right: 30px;
}

.nav-btn {
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.7;
}

.nav-btn:hover, .close-btn:hover {
    opacity: 1;
}

.prev-btn {
    left: 20px;
}

.next-btn {
    right: 20px;
}

/* 响应式设计（优化小屏幕标题显示） */
@media (max-width: 768px) {
    .waterfall-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .image-title {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .close-btn, .nav-btn {
        font-size: 30px;
        padding: 10px;
    }
    
    #imgTitle {
        font-size: 1.1em;
    }
}