/* YLP - carrello (inc/cart.css) */
:root {
  --ylp-blu: #2d4fa1;
  --ylp-blu-chiaro: #dfe8fb;
  --ylp-giallo: #ffcb05;
  --ylp-verde: #1f9d55;
  --ylp-rosso: #d93a2b;
  --ylp-testo: #1d2433;
  --ylp-grigio: #6b7385;
  --ylp-bordo: #e6e9f0;
}

/* --- Link Carrello e badge ------------------------------------------------ */
.showycart { position: relative; cursor: pointer; }
.ylp-badge {
  position: absolute; top: -6px; right: -12px;
  min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; background: var(--ylp-rosso); color: #fff;
  font: 700 12px/20px system-ui, sans-serif; text-align: center;
  box-shadow: 0 0 0 2px #fff;
}
.ylp-salta { animation: ylp-salta .6s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes ylp-salta {
  0% { transform: scale(1); } 30% { transform: scale(1.35) rotate(-8deg); }
  60% { transform: scale(.9) rotate(5deg); } 100% { transform: scale(1); }
}

/* --- Pannello ------------------------------------------------------------- */
.ylp-cart.offcanvas { width: min(420px, 100vw); color: var(--ylp-testo); }
.ylp-cart-head { background: var(--ylp-blu); color: #fff; }
.ylp-cart-head .offcanvas-title { font-weight: 700; display: flex; align-items: center; gap: .5rem; }
.ylp-cart-head .btn-close { filter: invert(1) grayscale(1) brightness(2); opacity: .9; }
.ylp-cart-ico { display: inline-block; animation: ylp-dondola 2.5s ease-in-out infinite; }
@keyframes ylp-dondola { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-10deg); } }

.ylp-cart-body { padding: .75rem 1rem; background: #f6f8fc; }
.ylp-cart-loading { text-align: center; color: var(--ylp-grigio); padding: 3rem 0; }

.ylp-cart-list { list-style: none; margin: 0; padding: 0; }
.ylp-cart-item {
  display: flex; gap: .85rem; padding: .75rem; margin-bottom: .6rem;
  background: #fff; border: 1px solid var(--ylp-bordo); border-radius: 14px;
  transition: opacity .25s, transform .25s;
}
.ylp-cart-item.ylp-esce { opacity: 0; transform: translateX(60px); }
.ylp-cart-item.ylp-attesa .ylp-cart-line { opacity: .5; }
.ylp-cart-img { flex: 0 0 64px; }
.ylp-cart-img img { width: 64px; height: auto; border-radius: 6px; box-shadow: 0 2px 6px rgba(0,0,0,.15); transition: transform .2s; }
.ylp-cart-img img:hover { transform: rotate(-4deg) scale(1.05); }
.ylp-cart-noimg { display: grid; place-items: center; width: 64px; height: 89px; font-size: 32px; background: var(--ylp-blu-chiaro); border-radius: 6px; }
.ylp-cart-info { flex: 1; min-width: 0; }
.ylp-cart-name { font-weight: 600; line-height: 1.25; }
.ylp-cart-name a { color: inherit; text-decoration: none; }
.ylp-cart-name a:hover { color: var(--ylp-blu); text-decoration: underline; }
.ylp-cart-unit { font-size: .85rem; color: var(--ylp-grigio); margin: .15rem 0 .5rem; }
.ylp-cart-row { display: flex; align-items: center; gap: .6rem; }
.ylp-cart-line { margin-left: auto; white-space: nowrap; transition: opacity .2s; }

.ylp-qty { display: inline-flex; align-items: center; border: 1px solid var(--ylp-bordo); border-radius: 999px; overflow: hidden; background: #fff; }
.ylp-qty-btn {
  width: 32px; height: 32px; border: 0; background: var(--ylp-blu-chiaro); color: var(--ylp-blu);
  font-size: 1.15rem; font-weight: 700; line-height: 1; cursor: pointer; transition: background .15s;
}
.ylp-qty-btn:hover:not(:disabled) { background: var(--ylp-giallo); color: var(--ylp-testo); }
.ylp-qty-btn:disabled { opacity: .35; cursor: default; }
.ylp-qty-in { width: 38px; height: 32px; border: 0; text-align: center; font-weight: 600; -moz-appearance: textfield; }
.ylp-qty-in::-webkit-outer-spin-button, .ylp-qty-in::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.ylp-cart-del {
  display: grid; place-items: center; width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--ylp-grigio); cursor: pointer;
}
.ylp-cart-del:hover { background: #fde8e6; color: var(--ylp-rosso); }

/* --- Carrello vuoto -------------------------------------------------------- */
.ylp-cart-vuoto { text-align: center; padding: 3rem 1rem; }
.ylp-cart-vuoto-ico { font-size: 64px; animation: ylp-galleggia 3s ease-in-out infinite; }
@keyframes ylp-galleggia { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-10px) rotate(6deg); } }

/* --- Piede: spedizione e totali -------------------------------------------- */
.ylp-cart-foot { padding: 1rem; background: #fff; border-top: 1px solid var(--ylp-bordo); box-shadow: 0 -6px 16px rgba(0,0,0,.05); }

.ylp-ship { margin-bottom: .75rem; }
.ylp-ship-msg { font-size: .92rem; margin: 0 0 .5rem; }
.ylp-ship-ok { color: var(--ylp-verde); }
.ylp-ship-bar { position: relative; height: 12px; margin: 0 22px 1.1rem 0; border-radius: 999px; background: var(--ylp-blu-chiaro); }
.ylp-ship-fill {
  height: 100%; border-radius: inherit; transition: width .6s cubic-bezier(.3, 1.3, .5, 1);
  background: linear-gradient(90deg, var(--ylp-giallo), #ffa000);
}
.ylp-ship-truck {
  position: absolute; top: 50%; font-size: 22px; line-height: 1;
  transform: translate(-50%, -58%) scaleX(-1); transition: left .6s cubic-bezier(.3, 1.3, .5, 1);
}
.ylp-ship-goal { position: absolute; right: -24px; top: 50%; transform: translateY(-55%); font-size: 20px; }
.ylp-ship-rates { list-style: none; margin: 0; padding: 0; font-size: .82rem; color: var(--ylp-grigio); }
.ylp-ship-rates li { display: flex; justify-content: space-between; gap: 1rem; }

.ylp-tot { margin: 0 0 .75rem; }
.ylp-tot > div { display: flex; justify-content: space-between; padding: .15rem 0; }
.ylp-tot dt { font-weight: 400; color: var(--ylp-grigio); }
.ylp-tot dd { margin: 0; font-weight: 600; }
.ylp-tot .ylp-tot-big { border-top: 1px dashed var(--ylp-bordo); margin-top: .35rem; padding-top: .5rem; font-size: 1.2rem; }
.ylp-tot .ylp-tot-big dt { color: var(--ylp-testo); font-weight: 700; }
.ylp-gratis { color: var(--ylp-verde); }
.ylp-tot-note { font-size: .75rem; color: var(--ylp-grigio); margin: -.35rem 0 .75rem; }

.ylp-cart-checkout {
  display: block; width: 100%; padding: .8rem 1rem; border-radius: 12px;
  background: var(--ylp-verde); color: #fff; font-size: 1.1rem; font-weight: 700;
  box-shadow: 0 4px 0 #157a40; transition: transform .1s, box-shadow .1s;
}
.ylp-cart-checkout:hover { background: #22ad5e; color: #fff; }
.ylp-cart-checkout:active { transform: translateY(3px); box-shadow: 0 1px 0 #157a40; }

/* --- Pulsanti AGGIUNGI in attesa ------------------------------------------- */
.add-cart.ylp-busy, .add-cart2.ylp-busy { pointer-events: none; opacity: .75; position: relative; color: transparent !important; }
.add-cart.ylp-busy::after, .add-cart2.ylp-busy::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px;
  border: 2px solid #fff; border-right-color: transparent; border-radius: 50%; animation: ylp-gira .7s linear infinite;
}
@keyframes ylp-gira { to { transform: rotate(360deg); } }

/* --- Effetti --------------------------------------------------------------- */
.ylp-volo { position: fixed; z-index: 10050; pointer-events: none; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.ylp-coriandoli { position: fixed; inset: 0; z-index: 10060; pointer-events: none; }

#ylp-toasts {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 10070;
  display: flex; flex-direction: column; gap: .5rem; width: min(92vw, 420px); pointer-events: none;
}
.ylp-toast {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .75rem 1rem; border-radius: 14px; color: #fff; background: var(--ylp-blu);
  box-shadow: 0 10px 30px rgba(0,0,0,.25); pointer-events: auto;
  animation: ylp-toast-in .35s cubic-bezier(.3, 1.5, .5, 1);
}
.ylp-toast-ok { background: var(--ylp-verde); }
.ylp-toast-err { background: var(--ylp-rosso); }
.ylp-toast-btn { flex: 0 0 auto; border: 0; border-radius: 999px; padding: .3rem .8rem; background: #fff; color: var(--ylp-testo); font-weight: 600; font-size: .85rem; }
.ylp-toast-via { opacity: 0; transform: translateY(10px); transition: opacity .35s, transform .35s; }
/* Con il carrello aperto gli avvisi stanno in alto, dentro il pannello */
body:has(.ylp-cart.show) #ylp-toasts { top: 64px; bottom: auto; left: auto; right: 12px; transform: none; width: min(396px, calc(100vw - 24px)); }
@keyframes ylp-toast-in { from { opacity: 0; transform: translateY(20px) scale(.95); } to { opacity: 1; transform: none; } }

/* --- Chi preferisce meno movimento ----------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .ylp-cart-ico, .ylp-cart-vuoto-ico, .ylp-salta, .ylp-toast { animation: none !important; }
  .ylp-ship-fill, .ylp-ship-truck, .ylp-cart-item { transition: none !important; }
}

/* --- Pulsante flottante "carrellino" --------------------------------------- */
#cart-icon { display: none !important; } /* vecchio pulsante */

.ylp-fab {
  position: fixed; right: 18px; bottom: 18px; z-index: 1030;
  width: 84px; height: 84px; padding: 0; border: 0; background: transparent; cursor: pointer;
  filter: drop-shadow(0 0 1.5px #fff) drop-shadow(0 0 1.5px #fff) drop-shadow(0 6px 10px rgba(12, 68, 124, .35));
  -webkit-tap-highlight-color: transparent;
}
.ylp-fab:focus-visible { outline: 3px solid var(--ylp-giallo); outline-offset: 4px; border-radius: 50%; }
.ylp-fab-corpo { display: block; animation: ylp-fab-galleggia 3s ease-in-out infinite; transition: transform .2s; }
.ylp-fab:hover .ylp-fab-corpo { transform: scale(1.08) rotate(-4deg); }
.ylp-fab:active .ylp-fab-corpo { transform: scale(.94); }
@keyframes ylp-fab-galleggia { 0%, 100% { translate: 0 0; } 50% { translate: 0 -4px; } }

/* occhi: normali che sbattono, felici dopo un'aggiunta, chiusi se il carrello è vuoto */
.ylp-fab-occhio { transform-box: fill-box; transform-origin: center; animation: ylp-fab-blink 4.5s infinite; }
@keyframes ylp-fab-blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
.ylp-fab-felici, .ylp-fab-chiusi, .ylp-fab-zzz { display: none; }
.ylp-fab-festa .ylp-fab-occhi { display: none; }
.ylp-fab-festa .ylp-fab-felici { display: inline; }
.ylp-fab-dorme .ylp-fab-occhi { display: none; }
.ylp-fab-dorme .ylp-fab-chiusi { display: inline; }
.ylp-fab-dorme .ylp-fab-zzz { display: inline; animation: ylp-fab-zzz 2.4s ease-in-out infinite; }
@keyframes ylp-fab-zzz { 0% { opacity: 0; transform: translate(0, 4px); } 40% { opacity: 1; } 100% { opacity: 0; transform: translate(6px, -8px); } }
.ylp-fab-dorme .ylp-fab-corpo { animation-duration: 5s; }

/* festa: dondola e le ruote girano */
.ylp-fab-festa .ylp-fab-corpo { animation: ylp-fab-dondola .7s ease; }
@keyframes ylp-fab-dondola { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-14deg) scale(1.1); } 40% { transform: rotate(12deg); } 60% { transform: rotate(-8deg); } 80% { transform: rotate(5deg); } }
.ylp-fab-festa .ylp-fab-ruota { animation: ylp-fab-ruote .7s linear; }
@keyframes ylp-fab-ruote { to { transform: rotate(720deg); } }

/* badge del pulsante */
.ylp-fab .ylp-badge {
  top: 2px; right: 0; min-width: 28px; height: 28px; padding: 0 7px;
  border-radius: 14px; font-size: 15px; line-height: 28px; box-shadow: 0 0 0 3px #fff;
}

/* avvisi sopra il pulsante sui telefoni */
@media (max-width: 576px) {
  .ylp-fab { right: 12px; bottom: 12px; }
  body.ylp-ha-fab #ylp-toasts { bottom: 104px; }
}

/* con il carrello aperto il pulsante si fa da parte */
body:has(.ylp-cart.show) .ylp-fab { opacity: 0; pointer-events: none; transition: opacity .2s; }

@media (prefers-reduced-motion: reduce) {
  .ylp-fab-corpo, .ylp-fab-occhio, .ylp-fab-zzz, .ylp-fab-ruota { animation: none !important; }
}
