/*
 | ck-cart-toast-v1.css — the beat between a tap on "Add to cart" and the shopper believing it.
 |
 | What the shelf did before this sheet: the confirmation was one green line of text inside the
 | option sheet, under the buttons, on a screen where the sheet is often already scrolled past it.
 | The number that actually matters — how many things are now in the cart — sits in a badge that
 | Livewire redraws a third of a second later with no motion at all, so a slow round trip reads
 | exactly like a dead button. This layer gives the same fact two moving witnesses: a note that
 | slides up over the screen and the cart marks that are already on the page (header pill, floating
 | cart button, phone dock tab) popping once as the new number lands.
 |
 | A new filename, never a query string: the edge holds a CSS URL for seven days.
 */

/*
 * The wrapper is the positioner and the card is the thing that moves, because the phone position
 * needs translateX(-50%) to centre itself and an entrance animation that also writes transform
 * would fight it. Two elements, one job each.
 */
.ck-cart-note {
    position: fixed;
    left: 50%;
    /*
     * Above the dock AND above the floating cart button, which already owns
     * `--ck-bottom-inset + 84px → +140px`. Nothing else is asked to move.
     */
    bottom: calc(var(--ck-bottom-inset, 0px) + 152px);
    /*
     * Above the dock, above the floating cart (99999), and above the full-screen picture viewer
     * (100020) — that viewer has its own Add-to-Cart door, and a note the overlay hides is a note
     * that never fired.
     */
    z-index: 100030;
    width: min(92vw, 420px);
    transform: translateX(-50%);
    /* Idle, the layer must not eat a single tap anywhere on the screen. */
    pointer-events: none;
}

.ck-cart-note[hidden] {
    display: none;
}

.ck-cart-note-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid #ececee;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 10px 30px rgba(17, 17, 17, 0.16);
    color: #171717;
    text-align: left;
}

/* --- the tick ------------------------------------------------------------ */

.ck-cart-note-tick {
    display: flex;
    flex: none;
    width: 30px;
    height: 30px;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    background: #e8f6ee;
    color: #16a34a;
}

.ck-cart-note-tick svg {
    width: 18px;
    height: 18px;
}

/* --- the words ----------------------------------------------------------- */

.ck-cart-note-body {
    display: flex;
    min-width: 0;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 1px;
}

.ck-cart-note-line {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.25;
}

.ck-cart-note-item {
    overflow: hidden;
    font-size: 12.5px;
    line-height: 1.3;
    color: #6b7280;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.ck-cart-note-go {
    flex: none;
    padding: 7px 12px;
    border-radius: 9999px;
    background: #c9161e;
    color: #fff;
    font-size: 12.5px;
    font-weight: 700;
    text-decoration: none;
    pointer-events: auto;
}

.ck-cart-note-go:active {
    background: #a5121a;
}

/* --- motion -------------------------------------------------------------- */

.ck-cart-note.is-in .ck-cart-note-card {
    animation: ck-cart-note-in 260ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.ck-cart-note.is-in .ck-cart-note-tick {
    animation: ck-cart-tick 340ms cubic-bezier(0.34, 1.56, 0.64, 1) 90ms both;
}

.ck-cart-note.is-out .ck-cart-note-card {
    animation: ck-cart-note-out 200ms ease-in both;
}

@keyframes ck-cart-note-in {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes ck-cart-note-out {
    from {
        opacity: 1;
        transform: none;
    }
    to {
        opacity: 0;
        transform: translateY(8px);
    }
}

/* The check arrives a beat after the card, so the eye lands on the card first. */
@keyframes ck-cart-tick {
    0% {
        opacity: 0;
        transform: scale(0.4);
    }
    60% {
        opacity: 1;
        transform: scale(1.14);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/*
 * One pop per cart mark, on the element that holds the number. Applied by the script only once the
 * redrawn badge is actually in the DOM — popping a node Livewire is about to replace throws the
 * animation away with it.
 */
.ck-cart-pop {
    animation: ck-cart-pop 480ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes ck-cart-pop {
    0% {
        transform: scale(1);
    }
    34% {
        transform: scale(1.26);
    }
    68% {
        transform: scale(0.94);
    }
    100% {
        transform: scale(1);
    }
}

.ck-cart-ring {
    animation: ck-cart-ring 620ms ease-out both;
}

@keyframes ck-cart-ring {
    from {
        box-shadow: 0 0 0 0 rgba(201, 22, 30, 0.45);
    }
    to {
        box-shadow: 0 0 0 14px rgba(201, 22, 30, 0);
    }
}

/* --- the desktop seat ---------------------------------------------------- */

/*
 * On a wide screen the floating cart owns the bottom-right corner and the dock is switched off
 * altogether, so the note goes bottom-left, where no control lives.
 */
@media (min-width: 1024px) {
    .ck-cart-note {
        left: auto;
        right: auto;
        bottom: 26px;
        left: 26px;
        width: 380px;
        transform: none;
    }
}

/* --- and the version for a shopper who asked for less motion ------------- */

@media (prefers-reduced-motion: reduce) {
    .ck-cart-note.is-in .ck-cart-note-card,
    .ck-cart-note.is-in .ck-cart-note-tick,
    .ck-cart-note.is-out .ck-cart-note-card,
    .ck-cart-pop,
    .ck-cart-ring {
        animation: none;
        transform: none;
    }

    /* The fact still has to arrive; only the movement goes. */
    .ck-cart-note.is-out {
        opacity: 0;
    }
}
