/* ===================== */
/* NOTIFICHE A PILLOLA   */
/* ===================== */

.toast-region {
    position: fixed;
    top: max(20px, env(safe-area-inset-top));
    left: 50%;
    z-index: 10050;
    width: max-content;
    max-width: calc(100vw - 32px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    transform: translateX(-50%);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    pointer-events: auto;
    cursor: pointer;
    filter: drop-shadow(0 10px 22px rgba(31, 157, 99, 0.22));
}

.toast--error {
    filter: drop-shadow(0 10px 22px rgba(159, 9, 9, 0.22));
}

/* cerchio con l'icona: entra con un rimbalzo */
.toast-icon {
    position: relative;
    z-index: 2;
    flex: 0 0 auto;
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    background: radial-gradient(circle at 35% 30%, #4fd492 0%, #1f9d63 72%);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.92);
    animation: toastPop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.toast-icon svg {
    width: 26px;
    height: 26px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
    transform-origin: 50% 12%;
    animation: toastRing 1s ease-in-out 0.45s both;
}

/* pillola: si apre da sinistra verso destra */
.toast-body {
    display: flex;
    align-items: center;
    min-height: 46px;
    margin-left: -27px;
    padding: 8px 24px 8px 42px;
    box-sizing: border-box;
    border-radius: 999px;
    background: #d7f4e5;
    color: #126b45;
    font-family: var(--font-secondary, 'Inter', sans-serif);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.35;
    clip-path: inset(0 100% 0 0 round 999px);
    animation: toastExpand 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.25s forwards;
}

.toast-text {
    opacity: 0;
    transform: translateX(-8px);
    animation: toastText 0.35s ease-out 0.5s forwards;
}

/* errore: rosso del sito, icona che "trema" */
.toast--error .toast-icon {
    background: radial-gradient(circle at 35% 30%, #d23a3a 0%, #9F0909 72%);
}

.toast--error .toast-icon svg {
    transform-origin: center;
    animation: toastShake 0.5s ease-in-out 0.45s both;
}

.toast--error .toast-body {
    background: #fbe3e3;
    color: #8a0b0b;
}

/* uscita */
.toast.is-leaving .toast-body {
    clip-path: inset(0 0 0 0 round 999px);
    animation: toastCollapse 0.3s ease-in forwards;
}

.toast.is-leaving .toast-text {
    opacity: 1;
    transform: none;
    animation: none;
}

.toast.is-leaving .toast-icon {
    animation: toastOut 0.3s ease-in 0.18s forwards;
}

@keyframes toastPop {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}

@keyframes toastRing {
    0%, 100% { transform: rotate(0); }
    15% { transform: rotate(18deg); }
    30% { transform: rotate(-15deg); }
    45% { transform: rotate(10deg); }
    60% { transform: rotate(-6deg); }
    75% { transform: rotate(3deg); }
}

@keyframes toastShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-3px); }
    40% { transform: translateX(3px); }
    60% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
}

@keyframes toastExpand {
    from { clip-path: inset(0 100% 0 0 round 999px); }
    to   { clip-path: inset(0 0 0 0 round 999px); }
}

@keyframes toastCollapse {
    from { clip-path: inset(0 0 0 0 round 999px); }
    to   { clip-path: inset(0 100% 0 0 round 999px); }
}

@keyframes toastText {
    to { opacity: 1; transform: none; }
}

@keyframes toastOut {
    to { transform: scale(0); opacity: 0; }
}

@media (max-width: 768px) {
    .toast-icon {
        width: 48px;
        height: 48px;
    }

    .toast-body {
        margin-left: -24px;
        padding-left: 36px;
        font-size: 14px;
    }
}
