/* 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;
}

/* ── 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;
}

.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 (all boxes become 1×1, 2-column grid) ── */
@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;
        min-height: 200px;
    }

    /* Images: switch to aspect-ratio so 1×1 cells look good */
    .iw-bento-cell--image,
    .iw-bento-cell--image_html {
        aspect-ratio: 4 / 3;
        min-height: 0;
    }

    .iw-bento-image {
        object-position: center;
    }

    .iw-bento-image-bg {
        background-position: center;
    }
}

/* ── Responsive: Mobile (all boxes 1×1, single column) ── */
@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;
        min-height: 150px;
    }

    .iw-bento-cell--image,
    .iw-bento-cell--image_html {
        aspect-ratio: 16 / 9;
        min-height: 0;
    }
}
