/* 26-toast.css
   ----------------------------------------------------------------
   Async completion feedback. Use when the operator may have moved
   away from the origin panel (e.g. recorded a movement on the form
   then scrolled the dashboard) and the inline `.alert` would be
   missed.

   Spec: docs/strategy/design-system/26-toast.md
   JS helper: static/ui/js/toasts.js (auto-dismiss, undo, stacking)

   ## Atoms
     .toast                 base shell · soft tinted background
     .toast.success         green tint (success-bg/border/dark)
     .toast.warning         amber tint
     .toast.error           red tint
     .toast.info            blue tint
     .toast-icon            optional 16px sprite slot (left)
     .toast-body            flex-1 message text
     .toast-action          inline link / undo button (right)
     .toast-dismiss         optional close x (right, fades in)

   ## Container
     .toast-stack           positioned stack
                            Mobile (<1024px): bottom-center anchored
                              ABOVE the 64px tabbar (84px clearance).
                            Desktop (>=1024px): bottom-right stack.
     .toast-stack.is-top    flip to top for sticky-headerless flows.
     .toast-stack.no-tabbar drop the +64px clearance (focused shell,
                            modals, auth pages).

   ## Behaviour (JS)
     Non-critical (success / info) auto-dismiss in 4s.
     Warning auto-dismiss in 6s.
     Errors require manual dismiss (must include .toast-dismiss).

   Replaces the inline 16-line block atlas frames used as the
   pattern reference (shell_mobile X.4 · inventory X.4).
   Tokens only. No raw colors.
   ---------------------------------------------------------------- */

.toast-stack {
  position: fixed;
  left: var(--space-3);
  right: var(--space-3);
  bottom: calc(var(--shell-tabbar-height, 72px) + var(--space-3));
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-2);
  z-index: 260;
  pointer-events: none;
}

.toast-stack.no-tabbar {
  bottom: var(--space-3);
}

.toast-stack.is-top {
  bottom: auto;
  top: calc(52px + var(--space-3));
  flex-direction: column;
}

.toast-stack > .toast {
  pointer-events: auto;
}

@media (min-width: 1024px) {
  .toast-stack {
    left: auto;
    right: var(--space-4);
    bottom: var(--space-4);
    max-width: 360px;
  }
  .toast-stack.is-top {
    top: var(--space-4);
  }
}

/* --- Atom ------------------------------------------------------- */
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-body);
  font-weight: 700;
  line-height: 1.4;
  box-shadow: var(--shadow);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 180ms ease-out, transform 180ms ease-out;
}

/* Browsers without @starting-style just render toasts open - safe fallback. */
@starting-style {
  .toast {
    opacity: 0;
    transform: translateY(8px);
  }
}

.toast.is-leaving {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 160ms ease-in, transform 160ms ease-in;
}

/* --- Tonal variants --------------------------------------------- */
.toast.success {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-dark);
}

.toast.warning {
  background: var(--warning-bg);
  border-color: var(--warning-border);
  color: var(--warning);
}

.toast.error {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--error-dark);
}

.toast.info {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: var(--info);
}

/* --- Icon slot --------------------------------------------------- */
.toast-icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  color: currentColor;
}

.toast-icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
}

/* --- Body / action / dismiss ------------------------------------ */
.toast-body {
  flex: 1 1 auto;
  min-width: 0;
}

.toast-action {
  margin-left: auto;
  flex-shrink: 0;
  background: transparent;
  border: 0;
  padding: var(--space-1) var(--space-2);
  font-family: inherit;
  font-size: var(--font-size-small);
  font-weight: 800;
  color: currentColor;
  cursor: pointer;
  text-decoration: underline;
}

.toast-dismiss {
  margin-left: auto;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
  color: currentColor;
  opacity: 0.65;
  cursor: pointer;
  font-family: inherit;
}

.toast-dismiss:hover {
  opacity: 1;
}

.toast-dismiss svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}
