/* Toasts. Fixed to the corner, stacked, out of the page flow. */

#flash-toasts {
    position: fixed;
    z-index: 1090;
    top: 16px;
    right: 16px;
    width: min(360px, calc(100vw - 24px));
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
    padding: 0;
    pointer-events: none;
}

body:has(.top-navbar) #flash-toasts,
body:has(.site-header) #flash-toasts {
    top: 72px;
}

.flash {
    --flash-accent: #1d4ed8;
    --flash-tint: #eef3ff;
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 0;
    padding: 12px 10px 12px 14px;
    background: #ffffff;
    color: #111827;
    border: 1px solid #e6e8ec;
    border-left: 3px solid var(--flash-accent);
    border-radius: 14px;
    box-shadow:
        0 10px 28px rgba(17, 24, 39, 0.12),
        0 2px 6px rgba(17, 24, 39, 0.06);
    overflow: hidden;
    pointer-events: auto;
    animation: flash-in 220ms ease;
}

.flash--success {
    --flash-accent: #0f7a4a;
    --flash-tint: #e7f6ee;
}

.flash--error,
.flash--danger {
    --flash-accent: #b42318;
    --flash-tint: #fdecec;
}

.flash--warning {
    --flash-accent: #b45309;
    --flash-tint: #fef4e6;
}

.flash--info,
.flash--debug {
    --flash-accent: #1d4ed8;
    --flash-tint: #eef3ff;
}

.flash__mark {
    display: grid;
    place-items: center;
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--flash-tint);
    color: var(--flash-accent);
}

.flash__mark svg {
    display: block;
    width: 16px;
    height: 16px;
}

.flash__text {
    flex: 1;
    min-width: 0;
    margin: 0;
    padding-top: 4px;
    font-size: 14px;
    line-height: 1.45;
    color: #111827;
}

.flash__text :is(ul, ol) {
    margin: 0;
    padding: 0;
    list-style: none;
}

.flash__text :is(ul, ol) li + li {
    margin-top: 0.2rem;
}

.flash__text p {
    margin: 0;
}

.flash__close {
    appearance: none;
    -webkit-appearance: none;
    display: grid;
    place-items: center;
    flex: none;
    width: 28px;
    height: 28px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
}

.flash__close svg {
    display: block;
    width: 14px;
    height: 14px;
}

.flash__close:hover {
    background: #f3f4f6;
    color: #111827;
}

.flash__close:focus-visible {
    outline: 2px solid var(--flash-accent);
    outline-offset: 1px;
}

.flash[data-autodismiss]::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    height: 2px;
    width: 100%;
    background: var(--flash-accent);
    opacity: 0.45;
    transform-origin: left center;
    animation: flash-life var(--flash-life, 5.2s) linear forwards;
}

.flash.is-paused[data-autodismiss]::after {
    animation-play-state: paused;
}

.flash.is-leaving {
    animation: flash-out 180ms ease forwards;
}

@keyframes flash-in {
    from {
        opacity: 0;
        transform: translateX(16px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes flash-out {
    to {
        opacity: 0;
        transform: translateX(16px);
    }
}

@keyframes flash-life {
    from {
        transform: scaleX(1);
    }
    to {
        transform: scaleX(0);
    }
}

@media (max-width: 640px) {
    #flash-toasts {
        top: 12px;
        right: 12px;
        left: 12px;
        width: auto;
    }

    body:has(.top-navbar) #flash-toasts,
    body:has(.site-header) #flash-toasts {
        top: 68px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .flash,
    .flash.is-leaving,
    .flash[data-autodismiss]::after {
        animation: none;
    }
}
