/* ==========================================================================
   Toast notifications (paired with assets/scripts/toast.js)
   ========================================================================== */

.toast-stack {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  width: min(23rem, calc(100vw - 2.5rem));
  pointer-events: none; /* clicks pass through the gaps between toasts */
}

.toast {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  overflow: hidden;
  padding: 0.7rem 0.8rem;
  border: 1px solid #ececec;
  border-radius: 12px;
  background-color: #fff;
  box-shadow: 0 14px 32px -12px rgba(16, 24, 40, 0.3),
    0 2px 6px rgba(16, 24, 40, 0.06);
  pointer-events: auto;

  /* Start state; .toast--in transitions to resting position. */
  opacity: 0;
  transform: translateX(120%);
  transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.21, 1.02, 0.73, 1);
}

.toast--in {
  opacity: 1;
  transform: translateX(0);
}

.toast--out {
  opacity: 0;
  transform: translateX(120%);
}

.toast__thumb {
  flex: 0 0 auto;
  width: 2.9rem;
  height: 2.9rem;
  overflow: hidden;
  border-radius: 8px;
  background-color: #f2f2f2;
}

.toast__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.toast__body {
  flex: 1 1 auto;
  min-width: 0;
}

.toast__title {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0 0 0.1rem;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #12805c;
}

.toast__tick {
  width: 0.95rem;
  height: 0.95rem;
  flex: 0 0 auto;
}

.toast__name {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.3;
  color: #161616;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast__meta {
  margin: 0.1rem 0 0;
  font-size: 0.75rem;
  color: #6d6d6d;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast__actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.15rem;
}

.toast__cta {
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  color: #111;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.18s ease;
}

.toast__cta:hover {
  background-color: #f2f2f2;
}

.toast__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: none;
  font-size: 1.15rem;
  line-height: 1;
  color: #9a9a9a;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.toast__close:hover {
  background-color: #f2f2f2;
  color: #333;
}

/* Countdown bar; pauses while the toast is hovered. */
.toast__progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 100%;
  transform-origin: left center;
  background: linear-gradient(90deg, #12805c, #3fbb8f);
  animation-name: toast-countdown;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

.toast--held .toast__progress {
  animation-play-state: paused;
}

@keyframes toast-countdown {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* Replayed when an item already on screen is added again. */
.toast--pulse {
  animation: toast-pulse 0.4s ease;
}

@keyframes toast-pulse {
  0%   { transform: translateX(0) scale(1); }
  40%  { transform: translateX(0) scale(1.035); }
  100% { transform: translateX(0) scale(1); }
}

@media (max-width: 30rem) {
  .toast-stack {
    right: 0.75rem;
    left: 0.75rem;
    bottom: 0.75rem;
    width: auto;
  }
  .toast {
    transform: translateY(120%);
  }
  .toast--in {
    transform: translateY(0);
  }
  .toast--out {
    transform: translateY(120%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: none;
    opacity: 1;
    transform: none;
  }
  .toast--in,
  .toast--out {
    transform: none;
  }
  .toast--out {
    opacity: 0;
  }
  .toast__progress {
    animation: none;
  }
  .toast--pulse {
    animation: none;
  }
}

/* Removal variant ------------------------------------------------------- */
.toast--danger .toast__title {
  color: #c0392b;
}

.toast--danger .toast__progress {
  background: linear-gradient(90deg, #c0392b, #e8705f);
}

/* Action button (Undo) - styled to match .toast__cta, which is an anchor. */
.toast__cta--action {
  border: 1px solid #dcdcdc;
  background-color: transparent;
  cursor: pointer;
  font-family: inherit;
}

.toast__cta--action:hover {
  background-color: #f2f2f2;
  border-color: #c7c7c7;
}

/* Top-centre stack, used for form/validation errors ---------------------- */
.toast-stack--top {
  top: 1.25rem;
  bottom: auto;
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  align-items: center;
}

/* Enter/exit from above rather than from the right. */
.toast-stack--top .toast {
  width: 100%;
  transform: translateY(-140%);
}
.toast-stack--top .toast--in {
  transform: translateY(0);
}
.toast-stack--top .toast--out {
  transform: translateY(-140%);
}

@media (max-width: 30rem) {
  .toast-stack--top {
    left: 0.75rem;
    right: 0.75rem;
    top: 0.75rem;
    width: auto;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast-stack--top .toast,
  .toast-stack--top .toast--in,
  .toast-stack--top .toast--out {
    transform: none;
  }
}
