/* ==========================================================================
   Toasts (v12, REDESIGN-PLAN section 4 "Okna i komunikaty")

   One quiet bar at the bottom centre, in the inverse of the page (light on
   the dark theme, dark on the light one) - the shape of the mockup's Undo
   bar. It is for Undo and for news the screen itself cannot show (a file
   saved outside the app, a link copied, an import's counts, an error that
   needs a step). A routine save that the screen already shows gets no toast.
   ========================================================================== */

.toast-stack {
  position: fixed;
  left: 50%;
  bottom: calc(var(--space-6) + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: var(--space-2);
  width: max-content;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: 22px;
  background: var(--undo-bg);
  color: var(--undo-fg);
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.6);
  min-width: 260px;
  max-width: 440px;
  font-size: var(--fs-footnote);
  font-weight: var(--fw-medium);
  pointer-events: auto;
  transform: translateY(12px);
  opacity: 0;
  transition: transform var(--dur-base) var(--ease-standard),
    opacity var(--dur-base) var(--ease-standard);
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

.toast__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: inline-flex;
}

/* Meaning colours on an inverse bar: the page's own colour for the icon of
   a plain note, the loss red for an error (as a dot-sized icon, never the
   text). */
.toast--success .toast__icon,
.toast--info .toast__icon {
  opacity: 0.7;
}

.toast--error .toast__icon {
  color: var(--loss);
}

/* The bar is inverse (light in the dark theme and the other way round), so
   the loss colour on it is the other theme's: --loss-on-inverse in variables.css. */
.toast--error .toast__icon {
  color: var(--loss-on-inverse);
}

/* The Undo bar's ring: full when the bar appears, empty when the time to
   take the change back has run out. */
.toast__count {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: inline-flex;
}

.toast__count svg {
  width: 22px;
  height: 22px;
  transform: rotate(-90deg);
}

.toast__count circle {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  opacity: 0.4;
  stroke-dasharray: 56.55;
  stroke-dashoffset: 0;
  animation: toast-count var(--toast-ms, 10s) linear forwards;
}

@keyframes toast-count {
  to {
    stroke-dashoffset: 56.55;
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast__count circle {
    animation: none;
  }
}

.toast__text {
  flex: 1;
  min-width: 0;
}

.toast__action {
  flex-shrink: 0;
  min-height: 32px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
  background: none;
  color: inherit;
  font-size: var(--fs-footnote);
  font-weight: var(--fw-semibold);
  white-space: nowrap;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.toast__action:hover {
  text-decoration-thickness: 2px;
}

.toast__action:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* Phones: above the floating tab bar (its height, css/layout.css) and its gap. */
@media (max-width: 880px) {
  .toast-stack {
    bottom: calc(var(--bottom-nav-gap, 8px) + var(--bottom-nav-h, 56px) + 12px);
  }

  .toast {
    min-width: 0;
    width: calc(100vw - 32px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: opacity var(--dur-fast) linear;
    transform: none;
  }
}
