/* 懒加载样式 */
.lazy-loading {
    opacity: 0.3;
    filter: blur(5px);
    transition: opacity 0.3s ease, filter 0.3s ease;
}

.lazy-loaded {
    opacity: 1;
    filter: blur(0);
    animation: fadeIn 0.5s ease-in-out;
}

.lazy-error {
    opacity: 0.5;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
}

/* 加载动画 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 占位符样式 */
.lazy-placeholder {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

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

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

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

/* 渐进式加载效果 */
.progressive-loading {
    position: relative;
}

.progressive-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 2s infinite;
    z-index: 1;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* 低质量图片占位符 (LQIP) */
.lqip-container {
    position: relative;
}

.lqip-container .lqip-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    filter: blur(10px);
    opacity: 0.7;
    z-index: 1;
}

.lqip-container .full-image {
    position: relative;
    z-index: 2;
    transition: opacity 0.3s ease;
}

.lqip-container.loading .full-image {
    opacity: 0;
}

.lqip-container.loaded .full-image {
    opacity: 1;
}

.lqip-container.loaded .lqip-image {
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* 性能优化相关样式 */

/* 减少重排和重绘 */
.will-change-transform {
    will-change: transform;
}

.will-change-opacity {
    will-change: opacity;
}

/* 硬件加速 */
.hardware-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* 图片优化 */
.optimized-image {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
}

/* 响应式图片断点 */
@media (max-width: 768px) {
    .lazy-loading {
        opacity: 0.5;
        filter: blur(3px);
    }
    
    .lazy-loaded {
        animation-duration: 0.3s;
    }
}

@media (max-width: 480px) {
    .lazy-loading {
        opacity: 0.7;
        filter: blur(2px);
    }
    
    /* 移动端优化：减少动画复杂度 */
    .lazy-loaded {
        animation: none;
        opacity: 1;
        filter: none;
    }
}

/* 打印样式优化 */
@media print {
    .lazy-loading,
    .lazy-loaded,
    .lazy-error {
        opacity: 1 !important;
        filter: none !important;
        animation: none !important;
    }
    
    .lazy-placeholder,
    .progressive-loading::before {
        display: none !important;
    }
}

/* 无障碍访问支持 */
.lazy-loading[aria-busy="true"] {
    position: relative;
}

.lazy-loading[aria-busy="true"]::after {
    content: '图片加载中...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    color: #666;
}

.lazy-error[aria-invalid="true"]::after {
    content: '图片加载失败';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    color: #dc3545;
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .lazy-loading {
        border: 2px dashed #000;
    }
    
    .lazy-error {
        border: 2px solid #ff0000;
    }
}

/* 减少动画偏好支持 */
@media (prefers-reduced-motion: reduce) {
    .lazy-loaded {
        animation: none;
    }
    
    .lazy-placeholder {
        animation: none;
        background: #f0f0f0;
    }
    
    .progressive-loading::before {
        animation: none;
        display: none;
    }
}