/* toast.css — the bottom-right notification stack built by toast.js.
   Deliberately its own class namespace (.as-toast*) rather than reusing the
   legacy `.toast` in style.css: that one is still used by the landing and auth
   pages, and it is positioned bottom-centre with a translateX(-50%) that would
   fight everything here. Leaving it untouched means no regression there. */

.as-toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 200;            /* above the modals, which sit at 90-100 */
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
  pointer-events: none;    /* the gaps between cards must not eat clicks */
}

.as-toast {
  position: relative;
  pointer-events: auto;
  width: min(360px, calc(100vw - 40px));
  padding: 14px 16px;
  border: 1px solid var(--border-strong, rgba(255, 255, 255, .14));
  border-radius: 14px;     /* RADIUS in toast.js must match this */
  background: rgba(18, 10, 7, .97);
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .9);
  color: var(--text);
  font-size: .88rem;
  line-height: 1.5;
  cursor: pointer;         /* clicking dismisses early */
  animation: as-toast-enter .26s cubic-bezier(.16, 1, .3, 1) both;
}

.as-toast.is-leaving {
  opacity: 0;
  transform: translateX(12px);
  transition: opacity .24s ease, transform .24s ease;
}

@keyframes as-toast-enter {
  from { opacity: 0; transform: translateX(16px) scale(.98); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

.as-toast-msg { position: relative; z-index: 1; display: block; }

/* The countdown ring. Sits over the card's own border, inside its corners. */
.as-toast-ring {
  position: absolute;
  inset: 0;
  overflow: visible;
  pointer-events: none;
}

.as-toast-ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, .07);
  stroke-width: 2;
}

/* pathLength="100" on the rect renormalises the perimeter to 100 units, so the
   dash is in percent regardless of the card's real size. dashoffset 100 -> 0
   draws the line once around, clockwise from the top-left corner. */
.as-toast-ring-line {
  fill: none;
  stroke: var(--primary, #ff8a1f);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: as-toast-ring var(--as-toast-dur, 10s) linear forwards;
}

@keyframes as-toast-ring {
  from { stroke-dashoffset: 100; }
  to   { stroke-dashoffset: 0; }
}

/* quiet-motion turns off decorative animation site-wide with `animation: none
   !important`. This ring is not decoration -- it is the visible form of the
   dismissal countdown, the same category as the request spinners that mode
   already exempts -- so it is re-enabled here on the same terms. */
html.quiet-motion .as-toast-ring-line {
  animation: as-toast-ring var(--as-toast-dur, 10s) linear forwards !important;
}
html.quiet-motion .as-toast {
  animation: as-toast-enter .26s cubic-bezier(.16, 1, .3, 1) both !important;
}

/* A genuine OS-level reduced-motion request is a different matter: that is a
   person asking for less movement, not a site toggle. The line is shown at rest
   as a plain full-perimeter outline and nothing sweeps. The toast still clears
   itself on time, because toast.js dismisses on a timer rather than waiting for
   this animation to end. */
@media (prefers-reduced-motion: reduce) {
  .as-toast-ring-line,
  html.quiet-motion .as-toast-ring-line {
    animation: none !important;
    stroke-dashoffset: 0;
    opacity: .5;
  }
  .as-toast,
  html.quiet-motion .as-toast { animation: none !important; }
  .as-toast.is-leaving { transition: none; }
}

/* On a phone the stack spans the width, so a long message does not end up in a
   narrow column against the right edge. */
@media (max-width: 560px) {
  .as-toast-stack {
    left: 16px;
    right: 16px;
    bottom: 16px;
    align-items: stretch;
  }
  .as-toast { width: auto; }
}
