/* app/assets/stylesheets/components/flash.css
   ─────────────────────────────────────────────────────────────────────────────
   Flash banners. Slide down from top. Auto-dismiss via Stimulus alert_controller.
   ───────────────────────────────────────────────────────────────────────────── */

.flash-region {
  position:   sticky;
  top:        var(--masthead-height);
  z-index:    var(--z-flash);
  width:      100%;
  transition: top 300ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* The masthead has scrolled away — take its place at the top. */
:root.masthead-hidden .flash-region {
  top: 0;
}

/* Pages whose nav lives inside the page body (home) can't put the region in
   flow under it, so it floats just below the nav instead. */
.flash-region--overlay {
  position: fixed;
  left:     0;
  right:    0;
}

.flash {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  gap:             var(--space-4);
  padding:         var(--space-3) var(--space-6);
  font-family:     var(--font-sans);
  font-size:       var(--text-sm);
  font-weight:     500;
  animation:       flash-in var(--transition-normal) ease;
}

@keyframes flash-in {
  from { transform: translateY(-8px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* The tints are translucent, which is right on a card but not on a banner that
   sticks over scrolling content — the page shows through it. Lay each tint
   over the solid page colour so the banner reads as one opaque strip. */
.flash-region .flash {
  background-color: var(--bg-page);
}

/* Notice — green tint for success */
.flash--notice {
  background-image: linear-gradient(var(--tint-green-bg), var(--tint-green-bg));
  color:         var(--tint-green-text);
  border-bottom: 1px solid var(--tint-green-border);
}

/* Alert — red tint for errors and warnings */
.flash--alert {
  background-image: linear-gradient(var(--tint-red-bg), var(--tint-red-bg));
  color:         var(--tint-red-text);
  border-bottom: 1px solid var(--tint-red-border);
}

/* Warning — amber tint */
.flash--warning {
  background-image: linear-gradient(var(--tint-amber-bg), var(--tint-amber-bg));
  color:         var(--tint-amber-text);
  border-bottom: 1px solid var(--tint-amber-border);
}

/* Info — blue tint */
.flash--info {
  background-image: linear-gradient(var(--tint-blue-bg), var(--tint-blue-bg));
  color:         var(--tint-blue-text);
  border-bottom: 1px solid var(--tint-blue-border);
}

.flash__message {
  flex: 1;
  line-height: var(--leading-snug);
}

.flash__dismiss {
  flex-shrink:  0;
  font-size:    18px;
  line-height:  1;
  color:        inherit;
  opacity:      0.6;
  background:   none;
  border:       none;
  cursor:       pointer;
  padding:      0;
  transition:   opacity var(--transition-fast);
}

.flash__dismiss:hover {
  opacity: 1;
}

/* Slide out animation class toggled by Stimulus */
.flash--dismissed {
  /* Not var(--transition-normal): that token already carries a timing
     function, and two in one shorthand makes the whole line invalid. */
  animation:  flash-out 200ms ease forwards;
}

@keyframes flash-out {
  from { transform: translateY(0);    opacity: 1; max-height: 100px; }
  to   { transform: translateY(-8px); opacity: 0; max-height: 0; padding: 0; }
}

/* ── Standalone flash (auth pages, forms) ────────────────────────────────── */

.flash--inline {
  position:      static;
  border-radius: var(--radius-md);
  border:        1px solid;
  margin-bottom: var(--space-4);
}

.flash--inline.flash--notice  { border-color: var(--tint-green-border); }
.flash--inline.flash--alert   { border-color: var(--tint-red-border); }
.flash--inline.flash--warning { border-color: var(--tint-amber-border); }
.flash--inline.flash--info    { border-color: var(--tint-blue-border); }
