/* Generic toast mechanism (flash). Linked EXPLICITLY in app/views/layouts/_head.html.erb through
   stylesheet_link_tag "toast", so it reaches BOTH layouts (application + SPA).
   Colours, radius and typeface come from tokens.css (one source: frontend/packages/design-tokens/src/tokens.ts),
   which declares them on .kl__toast-region as well as on .kl — so they resolve in the SPA layout too, where the
   region lies outside any .kl wrapper. Only the z-index below is this sheet's own: a token of the mechanism, not of
   the brand. */
:root {
  /* z-index ponad .kl__nav (20) i z zapasem nad warstwami aplikacji React. */
  --toast-z: 1200;
}

/* Region: prawy-górny róg, stos z odstępem. pointer-events: none na regionie, auto na
   pojedynczych toastach — region nie blokuje kliknięć tła między toastami. */
.kl__toast-region {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: var(--toast-z);
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

.kl__toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border-radius: var(--radius-field);
  padding: 14px 16px;
  font-size: .92rem;
  line-height: 1.45;
  border: 1px solid transparent;
  box-shadow: 0 10px 30px -12px color-mix(in srgb, var(--accent) 35%, transparent);
  /* WIDOCZNY domyślnie — bez opacity:0 w spoczynku, żeby komunikat był czytelny także
     bez JS / przy błędzie JS (flash niesie ważne treści). Animacją wejścia/wyjścia
     sterują klasy --enter/--closing dodawane przez JS. */
  transition: opacity .22s ease, transform .22s ease;
  font-family: var(--font-sans);
}

/* Stan startowy animacji wejścia — dodawany WYŁĄCZNIE przez JS (connect() w toast_controller.js), więc
   bez JS toast pozostaje widoczny. JS zdejmuje klasę w następnej klatce => slide-in. */
.kl__toast--enter { opacity: 0; transform: translateY(-8px); }

/* Animacja wyjścia (auto-dismiss / ręczne zamknięcie). */
.kl__toast--closing { opacity: 0; transform: translateY(-8px); }

.kl__toast-icon { flex-shrink: 0; margin-top: 1px; display: inline-flex; }
.kl__toast-icon svg { width: 18px; height: 18px; } /* normalizacja (inline_check = 22px) */

.kl__toast-message { margin: 0; flex: 1; word-break: break-word; } /* długie URL-e nie rozpychają */

.kl__toast-close {
  flex-shrink: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 2px;
  color: inherit;
  opacity: .7;
}
.kl__toast-close:hover,
.kl__toast-close:focus-visible { opacity: 1; }

/* Warianty (kolory z tokens.css — .kl__toast-region, jedno źródło frontend/packages/design-tokens/src/tokens.ts).
   Tekst = ciemny akcent rodziny: success → --success-dark, reszta → --error/--warning/--info. */
.kl__toast--success { background: var(--success-bg); border-color: var(--success-bd); color: var(--success-dark); }
.kl__toast--success .kl__toast-icon { color: var(--success); }
.kl__toast--error   { background: var(--error-bg);   border-color: var(--error-bd);   color: var(--error); }
.kl__toast--warning { background: var(--warning-bg); border-color: var(--warning-bd); color: var(--warning); }
.kl__toast--info    { background: var(--info-bg);    border-color: var(--info-bd);    color: var(--info); }

/* Mobile: pełna szerokość u góry. */
@media (max-width: 640px) {
  .kl__toast-region { top: 8px; right: 8px; left: 8px; width: auto; }
}

/* Reduced-motion: bez przejść (JS pokazuje/usuwa natychmiast). */
@media (prefers-reduced-motion: reduce) {
  .kl__toast { transition: none; transform: none; }
}
