/* ================================================================
   OHM Flexible Gallery — complete replacement gallery.css
   901px+: Elementor-selected 2 or 3 columns and individual spans
   601–900px: exactly 2 cards per row, irrespective of desktop spans
   600px and below: exactly 1 card per row
   ================================================================ */

.ohm-flex-gallery {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-flow: row;
    gap: var(--ohm-gallery-gap, 14px);
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

/* Honour the 2-column option in the Elementor widget on desktop. */
.ohm-flex-gallery--cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ohm-flex-gallery,
.ohm-flex-gallery * {
    box-sizing: border-box;
}

.ohm-flex-gallery__item {
    position: relative;
    grid-column: span 1;
    min-width: 0;
    height: auto;
    margin: 0;
    overflow: hidden;
    border-radius: var(--radius-sm, 12px);
    background: #222;
}

/* Desktop: each image uses the span selected in Elementor. */
.ohm-flex-gallery__item--span-2 { grid-column: span 2; }
.ohm-flex-gallery__item--span-3 { grid-column: span 3; }

.ohm-flex-gallery .ohm-flex-gallery__link {
    position: relative;
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    color: inherit;
    text-decoration: none;
}

/* Keep the image proportions you preferred on desktop. */
.ohm-flex-gallery .ohm-flex-gallery__item--span-2 .ohm-flex-gallery__link {
    aspect-ratio: 8 / 3;
}
.ohm-flex-gallery .ohm-flex-gallery__item--span-3 .ohm-flex-gallery__link {
    aspect-ratio: 4 / 3;
}

.ohm-flex-gallery .ohm-flex-gallery__image {
    position: absolute;
    inset: 0;
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    padding: 0;
    object-fit: cover;
    object-position: center;
    transition: transform .35s ease;
}

.ohm-flex-gallery__caption {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 18px 14px 12px;
    background: linear-gradient(transparent, rgba(0, 0, 0, .75));
    color: #fff;
    font: 500 .88rem/1.45 var(--head, sans-serif);
    pointer-events: none;
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
    .ohm-flex-gallery__link:hover .ohm-flex-gallery__image {
        transform: scale(1.035);
    }
}

/* Tablet: every card takes ONE of the TWO equal columns.
   Desktop span-2 / span-3 settings are deliberately ignored here. */
@media (min-width: 601px) and (max-width: 900px) {
    .ohm-flex-gallery,
    .ohm-flex-gallery--cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .ohm-flex-gallery > .ohm-flex-gallery__item,
    .ohm-flex-gallery > .ohm-flex-gallery__item--span-2,
    .ohm-flex-gallery > .ohm-flex-gallery__item--span-3 {
        grid-column: span 1 !important;
    }

    .ohm-flex-gallery .ohm-flex-gallery__link,
    .ohm-flex-gallery .ohm-flex-gallery__item--span-2 .ohm-flex-gallery__link,
    .ohm-flex-gallery .ohm-flex-gallery__item--span-3 .ohm-flex-gallery__link {
        aspect-ratio: 4 / 3;
    }
}

/* Mobile: every card spans the single available column. */
@media (max-width: 600px) {
    .ohm-flex-gallery,
    .ohm-flex-gallery--cols-2 {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .ohm-flex-gallery > .ohm-flex-gallery__item {
        grid-column: span 1 !important;
    }

    .ohm-flex-gallery .ohm-flex-gallery__link,
    .ohm-flex-gallery .ohm-flex-gallery__item--span-2 .ohm-flex-gallery__link,
    .ohm-flex-gallery .ohm-flex-gallery__item--span-3 .ohm-flex-gallery__link {
        aspect-ratio: 4 / 3;
    }
}


/* Keep the Gallery section in normal document flow */
@media (max-width: 900px) {

    .ohm-product-page .ohm-gallery-section:has(.ohm-flex-gallery) {
        --display: block;
        display: block !important;
        height: auto !important;
        min-height: 0 !important;
    }

    .ohm-product-page .ohm-gallery-section > .e-con-inner {
        display: block !important;
        height: auto !important;
        min-height: 0 !important;
    }

    .ohm-product-page .ohm-gallery-section .elementor-widget-ohm_flexible_gallery,
    .ohm-product-page .ohm-gallery-section .elementor-widget-ohm_flexible_gallery > .elementor-widget-container,
    .ohm-product-page .ohm-gallery-section .ohm-flex-gallery {
        width: 100%;
        height: auto !important;
        min-height: 0 !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ohm-flex-gallery__image { transition: none; }
}
