/**
 * 图片懒加载样式
 * 提供加载状态的视觉反馈
 */

/* 懒加载图片基础样式 */
img[data-src] {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    background-color: #f3f4f6;
    background-image: linear-gradient(45deg, #f9fafb 25%, transparent 25%), 
                      linear-gradient(-45deg, #f9fafb 25%, transparent 25%), 
                      linear-gradient(45deg, transparent 75%, #f9fafb 75%), 
                      linear-gradient(-45deg, transparent 75%, #f9fafb 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

/* 加载中状态 */
img.loading {
    opacity: 0.7;
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* 加载完成状态 */
img.loaded {
    opacity: 1;
    background: none;
}

/* 加载错误状态 */
img.error {
    opacity: 0.5;
    background: #fee2e2;
    position: relative;
}

img.error::after {
    content: "⚠️";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    color: #dc2626;
}

/* 脉冲动画 */
@keyframes pulse {
    0%, 100% {
        opacity: 0.7;
    }
    50% {
        opacity: 0.4;
    }
}

/* 骨架屏效果 */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* 响应式图片容器 */
.responsive-image-container {
    position: relative;
    overflow: hidden;
}

.responsive-image-container img {
    width: 100%;
    height: auto;
    display: block;
}

/* 图片占位符 */
.image-placeholder {
    background-color: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    font-size: 0.875rem;
    min-height: 200px;
}

.image-placeholder::before {
    content: "📷";
    font-size: 2rem;
    margin-bottom: 0.5rem;
    display: block;
}

/* 图片加载进度条 */
.image-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background-color: #3b82f6;
    width: 0%;
    transition: width 0.3s ease;
}

.image-progress.loading {
    animation: progress-loading 2s ease-in-out infinite;
}

@keyframes progress-loading {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

/* 图片淡入效果 */
.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

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

/* 移动设备优化 */
@media (max-width: 768px) {
    img[data-src] {
        background-size: 15px 15px;
    }
    
    .image-placeholder {
        min-height: 150px;
        font-size: 0.75rem;
    }
    
    .image-placeholder::before {
        font-size: 1.5rem;
    }
}

/* 高分辨率屏幕优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    img[data-src] {
        background-size: 10px 10px;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    img[data-src] {
        background-color: #374151;
        background-image: linear-gradient(45deg, #4b5563 25%, transparent 25%), 
                          linear-gradient(-45deg, #4b5563 25%, transparent 25%), 
                          linear-gradient(45deg, transparent 75%, #4b5563 75%), 
                          linear-gradient(-45deg, transparent 75%, #4b5563 75%);
    }
    
    .image-placeholder {
        background-color: #374151;
        color: #9ca3af;
    }
    
    .skeleton {
        background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
        background-size: 200% 100%;
    }
}

/* 减少动画的用户偏好 */
@media (prefers-reduced-motion: reduce) {
    img[data-src],
    img.loading,
    .fade-in,
    .skeleton,
    .image-progress {
        animation: none;
        transition: none;
    }
    
    img.loaded {
        opacity: 1;
    }
}