/* ============================================================
   IMAGE MODAL COMPONENT
   ============================================================
   Modal overlay and container styles for full-size image viewing.
   Provides smooth animations, responsive design, and accessibility
   features for viewing images in a lightbox-style modal.
   ============================================================ */

/* === Modal Overlay === */
.image-modal-overlay {
    /* Positioning and layout */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    
    /* Background and visibility */
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    
    /* Transitions */
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
    
    /* Flexbox for centering */
    display: flex;
    align-items: center;
    justify-content: center;
    
    /* Prevent scrolling when modal is open */
    overflow: hidden;
}

/* Active state - modal is visible */
.image-modal-overlay.is-active {
    opacity: 1;
    visibility: visible;
}

/* === Modal Container === */
.image-modal-container {
    /* Positioning */
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    width: auto;
    height: auto;
    
    /* Spacing */
    padding: 2rem;
    
    /* Animation */
    transform: scale(0.8);
    transition: transform 0.3s ease-in-out;
}

/* Active state - container is visible */
.image-modal-overlay.is-active .image-modal-container {
    transform: scale(1);
}

/* === Modal Image === */
.image-modal-image {
    /* Display */
    display: block;
    max-width: 100%;
    max-height: 90vh;
    width: auto;
    height: auto;
    
    /* Styling */
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    
    /* Smooth loading */
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

/* Image loaded state */
.image-modal-image.is-loaded {
    opacity: 1;
}

/* === Close Button === */
.image-modal-close {
    /* Positioning */
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 10000;
    
    /* Size and spacing */
    width: 40px;
    height: 40px;
    padding: 0;
    margin: 0;
    
    /* Styling */
    background-color: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: #ffffff;
    cursor: pointer;
    
    /* Flexbox for centering icon */
    display: flex;
    align-items: center;
    justify-content: center;
    
    /* Transitions */
    transition: all 0.2s ease-in-out;
    
    /* Remove default button styles */
    appearance: none;
    -webkit-appearance: none;
}

/* Hover state */
.image-modal-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

/* Active state */
.image-modal-close:active {
    transform: scale(0.95);
}

/* Close button icon (X) */
.image-modal-close::before,
.image-modal-close::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 2px;
    background-color: #ffffff;
    border-radius: 1px;
}

.image-modal-close::before {
    transform: rotate(45deg);
}

.image-modal-close::after {
    transform: rotate(-45deg);
}

/* === Image Caption (Optional) === */
.image-modal-caption {
    /* Positioning */
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    
    /* Styling */
    background-color: rgba(0, 0, 0, 0.7);
    color: #ffffff;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    line-height: 1.5;
    text-align: center;
    max-width: 80%;
    
    /* Animation */
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

/* Caption visible state */
.image-modal-overlay.is-active .image-modal-caption {
    opacity: 1;
}

/* === Clickable Image Indicator === */
.prose img {
    cursor: pointer;
    transition: opacity 0.2s ease-in-out;
}

.prose img:hover {
    opacity: 0.9;
}

/* === Responsive Design === */
@media (max-width: 768px) {
    .image-modal-container {
        padding: 1rem;
        max-width: 95vw;
    }
    
    .image-modal-image {
        max-height: 85vh;
    }
    
    .image-modal-close {
        width: 36px;
        height: 36px;
        top: 0.5rem;
        right: 0.5rem;
    }
    
    .image-modal-close::before,
    .image-modal-close::after {
        width: 16px;
    }
    
    .image-modal-caption {
        bottom: 0.5rem;
        padding: 0.5rem 1rem;
        font-size: 0.75rem;
        max-width: 90%;
    }
}

/* === Accessibility === */
.image-modal-overlay[aria-hidden="true"] {
    display: none;
}

/* Focus styles for keyboard navigation */
.image-modal-close:focus {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

/* === Loading State === */
.image-modal-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ffffff;
    font-size: 1rem;
    opacity: 0.7;
}
