/* Cascina Bonfiglio — Floating points badge (Figma 193:2777).
   Card 180.193x76 con shape SVG di Figma (corner r=3.6 + nub destro che si raccorda al jar)
   + cerchio jar 73x73 separato a destra. */
.cb-loyalty-floater {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 230; /* sopra al backdrop carrello (220) */
    display: block;
    width: 290px;  /* card 217 + jar agganciato */
    height: 94px;
    text-decoration: none;
    color: inherit;
    pointer-events: auto;
    isolation: isolate;
    transform: translateX(0);
    /* Ombra esatta da Figma Group 61 (layered drop-shadow, look soft realistico).
       Applicata sul wrapper così card+jar condividono la stessa silhouette di ombra. */
    filter:
        drop-shadow(-63px 124px 56px rgba(0, 0, 0, 0.01))
        drop-shadow(-35px 70px 47px rgba(0, 0, 0, 0.02))
        drop-shadow(-16px 31px 35px rgba(0, 0, 0, 0.03))
        drop-shadow(-4px 8px 19px rgba(0, 0, 0, 0.04));
    /* Default = stesso timing dell'EXIT del carrello (.28s ease-in): così la
       chiusura sincronizza floater e panel. L'apertura override sotto. */
    transition: transform .28s cubic-bezier(0.55, 0, 0.68, 0.05);
    animation: cb-floater-in .45s ease both;
}
.cb-loyalty-floater:hover { transform: translateY(-2px); }

/* Entry: solo opacity. NESSUN transform nel keyframe — altrimenti `both`
   blocca il translateY(0) e il translateX(-580) di cart-open non passa. */
@keyframes cb-floater-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* CARD: shape SVG da Figma (white fill + nub right + corner r=3.6).
   Nessuna ombra qui: la drop-shadow è sul wrapper (segue la silhouette card+jar). */
.cb-loyalty-floater__card {
    position: absolute;
    left: 0;
    top: 0;
    width: 217px;
    height: 100px;
    box-sizing: border-box;
    padding: 10px 20px 10px 12px;
    background-image: url('../img/loyalty/floater-card-bg.svg');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    display: flex;
    flex-direction: column;
    line-height: 1;
}

.cb-loyalty-floater__small {
    font-family: var(--cb-font-body);
    font-size: 9.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0;
    line-height: 1;
    color: #000;
}
.cb-loyalty-floater__num {
    font-family: var(--cb-font-body);
    font-size: 22px;
    font-weight: 700;
    color: var(--cb-green);
    letter-spacing: -1px;
    line-height: 1;
    margin-top: 4px;
}
.cb-loyalty-floater__msg {
    font-family: var(--cb-font-body);
    font-size: 11px;
    font-weight: 400;
    line-height: 13.5px;
    letter-spacing: -0.2px;
    color: #000;
    margin-top: 6px;
}
.cb-loyalty-floater__msg strong { font-weight: 700; }

/* Cerchio jar 73x73, allineato al nub della card (Figma jar starts at x=185
   relative to floater origin; card ends with nub at x≈179.28). */
.cb-loyalty-floater__jar {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 73px;
    height: 73px;
    background: #ffffff;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.cb-loyalty-floater__jar img {
    width: 31px;
    height: auto;
    display: block;
}

/* Quando il carrello è VISIBILE (e non in chiusura), trasla floater a sinistra
   in sync con la slide-in del cart (.35s ease-out). */
body:has(.cb-cart-sidebar:not([hidden]):not(.is-closing)) .cb-loyalty-floater {
    transform: translateX(-580px);
    transition: transform .35s cubic-bezier(0.22, 1, 0.36, 1);
}
body:has(.cb-cart-sidebar:not([hidden]):not(.is-closing)) .cb-loyalty-floater:hover {
    transform: translateX(-580px) translateY(-2px);
}

/* Laptop schermo piccolo (es. MacBook Air ≤1440px): card un po' più alta per ospitare il testo. */
@media (min-width: 769px) and (max-width: 1440px) {
    .cb-loyalty-floater__card { height: 88px; }
}

@media (max-width: 768px) {
    .cb-loyalty-floater { right: 12px; bottom: 14px; width: 232px; height: 76px; }
    .cb-loyalty-floater__card { width: 172px; height: 76px; padding: 7px 12px 7px 9px; }
    .cb-loyalty-floater__small { font-size: 8.5px; }
    .cb-loyalty-floater__num { font-size: 18px; letter-spacing: -.7px; margin-top: 2px; }
    .cb-loyalty-floater__msg { font-size: 9.5px; line-height: 11px; margin-top: 4px; }
    .cb-loyalty-floater__jar { width: 60px; height: 60px; }
    .cb-loyalty-floater__jar img { width: 26px; }

    body:has(.cb-cart-sidebar:not([hidden]):not(.is-closing)) .cb-loyalty-floater {
        transform: translateX(calc(100% + 24px));
        opacity: 0;
        pointer-events: none;
    }
}

@media (max-width: 480px) {
    .cb-loyalty-floater { right: 8px; bottom: 12px; width: 200px; height: 68px; }
    .cb-loyalty-floater__card { width: 148px; height: 68px; padding: 6px 10px 6px 8px; }
    .cb-loyalty-floater__num { font-size: 16px; }
    .cb-loyalty-floater__msg { font-size: 8.5px; line-height: 10px; }
    .cb-loyalty-floater__jar { width: 52px; height: 52px; }
    .cb-loyalty-floater__jar img { width: 22px; }
}

/* Solleva il floater sopra la sticky cart bar mobile (≤640px) quando visibile. */
@media (max-width: 640px) {
    body:has(.cb-cart-stickybar:not([hidden])) .cb-loyalty-floater {
        bottom: calc(80px + env(safe-area-inset-bottom));
    }
}

/* MacBook range (laptop desktop, escluso tablet/mobile e monitor desktop grandi) */
@media (min-width: 1025px) and (max-width: 1700px) {
    .cb-loyalty-floater { bottom: 75px; }
    .cb-loyalty-floater__card { height: 100px; }
}

/* Stato collassato: card scompare a destra, resta solo il jar (peek-and-collapse). */
.cb-loyalty-floater[data-cb-loyalty-state="collapsed"] .cb-loyalty-floater__card {
    opacity: 0;
    transform: translateX(160px);
    pointer-events: none;
}
.cb-loyalty-floater__card {
    transition: opacity .3s ease, transform .35s cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-reduced-motion: reduce) {
    .cb-loyalty-floater { transition: none; animation: none; }
    .cb-loyalty-floater__card { transition: none; }
}

/* Hide floater on pages where points are already prominently visible
   (cart, checkout, account) to avoid overlap with riepilogo / dashboard. */
body.page-template-page-carrello .cb-loyalty-floater,
body.page-template-page-pagamento .cb-loyalty-floater,
body.page-template-page-account .cb-loyalty-floater,
body.page-template-page-login .cb-loyalty-floater,
body.page-template-page-registrazione .cb-loyalty-floater,
body.page-template-page-conferma-email .cb-loyalty-floater,
body.page-template-page-recupero-password .cb-loyalty-floater,
body.page-template-page-reset-password .cb-loyalty-floater {
    display: none !important;
}
