/* CMS ImageBlock Component Styles */

/* ==========================================
   Base ImageBlock Styling
   ========================================== */
.cms-image-block {
    position: relative;
    display: block;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* ==========================================
   Column Span Classes (Grid Integration)
   ========================================== */
.cms-col-span-1 { max-width: 8.333%; }
.cms-col-span-2 { max-width: 16.666%; }
.cms-col-span-3 { max-width: 25%; }
.cms-col-span-4 { max-width: 33.333%; }
.cms-col-span-5 { max-width: 41.666%; }
.cms-col-span-6 { max-width: 50%; }
.cms-col-span-7 { max-width: 58.333%; }
.cms-col-span-8 { max-width: 66.666%; }
.cms-col-span-9 { max-width: 75%; }
.cms-col-span-10 { max-width: 83.333%; }
.cms-col-span-11 { max-width: 91.666%; }
.cms-col-span-12 { max-width: 100%; }

/* ==========================================
   Image Element
   ========================================== */
.cms-image-block-img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
}

.cms-image-block-link {
    display: block;
    text-decoration: none;
}

.cms-image-block-link:hover .cms-image-block-img {
    transform: scale(1.02);
}

/* ==========================================
   Image States
   ========================================== */

/* Empty State */
.cms-image-block-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    background-color: #f5f5f5;
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 32px;
}

/* Loading State */
.cms-image-block-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
}

/* Error State */
.cms-image-block-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    background-color: #fff5f5;
    border: 2px solid #d32f2f;
    border-radius: 8px;
    padding: 32px;
}

/* Placeholder State */
.cms-image-block-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 150px;
    background-color: #f5f5f5;
    border-radius: 8px;
    padding: 24px;
}

/* ==========================================
   Edit Mode
   ========================================== */
.cms-image-block-edit {
    position: relative;
    min-height: 150px;
}

.cms-image-block-preview {
    position: relative;
}

.cms-image-block-overlay {
    position: absolute;
    top: 8px;
    right: 8px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 5;
}

.cms-image-block-preview:hover .cms-image-block-overlay {
    opacity: 1;
}

.cms-image-block-overlay .mud-icon-button {
    background-color: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* ==========================================
   View Mode
   ========================================== */
.cms-image-block-content {
    position: relative;
}

/* Caption */
.cms-image-block-caption {
    padding: 8px 12px;
    background-color: #f5f5f5;
    border-radius: 0 0 4px 4px;
    text-align: center;
}

/* ==========================================
   Responsive Behavior
   ========================================== */
@media (max-width: 959px) {
    /* xs-sm: Full width, max-height 300px */
    .cms-image-block {
        max-width: 100% !important;
        max-height: 300px;
    }

    .cms-image-block-img {
        max-height: 300px;
        object-fit: cover;
    }
}

@media (min-width: 960px) {
    /* md+: Respect column span */
    .cms-image-block-img {
        max-height: var(--cms-image-max-height, 400px);
    }
}

/* ==========================================
   Image Fit Modes
   ========================================== */
.cms-image-block-img[style*="object-fit: cover"] {
    object-fit: cover;
}

.cms-image-block-img[style*="object-fit: contain"] {
    object-fit: contain;
}

.cms-image-block-img[style*="object-fit: fill"] {
    object-fit: fill;
}

.cms-image-block-img[style*="object-fit: none"] {
    object-fit: none;
}

/* ==========================================
   Lazy Loading
   ========================================== */
.cms-image-block-img[loading="lazy"] {
    /* Browser will handle lazy loading */
}

/* ==========================================
   Accessibility
   ========================================== */
.cms-image-block-link:focus {
    outline: 2px solid #f0b323;
    outline-offset: 2px;
}

.cms-image-block-img[alt=""],
.cms-image-block-img:not([alt]) {
    /* Visual indicator for missing alt text in development */
    border: 2px solid #d32f2f;
}

/* ==========================================
   Hover Effects
   ========================================== */
.cms-image-block:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* ==========================================
   Border Radius Support
   ========================================== */
.cms-image-block-img {
    /* Border radius set via inline styles */
}

/* ==========================================
   Animation & Transitions
   ========================================== */
.cms-image-block-content {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ==========================================
   Reduced Motion Support
   ========================================== */
@media (prefers-reduced-motion: reduce) {
    .cms-image-block,
    .cms-image-block-img,
    .cms-image-block-overlay {
        transition: none;
    }

    .cms-image-block-content {
        animation: none;
    }
}

/* ==========================================
   Print Styles
   ========================================== */
@media print {
    .cms-image-block-overlay,
    .cms-image-block-edit {
        display: none;
    }

    .cms-image-block-img {
        max-width: 100%;
        page-break-inside: avoid;
    }
}
