/*
 * Rabindra Medical Hall
 * Mobile Image Reliability + Responsive Rendering
 *
 * IMPORTANT:
 * This file changes presentation/loading behavior only.
 * It does NOT modify WooCommerce product data.
 */

/* -------------------------------------------------------------
   GLOBAL IMAGE SAFETY
------------------------------------------------------------- */

img {
    max-width: 100%;
    height: auto;
    display: block;
}

picture,
figure {
    max-width: 100%;
}

picture img {
    max-width: 100%;
}

/* Prevent image containers from creating horizontal overflow */
.rmh-product-image,
.rmh-product-image img,
.rmh-brand-card__logo-wrap,
.rmh-brand-card__logo,
.rmh-promo-card__image-wrap,
.rmh-promo-card__image {
    max-width: 100%;
    box-sizing: border-box;
}

/* -------------------------------------------------------------
   WOOCOMMERCE PRODUCT IMAGES
------------------------------------------------------------- */

.rmh-product-image {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: #f7faf8;
}

.rmh-product-image img,
.woocommerce ul.products li.product img,
.woocommerce-page ul.products li.product img {
    width: 100%;
    max-width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    object-position: center;
}

/* Do not allow lazy-loaded images to collapse */
.rmh-product-card img[loading="lazy"],
.woocommerce ul.products img[loading="lazy"] {
    min-height: 1px;
}

/* -------------------------------------------------------------
   BRAND / MANUFACTURER LOGOS
------------------------------------------------------------- */

.rmh-brand-card__logo-wrap {
    width: 100%;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.rmh-brand-card__logo {
    width: 140px;
    max-width: 80%;
    height: 48px;
    aspect-ratio: 140 / 48;
    object-fit: contain;
    object-position: center;
}

/* -------------------------------------------------------------
   HERO / PROMOTIONAL IMAGES
------------------------------------------------------------- */

.rmh-promo-card__image-wrap {
    width: 100%;
    overflow: hidden;
}

.rmh-promo-card__image {
    width: 100%;
    height: auto;
    aspect-ratio: 2 / 1;
    object-fit: cover;
    object-position: center;
}

/* -------------------------------------------------------------
   MOBILE — <= 768px
------------------------------------------------------------- */

@media (max-width: 768px) {
    img {
        max-width: 100%;
    }

    .rmh-product-image {
        width: 100%;
        min-width: 0;
        height: auto;
        aspect-ratio: 1 / 1;
    }

    .rmh-product-image img,
    .woocommerce ul.products li.product img,
    .woocommerce-page ul.products li.product img {
        width: 100%;
        height: 100%;
        max-width: 100%;
        object-fit: contain;
        object-position: center;
    }

    .rmh-brand-card__logo-wrap {
        min-height: 44px;
        height: 52px;
    }

    .rmh-brand-card__logo {
        width: 120px;
        max-width: 82%;
        height: 44px;
        object-fit: contain;
    }

    .rmh-promo-card__image {
        width: 100%;
        height: auto;
        aspect-ratio: 2 / 1;
        object-fit: cover;
    }
}

/* -------------------------------------------------------------
   SMALL MOBILE — <= 480px
------------------------------------------------------------- */

@media (max-width: 480px) {
    .rmh-product-image {
        min-height: 0;
        aspect-ratio: 1 / 1;
    }

    .rmh-product-image img,
    .woocommerce ul.products li.product img,
    .woocommerce-page ul.products li.product img {
        width: 100%;
        height: 100%;
        padding: 6px;
        object-fit: contain;
    }

    .rmh-brand-card__logo-wrap {
        height: 46px;
        min-height: 40px;
    }

    .rmh-brand-card__logo {
        width: 110px;
        height: 40px;
    }

    .rmh-promo-card__image {
        aspect-ratio: 2 / 1;
    }
}

/* -------------------------------------------------------------
   IMAGE ERROR FALLBACK
------------------------------------------------------------- */

img.rmh-image-error {
    object-fit: contain;
    opacity: .65;
}

/* Avoid broken-image icon taking over layout */
img {
    overflow: hidden;
}
