/* NCF Market Studio v1.2.5 — comparison-driven Top Selling correction.
   Only the homepage best-selling grid is resized. No cart/checkout logic changed. */
@media (min-width:769px) {
  .ncfg-home-main .ncfg-best-grid .ncfg-product-card {
    display:grid;
    grid-template-columns:minmax(0,var(--ncf-best-image-share,44%)) minmax(0,1fr);
    min-height:var(--ncf-best-card-height,245px);
    align-items:stretch;
  }
  .ncfg-home-main .ncfg-best-grid .ncfg-product-details {
    padding:18px clamp(12px,1.4vw,24px) 18px 8px;
    justify-content:center;
    align-items:flex-start;
  }
}
.ncfg-home-main .ncfg-best-grid .ncfg-product-picture {
  padding:6px;
  width:100%;
  min-width:0;
  background:#fff;
  align-items:center;
  justify-content:center;
}
.ncfg-home-main .ncfg-best-grid .ncfg-product-picture img {
  display:block;
  width:100%;
  height:100%;
  max-width:92%;
  max-height:var(--ncf-best-image-height,220px);
  object-fit:contain;
  object-position:center;
  padding:4px;
  transform:none;
}
.ncfg-home-main .ncfg-best-grid .ncfg-product-card:hover .ncfg-product-picture img {
  transform:scale(1.01);
}
.ncfg-home-main .ncfg-best-grid .ncfg-product-title {
  font-size:clamp(13px,1vw,17px);
  font-weight:700;
  line-height:1.32;
  margin:0 0 5px;
  color:#1b2825;
}
.ncfg-home-main .ncfg-best-grid .ncfg-price {
  font-size:clamp(14px,1.1vw,19px);
  line-height:1.35;
  margin:0;
}
.ncfg-home-main .ncfg-best-grid .ncfg-price del {
  margin-left:7px;
  font-size:0.8em;
}
.ncfg-home-main .ncfg-best-grid .ncfg-save {
  font-size:11px;
  line-height:1.3;
  margin:5px 0 0;
  padding:3px 8px;
  align-self:flex-start;
}
.ncfg-home-main .ncfg-best-grid .ncfg-product-actions {
  display:flex;
  flex-wrap:nowrap;
  justify-content:flex-start;
  align-items:center;
  gap:var(--ncf-best-action-gap,8px);
  width:min(100%,var(--ncf-best-action-width,240px));
  max-width:var(--ncf-best-action-width,240px);
  min-height:0;
  margin:12px 0 0;
  padding:0;
}
.ncfg-home-main .ncfg-best-grid .ncfg-product-actions > .ncfg-add-button,
.ncfg-home-main .ncfg-best-grid .ncfg-product-actions > .ncfg-quantity {
  min-width:0;
  flex:1 1 0;
  width:auto;
  height:var(--ncf-button-height,34px);
  margin:0;
}
.ncfg-home-main .ncfg-best-grid .ncfg-product-actions > .ncfg-buy-now {
  flex:0 0 78px;
  min-width:0;
  width:78px;
  height:var(--ncf-button-height,34px);
  white-space:nowrap;
}
.ncfg-home-main .ncfg-best-grid .ncfg-quantity {
  grid-template-columns:32px minmax(24px,1fr) 32px;
}
.ncfg-home-main .ncfg-best-grid .ncfg-quantity button {font-size:17px;}
.ncfg-home-main .ncfg-best-grid .ncfg-add-button {
  font-size:11px;
  font-weight:650;
  line-height:1.1;
  padding:3px 6px;
}
/* Badge positioning was previously relative to the photo link and appeared
   between the photo and product details. It now belongs to the card. */
.ncfg-home-main .ncfg-best-grid .ncfg-product-card > .ncfg-sale-label {
  position:absolute;
  top:0;
  right:0;
  z-index:3;
  border-radius:0 0 0 6px;
  padding:4px 9px;
  line-height:1.25;
  font-size:11px;
}
.ncfg-home-main .ncfg-just-grid .ncfg-product-card > .ncfg-sale-label {
  z-index:2;
}
@media (max-width:768px) {
  .ncfg-home-main .ncfg-best-grid .ncfg-product-card {
    min-height:0;
    display:flex;
    flex-direction:column;
  }
  .ncfg-home-main .ncfg-best-grid .ncfg-product-picture {
    padding:4px;
    aspect-ratio:1.05;
  }
  .ncfg-home-main .ncfg-best-grid .ncfg-product-picture img {
    max-width:96%;
    max-height:100%;
    padding:2px;
  }
  .ncfg-home-main .ncfg-best-grid .ncfg-product-details {
    padding:9px;
    align-items:stretch;
    justify-content:flex-start;
    gap:3px;
    flex:1;
  }
  .ncfg-home-main .ncfg-best-grid .ncfg-product-title {
    font-size:12px;
    line-height:1.25;
    min-height:30px;
  }
  .ncfg-home-main .ncfg-best-grid .ncfg-price {font-size:13px;}
  .ncfg-home-main .ncfg-best-grid .ncfg-save {font-size:10px;}
  .ncfg-home-main .ncfg-best-grid .ncfg-product-actions {
    width:100%;
    max-width:none;
    margin-top:auto;
    padding-top:6px;
    gap:4px;
  }
  .ncfg-home-main .ncfg-best-grid .ncfg-product-actions > .ncfg-buy-now {
    flex-basis:53px;
    width:53px;
    font-size:9px;
  }
  .ncfg-home-main .ncfg-best-grid .ncfg-quantity {
    grid-template-columns:23px minmax(18px,1fr) 23px;
  }
  .ncfg-home-main .ncfg-best-grid .ncfg-product-card > .ncfg-sale-label {
    font-size:9px;
    padding:3px 6px;
  }
}
@media (max-width:390px) {
  .ncfg-home-main .ncfg-best-grid .ncfg-product-actions > .ncfg-buy-now {
    flex-basis:48px;
    width:48px;
  }
  .ncfg-home-main .ncfg-best-grid .ncfg-add-button {
    font-size:10px;
    padding:2px 3px;
  }
}

/* Tablet: avoid nearly 350px-high product photos inside half-width cards. */
@media (min-width:541px) and (max-width:768px) {
 .ncfg-home-main .ncfg-best-grid .ncfg-product-card {
   display:grid;
   grid-template-columns:minmax(0,40%) minmax(0,1fr);
   min-height:195px;
 }
 .ncfg-home-main .ncfg-best-grid .ncfg-product-picture {aspect-ratio:auto;}
 .ncfg-home-main .ncfg-best-grid .ncfg-product-picture img {max-height:185px;}
 .ncfg-home-main .ncfg-best-grid .ncfg-product-details {
   justify-content:center; padding:10px;
 }
 .ncfg-home-main .ncfg-best-grid .ncfg-product-title {min-height:0;}
 .ncfg-home-main .ncfg-best-grid .ncfg-product-actions {margin-top:9px;padding-top:0;}
}

/* Avoid an inherited fixed width on mobile quantity controls and checkout button.
   Does not affect WooCommerce cart/checkout forms. */
.ncfg-home-main .ncfg-best-grid .ncfg-product-actions [hidden]{display:none!important}
@media (max-width:768px){
  .ncfg-home-main .ncfg-best-grid .ncfg-product-card{max-width:100%}
  .ncfg-home-main .ncfg-best-grid .ncfg-product-actions{min-width:0}
  .ncfg-home-main .ncfg-best-grid .ncfg-product-actions > .ncfg-add-button,
  .ncfg-home-main .ncfg-best-grid .ncfg-product-actions > .ncfg-quantity{min-width:0}
}
