/* ============================================
   toast.css: .bl-toast, the one small message at the bottom of the screen (BL.ui.toast in
   js/app/ui.js, which builds it on first use and reuses it: a new message replaces the one shown,
   never stacks).

   <div class="bl-toast is-shown" role="status" aria-live="polite" data-state="busy|done|info">
     <span class="bl-toast__icon" aria-hidden="true">…</span><span class="bl-toast__text">…</span>
   </div>

   busy: a spinner, stays until the next message; done: a green tick; info: a calm note (never
   red). It rises in on the motion tokens and fades out; under reduced motion it only fades and
   the spinner turns slowly. Phones: above the tab bar. A page with its own bar at the bottom
   lifts it with --bl-toast-bottom on its root (the owner wizard's action bar).
   ============================================ */

.bl-toast {
  position: fixed;
  left: 50%;
  bottom: var(--bl-toast-bottom, calc(var(--tabbar-h) + var(--safe-bottom) + var(--space-4)));
  z-index: var(--z-toast);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: max-content;
  max-width: calc(100vw - 2 * var(--gutter));
  margin: 0;
  padding: var(--space-3) var(--space-5) var(--space-3) var(--space-4);
  border-radius: var(--radius-pill);
  background: var(--color-ink);
  color: var(--color-surface);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  box-shadow: var(--shadow-3);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity var(--duration-base) var(--ease-out), transform var(--duration-base) var(--ease-out);
}

.bl-toast.is-shown {
  opacity: 1;
  transform: translate(-50%, 0);
}

.bl-toast__icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 16px;
}

.bl-toast[data-state="done"] .bl-toast__icon {
  color: var(--green-300);
}

.bl-toast[data-state="info"] .bl-toast__icon {
  color: var(--color-border);
}

/* The spinner: a ring with one bright quarter, turning. */
.bl-toast[data-state="busy"] .bl-toast__icon::before {
  content: "";
  box-sizing: border-box;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  opacity: 0.85;
  animation: bl-toast-spin 0.8s linear infinite;
}

@keyframes bl-toast-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (min-width: 768px) {
  .bl-toast {
    bottom: var(--bl-toast-bottom, var(--space-6));
  }
}

@media (prefers-reduced-motion: reduce) {
  .bl-toast,
  .bl-toast.is-shown {
    transform: translate(-50%, 0);
    transition: opacity var(--duration-fast) var(--ease-out);
  }

  .bl-toast[data-state="busy"] .bl-toast__icon::before {
    animation-duration: 2.4s;
  }
}
