/*
 * PC Cartes produits Blocksy
 * Cartes produits WooCommerce : voile, titre / prix / taxonomie au survol,
 * échange d'image avec dézoom, icône panier.
 * Styles, couleurs et affichage des éléments : Customizer de Blocksy.
 */

/* =========================================
   CARTES PRODUITS – titre + prix au survol
   ========================================= */

/* --- Calque posé sur l'image, même ratio qu'elle --- */
[data-products] .pc-carte-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  aspect-ratio: var(--pccp-ratio, 3 / 4);
  margin: 0 !important;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
  border-radius: var(--theme-border-radius, 3px);
  background: rgba(0, 0, 0, 0);
  transition: background var(--pccp-duree, .6s) ease;
}
[data-products] .product:hover .pc-carte-overlay {
  background: rgba(0, 0, 0, var(--pccp-voile, .25));
}

/* --- Bloc titre + prix + taxonomie --- */
[data-products] .pc-carte-infos {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  transform: translateY(0);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 15px;
  text-align: center;
  pointer-events: none;
  transition: top var(--pccp-duree, .6s) ease, transform var(--pccp-duree, .6s) ease;
}
[data-products] .product:hover .pc-carte-infos {
  top: 50%;
  transform: translateY(-50%);
}

/* Seuls les liens captent le clic ; ailleurs, le clic va à l'image */
[data-products] .pc-carte-infos a {
  pointer-events: auto;
}

/* Styles et couleurs : Customizer. Juste une ombre pour la lisibilité */
[data-products] .pc-carte-infos,
[data-products] .pc-carte-infos * {
  text-shadow: 0 1px 3px rgba(0, 0, 0, .4);
}
[data-products] .pc-carte-infos > * {
  margin: 0 !important;
}

/* --- Affichage selon le Customizer : absent de la carte = absent du bloc --- */
[data-products] .product:not(:has(> .woocommerce-loop-product__title)) .pc-carte-infos .woocommerce-loop-product__title,
[data-products] .product:not(:has(> .price)) .pc-carte-infos .price,
[data-products] .product:not(:has(> .entry-meta)) .pc-carte-infos .entry-meta {
  display: none;
}

/* --- Espace sous l'image : supprimé si plus rien n'est affiché dessous ---
   Blocksy ajoute sous l'image l'espacement réglé dans le Customizer
   (--product-element-spacing). Titre, prix, taxonomie et bouton étant
   masqués ou superposés, cet espace s'ajoutait à l'écart entre les rangées.
   Il est conservé si un autre élément (note, description, stock…) reste
   affiché sous l'image. */
[data-products] .product > figure:not(:has(~ :not(.woocommerce-loop-product__title, .price, .entry-meta, .ct-woo-card-actions, .pc-carte-overlay, .pc-carte-panier))) {
  margin-bottom: 0;
}

/* --- Badge promo au-dessus du calque --- */
[data-products] .onsale {
  z-index: 2;
}

/* --- Échange d'image déclenché par toute la carte, avec dézoom --- */
[data-hover=swap] .has-hover-effect .ct-swap {
  transform: scale(1.15);
  transition: opacity var(--pccp-duree-image, .8s) ease, transform var(--pccp-duree-image, .8s) ease;
}
@media (hover: hover) {
  [data-hover=swap] .product:hover .ct-swap {
    opacity: 1;
    transform: scale(1);
  }
  [data-hover=swap] .has-hover-effect .ct-swap + img {
    opacity: 1 !important;
  }
}

/* --- Écrans tactiles : voile et bloc affichés d'office --- */
@media (hover: none) {
  [data-products] .pc-carte-overlay {
    background: rgba(0, 0, 0, var(--pccp-voile, .25));
  }
  [data-products] .pc-carte-infos {
    top: 50%;
    transform: translateY(-50%);
  }
}

/* --- Éléments d'origine masqués (gardés dans le HTML pour :has) --- */
[data-products] .product > .woocommerce-loop-product__title,
[data-products] .product > .price,
[data-products] .product > .entry-meta,
[data-products] .product > .ct-woo-card-actions {
  display: none;
}

/* =========================================
   CARTES PRODUITS – icône panier
   ========================================= */

/* --- Réglages --- */
[data-products] .product {
  --pc-panier-decalage: 90px;   /* hauteur des 2 icônes + espacement */
  --pc-panier-taille: 35px;     /* diamètre du bouton */
  --pc-panier-icone: 20px;      /* taille de l'icône dans le rond */
}

/* --- Même position que les icônes Blocksy, décalée vers le bas --- */
[data-products] .pc-carte-panier {
  margin: var(--pc-panier-decalage) 0 0 0 !important;
}

/* --- Pastille sans texte (couleurs : Customizer) --- */
[data-products] .pc-carte-panier .button {
  width: var(--pc-panier-taille);
  height: var(--pc-panier-taille);
  min-height: 0;
  padding: 0;
  font-size: 0;
  border-radius: 100%;
}

/* --- Icône panier avec un + (hors chargement) --- */
[data-products] .pc-carte-panier .button:not(.loading)::after {
  content: "";
  width: var(--pc-panier-icone);
  height: var(--pc-panier-icone);
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7.5 9.5 10 3.5M16.5 9.5 14 3.5'/%3E%3Cpath d='M2.5 9.5h19l-2.2 10.5H4.7z'/%3E%3Cpath d='M12 12.5v5M9.5 15h5'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7.5 9.5 10 3.5M16.5 9.5 14 3.5'/%3E%3Cpath d='M2.5 9.5h19l-2.2 10.5H4.7z'/%3E%3Cpath d='M12 12.5v5M9.5 15h5'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* --- Après l'ajout : coche --- */
[data-products] .pc-carte-panier .button.added:not(.loading)::after {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5 10 17.5 19 7'/%3E%3C/svg%3E");
          mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5 10 17.5 19 7'/%3E%3C/svg%3E");
}

/* --- Lien texte « Voir le panier » masqué --- */
[data-products] .pc-carte-panier .added_to_cart {
  display: none;
}
