/* Image Fallback Styles */

/* Loading state */
.img-loading {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

/* Loaded state */
.img-loaded {
    opacity: 1;
}

/* Error state */
.img-error {
    opacity: 0.6;
    filter: grayscale(100%);
    border: 1px solid #e9ecef;
}

/* Image placeholder during loading */
img:not([src]),
img[src=""] {
    visibility: hidden;
}

/* Skeleton loader for images */
.img-skeleton {
    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;
    }
}

/* Specific fallback styling */
.profile-img-fallback {
    background-color: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    font-size: 2rem;
}

/* Lazy loading placeholder */
img[data-lazy-src] {
    background-color: #f8f9fa;
    min-height: 100px;
}

/* Broken image icon override */
img.img-error::before {
    content: '';
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="%236c757d"><path d="M21 5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5zm-2 14H5V5h14v14zm-7-7l-2.5 3.01L7 12l5 6h8l-4-5z"/></svg>') no-repeat center;
    background-size: contain;
    opacity: 0.3;
}

/* Aspect ratio containers for consistent layouts */
.img-container {
    position: relative;
    overflow: hidden;
    background-color: #f8f9fa;
}

.img-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Common aspect ratios */
.img-container-16-9 {
    padding-bottom: 56.25%; /* 16:9 */
}

.img-container-4-3 {
    padding-bottom: 75%; /* 4:3 */
}

.img-container-1-1 {
    padding-bottom: 100%; /* 1:1 */
}

/* Responsive image improvements */
img {
    max-width: 100%;
    height: auto;
}

/* Fix for specific problem areas mentioned in audit */

/* Hero section image fixes */
.banner3-dnaromance,
.banner3-datemetrix,
.banner3-genepool {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Profile picture fixes */
.profile-picture,
.rounded-circle {
    object-fit: cover;
    background-color: #f8f9fa;
}

/* Blog image fixes */
.blog-post-image,
.post-thumbnail {
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: cover;
}

/* Gallery image fixes */
.gallery-image {
    cursor: pointer;
    transition: transform 0.3s ease;
}

.gallery-image:hover {
    transform: scale(1.05);
}

/* Loading animation for large images */
.img-loading-large {
    position: relative;
    min-height: 300px;
}

.img-loading-large::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0F75BD;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Mobile optimizations */
@media (max-width: 768px) {
    img {
        /* Prevent images from being too large on mobile */
        max-height: 70vh;
    }
    
    .img-container {
        /* Ensure touch-friendly tap targets */
        min-height: 44px;
    }
}

/* Print styles */
@media print {
    .img-error {
        display: none;
    }
    
    img[data-lazy-src] {
        display: none;
    }
}

/* Accessibility improvements */
img[alt=""] {
    border: 2px solid orange;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .img-error {
        border: 2px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    img {
        transition: none !important;
        animation: none !important;
    }
}