/* Pop-up alert that closes itself, e.g. the grace-period alert after login.
   Bottom of the screen on phones (easy to reach), top right on wide screens. */

.toast {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 16px;
  z-index: 50;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 14px 12px 18px 16px;
  border-radius: var(--radius);
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-left: 6px solid var(--c-primary);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  animation: toast-in 0.25s ease-out;
}

.toast--warn { border-left-color: var(--c-warn); }
.toast--error { border-left-color: var(--c-bad); }
.toast--success { border-left-color: var(--c-good); }

.toast.is-leaving { animation: toast-out 0.25s ease-in forwards; }

.toast__body { flex: 1; }
.toast__title { margin: 0 0 2px; font-weight: 700; }
.toast--warn .toast__title { color: var(--c-warn); }
.toast__text { margin: 0; }
.toast__timer { margin: 6px 0 0; font-size: 0.8rem; color: var(--c-muted); }

.toast__close {
  border: 0;
  background: none;
  font-size: 1.5rem;
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
  margin: -10px -6px 0 0;
  color: var(--c-muted);
  cursor: pointer;
}

/* Shrinking bar shows the time left */
.toast__bar {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 4px;
  width: 100%;
  background: var(--c-warn);
  transform-origin: left;
  animation: toast-bar var(--toast-seconds, 5s) linear forwards;
}
.toast.is-paused .toast__bar { animation-play-state: paused; }

@keyframes toast-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(16px); } }
@keyframes toast-bar { to { transform: scaleX(0); } }

@media (min-width: 700px) {
  .toast { left: auto; right: 24px; bottom: auto; top: 72px; width: 380px; }
}

@media (prefers-reduced-motion: reduce) {
  .toast, .toast.is-leaving { animation: none; }
}
body:has(.bottombar) .toast { bottom: 72px; }
@media (min-width: 900px) { body:has(.bottombar) .toast { bottom: auto; } }
