/*
 * Toast notices. `.notice-stack` is the fixed bottom-right region the flash
 * fills; each `.notice` manages its own dismissal/auto-hide via the `notice`
 * Stimulus controller, which adds `.is-leaving` to trigger the exit transition.
 * The variant accent is carried in a single `--notice-accent` custom property.
 */
.notice-stack {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  width: min(22rem, calc(100vw - 2rem));
  /* let clicks fall through the gaps; each notice re-enables pointer events */
  pointer-events: none;
}

.notice {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  background: var(--notice-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--notice-accent);
  border-radius: 12px;
  padding: 0.875rem 0.9375rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.notice__icon {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 1px;
  color: var(--notice-accent);
}
.notice__body {
  flex: 1;
  font-size: 0.9rem;
  line-height: 1.4;
}
.notice__close {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  margin: -0.125rem -0.125rem 0 0;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color 0.12s ease, background 0.12s ease;
}
.notice__close svg {
  width: 1rem;
  height: 1rem;
}
.notice__close:hover {
  color: var(--color-text);
  background: var(--color-secondary-hover);
}
.notice__close:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-focus-ring);
}

/* Variant accent + tinted background */
.notice--success { --notice-accent: var(--color-success); --notice-bg: var(--color-success-subtle); }
.notice--warning { --notice-accent: var(--color-warning); --notice-bg: var(--color-warning-subtle); }
.notice--danger  { --notice-accent: var(--color-danger);  --notice-bg: var(--color-danger-subtle); }
.notice--info    { --notice-accent: var(--color-info);    --notice-bg: var(--color-info-subtle); }

/* Exit — added by the controller before removal */
.notice.is-leaving {
  opacity: 0;
  transform: translateX(0.75rem);
}

/* Enter (fill: none so it doesn't fight the exit transition afterwards) */
@media (prefers-reduced-motion: no-preference) {
  .notice {
    animation: notice-in 0.18s ease;
  }
}
@keyframes notice-in {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
}

/* Full-width along the bottom on narrow screens */
@media (max-width: 30rem) {
  .notice-stack {
    left: 0.75rem;
    right: 0.75rem;
    bottom: 0.75rem;
    width: auto;
  }
}
