/* kb toast - navy, slides in bottom left, icon pops, thin progress bar. Mockup 06-komponenter.html (TOAST).
   Markup is built by toast.js. Motion lives in no-preference only; reduced motion gets plain appear/disappear. */
@layer kb.components {
  .kb-toasts {
    position: fixed;
    left: 24px;
    bottom: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: calc(100vw - 48px);
    pointer-events: none; /* only the toasts themselves take clicks */
  }
  /* The stack is a manual popover (top layer, above modal dialogs): undo the browser's popover box. */
  .kb-toasts[popover] {
    inset: auto auto 24px 24px;
    margin: 0;
    padding: 0;
    border: 0;
    width: auto;
    height: auto;
    overflow: visible;
    background: transparent;
    color: inherit;
  }
  .kb-toasts[popover]:not(:popover-open) { display: none; }
  .kb-toasts[popover]:popover-open { display: flex; }

  .kb-toast {
    /* navy; a step lighter in dark so it separates from the page (mockup: #0d1f44 / #1b2b52) */
    --kb-toast-bg: #0d1f44;
    --kb-toast-bg: light-dark(#0d1f44, #1b2b52);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: min(320px, 100%);
    max-width: 440px;
    padding: 12px 14px;
    border-radius: var(--kb-radius-card);
    background: var(--kb-toast-bg);
    color: #ffffff;
    box-shadow: var(--kb-shadow-pop);
    pointer-events: auto;
    font-size: 15px;
    line-height: 1.35;
  }

  .kb-toast__icon {
    flex: none;
    width: 26px;
    height: 26px;
    border-radius: var(--kb-radius);
    display: grid;
    place-items: center;
    background: var(--kb-success);
    color: var(--kb-success-ink);
  }
  .kb-toast--error .kb-toast__icon { background: var(--kb-danger); color: var(--kb-danger-ink); }
  .kb-toast--info .kb-toast__icon { background: var(--kb-primary); color: var(--kb-primary-ink); }

  .kb-toast__icon svg {
    width: 16px;
    height: 16px;
    stroke-width: 2.4;
  }

  .kb-toast__text {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .kb-toast__action {
    flex: none;
    margin-left: auto;
    border: 0;
    border-radius: var(--kb-radius);
    background: rgba(255, 255, 255, .12);
    color: #ffffff;
    font: inherit;
    font-weight: 600;
    padding: 5px 10px;
    cursor: pointer;
  }
  .kb-toast__action:hover { background: rgba(255, 255, 255, .2); }
  .kb-toast__action:focus-visible {
    outline: 2px solid #8aa6ff;
    outline-offset: 2px;
  }

  .kb-toast__bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: linear-gradient(90deg, #6a52e4, #1f95ea);
    transform-origin: left;
    display: none; /* shown with motion only: a bar that shrinks is motion */
  }

  @media (prefers-reduced-motion: no-preference) {
    .kb-toast { animation: kb-toast-in .45s var(--kb-ease-out); }
    .kb-toast__icon svg {
      transform: scale(0);
      animation: kb-toast-pop .34s var(--kb-ease-spring) .25s forwards;
    }
    .kb-toast__bar {
      display: block;
      animation: kb-toast-shrink var(--kb-toast-ms, 2200ms) linear forwards;
    }
    .kb-toast.is-paused .kb-toast__bar { animation-play-state: paused; }
    /* shown again above a newer dialog: no second entrance (the bar keeps its place through a negative delay) */
    .kb-toast.is-settled { animation: none; }
    .kb-toast.is-settled .kb-toast__icon svg { animation: none; transform: none; }
    .kb-toast__action { transition: background-color .2s; }
  }

  @keyframes kb-toast-in { from { transform: translateX(-120%); opacity: 0; } to { transform: none; opacity: 1; } }
  @keyframes kb-toast-pop { to { transform: scale(1); } }
  @keyframes kb-toast-shrink { to { transform: scaleX(0); } }

  @media (max-width: 480px) {
    .kb-toasts { left: 12px; bottom: 12px; max-width: calc(100vw - 24px); }
    .kb-toasts[popover] { inset: auto auto 12px 12px; }
    .kb-toast { min-width: 0; }
  }
}
