/* --- TOAST NOTIFICATIONS --- */

.toast-container {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  pointer-events: none;
  max-width: 420px;
  width: 100%;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-surface);
  font-family: var(--font);
  font-size: 0.74rem;
  font-weight: 400;
  line-height: 1.5;
  position: relative;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

/* --- Entrance --- */
.toast--visible {
  animation: toastSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* --- Exit --- */
.toast--exiting {
  animation: toastSlideOut 0.3s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateY(-100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastSlideOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-100%);
  }
}

/* --- Type variants --- */

.toast--error {
  background: var(--error-dim);
  border: 1px solid var(--error-border);
  color: var(--error);
}

.toast--warning {
  background: var(--warning-dim);
  border: 1px solid var(--warning-border);
  color: var(--warning);
}

.toast--success {
  background: var(--success-dim);
  border: 1px solid var(--success-border);
  color: var(--success);
}

.toast--info {
  background: var(--info-dim);
  border: 1px solid var(--info-border);
  color: var(--info);
}

/* --- Icon --- */

.toast-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- Message --- */

.toast-message {
  flex: 1;
  min-width: 0;
  color: var(--text);
  word-break: break-word;
}

/* --- Close button --- */

.toast-close {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: none;
  border: none;
  border-radius: var(--radius-control);
  cursor: pointer;
  color: var(--dim);
  padding: 0;
  transition:
    color 0.15s ease,
    background 0.15s ease;
}

.toast-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.toast-close svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- Progress bar --- */

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 100%;
  transform-origin: left;
  animation: toastProgressShrink linear forwards;
  border-radius: 0 0 var(--radius-surface) var(--radius-surface);
}

@keyframes toastProgressShrink {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}

.toast-progress--error {
  background: var(--error);
}
.toast-progress--warning {
  background: var(--warning);
}
.toast-progress--success {
  background: var(--success);
}
.toast-progress--info {
  background: var(--info);
}

/* --- Responsive --- */

@media (max-width: 480px) {
  .toast-container {
    left: 0.75rem;
    right: 0.75rem;
    max-width: none;
  }
}

/* --- Reduced motion --- */

@media (prefers-reduced-motion: reduce) {
  .toast--visible {
    animation: none;
    opacity: 1;
    transform: none;
  }
  .toast--exiting {
    animation: none;
    opacity: 0;
  }
  .toast-progress {
    animation: none;
  }
}
