/* Generic toast mechanism (flash). Its tokens are declared on .kl__toast-region as well as on .kl, so they resolve in
   the SPA and admin layouts 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 style. */

@layer components {
  :root {
    /* z-index above .kl__nav (20) and with headroom over the layers of the React applications. */
    --toast-z: 1200;
  }

  /* pointer-events: none on the region, auto on the toasts — the region does not block clicks between toasts. */
  .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-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.45;
    border: 1px solid transparent;
    box-shadow: var(--shadow-xl);
    /* Visible at rest — no opacity: 0 — so the message stays readable without JS or on a JS error. */
    transition: opacity var(--duration-base) var(--ease-standard), transform var(--duration-base) var(--ease-standard);
  }

  .kl__toast--enter { opacity: 0; transform: translateY(-8px); }
  .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; } /* inline_check draws at 22px */

  .kl__toast-message { margin: 0; flex: 1; word-break: break-word; } /* long URLs do not stretch it */

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

  .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); }

  @media (max-width: 640px) {
    .kl__toast-region { top: 8px; right: 8px; left: 8px; width: auto; }
  }

  @media (prefers-reduced-motion: reduce) {
    .kl__toast { transition: none; transform: none; }
  }
}
