/*
 * Toasts in place of Magento's message bar (web/js/satrunner-toast.js, docs/toasts.html).
 * Centred at the top: on Desktop level with the cart card (90px), below 1024px 8px under the floating pill (74px);
 * on Mobile flush with the top of the cart while it is open (66px).
 * Slide down from above the screen, stay 4 s, slide back up. Colours as Magento's messages (success #e5efe5).
 */

/* Magento's own bar: hidden only once the toast script runs, so messages never get lost */
html.sr-toasts-ready .page.messages {
    display: none;
}

.sr-toasts {
    --sr-toast-top: 88px;
    position: fixed;
    top: var(--sr-toast-top);
    right: 0;
    left: 0;
    z-index: 999999; /* above the cart card, its backdrop and the chat button */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
    pointer-events: none;
}

.sr-toast {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    box-sizing: border-box;
    width: max-content; /* one row when there is room; wraps only when the space runs out */
    max-width: 100%;
    min-height: 64px;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.12);
    font-family: 'Montserrat', sans-serif;
    font-size: 1.6rem;
    font-weight: 500;
    line-height: 1.4;
    opacity: 0;
    pointer-events: auto;
    transform: translateY(calc(-100% - var(--sr-toast-top)));
    transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease;
}

.sr-toast.is-in {
    opacity: 1;
    transform: none;
}

.sr-toast.is-out {
    opacity: 0;
    transform: translateY(calc(-100% - var(--sr-toast-top)));
    transition-duration: 0.35s, 0.35s;
    transition-timing-function: cubic-bezier(0.55, 0, 1, 0.45), ease;
}

.sr-toast__icon {
    flex: none;
    display: flex;
    width: 24px;
    height: 24px;
}

.sr-toast__icon svg {
    width: 100%;
    height: 100%;
}

.sr-toast__text {
    min-width: 0;
}

.sr-toast__text a,
.sr-toast__text a:visited,
.sr-toast__text a:hover {
    color: inherit;
    text-decoration: underline;
}

.sr-toast--success {
    background: #e5efe5;
    color: #00843d;
}

.sr-toast--error {
    background: #fae5e5;
    color: #b30000;
}

.sr-toast--warning,
.sr-toast--notice {
    background: #fdf0d5;
    color: #6f4400;
}

/* Desktop with the cart card open: beside the card with a 48px gutter (web/css/satrunner-cart.css: 400px wide,
   right max(48px, …)), so it doesn't cover the card */
@media (min-width: 1024px) {
    html.sr-mcart-open .sr-toasts {
        right: calc(max(48px, (100% - 1372px) / 2) + 400px + 48px);
        align-items: flex-end;
        padding-right: 0;
    }
}

@media (max-width: 1023px) {
    .sr-toasts {
        --sr-toast-top: 72px;
    }
}

/* Mobile, cart open: flush with the top edge of the cart part of the grown pill (pill 10px + bar row 56px) */
@media (max-width: 448px) {
    html.sr-mcart-open .sr-toasts {
        --sr-toast-top: 64px;
    }
}

@media (max-width: 448px) {
    .sr-toast {
        width: 100%;
        padding: 16px 20px;
        font-size: 1.6rem;
    }
}

/* Reduced motion: fade only */
@media (prefers-reduced-motion: reduce) {
    .sr-toast,
    .sr-toast.is-out {
        transform: none;
        transition: opacity 0.2s ease;
    }
}
