/* ============================================
   Cart Icon Button — cart-icon-button.css
   ============================================ */

/* Icone SVG inline via content/mask — usiamo
   l'approccio class-based per massima compatibilità */

/* --- Reset testo sul pulsante --- */
a.add_to_cart_button.cib-ready,
button.add_to_cart_button.cib-ready {
    font-size: 0 !important;           /* nasconde il testo */
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    min-width: 0 !important;
    position: relative;
    overflow: hidden;
    transition: background-color 0.25s ease, transform 0.15s ease;
}

/* --- Icona di base: carrello --- */
a.add_to_cart_button.cib-ready::before,
button.add_to_cart_button.cib-ready::before {
    content: '';
    display: inline-block;
    width: 22px;
    height: 22px;
    background-color: currentColor;
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='21' r='1'/%3E%3Ccircle cx='20' cy='21' r='1'/%3E%3Cpath d='M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6'/%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='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='21' r='1'/%3E%3Ccircle cx='20' cy='21' r='1'/%3E%3Cpath d='M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6'/%3E%3C/svg%3E");
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-position: center;
    mask-position: center;
    transition: opacity 0.2s ease, transform 0.2s ease;
    flex-shrink: 0;
}

/* --- Nascondi la rotellina di caricamento di WooCommerce --- */
a.add_to_cart_button.cib-ready.loading::after,
button.add_to_cart_button.cib-ready.loading::after {
    display: none !important;
    content: none !important;
}

/* Stato loading: carrello leggermente più trasparente */
a.add_to_cart_button.cib-ready.loading::before,
button.add_to_cart_button.cib-ready.loading::before {
    opacity: 0.45;
}

/* --- Stato "aggiunto": check al posto del carrello --- */
a.add_to_cart_button.cib-ready.added::before,
button.add_to_cart_button.cib-ready.added::before {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%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='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
    opacity: 1;
    transform: scale(1.15);
}

/* Piccola animazione pop sul check */
@keyframes cib-pop {
    0%   { transform: scale(0.7);  opacity: 0; }
    60%  { transform: scale(1.25); opacity: 1; }
    100% { transform: scale(1.15); opacity: 1; }
}

a.add_to_cart_button.cib-ready.added::before,
button.add_to_cart_button.cib-ready.added::before {
    animation: cib-pop 0.3s ease forwards;
}

/* --- Rimuoviamo anche la rotellina di WC che usa ::before in alcuni temi --- */
a.add_to_cart_button.cib-ready.loading {
    pointer-events: none; /* evita doppio click durante l'ajax */
}
