/* Responsive Images Optimization for Post Content */

/* Post content container */
.post-content {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

/* Base styles for content images */
.content-image {
    width: 100%;
    height: auto;
    display: block;
    margin: 1rem auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    object-fit: contain;
    object-position: center;
    max-width: none;
}
.content-image{
  width: 100%;
  height: auto;
  display: block;
  background: #f8fafc;
}
a[data-fancybox="gallery"]{
  display: block;
  border-radius: 14px;
  overflow: clip;
}

/* No hover effects for content images */

/* Responsive image containers */
.post-content picture {
    display: block;
    width: 100%;
    margin: 1rem 0;
}

.post-content img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    object-fit: contain;
    object-position: center;
    display: block;
    max-width: none;
}

/* Lightbox gallery links */
.post-content a[data-fancybox] {
    display: block;
    text-decoration: none;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* No hover effects for lightbox links */

/* Mobile optimizations */
@media (max-width: 767px) {
    .content-image {
        margin: 0.75rem auto;
        border-radius: 6px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        width: 100%;
    }
    
    .post-content picture {
        margin: 0.75rem 0;
        width: 100%;
    }
    
    .post-content img {
        border-radius: 6px;
        width: 100%;
    }
    
    /* Prevent horizontal scroll on mobile */
    .post-content {
        overflow-x: hidden;
    }
}

/* Tablet optimizations */
@media (min-width: 768px) and (max-width: 1023px) {
    .content-image {
        margin: 1rem auto;
        width: 100%;
    }
    
    .post-content picture {
        width: 100%;
    }
    
    .post-content img {
        width: 100%;
    }
}

/* Desktop optimizations */
@media (min-width: 1024px) {
    .content-image {
        margin: 1.5rem auto;
        width: 100%;
    }
    
    .post-content picture {
        margin: 1.5rem 0;
        width: 100%;
    }
    
    .post-content img {
        width: 100%;
    }
}

/* Large desktop optimizations */
@media (min-width: 1280px) {
    .content-image {
        width: 100%;
    }
    
    .post-content picture {
        width: 100%;
    }
    
    .post-content img {
        width: 100%;
    }
}

/* Loading states */
.content-image[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.content-image[loading="lazy"].loaded {
    opacity: 1;
}

/* Error handling */
.content-image[style*="display: none"] {
    display: none !important;
}

/* Fancybox gallery optimizations */
.fancybox__container {
    --fancybox-bg: rgba(0, 0, 0, 0.9);
}

.fancybox__slide {
    padding: 20px;
}

.fancybox__image {
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Performance optimizations */
.content-image {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* WebP support detection */
.no-webp .content-image {
    /* Fallback for browsers that don't support WebP */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .content-image {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Print styles */
@media print {
    .content-image {
        max-width: 100%;
        box-shadow: none;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }
    
    .post-content a[data-fancybox] {
        text-decoration: none;
    }
    
    .post-content a[data-fancybox]:after {
        content: " (Click to view larger)";
        font-size: 0.8em;
        color: #666;
    }
}

/* Accessibility improvements */
.content-image:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .content-image,
    .post-content a[data-fancybox] {
        transition: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .content-image {
        box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
    }
    
    /* No hover effects in dark mode */
}
/* Ảnh trong nội dung: đảm bảo co giãn theo container */
.content-image{
  width: 100%;
  height: auto;
  display: block;
  background: #f8fafc;
  border-radius: 14px;
}

/* Anchor bọc ảnh (Fancybox) giữ đúng layout */
a[data-fancybox="gallery"]{
  display: block;
  border-radius: 14px;
  overflow: clip;
  line-height: 0;
}

/* Tránh ảnh dính sát mép container quá mức trên màn nhỏ */
@media (max-width: 480px){
  .post-card { padding: 1rem; }
}
