/* ===============================================================
   AL-HIJRA OFFICIAL — MOBILE PRODUCT PHOTO FRAME FIX v1.2.4
   Applies ONLY to public catalog cards at <=650px.
   Detail pages remain unchanged and preserve original image ratios.
   =============================================================== */
@media screen and (max-width:650px) {
  /* Keep precisely two catalog cards per row, even on small phones. */
  body .product-grid {
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:10px;
    align-items:start;
  }
  body .product-grid > .product-card {
    min-width:0;
    max-width:100%;
    overflow:hidden;
  }
  /* Definite square containing block, not percentage height of auto. */
  body .product-grid > .product-card .gallery.gallery-card,
  body .product-grid > .product-card .af-photo {
    box-sizing:border-box;
    position:relative;
    display:block;
    width:100%;
    height:auto;
    min-height:0;
    aspect-ratio:1 / 1;
    overflow:hidden;
    border-radius:0;
    background:#f2f4f0;
  }
  /* A 100%-height flex track can size incorrectly inside aspect-ratio:auto. */
  body .product-grid > .product-card .gallery-card .gallery-track {
    position:absolute;
    inset:0;
    display:flex;
    height:100%;
    width:100%;
    min-width:0;
  }
  body .product-grid > .product-card .gallery-card .gallery-slide {
    position:relative;
    display:flex;
    flex:0 0 100%;
    width:100%;
    height:100%;
    padding:0;
    margin:0;
    min-width:0;
    overflow:hidden;
    align-items:center;
    justify-content:center;
  }
  /* Fill square frame without stretching; edges of non-square photos may crop. */
  body .product-grid > .product-card .gallery-card .gallery-slide img,
  body .product-grid > .product-card .af-photo > img {
    display:block;
    width:100%;
    height:100%;
    min-width:0;
    min-height:0;
    max-width:none;
    max-height:none;
    object-fit:cover;
    object-position:center center;
    margin:0;
    padding:0;
    border:0;
  }
  body .product-grid > .product-card .af-photo { display:grid; place-items:center; }
  body .product-grid > .product-card .af-photo > img {
    position:absolute;
    inset:0;
  }
  /* Make carousel navigation fit inside the square photo frame. */
  body .product-grid > .product-card .gallery-card .gallery-arrow {
    width:28px;
    height:28px;
    font-size:21px;
    z-index:4;
  }
  body .product-grid > .product-card .gallery-card .gallery-prev { left:3px; }
  body .product-grid > .product-card .gallery-card .gallery-next { right:3px; }
  body .product-grid > .product-card .gallery-card .gallery-counter {
    right:5px;
    bottom:5px;
    font-size:9px;
    padding:4px 6px;
  }
  body .product-grid > .product-card .product-info { min-width:0; }
}
