/*
 * Shop Grid Layout: uniform product cards for the Enfold theme's WooCommerce product lists.
 * Every card in a row has the same height; pictures sit in an identical square frame;
 * titles start on the same line, prices and buttons end on the same line.
 */

/* ---- the grid: even gaps, as many equal columns as fit ---- */
#top #main ul.products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));   /* four across on a full width page, three beside a sidebar */
  gap: 22px;
  margin: 0 0 30px;
  padding: 0;
  clear: both;
}
#top #main ul.products::before,
#top #main ul.products::after {
  content: none;
  display: none;
}
#top #main ul.products li.product {
  float: none !important;
  clear: none !important;
  width: auto !important;
  margin: 0 !important;
  padding: 0;
  min-width: 0;
  display: flex;
  list-style: none;
}

/* ---- the card ---- */
#top #main ul.products .inner_product {
  display: flex;
  flex-direction: column;
  width: 100%;
  background: #fff;
  border: 1px solid #e7eaf1;
  border-radius: 12px;
  overflow: hidden;
  transition: box-shadow .25s ease, transform .25s ease, border-color .25s ease;
}
#top #main ul.products li.product:hover .inner_product {
  border-color: #d5dbe8;
  box-shadow: 0 12px 28px rgba(23, 37, 84, .10);
  transform: translateY(-3px);
}
#top #main ul.products a.woocommerce-LoopProduct-link {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  border-radius: 0;
  overflow: visible;
}

/* ---- the picture: one square frame, the whole picture always visible ---- */
#top #main ul.products .thumbnail_container {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #fff;
  overflow: hidden;
}
#top #main ul.products .thumbnail_container img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0;
  transition: transform .35s ease;
}
#top #main ul.products li.product:hover .thumbnail_container img {
  transform: scale(1.03);
}

/* ---- title and price: title at the top, price at the bottom of the same block ---- */
#top #main ul.products .inner_product_header {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  padding: 14px 16px;
  background: #fff;
  border-top: 1px solid #eef0f5;
}
#top #main ul.products .inner_product_header .avia-arrow {
  display: none;
}
#top #main ul.products .inner_product_header_table,
#top #main ul.products .inner_product_header_cell {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  width: 100%;
  height: auto;
}
#top #main ul.products h2.woocommerce-loop-product__title {
  margin: 0;
  padding: 0;
  font-size: 15px;
  line-height: 1.75;
  min-height: 3.5em;            /* room for two lines, so one and two line titles line up */
  text-align: center;
}
#top #main ul.products .inner_product_header .price {
  display: block;
  margin-top: auto;
  padding-top: 8px;
  font-size: 16px;
  line-height: 1.4;
  text-align: center;
}

/* ---- buttons: always readable, always on the bottom edge ---- */
#top #main ul.products .avia_cart_buttons {
  display: flex;
  opacity: 1;
  margin: 0;
  padding: 0;
  background: #fafbfd;
  border-top: 1px solid #eef0f5;
  overflow: hidden;
}
#top #main ul.products .avia_cart_buttons .button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1 1 0;
  float: none;
  width: auto;
  min-width: 0;
  margin: 0;
  padding: 13px 6px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  transition: background-color .2s ease;
}
#top #main ul.products .avia_cart_buttons .button ~ .button {
  border-inline-start: 1px solid #eef0f5;
}
#top #main ul.products .avia_cart_buttons .button:hover {
  background: #f0f3fb;
}
#top #main ul.products .avia_cart_buttons .button-mini-delimiter {
  display: none;                /* the theme's own short divider; the full height one above replaces it */
}

/* ---- items that are out of stock: say so on the picture (the buttons stay as they are, so the row still lines up) ---- */
#top #main ul.products li.product.outofstock .thumbnail_container img {
  opacity: .55;
}
#top #main ul.products li.product.outofstock .thumbnail_container::after {
  content: var(--shopgrid-out-of-stock, "");   /* the shop's own translated wording, set by the plugin */
  position: absolute;
  top: 12px;
  inset-inline-start: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(31, 41, 55, .82);
  color: #fff;
  font-size: 12px;
  line-height: 1.6;
}

/* ---- tablets and phones ---- */
@media only screen and (max-width: 767px) {
  #top #main ul.products {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  #top #main ul.products .inner_product_header {
    padding: 10px 10px 12px;
  }
  #top #main ul.products h2.woocommerce-loop-product__title {
    font-size: 14px;
  }
  #top #main ul.products .inner_product_header .price {
    font-size: 15px;
  }
  #top #main ul.products .avia_cart_buttons {
    flex-direction: column;
  }
  #top #main ul.products .avia_cart_buttons .button {
    flex: 0 0 auto;
    padding: 10px 4px;
  }
  #top #main ul.products .avia_cart_buttons .button ~ .button {
    border-inline-start: 0;
    border-top: 1px solid #eef0f5;
  }
  #top #main ul.products li.product:hover .inner_product {
    transform: none;
  }
}
@media only screen and (max-width: 339px) {
  #top #main ul.products {
    grid-template-columns: minmax(0, 1fr);
  }
}
