/* Toast notifications — see public/js/toaster.js */

.toaster {
    --toaster-bg: #fff;
    --toaster-border: #e4e4e7;
    --toaster-border-bottom: rgb(212 212 216 / .8);
    --toaster-heading: #27272a;
    --toaster-text: #71717a;
    --toaster-close: #a1a1aa;
    --toaster-close-hover-bg: rgb(39 39 42 / .05);
    --toaster-success: #65a30d;
    --toaster-error: #f43f5e;
    --toaster-warning: #f59e0b;
    --toaster-info: #3b82f6;

    position: fixed;
    top: 0;
    /* Top-right in both LTR and RTL, where the SweetAlert toasts used to appear. */
    right: 0;
    /* Above Bootstrap modals (1055) and the wire-elements modal/slide-over overlays (99999999 / 999999999). */
    z-index: 9999999999;
    display: flex;
    flex-direction: column;
    width: min(28rem, 100%);
    padding: 1rem;
    pointer-events: none;
}

.toaster-item {
    --toaster-accent: var(--toaster-info);

    position: relative;
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: .625rem;
    padding: .625rem;
    overflow: hidden;
    background: var(--toaster-bg);
    border: 1px solid var(--toaster-border);
    border-bottom-color: var(--toaster-border-bottom);
    border-radius: .875rem;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);
    pointer-events: auto;
    transition:
        transform .2s cubic-bezier(.2, 0, 0, 1),
        opacity .2s ease,
        height .2s ease,
        margin .2s ease,
        padding .2s ease;
}

.toaster-item.is-entering {
    transform: translateY(-.5rem) scale(.97);
    opacity: 0;
}

.toaster-item.is-leaving {
    height: 0 !important;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-color: transparent;
    overflow: hidden;
    transform: scale(.97);
    opacity: 0;
}

.toaster-main {
    display: flex;
    flex: 1;
    align-items: center;
    gap: .75rem;
    min-width: 0;
    padding-block: .375rem;
    padding-inline-start: .5rem;
}

.toaster-icon {
    flex-shrink: 0;
    display: flex;
    width: 1.375rem;
    height: 1.375rem;
    color: var(--toaster-accent);
}

.toaster-icon svg {
    width: 100%;
    height: 100%;
}

.toaster-success { --toaster-accent: var(--toaster-success); }
.toaster-error { --toaster-accent: var(--toaster-error); }
.toaster-warning { --toaster-accent: var(--toaster-warning); }
.toaster-info { --toaster-accent: var(--toaster-info); }

.toaster-content {
    min-width: 0;
    font-size: .9375rem;
    line-height: 1.375rem;
    overflow-wrap: anywhere;
}

.toaster-heading {
    font-weight: 500;
    color: var(--toaster-heading);
}

.toaster-text {
    font-size: .875rem;
    color: var(--toaster-text);
}

/* Without a heading the message itself is the heading. */
.toaster-heading[hidden] + .toaster-text {
    font-size: inherit;
    font-weight: 500;
    color: var(--toaster-heading);
}

.toaster-close {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    color: var(--toaster-close);
    background: transparent;
    border: 0;
    border-radius: .375rem;
    cursor: pointer;
    transition: color .15s ease, background-color .15s ease;
}

.toaster-close:hover,
.toaster-close:focus-visible {
    color: var(--toaster-heading);
    background: var(--toaster-close-hover-bg);
}

.toaster-close:focus-visible {
    outline: 2px solid var(--toaster-info);
    outline-offset: -2px;
}

.toaster-close svg {
    width: 1.25rem;
    height: 1.25rem;
}

.toaster-progress {
    position: absolute;
    bottom: 0;
    inset-inline-start: 0;
    width: 100%;
    height: 3px;
    background: var(--toaster-accent);
    opacity: .55;
    animation: toaster-progress var(--toaster-duration) linear forwards;
}

/* Paused in the same situations as the countdown in toaster.js. */
.toaster-item:hover .toaster-progress,
.toaster-item:focus-within .toaster-progress {
    animation-play-state: paused;
}

@keyframes toaster-progress {
    to { width: 0; }
}

@media (max-width: 575.98px) {
    .toaster {
        padding: .75rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .toaster-item {
        transition: opacity .2s ease;
    }

    .toaster-item.is-entering,
    .toaster-item.is-leaving {
        transform: none;
    }
}
