/*
 * „Rückgängig statt Rückfrage“ (Paket 15a): Meldung unten in der Mitte, schiefer Grund, Taste
 * „Rückgängig“, Balken für die verbleibenden 10 Sekunden. Einzige Animation im Tagesbetrieb.
 */

.undo-stack {
    position: fixed;
    left: 50%;
    bottom: calc(var(--footer-h, 50px) + 20px);
    z-index: 150;
    display: grid;
    gap: 8px;
    width: min(560px, calc(100vw - 32px));
    transform: translateX(-50%);
    pointer-events: none;
}

.undo {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
    padding: 12px 8px 14px 16px;
    border-radius: 8px;
    background: var(--c-slate, #364a5e);
    color: #fff;
    box-shadow: 0 10px 30px rgba(10, 20, 50, 0.3);
    font-size: 15px;
    line-height: 1.4;
    pointer-events: auto;
}

.undo form {
    display: contents;
}

.undo__text {
    flex: 1;
    min-width: 0;
}

.undo__btn {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 4px 12px;
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: var(--radius, 3px);
    background: transparent;
    color: #fff;
    font: inherit;
    font-weight: 500;
    cursor: pointer;
}

.undo__btn:hover,
.undo__btn:focus-visible {
    background: rgba(255, 255, 255, 0.16);
}

.undo__btn:focus-visible,
.undo__close:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 1px;
}

.undo__btn[disabled] {
    opacity: 0.7;
    cursor: progress;
}

.undo__keys {
    padding: 0 4px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 3px;
    font-size: 12px;
}

.undo__close {
    flex: none;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: var(--radius, 3px);
    background: transparent;
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.undo__close:hover {
    background: rgba(255, 255, 255, 0.12);
}

.undo__timer {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 3px;
    background: #9ff0a0;
    transform-origin: left;
    animation: undo-timer 10s linear forwards;
}

.undo--done .undo__text::before {
    content: "✓ ";
}

.undo--error {
    background: var(--c-danger-text, #8c0d12);
}

@keyframes undo-timer {
    to { transform: scaleX(0); }
}

@media (prefers-reduced-motion: reduce) {
    .undo__timer {
        animation: none;
        opacity: 0.6;
    }
}

@media (forced-colors: active) {
    .undo {
        border: 2px solid CanvasText;
    }

    .undo__timer {
        background: Highlight;
    }
}

@media print {
    .undo-stack {
        display: none;
    }
}
