/* =========================
   Toasts
========================= */

@use "../kit-deps" as *;

.toast {
  position: fixed;
  z-index: 1100;
  bottom: -100px;
  right: $space-4;
  max-width: 420px;
  width: calc(100% - #{$space-8});

  background: $neutral-0;
  border: $border-width-base $border-style-base $border-color-muted;
  border-left-width: $border-width-accent;
  border-radius: $radius-md;
  padding: 0;
  opacity: 0;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba($neutral-900, 0.16);

  transition:
    opacity $motion-slow $motion-ease,
    bottom $motion-slow $motion-ease;

  &.a-show {
    bottom: $space-4;
    opacity: 1;
  }

  &.a-hide {
    bottom: $space-4 - 60px;
    opacity: 0;
  }

  .toast-content {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: $space-3 $space-4;
    padding-right: $space-10;

    .toast-header {
      display: flex;
      align-items: center;
      gap: $space-2;
      font-size: 14px;
      font-weight: $font-weight-bold;
      text-transform: uppercase;
      color: $neutral-900;
      line-height: 1;

      .vmk-icon {
        width: $icon-size-md;
        height: $icon-size-md;
        flex-shrink: 0;
      }
    }

    .toast-text {
      font-size: 14px;
      padding: $space-2 0 0;
      margin: 0;
      color: $neutral-700;
      line-height: 1.5;
    }
  }

  .toast-close {
    position: absolute;
    top: $space-1;
    right: $space-2;
    color: $neutral-600;
    width: 32px;
    height: 32px;
    border-color: transparent;
    background: transparent;
    border-radius: $radius-full;
    cursor: pointer;
    transition:
      background-color $motion-base $motion-ease,
      color $motion-base $motion-ease;

    &:hover {
      background-color: $neutral-100;
      color: $neutral-900;
    }

    &:focus-visible {
      @include focus_ring;
    }
  }

  .toast-progress {
    height: 3px;
    width: 100%;
    background: $neutral-100;
    overflow: hidden;
    margin-top: 1px;

    .toast-progress-bar {
      height: 100%;
      width: 100%;
      transform-origin: left;
      animation: toast-progress linear forwards;
      background: $neutral-900;
    }
  }

  &.toast-info {
    border-color: $color-info;
    background: $info-bg;

    .toast-header .vmk-icon {
      color: $color-info;
    }

    .toast-progress-bar {
      background: $color-info;
    }
  }

  &.toast-success {
    border-color: $color-success;
    background: $success-bg;

    .toast-header .vmk-icon {
      color: $color-success;
    }

    .toast-progress-bar {
      background: $color-success;
    }
  }

  &.toast-warning {
    border-color: $color-warning;
    background: $warning-bg;

    .toast-header .vmk-icon {
      color: $color-warning;
    }

    .toast-progress-bar {
      background: $color-warning;
    }
  }

  &.toast-danger,
  &.toast-error {
    border-color: $color-error;
    background: $danger-bg;

    .toast-header .vmk-icon {
      color: $color-error;
    }

    .toast-progress-bar {
      background: $color-error;
    }
  }
}

@keyframes toast-progress {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}
