/*
 * The flash: the one message that answers "you just did something". A white card with a mint check,
 * in the window's bottom-right corner, a full-width card at the bottom on phones. A notice fades after 3 s,
 * pausing under the pointer; an alert stays until closed. The page itself shows the result and any Undo.
 */
@layer components {
  .flash {
    position: fixed;
    right: var(--space-6);
    bottom: calc(var(--space-6) + env(safe-area-inset-bottom));
    z-index: 20;
    display: flex;
    gap: var(--space-4);
    align-items: center;
    width: min(26rem, 100% - 2 * var(--gutter));
    padding: var(--space-4) var(--space-5) var(--space-4) var(--space-4);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    color: var(--color-ink);
    box-shadow: var(--shadow-float);
    overflow-wrap: anywhere;
    animation: flash-in var(--duration) var(--ease) both;

    &:hover { animation-play-state: paused; }
  }

  .flash--notice { animation: flash-in var(--duration) var(--ease) both, flash-out 400ms ease-in 3s forwards; }

  .flash__badge {
    display: grid;
    flex: none;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: var(--radius-md);
    background: var(--color-mint);
    font-size: var(--text-lg);
    font-weight: var(--weight-bold);

    svg { width: 1.125rem; height: 1.125rem; }
  }

  .flash--alert .flash__badge { background: var(--color-coral); }

  .flash__text {
    display: grid;
    flex: 1;
    gap: 2px;
    min-width: 0;

    strong { font-size: var(--text-md); letter-spacing: var(--tracking-snug); }
  }

  .flash__close { flex: none; margin-right: calc(-1 * var(--space-2)); text-decoration: none; }

  @keyframes flash-in { from { opacity: 0; translate: 0 var(--space-4); scale: 0.97; } }
  @keyframes flash-out { to { opacity: 0; translate: 0 var(--space-2); } }

  /* Without motion the fade would hide it at once, so it stays until the next page. */
  @media (prefers-reduced-motion: reduce) {
    .flash, .flash--notice { animation: none; }
  }

  @media (max-width: 767px) {
    .flash {
      right: var(--space-3);
      bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
      width: calc(100% - 2 * var(--space-3));
      padding: var(--space-3) var(--space-4) var(--space-3) var(--space-3);
      gap: var(--space-3);
    }

    .flash__badge { width: 2.25rem; height: 2.25rem; }
  }
}
