/**
 * 图片加载优化样式
 * 配合advanced-image-optimizer.js使用
 */


/* 图片渐入效果 */

img[data-src] {
    opacity: 0;
    transition: opacity 0.5s ease;
}

img[data-src].loaded {
    opacity: 1;
}


/* 轮播图优化 */

.carousel-slide {
    transition: opacity 0.5s ease-in-out, transform 0.5s ease-in-out;
}

.carousel-slide.optimized {
    transform: scale(1);
}


/* 图片占位符样式 */

.image-placeholder {
    background-color: #f0f0f0;
    position: relative;
    overflow: hidden;
}

.image-placeholder::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: placeholder-shimmer 1.5s infinite;
}

@keyframes placeholder-shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 150%;
    }
}


/* 加载中图片样式 */

.loading-image-container {
    position: relative;
}

.loading-image-container::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: #3498db;
    animation: spin 1s ease-in-out infinite;
    transform: translate(-50%, -50%);
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}


/* 图片加载失败样式 */

.image-load-error {
    position: relative;
    background-color: #f8f8f8;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100px;
}

.image-load-error::before {
    content: "!";
    font-size: 24px;
    color: #e74c3c;
    border: 2px solid #e74c3c;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}


/* 优化移动设备上的图片显示 */

@media (max-width: 768px) {
    .carousel-slide {
        height: 200px;
    }
    .image-placeholder::before {
        width: 30%;
    }
}