/**
 * Comprehensive responsive image styles for single post content
 *
 * @package dumabyt
 */

/* Base responsive image styles */
.entry-content img,
.entry-content figure img,
.entry-content .wp-block-image img,
.entry-content .wp-block-gallery img,
.article-content img,
.prose img {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    display: block !important;
    margin-left: auto !important;
    margin-right: auto !important;
    object-fit: contain !important;
}

/* Figure containers */
.entry-content figure,
.entry-content .wp-block-image,
.entry-content .wp-block-gallery,
.article-content figure {
    max-width: 100% !important;
    width: 100% !important;
    text-align: center !important;
    overflow: hidden !important;
}

/* Desktop styles - limit max width to 800px */
@media (min-width: 768px) {
    .entry-content img,
    .entry-content figure img,
    .entry-content .wp-block-image img,
    .article-content img,
    .prose img {
        max-width: 800px !important;
    }
    
    .entry-content figure,
    .entry-content .wp-block-image,
    .article-content figure {
        max-width: 800px !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
}

/* Mobile styles - ensure images fit within viewport */
@media (max-width: 767px) {
    .entry-content img,
    .entry-content figure img,
    .entry-content .wp-block-image img,
    .entry-content .wp-block-gallery img,
    .article-content img,
    .prose img {
        max-width: calc(100vw - 3rem) !important;
        width: 100% !important;
        height: auto !important;
        object-fit: contain !important;
    }
    
    .entry-content figure,
    .entry-content .wp-block-image,
    .entry-content .wp-block-gallery,
    .article-content figure {
        max-width: calc(100vw - 3rem) !important;
        width: 100% !important;
        margin: 1rem auto !important;
        overflow: hidden !important;
    }
    
    /* Prevent horizontal scrolling */
    .entry-content,
    .article-content {
        overflow-x: hidden !important;
    }
    
    /* Ensure container doesn't exceed viewport */
    .lg\:col-span-3 {
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }
}

/* Very small screens - extra constraints */
@media (max-width: 480px) {
    .entry-content img,
    .entry-content figure img,
    .entry-content .wp-block-image img,
    .article-content img,
    .prose img {
        max-width: calc(100vw - 2rem) !important;
        width: 100% !important;
    }
    
    .entry-content figure,
    .entry-content .wp-block-image,
    .article-content figure {
        max-width: calc(100vw - 2rem) !important;
        margin: 0.75rem auto !important;
    }
}

/* WordPress block specific fixes */
.wp-block-image.aligncenter,
.wp-block-image.alignleft,
.wp-block-image.alignright {
    max-width: 100% !important;
}

@media (max-width: 767px) {
    .wp-block-image.aligncenter,
    .wp-block-image.alignleft,
    .wp-block-image.alignright {
        max-width: calc(100vw - 3rem) !important;
        margin-left: auto !important;
        margin-right: auto !important;
        float: none !important;
    }
}

/* Gallery blocks */
.wp-block-gallery {
    max-width: 100% !important;
}

@media (max-width: 767px) {
    .wp-block-gallery {
        max-width: calc(100vw - 3rem) !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
    
    .wp-block-gallery .wp-block-image {
        max-width: 100% !important;
    }
}

/* Image captions */
.entry-content figcaption,
.article-content figcaption,
.wp-block-image figcaption {
    text-align: center !important;
    max-width: 100% !important;
    word-wrap: break-word !important;
}

/* Responsive classes added by PHP filter */
.responsive-post-image {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    display: block !important;
    margin-left: auto !important;
    margin-right: auto !important;
    object-fit: contain !important;
}

.responsive-post-figure {
    max-width: 100% !important;
    width: 100% !important;
    text-align: center !important;
    overflow: hidden !important;
}

/* Desktop constraints for responsive classes */
@media (min-width: 768px) {
    .responsive-post-image {
        max-width: 800px !important;
    }

    .responsive-post-figure {
        max-width: 800px !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
}

/* Mobile responsive for new classes */
@media (max-width: 767px) {
    .responsive-post-image {
        max-width: calc(100vw - 3rem) !important;
        width: 100% !important;
    }

    .responsive-post-figure {
        max-width: calc(100vw - 3rem) !important;
        margin: 1rem auto !important;
    }
}

/* Override any conflicting styles */
.entry-content img[style*="width"],
.article-content img[style*="width"] {
    max-width: 100% !important;
}

@media (max-width: 767px) {
    .entry-content img[style*="width"],
    .article-content img[style*="width"] {
        max-width: calc(100vw - 3rem) !important;
        width: 100% !important;
    }
}
