/* ==========================================================================
   Product cards -- shop archive, category archives, and [products] grids.
   Loaded site-wide because Astra's shop_customization() has no is_shop() guard,
   so a homepage [products] grid produces identical markup to the archive.

   Selectors lead with WooCommerce core classes so the card survives a theme
   change; the two Astra wrappers are additive only and tagged ASTRA-DEP.
   ========================================================================== */

/* The column count comes from Woo's own .columns-N wrapper class, which reflects what
   the shortcode (or Astra's shop setting) actually asked for. auto-fit was previously
   used here and silently ignored that number -- it fitted as many tracks as the width
   allowed, so a 4-up request could render 3 or 5. */
.woocommerce ul.products {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: var(--millet-gap);
  margin: 0;
  padding: 0;
}
.woocommerce.columns-2 ul.products { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.woocommerce.columns-3 ul.products { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.woocommerce.columns-4 ul.products { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.woocommerce.columns-5 ul.products { grid-template-columns: repeat(5, minmax(0, 1fr)); }

@media (max-width: 900px) {
  .woocommerce ul.products,
  .woocommerce[class*="columns-"] ul.products { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .woocommerce ul.products,
  .woocommerce[class*="columns-"] ul.products { grid-template-columns: 1fr; }
}
.woocommerce ul.products::before,
.woocommerce ul.products::after { content: none; } /* kill the legacy float clearfix */

.woocommerce ul.products li.product {
  width: 100%;
  margin: 0;
  padding: 0 0 16px;
  float: none;
  clear: none;
  display: flex;
  flex-direction: column;
  background: var(--millet-card);
  border: 1px solid var(--millet-border);
  border-radius: var(--millet-radius);
  overflow: hidden;
  box-shadow: var(--millet-shadow);
  transition: box-shadow .18s ease, transform .18s ease;
}
.woocommerce ul.products li.product:hover { box-shadow: 0 6px 20px rgba(30,26,16,.12); transform: translateY(-2px); }

.woocommerce ul.products li.product a img {
  margin: 0 0 14px;
  aspect-ratio: 1;
  object-fit: cover;
  width: 100%;
  display: block;
}

/* ASTRA-DEP: Astra wraps the thumbnail and the summary. These rules only refine
   spacing -- if the wrappers disappear the core rules above still yield a usable card. */
.woocommerce ul.products li.product .astra-shop-thumbnail-wrap { margin: 0; }
.woocommerce ul.products li.product .astra-shop-summary-wrap { padding: 0 16px; display: flex; flex-direction: column; gap: 6px; flex: 1 1 auto; }

.woocommerce ul.products li.product .woocommerce-loop-product__title {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--millet-ink);
  padding: 0;
  margin: 0;
}
.woocommerce ul.products li.product .price { color: var(--millet-ink); font-size: 1.05rem; font-weight: 800; margin: 6px 0 0; }
.woocommerce ul.products li.product .star-rating { font-size: .8rem; color: var(--millet-gold); margin: 0; }
.millet-review-count { font-size: .75rem; color: var(--millet-body); }

.woocommerce ul.products li.product .button {
  margin-top: auto;
  background: var(--millet-green);
  color: var(--millet-cream);
  border: 0;
  padding: 11px 16px;
  text-align: center;
  font-size: .82rem;
}
.woocommerce ul.products li.product .button:hover { background: var(--millet-green-dark); color: var(--millet-cream); }

/* Out-of-stock / sale flags */
.woocommerce ul.products li.product .onsale,
.woocommerce span.onsale {
  background: var(--millet-gold);
  color: var(--millet-ink);
  border-radius: 6px;
  font-size: .68rem;
  font-weight: 800;
  min-height: auto;
  min-width: auto;
  line-height: 1;
  padding: 5px 9px;
}

/* ==========================================================================
   Product-category cards -- WooCommerce's [product_categories] shortcode.
   Items carry li.product-category.product, so all the card styling above
   (background, border, radius, shadow, hover) already applies. Only the
   category-specific bits are needed here.
   ========================================================================== */

/* The card is a flex column with overflow:hidden (which clips the image to the border
   radius). A category card puts image + title + description inside ONE anchor, so that
   anchor is a single flex child -- and as a shrinkable one it got compressed to the
   image's height, pushing the title into the clipped overflow. It was in the DOM and
   styled correctly, just invisible. flex-shrink:0 keeps it at its content height. */
.woocommerce ul.products li.product.product-category > a {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  text-decoration: none;
}

/* Same 1:1 crop as the product cards, so both grids read as one system.
   (The mockup uses 4/3 for both card types -- change here and on
   `li.product a img` together if you prefer that.) */
.woocommerce ul.products li.product-category img {
  aspect-ratio: 1;
  object-fit: cover;
  width: 100%;
  margin: 0 0 14px;
}

/* ASTRA-DEP: Astra renders the category title as an absolutely-positioned white pill
   floating over the image (position:absolute; background:rgba(255,255,255,.88);
   text-transform:uppercase; left/right:1em; bottom:1.8em). The mockup puts a plain
   sentence-case title below the image instead, so every one of those properties has to
   be reset explicitly -- omitting them leaves the pill in place.

   `.product` is repeated alongside `.product-category` on purpose: Astra's selector is
   also 0-4-2, so without the extra class this ties and load order decides the winner. */
.woocommerce ul.products li.product.product-category .woocommerce-loop-category__title {
  position: static;
  background: transparent;
  background-color: transparent;
  text-transform: none;
  text-align: left;
  left: auto;
  right: auto;
  bottom: auto;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--millet-ink);
  padding: 18px 20px 0;
  margin: 0;
}
/* Astra tints the pill on hover; with no pill there is nothing to tint. */
.woocommerce ul.products li.product.product-category > a:hover .woocommerce-loop-category__title {
  background-color: transparent;
}

/* Three of the four categories on the homepage are empty today, so a "0 Products"
   badge on each would read as broken rather than informative. The card's job is to
   point at the archive, not to report stock levels. */
.woocommerce ul.products li.product-category .woocommerce-loop-category__title .count {
  display: none;
}

/* Tagline sits directly under the category name, sharing its 20px gutter, with room
   above it and below the card so the text block does not crowd the image. */
.millet-category-tagline {
  padding: 6px 20px 18px;
  font-size: .88rem;
  line-height: 1.5;
  color: var(--millet-body);
}
.millet-category-tagline p { margin: 0; }

/* The card's own bottom padding would double up under the tagline's. */
.woocommerce ul.products li.product.product-category { padding-bottom: 0; }

/* ASTRA-DEP: Astra's hover overlay add-to-cart button on product cards. The cards
   already carry their own full-width Add to Cart, so this duplicates it. */
.ast-on-card-button {
  display: none;
}
