/* Shared toast notifications for authenticated and guest screens. */
.toast-stack {
    position: fixed !important;
    z-index: 1000;
    top: 20px;
    right: 20px;
    width: min(390px, calc(100vw - 32px)) !important;
    max-width: none !important;
    margin: 0 !important;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast-stack .toast-item {
    --toast-ink: #17324d;
    --toast-start: #f8fbff;
    --toast-end: #edf4ff;
    --toast-border: #bfd3eb;
    position: relative;
    width: 100%;
    min-height: 42px;
    padding: 10px 46px 10px 16px !important;
    overflow: hidden;
    border-radius: 14px !important;
    color: var(--toast-ink) !important;
    border: 1px solid var(--toast-border) !important;
    background: linear-gradient(135deg, var(--toast-start), var(--toast-end)) !important;
    box-shadow: 0 18px 45px -18px rgba(15, 23, 42, .38) !important;
    backdrop-filter: blur(16px);
    pointer-events: auto;
    animation: toast-enter .42s cubic-bezier(.2, .9, .25, 1.15) both !important;
}

.toast-stack .toast-item.alert--success,
.toast-stack .toast-item.flash--success {
    --toast-ink: #087052;
    --toast-start: #f2fff9;
    --toast-end: #dcf8eb;
    --toast-border: #8dddbc;
}

.toast-stack .toast-item.alert--error,
.toast-stack .toast-item.flash--error {
    --toast-ink: #a51d37;
    --toast-start: #fff7f8;
    --toast-end: #ffe3e8;
    --toast-border: #f3a4b2;
}

.toast-stack .toast-item.alert--warning,
.toast-stack .toast-item.flash--warning {
    --toast-ink: #87520b;
    --toast-start: #fffdf4;
    --toast-end: #fff0c7;
    --toast-border: #e8c56c;
}

.toast-stack .toast-item.alert--info,
.toast-stack .toast-item.flash--info {
    --toast-ink: #145ca8;
    --toast-start: #f5faff;
    --toast-end: #dcecff;
    --toast-border: #91bce9;
}

.toast-stack .toast-item .alert__text,
.toast-stack .toast-item .flash__text {
    color: inherit !important;
    font-weight: 600;
    line-height: 1.5;
}

.toast-stack .toast-item.is-leaving {
    animation: toast-leave .28s ease forwards !important;
}

.toast-close {
    position: absolute;
    top: 50%;
    right: 11px;
    width: 28px;
    height: 28px;
    transform: translateY(-58%);
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: currentColor;
    font: 700 18px/1 system-ui, sans-serif;
    opacity: .65;
    cursor: pointer;
}
.toast-close:hover { opacity: 1; background: color-mix(in srgb, currentColor 10%, transparent); }

.toast-progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: currentColor;
    transform-origin: left center;
    animation: toast-countdown var(--toast-duration, 5s) linear forwards;
    opacity: .7;
}
.toast-item.is-paused .toast-progress { animation-play-state: paused; }

/* On sign-in, keep logout/login notices away from the brand header. The card's
   entrance transform makes this fixed stack anchor to the card, which gives a
   neat bottom-right placement inside the visual. */
.auth-page .toast-stack {
    top: auto;
    right: 20px;
    bottom: 20px;
}

@keyframes toast-enter {
    from { opacity: 0; transform: translate3d(36px, -8px, 0) scale(.96); }
    to { opacity: 1; transform: none; }
}
@keyframes toast-leave {
    to { opacity: 0; transform: translate3d(45px, 0, 0) scale(.96); }
}
@keyframes toast-countdown { to { transform: scaleX(0); } }

@media (max-width: 620px) {
    .toast-stack { top: 12px; right: 12px; width: calc(100vw - 24px) !important; }
    .auth-page .toast-stack { top: auto; right: 12px; bottom: 12px; }
}

:root[data-theme="dark"] .toast-stack .toast-item {
    --toast-ink: #dcecff;
    --toast-start: #17243a;
    --toast-end: #101a2b;
    --toast-border: #3b5a80;
}

:root[data-theme="dark"] .toast-stack .toast-item.alert--success,
:root[data-theme="dark"] .toast-stack .toast-item.flash--success { --toast-ink: #82e6bd; --toast-border: #287c61; }
:root[data-theme="dark"] .toast-stack .toast-item.alert--error,
:root[data-theme="dark"] .toast-stack .toast-item.flash--error { --toast-ink: #ff9bad; --toast-border: #944052; }
:root[data-theme="dark"] .toast-stack .toast-item.alert--warning,
:root[data-theme="dark"] .toast-stack .toast-item.flash--warning { --toast-ink: #f5cd78; --toast-border: #80642e; }
:root[data-theme="dark"] .toast-stack .toast-item.alert--info,
:root[data-theme="dark"] .toast-stack .toast-item.flash--info { --toast-ink: #8bc6ff; --toast-border: #356a9c; }

@media (prefers-reduced-motion: reduce) {
    .toast-stack .toast-item { animation: none !important; }
}
