/**
 * A2Z Grid Expert - Nuclear Force Fix CSS
 * Aggressive layout enforcement to bypass any external interference.
 */

/* 1. RESET & FOUNDATION */
.a2z-grid-expert-forced-v3,
.elementor-widget-a2z-grid .a2z-grid-expert-forced-v3 {
    display: grid !important;
    width: 100% !important;
    aspect-ratio: 16 / 9 !important;
    gap: var(--a2z-gap-desktop, 8px) !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-sizing: border-box !important;
    min-height: 450px !important;
}

@media (max-width: 767px) {
    .a2z-grid-expert-forced-v3 {
        aspect-ratio: 1 / 1 !important;
        gap: var(--a2z-gap-mobile, 4px) !important;
        min-height: 350px !important;
    }
}

/* 2. SLOT ENGINE */
.a2z-grid-expert-forced-v3 .a2z-v2-slot {
    position: relative !important;
    overflow: hidden !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: #f0f0f0 !important;
    /* Visual aid if image fails */
}

/* 3. IMAGE & TRIGGER ENGINE */
.a2z-grid-expert-forced-v3 .a2z-images__trigger {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    cursor: pointer !important;
    position: relative !important;
    overflow: hidden !important;
}

.a2z-grid-expert-forced-v3 .a2z-v2-slot img {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: inherit !important;
    display: block !important;
}

/* 4. PATTERN REALIZATION */

/* 4.0 Single Image (1 image) */
.a2z-grid-expert-forced-v3.a2z-v2-single {
    grid-template-columns: 1fr !important;
    grid-template-rows: 1fr !important;
}

/* 4.1 Symmetric (4 images) */
.a2z-grid-expert-forced-v3.a2z-v2-p4-symmetric {
    grid-template-columns: 1.1fr 1fr 1.1fr !important;
    grid-template-rows: repeat(2, 1fr) !important;
}

.a2z-grid-expert-forced-v3.a2z-v2-p4-symmetric .a2z-v2-slot-1 {
    grid-row: span 2 !important;
    grid-column: 1 !important;
}

.a2z-grid-expert-forced-v3.a2z-v2-p4-symmetric .a2z-v2-slot-2 {
    grid-column: 2 !important;
    grid-row: 1 !important;
}

.a2z-grid-expert-forced-v3.a2z-v2-p4-symmetric .a2z-v2-slot-3 {
    grid-column: 2 !important;
    grid-row: 2 !important;
}

.a2z-grid-expert-forced-v3.a2z-v2-p4-symmetric .a2z-v2-slot-4 {
    grid-row: span 2 !important;
    grid-column: 3 !important;
}

/* 4.2 Grid (4 images) */
.a2z-grid-expert-forced-v3.a2z-v2-p4-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    grid-template-rows: repeat(2, 1fr) !important;
}

/* 4.3 Feature Left (3 images) */
.a2z-grid-expert-forced-v3.a2z-v2-p3-feature-left {
    grid-template-columns: 1.5fr 1fr !important;
    grid-template-rows: repeat(2, 1fr) !important;
}

.a2z-grid-expert-forced-v3.a2z-v2-p3-feature-left .a2z-v2-slot-1 {
    grid-row: span 2 !important;
}

/* 4.4 Feature Right (3 images) */
.a2z-grid-expert-forced-v3.a2z-v2-p3-feature-right {
    grid-template-columns: 1fr 1.5fr !important;
    grid-template-rows: repeat(2, 1fr) !important;
}

.a2z-grid-expert-forced-v3.a2z-v2-p3-feature-right .a2z-v2-slot-2 {
    grid-row: span 2 !important;
}

/* 4.4.1 Feature Top (3 images) */
.a2z-grid-expert-forced-v3.a2z-v2-p3-feature-top {
    grid-template-columns: repeat(2, 1fr) !important;
    grid-template-rows: 1.5fr 1fr !important;
}

.a2z-grid-expert-forced-v3.a2z-v2-p3-feature-top .a2z-v2-slot-1 {
    grid-column: span 2 !important;
}

/* 4.4.2 Verticals (3 images) */
.a2z-grid-expert-forced-v3.a2z-v2-p3-verticals {
    grid-template-columns: repeat(3, 1fr) !important;
    grid-template-rows: 1fr !important;
}

/* 4.5 Split (2 images) */
.a2z-grid-expert-forced-v3.a2z-v2-p2-split {
    grid-template-columns: repeat(2, 1fr) !important;
    grid-template-rows: 1fr !important;
}

/* 4.5.1 Stack (2 images) */
.a2z-grid-expert-forced-v3.a2z-v2-p2-stack {
    grid-template-columns: 1fr !important;
    grid-template-rows: repeat(2, 1fr) !important;
}

/* 5. HEADER FIXES */
.a2z-grid-expert-wrapper .a2z-images-header-wrapper {
    width: 100% !important;
    margin-bottom: 35px !important;
    display: block !important;
}

.a2z-grid-expert-wrapper .a2z-images-header-divider {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 20px !important;
    width: 100% !important;
}

.a2z-grid-expert-wrapper .a2z-images-header-title {
    margin: 0 !important;
    padding: 0 !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 20px !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    color: #000 !important;
    /* Force black title if not specified */
    white-space: nowrap !important;
    line-height: 1 !important;
    display: block !important;
}

.a2z-grid-expert-wrapper .a2z-images-header-divider::before,
.a2z-grid-expert-wrapper .a2z-images-header-divider::after {
    content: "" !important;
    flex: 1 !important;
    height: 1px !important;
    background-color: #d5d5d5 !important;
    display: block !important;
}

.a2z-grid-expert-wrapper .a2z-images-header-description {
    text-align: center !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 15px !important;
    color: #666 !important;
    margin-top: 15px !important;
    line-height: 1.5 !important;
    display: block !important;
}

/* 6. OVERFLOW GRID (images 5+) */
.a2z-grid-expert-overflow {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: var(--a2z-gap-desktop, 8px) !important;
    margin-top: var(--a2z-gap-desktop, 8px) !important;
    width: 100% !important;
}

.a2z-grid-expert-overflow .a2z-overflow-slot {
    position: relative !important;
    overflow: hidden !important;
    aspect-ratio: 16 / 9 !important;
    background: #f0f0f0 !important;
}

.a2z-grid-expert-overflow .a2z-overflow-slot img {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
}

.a2z-grid-expert-overflow .a2z-images__trigger {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    cursor: pointer !important;
    position: relative !important;
    overflow: hidden !important;
}

@media (max-width: 767px) {
    .a2z-grid-expert-overflow {
        grid-template-columns: 1fr !important;
        gap: var(--a2z-gap-mobile, 4px) !important;
        margin-top: var(--a2z-gap-mobile, 4px) !important;
    }

    .a2z-grid-expert-overflow .a2z-overflow-slot {
        aspect-ratio: 4 / 3 !important;
    }
}

/* 7. MOBILE RESPONSIVE - 3+ images only */
@media (max-width: 767px) {

    /* 3-image patterns: stack to 1 featured + 2 side-by-side */
    .a2z-grid-expert-forced-v3.a2z-v2-p3-feature-left,
    .a2z-grid-expert-forced-v3.a2z-v2-p3-feature-right {
        grid-template-columns: 1fr 1fr !important;
        grid-template-rows: 1.4fr 1fr !important;
    }

    .a2z-grid-expert-forced-v3.a2z-v2-p3-feature-left .a2z-v2-slot-1 {
        grid-row: 1 !important;
        grid-column: span 2 !important;
    }

    .a2z-grid-expert-forced-v3.a2z-v2-p3-feature-right .a2z-v2-slot-2 {
        grid-row: 1 !important;
        grid-column: span 2 !important;
        order: -1 !important;
    }

    .a2z-grid-expert-forced-v3.a2z-v2-p3-feature-top {
        grid-template-columns: 1fr 1fr !important;
        grid-template-rows: 1.4fr 1fr !important;
    }

    .a2z-grid-expert-forced-v3.a2z-v2-p3-verticals {
        grid-template-columns: 1fr 1fr !important;
        grid-template-rows: 1fr 1fr !important;
    }

    .a2z-grid-expert-forced-v3.a2z-v2-p3-verticals .a2z-v2-slot-1 {
        grid-column: span 2 !important;
    }

    /* 4-image symmetric: stack to 2x2 */
    .a2z-grid-expert-forced-v3.a2z-v2-p4-symmetric {
        grid-template-columns: 1fr 1fr !important;
        grid-template-rows: 1fr 1fr !important;
    }

    .a2z-grid-expert-forced-v3.a2z-v2-p4-symmetric .a2z-v2-slot-1 {
        grid-row: auto !important;
        grid-column: auto !important;
    }

    .a2z-grid-expert-forced-v3.a2z-v2-p4-symmetric .a2z-v2-slot-2 {
        grid-column: auto !important;
        grid-row: auto !important;
    }

    .a2z-grid-expert-forced-v3.a2z-v2-p4-symmetric .a2z-v2-slot-3 {
        grid-column: auto !important;
        grid-row: auto !important;
    }

    .a2z-grid-expert-forced-v3.a2z-v2-p4-symmetric .a2z-v2-slot-4 {
        grid-row: auto !important;
        grid-column: auto !important;
    }

    /* 4-image grid: already 2x2, just confirm */
    .a2z-grid-expert-forced-v3.a2z-v2-p4-grid {
        grid-template-columns: 1fr 1fr !important;
        grid-template-rows: 1fr 1fr !important;
    }

    /* Mobile header spacing */
    .a2z-grid-expert-wrapper .a2z-images-header-wrapper {
        margin-bottom: 20px !important;
    }
}