/* SuperNOVA UI: Toast */

.nova-toast-region {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1200;

    display: flex;
    align-items: flex-end;
    flex-direction: column;
    gap: 12px;

    width: min(420px, calc(100vw - 48px));

    pointer-events: none;
}

.nova-toast {
    --nova-toast-accent: var(--info);
    --nova-toast-accent-soft: var(--info-surface);
    --nova-toast-border: var(--info-border);

    position: relative;

    display: grid;
    grid-template-columns: 4px 42px minmax(0, 1fr);
    align-items: start;
    column-gap: 14px;

    width: 100%;
    min-height: 88px;
    overflow: hidden;

    border: 1px solid var(--nova-toast-border);
    border-radius: 18px;

    color: var(--text-primary);
    background: var(--toast-background);

    box-shadow: var(--shadow-toast);

    pointer-events: auto;

    backdrop-filter: blur(20px);
}

.nova-toast__accent {
    align-self: stretch;

    width: 4px;
    min-height: 100%;

    background: var(--nova-toast-accent);
    box-shadow: 0 0 16px var(--nova-toast-accent);
}

.nova-toast__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 42px;
    height: 42px;
    margin-top: 18px;

    border: 1px solid var(--nova-toast-border);
    border-radius: 13px;

    color: var(--nova-toast-accent);
    background: var(--nova-toast-accent-soft);
}

.nova-toast__icon svg {
    width: 21px;
    height: 21px;

    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nova-toast__content {
    min-width: 0;
    padding: 18px 50px 20px 0;
}

.nova-toast__title {
    color: var(--text-primary);

    font-size: 0.94rem;
    font-weight: 750;
    line-height: 1.35;
    letter-spacing: -0.01em;
}

.nova-toast__message {
    margin-top: 5px;

    color: var(--text-secondary);

    font-size: 0.86rem;
    line-height: 1.5;
}

.nova-toast__content > :first-child {
    margin-top: 0;
}

.nova-toast__content > :last-child {
    margin-bottom: 0;
}

.nova-toast__close {
    position: absolute;
    top: 14px;
    right: 12px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 30px;
    height: 30px;
    margin: 0;
    padding: 0;

    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    outline: none;

    color: var(--text-muted);
    background: var(--surface-control-readonly);

    cursor: pointer;

    transition:
        transform 150ms ease,
        border-color 150ms ease,
        color 150ms ease,
        background 150ms ease,
        box-shadow 150ms ease;
}

.nova-toast__close:hover {
    border-color: var(--border-hover);

    color: var(--text-primary);
    background: var(--surface-control-focus);
}

.nova-toast__close:focus-visible {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

.nova-toast__close:active {
    transform: scale(0.94);
}

.nova-toast__close svg {
    width: 14px;
    height: 14px;

    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
}

.nova-toast__progress {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 4px;

    height: 3px;
    overflow: hidden;

    background: var(--surface-control-readonly);
}

.nova-toast__progress-bar {
    width: 100%;
    height: 100%;

    background:
        linear-gradient(
            90deg,
            var(--nova-toast-accent),
            transparent
        );

    transform-origin: left center;
}

/* Variants */

.nova-toast--info {
    --nova-toast-accent: var(--info);
    --nova-toast-accent-soft: var(--info-surface);
    --nova-toast-border: var(--info-border);
}

.nova-toast--success {
    --nova-toast-accent: var(--success);
    --nova-toast-accent-soft: var(--success-surface);
    --nova-toast-border: var(--success-border);
}

.nova-toast--warning {
    --nova-toast-accent: var(--warning);
    --nova-toast-accent-soft: var(--warning-surface);
    --nova-toast-border: var(--warning-border);
}

.nova-toast--danger {
    --nova-toast-accent: var(--danger-accent);
    --nova-toast-accent-soft: var(--danger-surface);
    --nova-toast-border: var(--danger-border);
}

.nova-toast--persistent .nova-toast__progress {
    display: none;
}

/* Static showcase layout */

.nova-toast-preview {
    display: grid;
    gap: 12px;

    width: min(100%, 420px);
}

.nova-toast-preview .nova-toast {
    position: relative;
}

/* Responsive */

@media (max-width: 720px) {
    .nova-toast-region {
        top: calc(env(safe-area-inset-top) + 12px);
        right: 14px;
        bottom: auto;
        left: 14px;

        align-items: stretch;

        width: auto;
    }

    .nova-toast {
        grid-template-columns: 4px 38px minmax(0, 1fr);

        min-height: 82px;
        border-radius: 16px;
    }

    .nova-toast__icon {
        width: 38px;
        height: 38px;
        margin-top: 16px;
        border-radius: 12px;
    }

    .nova-toast__content {
        padding-top: 16px;
        padding-bottom: 18px;
        padding-right: 44px;
    }

    .nova-toast__close {
        top: 12px;
        right: 10px;

        width: 28px;
        height: 28px;
    }
}

/* Runtime behaviour */

.nova-toast--runtime {
    opacity: 0;
    transform: translateY(-12px) scale(0.985);
}

.nova-toast--runtime.nova-toast--visible {
    animation: nova-toast-enter 220ms ease-out forwards;
}

.nova-toast--runtime.nova-toast--closing {
    animation: nova-toast-leave 180ms ease-in forwards;
}

.nova-toast--runtime .nova-toast__progress-bar {
    animation:
        nova-toast-countdown
        var(--nova-toast-duration)
        linear
        forwards;
}

.nova-toast--runtime.nova-toast--paused .nova-toast__progress-bar {
    animation-play-state: paused;
}

@keyframes nova-toast-enter {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(0.985);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes nova-toast-leave {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    to {
        opacity: 0;
        transform: translateY(-8px) scale(0.985);
    }
}

@keyframes nova-toast-countdown {
    from {
        transform: scaleX(1);
    }

    to {
        transform: scaleX(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .nova-toast--runtime,
    .nova-toast--runtime.nova-toast--visible,
    .nova-toast--runtime.nova-toast--closing {
        animation-duration: 1ms;
    }

    .nova-toast--runtime .nova-toast__progress-bar {
        animation-timing-function: linear;
    }
}