/* Single-slot message toaster. One toast visible at a time; the JS surfaces
   queued messages in turn. Level-distinct via --toast-accent while keeping
   the card quiet enough to sit above the page. Reduced-motion safe and RTL-aware. */

.toaster {
  position: fixed;
  inset-block-start: 84px;
  inset-inline: 0;
  z-index: 115;
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 0 12px;
  pointer-events: none;
}

.toast {
  --toast-accent: var(--accent-light);
  --toast-accent-soft: rgba(176, 139, 90, 0.14);
  --toast-border: rgba(176, 139, 90, 0.26);
  --toast-shadow: rgba(0, 0, 0, 0.24);
  position: relative;
  pointer-events: auto;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  width: min(420px, 100%);
  padding: 12px 12px 12px 15px;
  border: 1px solid var(--toast-border);
  border-radius: 16px;
  background: rgba(29, 26, 23, 0.96);
  box-shadow: 0 14px 34px var(--toast-shadow), var(--inset-light);
  backdrop-filter: blur(14px);
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.6;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.24s ease, transform 0.24s ease, box-shadow 0.24s ease;
}

/* Accent stripe — on the start (leading) edge, which is the right in RTL. */
.toast::before {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 4px;
  background: var(--toast-accent);
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.is-leaving {
  opacity: 0;
  transform: translateY(-10px);
}

.toast-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 10px;
  background: var(--toast-accent-soft);
  color: var(--toast-accent);
}

.toast-icon .ph {
  font-size: 1.2rem;
  line-height: 1;
}

.toast-body {
  min-width: 0;
}

.toast-text {
  display: block;
  overflow-wrap: anywhere;
}

.toast-close {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.toast-close .ph {
  font-size: 0.95rem;
  line-height: 1;
}

.toast-close:hover {
  color: #fff;
  border-color: var(--toast-border);
  background: var(--toast-accent-soft);
}

.toast-close:focus-visible {
  outline: 2px solid var(--toast-accent);
  outline-offset: 3px;
}

/* Per-level theming: stripe, icon tint, and restrained border strength. */
.toast.success {
  --toast-accent: var(--success);
  --toast-accent-soft: rgba(111, 143, 104, 0.14);
  --toast-border: rgba(111, 143, 104, 0.28);
}

.toast.error {
  --toast-accent: var(--danger);
  --toast-accent-soft: rgba(183, 93, 81, 0.16);
  --toast-border: rgba(183, 93, 81, 0.42);
  --toast-shadow: rgba(0, 0, 0, 0.3);
}

.toast.warning {
  --toast-accent: #d6a65a;
  --toast-accent-soft: rgba(214, 166, 90, 0.15);
  --toast-border: rgba(214, 166, 90, 0.38);
  --toast-shadow: rgba(0, 0, 0, 0.28);
}

.toast.info {
  --toast-accent: var(--accent-light);
  --toast-accent-soft: rgba(176, 139, 90, 0.13);
  --toast-border: rgba(176, 139, 90, 0.24);
}

@supports (color: color-mix(in srgb, white 50%, black)) {
  .toast {
    background: color-mix(in srgb, var(--panel) 92%, transparent);
  }

  .toast-icon,
  .toast-close:hover {
    background: color-mix(in srgb, var(--toast-accent) 15%, transparent);
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    transform: none;
    transition: opacity 0.18s ease;
  }
  .toast.is-leaving {
    transform: none;
  }
}

/* Mobile: fuller-width toasts that sit clear of the app shell. */
@media (max-width: 700px) {
  .toaster {
    inset-block-start: 74px;
    align-items: stretch;
  }
  .toast {
    width: 100%;
    padding: 12px 12px 12px 14px;
    font-size: 0.86rem;
  }
}
