/* 基础样式 */
.hidden {
    display: none !important;
}

/* 全局禁止文本选择和拖拽 */
.gallery-wrapper,
.main-image-container,
.gallery-thumbs,
.lightbox,
.lightbox-content {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* 画廊容器 */
.gallery-wrapper {
    margin: 20px auto;
    padding: 0 15px;
    max-width: 1400px;
}

/* 主图容器（带IMG文字背景） */
.main-image-container {
    width: 100%;
    height: 450px;
    margin: 0 auto 15px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
    cursor: zoom-in;
    -webkit-tap-highlight-color: transparent;
}

/* IMG文字背景 */
.main-image-container::before {
    content: "IMG";
    position: absolute;
    font-size: 120px;
    font-weight: 700;
    color: rgba(240, 240, 240, 0.8);
    letter-spacing: -10px;
    z-index: 1;
    pointer-events: none;
    user-select: none;
    transform: scale(1.2);
}

.main-image-container img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    transition: opacity 0.3s ease;
    pointer-events: none;
    user-drag: none;
    -webkit-user-drag: none;
    z-index: 2;
    position: relative;
}
.main-image-container img.fade {
    opacity: 0;
}

.main-image-caption {
    position: absolute;
    left: 50%;
    bottom: 10px;
    transform: translateX(-50%);
    padding: 3px 10px;
    font-size: 12px;
    color: #222;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 3px;
    margin: 0;
    white-space: nowrap;
    z-index: 3; /* 确保在文字背景上方 */
}

/* 缩略图区域 */
.gallery-thumbs {
    width: 100%;
    margin: 0 auto 30px;
    overflow-x: auto;
    padding: 8px 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.gallery-thumbs::-webkit-scrollbar {
    display: none;
}

.gallery-thumbs-list {
    display: flex;
    gap: 8px;
    padding: 4px 0;
    min-width: max-content;
}

.thumb-wrapper {
    width: 100px;
    height: 100px;
    flex: 0 0 auto;
    overflow: hidden;
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #f5f5f5; /* 缩略图保留浅灰背景 */
}
.thumb-wrapper:hover:not(.active) {
    transform: scale(1.02);
    border-color: #eee;
}
.thumb-wrapper.active {
    border-color: #666;
    box-shadow: 0 0 0 2px rgba(102, 102, 102, 0.1);
}
.thumb-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    user-drag: none;
    -webkit-user-drag: none;
}

/* 灯箱样式 */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    backdrop-filter: blur(8px);
}
.lightbox.active {
    display: flex;
    animation: fadeIn 0.4s ease;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 80vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    pointer-events: none;
    user-drag: none;
    -webkit-user-drag: none;
}

.lightbox-swipe-hint {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: #666;
    font-size: 12px;
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 20px;
    pointer-events: none;
}

.lightbox-caption {
    position: absolute;
    bottom: 15px;
    left: 0;
    right: 0;
    color: #222;
    text-align: center;
    font-size: 14px;
    padding: 0 20px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    color: #555;
    font-size: 24px;
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.7);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
    z-index: 10;
}
.lightbox-close:hover {
    background: #f5f5f5;
    color: #000;
}

.lightbox-pagination {
    position: absolute;
    top: 20px;
    left: 20px;
    color: #555;
    font-size: 13px;
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 20px;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .main-image-container {
        height: 300px;
    }
    /* 移动端缩小IMG文字 */
    .main-image-container::before {
        font-size: 80px;
        letter-spacing: -8px;
    }
    .thumb-wrapper {
        width: 80px;
        height: 80px;
    }
    .lightbox-caption {
        font-size: 13px;
        bottom: 12px;
    }
    .lightbox-close {
        top: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
    }
    .lightbox-pagination {
        top: 15px;
        left: 15px;
        font-size: 12px;
    }
    .lightbox-swipe-hint {
        top: 15px;
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .main-image-container {
        height: 220px;
    }
    /* 小屏进一步缩小IMG文字 */
    .main-image-container::before {
        font-size: 60px;
        letter-spacing: -6px;
    }
    .thumb-wrapper {
        width: 70px;
        height: 70px;
    }
    .lightbox-content {
        max-width: 95%;
    }
    .lightbox-caption {
        bottom: 10px;
    }
}