/**
 * CSS Fallback System for Background Images
 * Provides automatic fallback for CSS background images
 */

/* =============================================================================
   IMAGE FALLBACK SYSTEM - CSS COMPONENTS
   ============================================================================= */

/* Base fallback class for any element with background image */
.bg-image-fallback {
    background-image: url('/assets/logo-bg-gradient.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
}

/* Overlay for fallback indication */
.bg-image-fallback::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.1);
    pointer-events: none;
    z-index: 1;
}

/* Multi-layer fallback approach */
.bg-with-fallback {
    background-image:
        url('/assets/logo-bg-gradient.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Gallery specific fallbacks */
.gallery-item .bg-with-fallback {
    background-image:
        url('/assets/logo-bg-gradient.jpg');
}

/* Product image fallbacks */
.product-image-fallback {
    background-image: url('/assets/logo-bg-gradient.jpg');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
}

/* Event image fallbacks */
.event-image-fallback {
    background-image: url('/assets/logo-bg-gradient.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Blog image fallbacks */
.blog-image-fallback {
    background-image: url('/assets/logo-bg-gradient.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Keep blog-card thumbnails aligned without distorting their source images. */
.home-blog-style-one-item>img {
    display: block;
    width: 100%;
    aspect-ratio: 3 / 2;
    object-fit: cover;
    object-position: center;
    background: #f3f3f3;
}

/* Avatar fallbacks */
.avatar-fallback {
    background-image: url('/assets/logo-bg-gradient.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 50%;
}

/* =============================================================================
   RESPONSIVE FALLBACK ADJUSTMENTS
   ============================================================================= */

@media (max-width: 768px) {

    .bg-image-fallback,
    .bg-with-fallback,
    .gallery-item .bg-with-fallback {
        background-size: contain;
    }
}

/* =============================================================================
   LOADING STATES FOR FALLBACK IMAGES
   ============================================================================= */

.image-loading {
    position: relative;
    overflow: hidden;
}

.image-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: loading-shimmer 1.5s infinite;
    z-index: 2;
}

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

    100% {
        left: 100%;
    }
}

/* =============================================================================
   FALLBACK ICONS AND INDICATORS
   ============================================================================= */

.fallback-indicator {
    position: relative;
}

.fallback-indicator::after {
    content: '🖼️';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    opacity: 0.3;
    pointer-events: none;
    z-index: 3;
}

/* Different icons for different content types */
.fallback-indicator.gallery::after {
    content: '🖼️';
}

.fallback-indicator.product::after {
    content: '📦';
}

.fallback-indicator.event::after {
    content: '📅';
}

.fallback-indicator.blog::after {
    content: '📰';
}

.fallback-indicator.user::after {
    content: '👤';
}

/* =============================================================================
   HIGH CONTRAST AND ACCESSIBILITY
   ============================================================================= */

@media (prefers-contrast: high) {
    .bg-image-fallback::before {
        background: rgba(0, 0, 0, 0.3);
    }

    .fallback-indicator::after {
        opacity: 0.6;
        text-shadow: 0 0 3px rgba(255, 255, 255, 0.8);
    }
}

@media (prefers-reduced-motion: reduce) {
    .image-loading::before {
        animation: none;
    }
}

/* =============================================================================
   PRINT STYLES
   ============================================================================= */

@media print {

    .bg-image-fallback,
    .bg-with-fallback {
        background-image: none !important;
        border: 1px solid #ccc;
    }

    .fallback-indicator::after {
        content: '[Image: ' attr(data-alt) ']';
        font-size: 12px;
        opacity: 1;
    }
}

/* =============================================================================
   DARK MODE SUPPORT
   ============================================================================= */

@media (prefers-color-scheme: dark) {
    .bg-image-fallback::before {
        background: rgba(255, 255, 255, 0.1);
    }

    .fallback-indicator::after {
        filter: brightness(1.2);
    }
}

/* =============================================================================
   UTILITY CLASSES
   ============================================================================= */

/* Force fallback (for testing) */
.force-fallback {
    background-image: url('/assets/logo-bg-gradient.jpg') !important;
}

/* Hide fallback indicator */
.no-fallback-indicator::after {
    display: none !important;
}

/* Fallback with custom opacity */
.fallback-light::before {
    background: rgba(0, 0, 0, 0.05);
}

.fallback-dark::before {
    background: rgba(0, 0, 0, 0.3);
}