/* ===================================
   RESPONSIVE IMAGE OPTIMIZATION
   =================================== */

/* Picture element base styling */
picture {
    display: block;
    max-width: 100%;
}

picture img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* For mobile screens, ensure full width */
@media (max-width: 768px) {
    picture {
        width: 100%;
    }
    
    picture img {
        width: 100%;
    }
}

/* Image loading states */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

img[loading="lazy"].loaded,
img[loading="eager"] {
    opacity: 1;
}

/* Placeholder for missing images */
.placeholder-image {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    color: #6c757d;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    position: relative;
    overflow: hidden;
}

.placeholder-image::before {
    content: '🖼️';
    font-size: 2rem;
    margin-right: 0.5rem;
    opacity: 0.5;
}

/* Article Images - Simple, no format restrictions */
.article-image {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: block;
    margin: 0 auto 20px auto;
}

/* For mobile, keep images responsive */
@media (max-width: 768px) {
    .article-image {
        max-width: 100%;
        margin: 0 auto 15px auto;
    }
}

/* For desktop, keep images responsive */
@media (min-width: 769px) {
    .article-image {
        max-width: 100%;
        margin: 0 auto 20px auto;
    }
}

.article-image:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

/* Simple rule for article detail pages */
.article-detail .article-image {
    max-width: 100%;
    height: auto;
    margin: 0 auto 25px auto;
    display: block;
}

/* Mobile specific for article detail */
@media (max-width: 768px) {
    .article-detail .article-image {
        margin-bottom: 20px;
    }
}

/* Card Images */
.card-img-top {
    height: 200px;
    object-fit: cover;
    object-position: center;
    transition: transform 0.3s ease;
    border-radius: 8px 8px 0 0;
}

.card:hover .card-img-top {
    transform: scale(1.05);
}

/* Avatar Images - General */
.avatar {
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.2s ease;
}

.avatar:hover {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.avatar-sm {
    width: 32px;
    height: 32px;
}

.avatar-md {
    width: 50px;
    height: 50px;
}

.avatar-lg {
    width: 80px;
    height: 80px;
}

/* Author Avatar - No effects, clean styling */
.author-info .avatar,
.author-card .avatar,
.avatar-container .avatar,
.d-flex .rounded-circle[alt*="Admin"],
.d-flex .rounded-circle[alt*="User"],
.d-flex .rounded-circle[alt*="Author"] {
    border-radius: 50% !important;
    object-fit: cover !important;
    border: none !important;
    box-shadow: none !important;
    transition: none !important;
    transform: none !important;
    cursor: default !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: 40px !important;
    max-height: 40px !important;
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    background: none !important;
    flex-shrink: 0 !important;
}

.author-info .avatar:hover,
.author-card .avatar:hover,
.avatar-container .avatar:hover,
.d-flex .rounded-circle[alt*="Admin"]:hover,
.d-flex .rounded-circle[alt*="User"]:hover,
.d-flex .rounded-circle[alt*="Author"]:hover {
    transform: none !important;
    box-shadow: none !important;
    border: none !important;
}

/* Author Avatar Sizes - Clean and simple */
.author-info .avatar-sm,
.author-card .avatar-sm,
.avatar-container .avatar-sm {
    width: 30px !important;
    height: 30px !important;
    font-size: 0.75rem !important;
}

.author-info .avatar-md,
.author-card .avatar-md,
.avatar-container .avatar-md {
    width: 40px !important;
    height: 40px !important;
    font-size: 1rem !important;
}

.author-info .avatar-lg,
.author-card .avatar-lg,
.avatar-container .avatar-lg {
    width: 50px !important;
    height: 50px !important;
    font-size: 1.1rem !important;
}

.avatar-xl {
    width: 200px;
    height: 200px;
}

/* Logo Images */
.logo-image {
    height: 50px;
    width: auto;
    object-fit: contain;
    transition: opacity 0.3s ease;
}

.logo-image:hover {
    opacity: 0.8;
}

/* Hero Images */
.hero-image {
    width: 100%;
    height: 400px;
    object-fit: cover;
    object-position: center;
    border-radius: 0;
}

/* Thumbnail Images */
.thumbnail {
    border-radius: 8px;
    object-fit: cover;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.thumbnail:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Image gallery grid */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.image-grid img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
    transition: transform 0.3s ease;
}

.image-grid img:hover {
    transform: scale(1.02);
}

/* Responsive breakpoints */
@media (max-width: 768px) {
    .hero-image {
        height: 250px;
    }
    
    .card-img-top {
        height: 150px;
    }
    
    .article-image {
        border-radius: 8px;
        max-height: 220px !important;
        height: 220px !important;
        object-fit: cover !important;
        margin-bottom: 15px !important;
    }
    
    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 0.5rem;
    }
}

@media (max-width: 576px) {
    .hero-image {
        height: 200px;
    }
    
    .card-img-top {
        height: 120px;
    }
    
    .logo-image {
        height: 40px;
    }
    
    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}

/* Aspect ratio utilities */
.aspect-ratio-16-9 {
    aspect-ratio: 16 / 9;
}

.aspect-ratio-4-3 {
    aspect-ratio: 4 / 3;
}

.aspect-ratio-1-1 {
    aspect-ratio: 1 / 1;
}

.aspect-ratio-3-2 {
    aspect-ratio: 3 / 2;
}

/* Image loading spinner */
.image-loading {
    position: relative;
    background: #f8f9fa;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-loading::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 4px solid #e9ecef;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: image-spin 1s linear infinite;
}

@keyframes image-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Print optimizations */
@media print {
    .article-image,
    .card-img-top,
    .hero-image {
        filter: grayscale(100%);
        -webkit-filter: grayscale(100%);
    }
    
    .avatar,
    .thumbnail {
        display: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .placeholder-image {
        background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
        border-color: #4a5568;
        color: #a0aec0;
    }
    
    .avatar {
        border-color: #2d3748;
    }
    
    .image-loading {
        background: #2d3748;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .article-image,
    .card-img-top,
    .avatar,
    .thumbnail,
    .image-grid img {
        transition: none;
    }
    
    .card:hover .card-img-top,
    .article-image:hover,
    .avatar:hover,
    .thumbnail:hover,
    .image-grid img:hover {
        transform: none;
    }
}

/* High DPI/Retina display optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .logo-image {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}
