/* IW Bento Grid */

.iw-bento-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    width: 100%;
}

/* ── Cell Base ── */
.iw-bento-cell {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    min-height: 0;
    min-width: 0;
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s ease, transform 0.6s ease, box-shadow 0.4s ease;
    will-change: transform, opacity;
}

.iw-bento-cell--visible {
    opacity: 1;
    transform: translateY(0);
}

.iw-bento-cell--visible:hover {
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.22);
    /* Subtle lift — matches the IW Blog grid card hover */
    transform: translateY(-2px);
}

/* Editor visibility — JS reveal listener doesn't fire reliably inside the
   Elementor editor iframe, so cells stay invisible (opacity:0) and content
   is unselectable. Force visible state when the editor is active. */
body.elementor-editor-active .iw-bento-cell,
body.elementor-editor-preview .iw-bento-cell {
    opacity: 1 !important;
    transform: none !important;
}


/* ── Auto-Generate Placeholder ── */
.iw-bento-cell--auto {
    display: flex;
    align-items: center;
    justify-content: center;
}

.iw-bento-auto {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    padding: 16px;
    width: 100%;
    height: 100%;
}

.iw-bento-auto__label {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
}

.iw-bento-auto__size {
    font-size: 13px;
    opacity: 0.6;
    font-weight: 400;
}

/* ── HTML Content ── */
.iw-bento-cell--html {
    display: flex;
    flex-direction: column;
}

/* ── Image Content ── */
.iw-bento-image-link {
    display: block;
    width: 100%;
    height: 100%;
}

.iw-bento-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ── Image + HTML Overlay ── */
.iw-bento-image-bg {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
}

.iw-bento-overlay {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
}

/* ── Editor Placeholder ── */
.iw-bento-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.05);
    color: #999;
    font-size: 14px;
    font-style: italic;
}

/* ── Flip Card ── */
.iw-bento-flip {
    perspective: 1200px;
    overflow: visible;
    background: none;
    transform-style: preserve-3d;
}

.iw-bento-flip__inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.iw-bento-flip.is-flipped .iw-bento-flip__inner {
    transform: rotateY(180deg);
}

.iw-bento-flip__face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: inherit;
    overflow: hidden;
}

.iw-bento-flip__front {
    z-index: 2;
}

.iw-bento-flip__back {
    transform: rotateY(180deg);
    z-index: 1;
}

/* ── Responsive: Tablet (2-column grid, all squares except last) ── */
@media (max-width: 1024px) {
    .iw-bento-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: auto !important;
    }

    .iw-bento-cell {
        grid-column: span 1 !important;
        grid-row: span 1 !important;
        aspect-ratio: 1 / 1;
        min-height: 0;
    }

    /* Last cell spans both columns and stays a wider rectangle. */
    .iw-bento-cell:last-child {
        grid-column: span 2 !important;
        aspect-ratio: 2 / 1;
    }

    .iw-bento-cell--image,
    .iw-bento-cell--image_html {
        min-height: 0;
    }
    .iw-bento-image {
        object-position: center;
    }
    .iw-bento-image-bg {
        background-position: center;
    }
}

/* ── Responsive: Mobile (single column, all squares except first) ── */
@media (max-width: 767px) {
    .iw-bento-grid {
        grid-template-columns: 1fr;
        grid-auto-rows: auto !important;
    }

    .iw-bento-cell {
        grid-column: span 1 !important;
        grid-row: span 1 !important;
        aspect-ratio: 1 / 1;
        min-height: 0;
    }

    /* First cell stays tall — spans 2 rows for a vertical rectangle. */
    .iw-bento-cell:first-child {
        grid-row: span 2 !important;
        aspect-ratio: 1 / 2;
    }
    /* Reset last-child override from tablet rules so mobile applies cleanly */
    .iw-bento-cell:last-child {
        grid-column: span 1 !important;
        aspect-ratio: 1 / 1;
    }

    .iw-bento-cell--image,
    .iw-bento-cell--image_html {
        min-height: 0;
    }
}
