/* Toast: a short message on a white glass pill, with a round coloured dot ("Added to your basket."). Built by site.js.
   Four types, told apart by the dot: success (blue tick), info (deep blue i), warning (amber !), error (red !).
   Success and info leave by themselves; warning and error stay until closed, so nobody misses them.
   Always one line, bottom right, as wide as its words (at most the screen less the gutters); a text too long for that
   ends in "…", so keep toast texts short (about 30 characters fit on a 320px phone). Needs Bootstrap Icons. */

.toasts {
  position: fixed;
  z-index: var(--z-toast);
  right: var(--sp-4);
  bottom: calc(var(--sp-4) + env(safe-area-inset-bottom, 0px));
  left: var(--sp-4);
  display: grid;
  grid-template-columns: minmax(0, 1fr); /* a long toast is held to the screen's width (and ends in …) */
  justify-items: end;
  gap: var(--sp-2);
  pointer-events: none; /* clicks pass through the empty stack, not through the toasts */
}

@media (min-width: 576px) {
  .toasts {
    right: var(--sp-6);
    bottom: calc(var(--sp-6) + env(safe-area-inset-bottom, 0px));
  }
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  max-width: 100%;
  padding: var(--sp-2) var(--sp-3) var(--sp-2) var(--sp-2);
  font-size: var(--fs-small);
  line-height: var(--lh-body);
  color: var(--c-heading);
  background-image: linear-gradient(var(--c-glass-top), var(--c-glass-bottom));
  background-color: var(--c-glass-toast); /* glass over whatever is behind, still easy to read */
  border: var(--border-1) solid var(--c-glass-edge);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-glass), var(--shadow-1);
  -webkit-backdrop-filter: var(--blur-bar); /* Safari before 18 */
  backdrop-filter: var(--blur-bar);
  pointer-events: auto;
  animation: toast-in var(--duration-base) var(--ease);
  transition: opacity var(--duration-base) var(--ease);
}

/* The round dot with the type's sign in white. */
.toast__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: var(--sp-8);
  height: var(--sp-8);
  font-size: var(--fs-body);
  line-height: 1;
  color: var(--c-page);
  border-radius: 50%;
}

.toast__icon::before {
  vertical-align: top; /* Bootstrap Icons lowers each icon to sit on a text line; here it is centred instead */
}

.toast--success .toast__icon { background-color: var(--c-menu-button); }
.toast--info .toast__icon    { background-color: var(--c-accent-text); }
.toast--warning .toast__icon { background-color: var(--c-warning-dot); }
.toast--error .toast__icon   { background-color: var(--c-error); }

.toast__text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap; /* always one line */
  text-overflow: ellipsis;
}

.toast__close {
  flex: none;
  display: grid;
  place-items: center;
  width: var(--sp-6);
  height: var(--sp-6);
  font-size: var(--fs-xs);
  color: var(--c-text-muted);
  border-radius: 50%;
}

.toast__close:hover {
  color: var(--c-heading);
  background-color: var(--c-ground);
}

.toast--leaving {
  opacity: 0;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(var(--sp-4));
  }
}
