/* ============================================================================
   toasts.css — the one place Django messages are styled, site-wide.
   ============================================================================

   Pairs with templates/_messages.html and static/JS/toasts.js.

   These rules used to live inside auth.css, which meant login was the only
   page that could display a message. Django keeps a message in the session
   until a template actually iterates it, so every message raised on a page
   that never rendered one survived until the user next opened login — and
   dumped there, all at once, sometimes days late.

   The class prefix stays `af-` so the auth templates that already use it keep
   working; this is now a site-wide component, not an auth-only one.

   Placement: `--af-toast-top` lets a page with a sticky header push the stack
   below it (see base.html), without a second set of rules.
   ========================================================================= */

.af-toasts {
    position: fixed;
    top: var(--af-toast-top, 1.25rem);
    right: 1.25rem;
    z-index: 9999;
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: min(380px, calc(100vw - 2.5rem));
    pointer-events: none;   /* clicks fall through the gaps to the page */
}

.af-toast {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.85rem 0.9rem 0.85rem 1.15rem;
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
    font-family: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', sans-serif;
    font-size: 0.89rem;
    line-height: 1.45;
    font-weight: 500;
    color: #fff;
    background: #2563eb;
    pointer-events: auto;
    animation: af-toast-in 320ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.af-toast.success { background: #16a34a; }
.af-toast.error   { background: #dc2626; }
.af-toast.warning { background: #d97706; }
.af-toast.debug   { background: #475569; }
.af-toast.is-out  { animation: af-toast-out 220ms cubic-bezier(0.22, 1, 0.36, 1) both; }

.af-toast__icon { flex-shrink: 0; font-weight: 700; }
.af-toast__text { flex: 1; min-width: 0; overflow-wrap: anywhere; }

.af-toast__close {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    margin: -2px -2px 0 0;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 1rem;
    line-height: 1;
    opacity: 0.7;
    cursor: pointer;
    transition: opacity 140ms ease, background 140ms ease;
}
.af-toast__close:hover { opacity: 1; background: rgba(255, 255, 255, 0.18); }
.af-toast__close:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

@keyframes af-toast-in {
    from { opacity: 0; transform: translateX(110%) scale(0.96); }
    to   { opacity: 1; transform: none; }
}
@keyframes af-toast-out {
    to { opacity: 0; transform: translateX(110%) scale(0.96); }
}

@media (prefers-reduced-motion: reduce) {
    .af-toast, .af-toast.is-out {
        animation-duration: 0.001ms !important;
    }
}

@media (max-width: 520px) {
    .af-toasts {
        top: var(--af-toast-top, 0.75rem);
        right: 0.75rem;
        left: 0.75rem;
        max-width: none;
    }
}
