/* Article Image Optimization for Long Images */
/* This file provides enhanced display for various image aspect ratios in article content */

/* Base article image styles with enhanced display */
.article-content img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 2rem auto;
    display: block;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

/* Enhanced hover effects */
.article-content img:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.15);
    border-radius: 16px;
}

/* Long/Tall image optimization */
.article-content img[style*="height"] {
    max-height: 80vh;
    width: auto;
    object-fit: contain;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 1rem;
}

/* Very tall images (certificates, infographics, documents) */
.article-content .very-tall-image,
.article-content img[data-aspect="very-tall"] {
    max-height: 80vh !important;
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
    margin: 2rem auto !important;
    display: block !important;
    cursor: zoom-in !important;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1) !important;
    border-radius: 12px !important;
    background: transparent !important;
}

/* Container for very tall images */
.article-content .very-tall-image-container {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
    padding: 2rem !important;
    border-radius: 16px !important;
    border: 1px solid #dee2e6 !important;
    text-align: center !important;
    margin: 2rem 0 !important;
    overflow: hidden !important;
}

.article-content .very-tall-image-container:hover {
    background: linear-gradient(135deg, #f1f3f4 0%, #e8eaf6 100%) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.12) !important;
}

.article-content .very-tall-image-container img {
    margin: 0 !important;
    background: white !important;
    border: 1px solid #e0e0e0 !important;
}

/* Very long images (aspect ratio detection via CSS) */
/* Default behavior handled by base styles above */

/* Portrait/tall images optimization */
@media (min-width: 768px) {
    .article-content img {
        max-height: 70vh;
    }
    
    /* For images that are very tall */
    .article-content .tall-image,
    .article-content img[data-aspect="portrait"] {
        max-height: 60vh;
        width: auto;
        margin: 2rem auto;
        object-fit: contain;
        background: #f8f9fa;
        padding: 1.5rem;
        border: 1px solid #dee2e6;
    }
}

/* Wide images optimization */
.article-content .wide-image,
.article-content img[data-aspect="landscape"] {
    width: 100%;
    height: auto;
    max-height: 50vh;
    object-fit: cover;
    object-position: center;
}

/* Ultra-wide images (panoramic) */
.article-content .panoramic-image,
.article-content img[data-aspect="panoramic"] {
    width: 100%;
    height: auto;
    max-height: 40vh;
    object-fit: cover;
    object-position: center;
    border-radius: 20px;
}

/* Image container for better control */
.article-content .image-container {
    position: relative;
    margin: 2rem 0;
    text-align: center;
    background: #f8f9fa;
    border-radius: 12px;
    padding: 1rem;
    overflow: hidden;
}

.article-content .image-container img {
    margin: 0;
    max-height: 70vh;
    width: auto;
    object-fit: contain;
    background: transparent;
    box-shadow: none;
    border-radius: 8px;
}

.article-content .image-container:hover img {
    transform: scale(1.02);
}

/* Image caption styling */
.article-content .image-caption,
.article-content figcaption {
    font-size: 0.9rem;
    color: #6c757d;
    text-align: center;
    margin-top: 0.5rem;
    font-style: italic;
    line-height: 1.4;
}

/* Full-width image option */
.article-content .full-width-image {
    width: calc(100% + 2rem);
    margin-left: -1rem;
    margin-right: -1rem;
    border-radius: 0;
}

@media (min-width: 768px) {
    .article-content .full-width-image {
        width: calc(100% + 4rem);
        margin-left: -2rem;
        margin-right: -2rem;
        border-radius: 0;
    }
}

/* Lightbox-style image viewer */
.article-content .zoomable-image {
    cursor: zoom-in;
    position: relative;
}

.article-content .zoomable-image::after {
    content: '🔍';
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s ease;
    font-size: 12px;
}

.article-content .zoomable-image:hover::after {
    opacity: 1;
}

/* Image grid for multiple images */
.article-content .image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.article-content .image-grid img {
    margin: 0;
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .article-content img {
        margin: 1.5rem auto;
        border-radius: 8px;
        max-height: 60vh;
    }
    
    .article-content .image-container {
        padding: 0.5rem;
        margin: 1.5rem 0;
    }
    
    .article-content .image-container img {
        max-height: 50vh;
    }
    
    .article-content .full-width-image {
        width: calc(100% + 1rem);
        margin-left: -0.5rem;
        margin-right: -0.5rem;
    }
    
    .article-content .image-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .article-content .image-grid img {
        height: 150px;
    }
}

@media (max-width: 480px) {
    .article-content img {
        margin: 1rem auto;
        max-height: 50vh;
    }
    
    .article-content .image-container img {
        max-height: 40vh;
    }
    
    .article-content .image-grid img {
        height: 120px;
    }
}

/* High-resolution display optimization */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .article-content img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Print styles */
@media print {
    .article-content img {
        max-height: none !important;
        width: 100% !important;
        object-fit: contain !important;
        page-break-inside: avoid;
        margin: 1rem 0;
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .article-content .image-container {
        background: none;
        padding: 0;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .article-content .image-container {
        background: #2d3748;
        border: 1px solid #4a5568;
    }
    
    .article-content img[style*="background"] {
        background: #2d3748 !important;
    }
    
    .article-content .image-caption,
    .article-content figcaption {
        color: #a0aec0;
    }
}

/* Loading state for images */
.article-content img[data-loading="true"] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Accessibility improvements */
.article-content img[alt=""] {
    border: 2px dashed #dc3545;
}

.article-content img[alt=""]:before {
    content: "Missing alt text";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #dc3545;
    color: white;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    z-index: 1;
}

/* Performance optimization */
.article-content img {
    will-change: transform;
    backface-visibility: hidden;
    transform: translateZ(0);
}
