/* 15.2795, 15.2796: every notice in one look - Telegram's message (kit/noticecard.js): the face, the name, the time,
   the words, the buttons under them, the quick reply; a stack in the lower right corner on a computer, one banner
   at the top on a phone */
#toasts {
  position: fixed; z-index: var(--z-toast);
  right: var(--sp-300); bottom: var(--sp-300);
  display: flex; flex-direction: column; justify-content: flex-end; gap: var(--sp-100);
  width: min(380px, calc(100vw - 2 * var(--sp-300)));
  max-height: calc(100dvh - 2 * var(--sp-300));
  pointer-events: none;
}
/* 15.2660: while a question in words asks, the notices stand under its veil with the page */
#toasts.hushed { z-index: calc(var(--z-dialog) - 1); }
#toasts > * { pointer-events: auto; }
html[data-nav="drawer"][data-nav-open] #toasts > * { pointer-events: none; }

.toast {
  position: relative; display: flex; flex-wrap: wrap; gap: var(--sp-150); align-items: flex-start; flex: none;
  width: 100%; padding: var(--sp-150) var(--sp-200) var(--sp-150) var(--sp-150);
  border-radius: var(--r-l); background: var(--card);
  box-shadow: 0 0 0 var(--bw) var(--line), var(--sh-overlay);
  color: var(--ink); text-align: left;
  /* the cross stands over the corner (a card clips by the kit's rule) */
  overflow: visible;
  opacity: 0; transform: translateY(var(--sp-100));
  transition: opacity .2s ease, transform .2s ease;
}
.toast.shown { opacity: 1; transform: none; }
.toast.opens { cursor: pointer; }
.toast.opens:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }

/* the face: a chat's avatar, else the kind's sign in its colours */
.toast > .msgr-avatar, .toast-face { flex: none; width: 44px; height: 44px; }
.toast-face {
  display: grid; place-items: center; border-radius: var(--r-full);
  background: var(--acc-weak); color: var(--acc-ink, var(--acc));
}
.toast-face.good   { background: var(--good-weak);   color: var(--good-ink); }
.toast-face.warn   { background: var(--warn-weak);   color: var(--warn-ink); }
.toast-face.danger { background: var(--danger-weak); color: var(--danger-ink); }

.toast-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; align-self: center; }
.toast-head { display: flex; align-items: baseline; gap: var(--sp-100); }
.toast-title {
  flex: 1; min-width: 0; font-weight: var(--fw-bold); font-size: var(--fs); line-height: var(--lh); color: var(--ink);
  overflow-wrap: anywhere;
}
.toast.chat .toast-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast-time { flex: none; font-size: var(--fs-xs); line-height: var(--lh-xs); color: var(--ink3); }
.toast-line { display: flex; align-items: flex-end; gap: var(--sp-150); }
.toast-text {
  flex: 1; min-width: 0; font-size: var(--fs-s); line-height: var(--lh-s); color: var(--ink2);
  white-space: pre-line; overflow-wrap: anywhere;
}
/* a message's words in two lines, as Telegram's */
.toast.chat .toast-text {
  white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.toast-who { color: var(--ink); }
/* the count is the chat list's own (.msgr-unread) */
.toast-count { flex: none; line-height: var(--sp-250); }

/* 15.3032: the buttons, a row of their own under the face and the words, as wide as the card, a field's height */
/* the card's right edge keeps room for the cross over the words; the row stands off both edges alike */
.toast-actions {
  display: flex; flex-wrap: wrap; gap: var(--sp-100);
  flex: 1 0 calc(100% + var(--sp-200) - var(--sp-150)); margin-inline-end: calc(var(--sp-150) - var(--sp-200));
}
.toast-action { flex: 1 1 0; min-width: max-content; height: var(--h-field); gap: var(--sp-075); }

/* the quick reply in place of the buttons: the program's one message field (css/messagefield.css) */
.toast-reply { margin-top: var(--sp-100); }
.toast-reply-note { font-size: var(--fs-xs); line-height: var(--lh-xs); color: var(--danger-ink); }

/* the cross shows under a mouse, at the card's corner, as Telegram's */
.toast-close.icon-btn {
  position: absolute; top: calc(-1 * var(--sp-075)); right: calc(-1 * var(--sp-075));
  width: 24px; height: 24px; min-width: 0; min-height: 0; padding: 0; border-radius: var(--r-full);
  background: var(--card); color: var(--ink2); box-shadow: 0 0 0 var(--bw) var(--line), var(--sh-overlay);
  opacity: 0; transition: opacity .15s ease;
}
.toast:is(:hover, :focus-within) .toast-close { opacity: 1; }

/* a phone, upright or on its side: a banner at the top (on its side - in the middle, as wide as upright), swiped up */
@media (max-width: 600px), (pointer: coarse) and (max-height: 500px) {
  #toasts {
    left: var(--sp-100); right: var(--sp-100); bottom: auto; width: auto; max-width: 420px; margin-inline: auto;
    top: calc(env(safe-area-inset-top, 0px) + var(--sp-100));
    justify-content: flex-start;
    max-height: calc(100dvh - 2 * var(--sp-100));
  }
  .toast {
    padding-bottom: var(--sp-250);
    transform: translateY(calc(-1 * var(--sp-200))); touch-action: none;
  }
  .toast.shown { transform: none; }
  .toast-close.icon-btn { display: none; }
  /* the grip says the banner is swiped up */
  .toast::after {
    content: ""; position: absolute; left: 50%; bottom: 5px; width: 36px; height: 4px; margin-left: -18px;
    border-radius: var(--r-full); background: var(--line);
  }
}
html[data-motion="calm"] :is(.toast, .toast-close) { transition: none; }
@media (prefers-reduced-motion: reduce) {
  .toast, .toast-close { transition: none; }
}
