/* =========================================================================
   ToastifyStack — iPhone-style stacked notifications (single module)
   ========================================================================= */

.toastify-host {
  position: fixed;
  top: max(0.75rem, env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10050;
  width: min(22.5rem, calc(100vw - 1.5rem));
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.45rem;
}

html[dir="rtl"] .toastify-host {
  /* still centered */
}

.toastify-card {
  pointer-events: auto;
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.65rem;
  align-items: start;
  padding: 0.85rem 0.9rem 0.95rem;
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface, #1c1c1e) 88%, transparent);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid color-mix(in srgb, var(--border, #3a3a3c) 70%, transparent);
  box-shadow:
    0 12px 40px -8px rgba(0, 0, 0, 0.55),
    0 0 0 0.5px rgba(255, 255, 255, 0.06) inset;
  color: var(--text, #f5f5f7);
  cursor: pointer;
  overflow: hidden;
  transform-origin: top center;
  animation: toastify-in 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
  transition: transform 0.28s ease, opacity 0.28s ease, margin 0.28s ease;
}

html[data-theme="light"] .toastify-card {
  background: color-mix(in srgb, #f5f5f7 92%, transparent);
  color: #1c1c1e;
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow:
    0 12px 32px -10px rgba(0, 0, 0, 0.18),
    0 0 0 0.5px rgba(0, 0, 0, 0.04) inset;
}

.toastify-card.is-leaving {
  animation: toastify-out 0.32s ease forwards;
  pointer-events: none;
}

.toastify-card:active {
  transform: scale(0.98);
}

.toastify-icon {
  width: 2rem;
  height: 2rem;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  background: var(--accent-soft, rgba(227, 179, 65, 0.15));
  color: var(--accent, #e3b341);
}

.toastify-card[data-kind="success"] .toastify-icon {
  background: rgba(158, 203, 140, 0.18);
  color: #9ecb8c;
}
.toastify-card[data-kind="error"] .toastify-icon,
.toastify-card[data-kind="danger"] .toastify-icon {
  background: rgba(229, 99, 122, 0.18);
  color: #e5637a;
}
.toastify-card[data-kind="info"] .toastify-icon {
  background: rgba(111, 179, 210, 0.18);
  color: #6fb3d2;
}
.toastify-card[data-kind="notification"] .toastify-icon {
  background: rgba(227, 179, 65, 0.18);
  color: var(--accent, #e3b341);
}

.toastify-body {
  min-width: 0;
  padding-top: 0.1rem;
}

.toastify-app {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted, #8b93a7);
  margin-bottom: 0.15rem;
}

.toastify-title {
  font-size: 0.9rem;
  font-weight: 650;
  line-height: 1.25;
  color: inherit;
  margin: 0 0 0.15rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.toastify-text {
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--text-muted, #8b93a7);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.toastify-close {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-faint, #5c6478);
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  margin-top: -0.1rem;
}
.toastify-close:hover {
  background: rgba(127, 127, 127, 0.15);
  color: inherit;
}

.toastify-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: transparent;
  overflow: hidden;
}
.toastify-progress > span {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left center;
  background: var(--accent, #e3b341);
  opacity: 0.75;
  animation-name: toastify-progress;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}
html[dir="rtl"] .toastify-progress > span {
  transform-origin: right center;
}

.toastify-card[data-kind="success"] .toastify-progress > span { background: #9ecb8c; }
.toastify-card[data-kind="error"] .toastify-progress > span,
.toastify-card[data-kind="danger"] .toastify-progress > span { background: #e5637a; }
.toastify-card[data-kind="info"] .toastify-progress > span { background: #6fb3d2; }

@keyframes toastify-in {
  from {
    opacity: 0;
    transform: translateY(-120%) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toastify-out {
  to {
    opacity: 0;
    transform: translateY(-40%) scale(0.94);
    margin-bottom: -4rem;
  }
}

@keyframes toastify-progress {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

@media (prefers-reduced-motion: reduce) {
  .toastify-card,
  .toastify-card.is-leaving,
  .toastify-progress > span {
    animation: none !important;
    transition: none !important;
  }
}
