/**
 * 前端文章展示 - 瀑布流图片样式（真正的瀑布流 - Masonry布局）
 * 用于单篇文章页面展示资源图片
 * 使用JavaScript动态计算实现真正的瀑布流效果
 */

/* 瀑布流容器 - 使用绝对定位实现真正的Masonry布局 */
.zfve-waterfall-gallery {
    position: relative;
    margin: 30px 0;
    padding: 20px;
    background: var(--body-bg-color, #f8f9fa);
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
    /* 高度将由JavaScript动态设置 */
    min-height: 300px;
}

/* 瀑布流项目 - 使用绝对定位 */
.zfve-waterfall-item {
    position: absolute;
    /* left和top将由JavaScript动态设置 */
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    background: #f0f0f0;
    /* 初始状态稍微透明，等待JavaScript布局完成 */
    opacity: 0.3;
    transform: translateY(10px);
    /* 确保容器尺寸固定且无内边距 */
    display: block;
    padding: 0 !important;
    margin: 0 !important;
    border: none;
    box-sizing: border-box;
}

/* 布局完成后显示项目 */
.zfve-waterfall-item.zfve-positioned {
    opacity: 1;
    transform: translateY(0);
}

.zfve-waterfall-item:hover {
    transform: translateY(-5px) !important;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.35);
    z-index: 10;
}

/* 图片样式 - 完全填充容器，不留空白 */
.zfve-waterfall-item img {
    width: 100% !important;
    height: 100% !important;
    display: block !important;
    object-fit: cover !important;  /* 裁剪图片以完全填充容器 */
    object-position: center !important;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: #f8f9fa;
    /* 确保没有边距和边框 */
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    /* 防止图片底部留白 */
    vertical-align: top;
    /* 强制填充 */
    min-width: 100%;
    min-height: 100%;
    max-width: 100%;
    max-height: 100%;
}

.zfve-waterfall-item:hover img {
    transform: scale(1.08);
    filter: brightness(1.05);
}

/* 遮罩层效果 */
.zfve-waterfall-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.7) 0%, rgba(118, 75, 162, 0.7) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
    pointer-events: none;
}

.zfve-waterfall-item:hover::before {
    opacity: 0.3;
}

/* 图片放大图标 */
.zfve-waterfall-item::after {
    content: '\f00e'; /* Font Awesome search-plus icon */
    font-family: 'FontAwesome';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-size: 36px;
    color: white;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2;
    pointer-events: none;
}

.zfve-waterfall-item:hover::after {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

/* 响应式设计 - 调整间距和图标大小 */
@media (max-width: 1200px) {
    .zfve-waterfall-gallery {
        padding: 15px;
    }
}

@media (max-width: 768px) {
    .zfve-waterfall-gallery {
        padding: 12px;
        margin: 20px 0;
    }

    .zfve-waterfall-item::after {
        font-size: 28px;
    }
}

@media (max-width: 480px) {
    .zfve-waterfall-gallery {
        padding: 10px;
    }

    .zfve-waterfall-item::after {
        font-size: 24px;
    }
}

/* 暗色模式支持 */
@media (prefers-color-scheme: dark) {
    .zfve-waterfall-gallery {
        background: rgba(255, 255, 255, 0.03);
    }
    
    .zfve-waterfall-item {
        background: rgba(255, 255, 255, 0.05);
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
    }
    
    .zfve-waterfall-item:hover {
        box-shadow: 0 8px 25px rgba(102, 126, 234, 0.45);
    }
}

/* 图片加载动画 */
.zfve-waterfall-item img {
    animation: zfveImageFadeIn 0.5s ease-in-out;
}

@keyframes zfveImageFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* JavaScript未加载时的降级方案 - 2秒后自动显示 */
.zfve-waterfall-gallery {
    animation: zfveGalleryReady 0.3s ease-in-out 2s forwards;
}

@keyframes zfveGalleryReady {
    to {
        /* 如果2秒后JavaScript还没执行，确保容器可见 */
        min-height: auto;
    }
}

/* 降级方案：如果JavaScript未执行，3秒后强制显示所有项目 */
.zfve-waterfall-item {
    animation: zfveFallbackShow 0.5s ease-in-out 3s forwards;
}

@keyframes zfveFallbackShow {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 图片点击放大效果（配合lightbox使用） */
.zfve-waterfall-item.zfve-lightbox-active {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90vw;
    height: 90vh;
    max-width: 1200px;
    max-height: 800px;
    z-index: 999999;
    aspect-ratio: auto;
}

.zfve-waterfall-item.zfve-lightbox-active img {
    object-fit: contain;
    transform: scale(1);
}

