/* Universal Undo Toast — May-2026 (action-points-2026-05-08 §13.10).
 *
 * Renders bottom-left, stacking newest at the bottom (Notion Calendar
 * pattern). Each toast is self-contained: a row of message + Undo button
 * + close × + a 5-second drain bar.
 */

.undo-toast-host {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;       /* user feedback: notifications go on the right */
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  z-index: var(--z-toast, 11500);
  pointer-events: none;
}

.undo-toast {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 18rem;
  max-width: 28rem;
  padding: 0.7rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  transition: opacity 0.18s ease, transform 0.18s ease;
  overflow: hidden;
}

.undo-toast--visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.undo-toast--leaving {
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
}

.undo-toast__icon {
  color: var(--text-muted);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.undo-toast__message {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text-strong);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.undo-toast__btn {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
}

.undo-toast__btn:hover:not(:disabled) {
  background: var(--primary);
  color: var(--text-inverse);
}

.undo-toast__btn:disabled {
  opacity: 0.5;
  cursor: progress;
}

.undo-toast__close {
  background: transparent;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  padding: 0.25rem;
  font-size: 0.75rem;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s ease;
}

.undo-toast__close:hover {
  color: var(--text-strong);
}

/* Drain bar — pure CSS countdown, no JS per-frame loop. The custom
   property `--undo-toast-ttl` is set inline by undo-toast.js. */
.undo-toast__progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  background: var(--primary);
  transform-origin: left;
  animation: undo-toast-drain var(--undo-toast-ttl, 5000ms) linear forwards;
  width: 100%;
}

@keyframes undo-toast-drain {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

@media (max-width: 640px) {
  .undo-toast-host {
    left: 0.75rem;
    right: 0.75rem;
    bottom: 0.75rem;
    align-items: stretch;
  }
  .undo-toast {
    min-width: 0;
    max-width: none;
  }
}
