/* Toast notifications — bottom right, auto-dismissing, stacked. */

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    /* The container spans the corner but must not swallow clicks on the page beneath;
       individual toasts re-enable pointer events for their own dismiss button. */
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 280px;
    max-width: 380px;
    padding: 14px 16px;
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, .12);

    /* Off-screen until the script adds .is-visible, so the slide-in is a transition
       rather than an animation that could fire before positioning settles. */
    transform: translateX(calc(100% + 32px));
    opacity: 0;
    transition: transform .2s ease, opacity .2s ease;
}

.toast.is-visible { transform: translateX(0); opacity: 1; }

/* Leaving: slide back out, then the script removes the node on transitionend. */
.toast.is-leaving { transform: translateX(calc(100% + 32px)); opacity: 0; }

.toast-success { border-left-color: var(--green); }
.toast-error   { border-left-color: var(--red); }
.toast-warning { border-left-color: var(--yellow); }
.toast-info    { border-left-color: var(--accent); }

.toast-icon {
    flex: 0 0 auto;
    font-size: 1rem;
    line-height: 1.4;
}

.toast-success .toast-icon { color: var(--green); }
.toast-error   .toast-icon { color: var(--red); }
.toast-warning .toast-icon { color: var(--yellow); }
.toast-info    .toast-icon { color: var(--accent); }

.toast-body { flex: 1 1 auto; min-width: 0; }

.toast-title {
    font-weight: 700;
    font-size: .9rem;
    color: var(--fg);
}

.toast-message {
    margin-top: 2px;
    font-size: .84rem;
    line-height: 1.45;
    color: var(--fg-muted);
    overflow-wrap: anywhere;
}

.toast-close {
    flex: 0 0 auto;
    padding: 0 2px;
    font-size: .95rem;
    line-height: 1;
    color: var(--fg-muted);
    background: none;
    border: none;
    cursor: pointer;
    opacity: .6;
    transition: opacity .2s ease, color .2s ease;
}

.toast-close:hover { opacity: 1; color: var(--fg); }

/* Progress bar: shrinks over the toast's lifetime. Paused on hover so a message is
   never yanked away mid-read. */
.toast-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 100%;
    transform-origin: left center;
    background: var(--border-strong);
    animation: toast-progress linear forwards;
}

.toast-success .toast-progress { background: var(--green); }
.toast-error   .toast-progress { background: var(--red); }
.toast-warning .toast-progress { background: var(--yellow); }
.toast-info    .toast-progress { background: var(--accent); }

.toast:hover .toast-progress { animation-play-state: paused; }

@keyframes toast-progress {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

@media (max-width: 480px) {
    .toast-container { left: 16px; right: 16px; bottom: 16px; }
    .toast { min-width: 0; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
    .toast { transition: opacity .2s ease; transform: none; }
    .toast.is-visible { transform: none; }
    .toast.is-leaving { transform: none; }
}
