/**
 * DXP Responsive Cover Block Styles - SIMPLIFIED SINGLE DIV APPROACH
 * Handles responsive background images with a single div that changes dynamically
 */

/* Base responsive cover styling */
.wp-block-cover.dxp-responsive-cover {
    position: relative;
}

/* Single responsive background div - JavaScript will handle image switching */
.wp-block-cover.dxp-responsive-cover .dxp-responsive-bg {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 10 !important;
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    display: none !important; /* Hidden by default, JavaScript will show when needed */
}

/* Ensure content stays above background images */
.wp-block-cover.dxp-responsive-cover .wp-block-cover__inner-container {
    position: relative;
    z-index: 20 !important;
}

/* WordPress background overlay should be above images but below content */
.wp-block-cover.dxp-responsive-cover .wp-block-cover__background {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 15 !important;
}

/* Ensure WordPress original image has correct z-index */
.wp-block-cover.dxp-responsive-cover .wp-block-cover__image-background {
    z-index: 5 !important;
}

/* Loading state */
.wp-block-cover.dxp-responsive-cover.is-loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-top-color: transparent;
    border-radius: 50%;
    animation: responsive-cover-loading 1s linear infinite;
    z-index: 25;
}

@keyframes responsive-cover-loading {
    to {
        transform: rotate(360deg);
    }
}

/* Success state */
.wp-block-cover.dxp-responsive-cover.image-loaded {
    /* Optional: Add any success styling here */
}

/* Error state */
.wp-block-cover.dxp-responsive-cover.image-error {
    border: 2px solid #dc3232;
}

.wp-block-cover.dxp-responsive-cover.image-error::after {
    content: '⚠️ Image failed to load';
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(220, 50, 50, 0.9);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 25;
}

/* Enhanced responsive behavior for very small screens */
@media (max-width: 480px) {
    .wp-block-cover.dxp-responsive-cover {
        min-height: 250px;
    }
}

/* Focus and accessibility improvements */
.wp-block-cover.dxp-responsive-cover:focus-within {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .wp-block-cover.dxp-responsive-cover {
        background-image: none !important;
        border: 1px solid #ccc;
    }
    
    .wp-block-cover.dxp-responsive-cover .dxp-responsive-bg {
        display: none !important;
    }
    
    .wp-block-cover.dxp-responsive-cover::after {
        content: '[Responsive Cover Image]';
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        color: #666;
        font-size: 14px;
        z-index: 25;
    }
}

/* Debug mode - uncomment for testing */
/*
.wp-block-cover.dxp-responsive-cover {
    border: 2px solid red !important;
}

.wp-block-cover.dxp-responsive-cover .dxp-responsive-bg {
    border: 2px solid blue !important;
}

.wp-block-cover.dxp-responsive-cover .wp-block-cover__image-background {
    border: 2px solid green !important;
}
*/
