/* === product-media-fix:start === */
/* Product image module repair (2026-11-27, extended 2026-11-30 listing2)
   1) Demo06 homepage "Products in editorial rows": compact left-image / right-text rows.
   2) Stop full-width grey letterboxes on leftover vertical cards
      (height:210px + object-fit:contain + auto-fit).
   3) Category listing pages: [data-dynamic-product-list].product-list and
      any .product-card inside .catalog-layout become compact 200x140 / right-text
      editorial rows. This MUST win over every template (hbmmt, demo02-16, etc.).
      Also covers orphaned cards that sit as siblings after an emptied .product-list.
   Featured home grids ([data-view="featured"] without .d6-list) and about-page
   cards (body.is-about) are left unchanged.
*/

/* ----- Editorial rows (template 6 / .d6-list) ----- */
body:not(.is-about) .d6-list{
  display:grid !important;
  grid-template-columns:1fr !important;
  gap:0 !important;
}
body:not(.is-about) .d6-list > .d6-row,
body:not(.is-about) .d6-list > article.d6-row,
body:not(.is-about) .d6-list > .d2-prod,
body:not(.is-about) .d6-list > .product-card{
  display:grid !important;
  grid-template-columns:200px minmax(0,1fr) !important;
  gap:24px !important;
  align-items:center !important;
  padding:22px 0 !important;
  border:0 !important;
  border-top:1px solid var(--theme-line,#e5e7eb) !important;
  border-radius:0 !important;
  background:#fff !important;
  box-shadow:none !important;
  overflow:hidden !important;
}
body:not(.is-about) .d6-list > .d6-row > img,
body:not(.is-about) .d6-list > .d6-row > a > img,
body:not(.is-about) .d6-list > .d6-row .d6-row-media,
body:not(.is-about) .d6-list > .d6-row .d6-row-media img,
body:not(.is-about) .d6-list > .d2-prod > .d2-prod-img,
body:not(.is-about) .d6-list > .product-card > .product-card-image{
  width:200px !important;
  max-width:200px !important;
  height:140px !important;
  max-height:140px !important;
  min-height:0 !important;
  aspect-ratio:auto !important;
  object-fit:cover !important;
  object-position:center !important;
  display:block !important;
  background:#f8fafc !important;
  border-radius:4px !important;
  overflow:hidden !important;
}
body:not(.is-about) .d6-list > .d2-prod > .d2-prod-img img,
body:not(.is-about) .d6-list > .product-card > .product-card-image img{
  width:100% !important;
  height:100% !important;
  object-fit:cover !important;
  object-position:center !important;
}
body:not(.is-about) .d6-list > .d2-prod > .d2-prod-body,
body:not(.is-about) .d6-list > .product-card > .card-body{
  padding:0 4px 0 0 !important;
}
body:not(.is-about) .d6-list .product-detail-button{
  width:auto !important;
  background:transparent !important;
  color:var(--theme-primary) !important;
  padding:0 !important;
  justify-content:flex-start !important;
  font-weight:700 !important;
}

@media(max-width:700px){
  body:not(.is-about) .d6-list > .d6-row,
  body:not(.is-about) .d6-list > .d2-prod,
  body:not(.is-about) .d6-list > .product-card{
    grid-template-columns:1fr !important;
    gap:14px !important;
    padding:18px 0 !important;
  }
  body:not(.is-about) .d6-list > .d6-row > img,
  body:not(.is-about) .d6-list > .d6-row > a > img,
  body:not(.is-about) .d6-list > .d6-row .d6-row-media,
  body:not(.is-about) .d6-list > .d6-row .d6-row-media img,
  body:not(.is-about) .d6-list > .d2-prod > .d2-prod-img,
  body:not(.is-about) .d6-list > .product-card > .product-card-image{
    width:100% !important;
    max-width:none !important;
    height:200px !important;
    max-height:none !important;
  }
}

/* ----- Non-listing grids: modest 4/3 wells, no auto-fit stretch ----- */
.d2-prod-grid{
  grid-template-columns:repeat(auto-fill,minmax(240px,1fr));
}
body:not(.is-listing) .product-list:not([data-dynamic-product-list]):not(.product-list-editorial){
  grid-template-columns:repeat(auto-fill,minmax(240px,1fr));
}
.d2-prod-grid > .d2-prod > .d2-prod-img,
body:not(.is-listing) .product-list:not([data-dynamic-product-list]) > .product-card > .product-card-image{
  aspect-ratio:4/3;
  height:auto;
  min-height:0;
  overflow:hidden;
  background:#f8fafc;
}
.d2-prod-grid > .d2-prod > .d2-prod-img img,
body:not(.is-listing) .product-list:not([data-dynamic-product-list]) > .product-card > .product-card-image img{
  width:100%;
  height:100%;
  object-fit:cover;
  object-position:center;
}

/* ----- Category listing: single-column editorial rows -----
   Selectors do not depend on body.is-listing (some themes emit a bare <body>).
   .catalog-layout .product-card also covers leftover SSR cards that were
   left as siblings after a truncated empty .product-list (Dongjie repair bug).
   !important beats style.css auto-fit / height:210-260px / object-fit:contain
   and later theme.css rules.
*/
html body:not(.is-about) .catalog-layout .product-list,
html body:not(.is-about) .product-list[data-dynamic-product-list]:not([data-view="featured"]),
html body:not(.is-about) .product-list.product-list-editorial{
  display:grid !important;
  grid-template-columns:1fr !important;
  gap:0 !important;
}

html body:not(.is-about) .catalog-layout .product-list .product-card,
html body:not(.is-about) .catalog-layout .product-card,
html body:not(.is-about) .product-list[data-dynamic-product-list]:not([data-view="featured"]) .product-card,
html body:not(.is-about) .product-list.product-list-editorial .product-card,
html body:not(.is-about) .product-list .product-card.product-row{
  display:grid !important;
  grid-template-columns:200px minmax(0,1fr) !important;
  gap:24px !important;
  align-items:center !important;
  padding:22px 0 !important;
  border:0 !important;
  border-top:1px solid var(--theme-line,#e5e7eb) !important;
  border-radius:0 !important;
  background:#fff !important;
  box-shadow:none !important;
  overflow:hidden !important;
  max-width:none !important;
}

html body:not(.is-about) .catalog-layout .product-list .product-card > .product-card-image,
html body:not(.is-about) .catalog-layout .product-card > .product-card-image,
html body:not(.is-about) .product-list[data-dynamic-product-list]:not([data-view="featured"]) .product-card > .product-card-image,
html body:not(.is-about) .product-list.product-list-editorial .product-card > .product-card-image,
html body:not(.is-about) .product-list .product-card.product-row > .product-card-image{
  display:block !important;
  grid-column:1 !important;
  grid-row:1 !important;
  width:200px !important;
  max-width:200px !important;
  height:140px !important;
  min-height:0 !important;
  max-height:140px !important;
  aspect-ratio:auto !important;
  position:relative !important;
  background:#f8fafc !important;
  border-radius:4px !important;
  overflow:hidden !important;
}

html body:not(.is-about) .catalog-layout .product-list .product-card > .product-card-image img,
html body:not(.is-about) .catalog-layout .product-card > .product-card-image img,
html body:not(.is-about) .product-list[data-dynamic-product-list]:not([data-view="featured"]) .product-card > .product-card-image img,
html body:not(.is-about) .product-list.product-list-editorial .product-card > .product-card-image img,
html body:not(.is-about) .product-list .product-card.product-row > .product-card-image img{
  width:100% !important;
  height:100% !important;
  max-height:none !important;
  object-fit:cover !important;
  object-position:center !important;
}

html body:not(.is-about) .catalog-layout .product-list .product-card > .card-body,
html body:not(.is-about) .catalog-layout .product-card > .card-body,
html body:not(.is-about) .product-list[data-dynamic-product-list]:not([data-view="featured"]) .product-card > .card-body,
html body:not(.is-about) .product-list.product-list-editorial .product-card > .card-body,
html body:not(.is-about) .product-list .product-card.product-row > .card-body{
  display:flex !important;
  flex-direction:column !important;
  justify-content:center !important;
  grid-column:2 !important;
  grid-row:1 !important;
  min-width:0 !important;
  padding:0 4px 0 0 !important;
}

html body:not(.is-about) .catalog-layout .product-list .product-card .tag,
html body:not(.is-about) .catalog-layout .product-card .tag,
html body:not(.is-about) .product-list[data-dynamic-product-list]:not([data-view="featured"]) .product-card .tag,
html body:not(.is-about) .product-list.product-list-editorial .product-card .tag,
html body:not(.is-about) .product-list .product-card.product-row .tag{
  position:static !important;
  margin-bottom:8px !important;
}

html body:not(.is-about) .catalog-layout .product-list .product-card .product-detail-button,
html body:not(.is-about) .catalog-layout .product-card .product-detail-button,
html body:not(.is-about) .product-list[data-dynamic-product-list]:not([data-view="featured"]) .product-card .product-detail-button,
html body:not(.is-about) .product-list.product-list-editorial .product-card .product-detail-button,
html body:not(.is-about) .product-list .product-card.product-row .product-detail-button{
  width:auto !important;
  align-self:flex-start !important;
  background:transparent !important;
  color:var(--theme-primary) !important;
  padding:0 !important;
  justify-content:flex-start !important;
  font-weight:700 !important;
  box-shadow:none !important;
  border:0 !important;
  min-height:0 !important;
  border-radius:0 !important;
}

html body:not(.is-about) .catalog-layout .product-list .product-card .product-detail-button:hover,
html body:not(.is-about) .catalog-layout .product-card .product-detail-button:hover,
html body:not(.is-about) .product-list[data-dynamic-product-list]:not([data-view="featured"]) .product-card .product-detail-button:hover,
html body:not(.is-about) .product-list.product-list-editorial .product-card .product-detail-button:hover,
html body:not(.is-about) .product-list .product-card.product-row .product-detail-button:hover{
  background:transparent !important;
  color:var(--theme-primary-dark,#1e3a8a) !important;
}

@media(max-width:700px){
  html body:not(.is-about) .catalog-layout .product-list .product-card,
  html body:not(.is-about) .catalog-layout .product-card,
  html body:not(.is-about) .product-list[data-dynamic-product-list]:not([data-view="featured"]) .product-card,
  html body:not(.is-about) .product-list.product-list-editorial .product-card,
  html body:not(.is-about) .product-list .product-card.product-row{
    grid-template-columns:1fr !important;
    gap:14px !important;
    padding:18px 0 !important;
  }
  html body:not(.is-about) .catalog-layout .product-list .product-card > .product-card-image,
  html body:not(.is-about) .catalog-layout .product-card > .product-card-image,
  html body:not(.is-about) .product-list[data-dynamic-product-list]:not([data-view="featured"]) .product-card > .product-card-image,
  html body:not(.is-about) .product-list.product-list-editorial .product-card > .product-card-image,
  html body:not(.is-about) .product-list .product-card.product-row > .product-card-image{
    grid-column:1 !important;
    grid-row:auto !important;
    width:100% !important;
    max-width:none !important;
    height:200px !important;
    max-height:none !important;
  }
  html body:not(.is-about) .catalog-layout .product-list .product-card > .card-body,
  html body:not(.is-about) .catalog-layout .product-card > .card-body,
  html body:not(.is-about) .product-list[data-dynamic-product-list]:not([data-view="featured"]) .product-card > .card-body,
  html body:not(.is-about) .product-list.product-list-editorial .product-card > .card-body,
  html body:not(.is-about) .product-list .product-card.product-row > .card-body{
    grid-column:1 !important;
    grid-row:auto !important;
  }
}
/* === product-media-fix:end === */
