/* DDHQ WCPC - Swiper skin + controllable typography/colors via CSS variables
   Fixes:
   - consistent card layout (image, title, price, button)
   - prevent huge line-height/wrap issues
   - keep arrows centered on media area (not on full card)
   - add safe paddings so arrows don’t cover content
*/
.ddhq-wcpc { position: relative; --ddhq-wcpc-button-width: 100%; }
.ddhq-wcpc__header { margin: 0 0 10px; }
.ddhq-wcpc__title { margin: 0; }

/* Swiper base */
.ddhq-wcpc__swiper { position: relative; }
.ddhq-wcpc .swiper-wrapper { margin: 0; padding: 0; list-style: none; }
.ddhq-wcpc li.product.swiper-slide { height: auto; }

/* Make each product card a flex column so price/button align nicely */
.ddhq-wcpc li.product.swiper-slide{
  display: flex;
  flex-direction: column;
}

/* Ensure thumbnail/media area behaves and arrows align to it */
.ddhq-wcpc li.product.swiper-slide a.woocommerce-LoopProduct-link{
  display: block;
}

/* If theme adds extra bottom margins, normalize inside carousel only */
.ddhq-wcpc li.product.swiper-slide .woocommerce-loop-product__title,
.ddhq-wcpc li.product.swiper-slide .price{
  margin-left: 0;
  margin-right: 0;
}

/* Typography + color (scoped so it doesn't affect other grids) */
.ddhq-wcpc .woocommerce-loop-product__title{
  font-size: var(--ddhq-wcpc-product-title-size, clamp(15px, 1.2vw, 20px));
  line-height: 1.25;
  letter-spacing: 0.2px;
  color: var(--ddhq-wcpc-product-title-color, inherit);
  margin-top: 12px;
  margin-bottom: 8px;

  /* Prevent awkward giant wraps */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ddhq-wcpc .price{
  font-size: var(--ddhq-wcpc-price-size, 14px);
  line-height: 1.2;
  color: var(--ddhq-wcpc-price-color, inherit);
  margin-bottom: 10px;
}

/* Button styling */
.ddhq-wcpc a.button,
.ddhq-wcpc button.button,
.ddhq-wcpc .button{
  background: var(--ddhq-wcpc-button-bg, inherit);
  color: var(--ddhq-wcpc-button-color, inherit);
  border-radius: var(--ddhq-wcpc-button-radius, 999px);
  padding: 10px 16px;
  line-height: 1;
  align-self: flex-start;
}

/* Add padding so arrows don’t overlap media on tight containers */
.ddhq-wcpc__swiper{
  padding-left: 48px;
  padding-right: 48px;
}

/* Position arrows relative to the media area:
   We approximate by anchoring at 28% height of the slide (works well for product cards).
*/
.ddhq-wcpc__nav {
  position: absolute;
  top: 28%;
  z-index: 5;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.12);
  background: var(--ddhq-wcpc-nav-bg, #fff);
  cursor: pointer;
  transform: translateY(-50%);
  box-shadow: 0 4px 14px rgba(0,0,0,.06);
}
.ddhq-wcpc__prev { left: 10px; }
.ddhq-wcpc__next { right: 10px; }

.ddhq-wcpc__nav:after {
  content: '';
  display: block;
  width: 10px;
  height: 10px;
  border-top: 2px solid var(--ddhq-wcpc-nav-color, rgba(0,0,0,.7));
  border-right: 2px solid var(--ddhq-wcpc-nav-color, rgba(0,0,0,.7));
  position: absolute;
  top: 50%;
  left: 50%;
}
.ddhq-wcpc__prev:after { transform: translate(-35%, -50%) rotate(-135deg); }
.ddhq-wcpc__next:after { transform: translate(-65%, -50%) rotate(45deg); }

/* Pagination */
.ddhq-wcpc__pagination { margin-top: 12px; text-align: center; }
.ddhq-wcpc .swiper-pagination-bullet{
  background: var(--ddhq-wcpc-dots-color, rgba(0,0,0,.25));
  opacity: 1;
}
.ddhq-wcpc .swiper-pagination-bullet-active{
  background: var(--ddhq-wcpc-dots-active-color, rgba(0,0,0,.7));
}

/* Mobile tweaks */
@media (max-width: 767px){
  .ddhq-wcpc__swiper{ padding-left: 44px; padding-right: 44px; }
  .ddhq-wcpc__nav{ top: 26%; }
  .ddhq-wcpc .woocommerce-loop-product__title{
    -webkit-line-clamp: 3;
  }
}


/* Alignment options */
.ddhq-wcpc--center .woocommerce-loop-product__title,
.ddhq-wcpc--center .price,
.ddhq-wcpc--center .button { text-align: center; }
.ddhq-wcpc--center .button{ align-self: center; }


.ddhq-wcpc--hover-atc li.product:hover .button,
.ddhq-wcpc--hover-atc li.product:hover a.add_to_cart_button,
.ddhq-wcpc--hover-atc li.product:hover a.product_type_simple,
.ddhq-wcpc--hover-atc li.product:hover a.product_type_variable{
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Always show on touch devices */
@media (hover: none) {
  .ddhq-wcpc--hover-atc li.product .button,
  .ddhq-wcpc--hover-atc li.product a.add_to_cart_button,
  .ddhq-wcpc--hover-atc li.product a.product_type_simple,
  .ddhq-wcpc--hover-atc li.product a.product_type_variable{
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }
}


/* Hover-reveal Add to Cart (robust selectors) */
.ddhq-wcpc--hover-atc li.product .button,
.ddhq-wcpc--hover-atc li.product a.add_to_cart_button,
.ddhq-wcpc--hover-atc li.product a.ajax_add_to_cart,
.ddhq-wcpc--hover-atc li.product a.product_type_simple,
.ddhq-wcpc--hover-atc li.product a.product_type_variable,
.ddhq-wcpc--hover-atc li.product a.product_type_external,
.ddhq-wcpc--hover-atc li.product a.product_type_grouped,
.ddhq-wcpc--hover-atc li.product a.added_to_cart{
  opacity: 0 !important;
  visibility: hidden !important;
  transform: translateY(8px);
  pointer-events: none;
  max-height: 0;
  overflow: hidden;
  margin-top: 0 !important;
  transition: opacity .18s ease, transform .18s ease, max-height .18s ease, visibility .18s ease, margin-top .18s ease;
}

/* On hover, reveal */
.ddhq-wcpc--hover-atc li.product:hover .button,
.ddhq-wcpc--hover-atc li.product:hover a.add_to_cart_button,
.ddhq-wcpc--hover-atc li.product:hover a.ajax_add_to_cart,
.ddhq-wcpc--hover-atc li.product:hover a.product_type_simple,
.ddhq-wcpc--hover-atc li.product:hover a.product_type_variable,
.ddhq-wcpc--hover-atc li.product:hover a.product_type_external,
.ddhq-wcpc--hover-atc li.product:hover a.product_type_grouped,
.ddhq-wcpc--hover-atc li.product:hover a.added_to_cart{
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateY(0);
  pointer-events: auto;
  max-height: 120px;
  overflow: visible;
  margin-top: 10px !important;
}

/* Make CTA look like the sample (pill + centered). Themes can override; we keep it scoped */
.ddhq-wcpc--hover-atc li.product a.add_to_cart_button,
.ddhq-wcpc--hover-atc li.product a.ajax_add_to_cart,
.ddhq-wcpc--hover-atc li.product a.product_type_simple,
.ddhq-wcpc--hover-atc li.product a.product_type_variable,
.ddhq-wcpc--hover-atc li.product a.product_type_external,
.ddhq-wcpc--hover-atc li.product a.product_type_grouped{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  width: var(--ddhq-wcpc-button-width, auto);
  min-height: 40px;
}

/* If centered layout, default to full-width button (sample-like) */
.ddhq-wcpc--center{
  --ddhq-wcpc-button-width: 100%;
}

/* Always show on touch devices */
@media (hover: none) {
  .ddhq-wcpc--hover-atc li.product .button,
  .ddhq-wcpc--hover-atc li.product a.add_to_cart_button,
  .ddhq-wcpc--hover-atc li.product a.ajax_add_to_cart,
  .ddhq-wcpc--hover-atc li.product a.product_type_simple,
  .ddhq-wcpc--hover-atc li.product a.product_type_variable,
  .ddhq-wcpc--hover-atc li.product a.product_type_external,
  .ddhq-wcpc--hover-atc li.product a.product_type_grouped,
  .ddhq-wcpc--hover-atc li.product a.added_to_cart{
    opacity: 1 !important;
    visibility: visible !important;
    transform: none;
    pointer-events: auto;
    max-height: none;
    overflow: visible;
    margin-top: 10px !important;
  }
}


.ddhq-wcpc .star-rating::before{
  content: "sssss";
  color: rgba(0,0,0,.25);
  float: left;
  top: 0;
  left: 0;
  position: absolute;
}
.ddhq-wcpc .star-rating span{
  overflow: hidden;
  float: left;
  top: 0;
  left: 0;
  position: absolute;
  padding-top: 1.5em; /* push text away */
  font-size: 0 !important;
  line-height: 0 !important;
}
.ddhq-wcpc .star-rating span::before{
  content: "sssss";
  color: rgba(0,0,0,.75);
  top: 0;
  left: 0;
  position: absolute;
}


/* WC star-rating fallback (and fill fix) */
.ddhq-wcpc .star-rating{
  position: relative;
  overflow: hidden;
  display: inline-block;
  height: 1em;
  line-height: 1;
  width: 5.4em; /* 5 stars */
  font-size: 14px;
  font-family: star, sans-serif;
}
.ddhq-wcpc .star-rating::before{
  content: "sssss";
  color: rgba(0,0,0,.25);
  position: absolute;
  top: 0;
  left: 0;
  font-size: 14px;
  line-height: 1;
}
.ddhq-wcpc .star-rating span{
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  height: 1em;
  overflow: hidden; /* this is what creates the fill using inline width % */
  text-indent: -9999px; /* hide "Rated x out of 5" */
  white-space: nowrap;
}
.ddhq-wcpc .star-rating span::before{
  content: "sssss";
  color: rgba(0,0,0,.75);
  position: absolute;
  top: 0;
  left: 0;
  font-size: 14px; /* IMPORTANT: don't inherit hidden text */
  line-height: 1;
  text-indent: 0;
}

/* Full-width Add to Cart like the sample */
.ddhq-wcpc li.product a.add_to_cart_button,
.ddhq-wcpc li.product a.ajax_add_to_cart,
.ddhq-wcpc li.product a.product_type_simple,
.ddhq-wcpc li.product a.product_type_variable,
.ddhq-wcpc li.product a.product_type_external,
.ddhq-wcpc li.product a.product_type_grouped,
.ddhq-wcpc li.product .button{
  width: var(--ddhq-wcpc-button-width, 100%);
  min-width: var(--ddhq-wcpc-button-width, 100%);
  justify-content: center;
}
