:root {
  --#{$CSS_VAR_PFX}toast-txt-color: var(--#{$CSS_VAR_PFX}txt-color);
  --#{$CSS_VAR_PFX}toast-bg-color: var(--#{$CSS_VAR_PFX}bg-color);
  --#{$CSS_VAR_PFX}toast-border-color: var(--#{$CSS_VAR_PFX}bg-color-darker);
  --#{$CSS_VAR_PFX}toast-inner-space: 2.5em;
  --#{$CSS_VAR_PFX}toast-animation-show-duration: #{$TOAST_SHOW_ANIMATION_DURATION};
  --#{$CSS_VAR_PFX}toast-animation-hide-duration: #{$TOAST_HIDE_ANIMATION_DURATION};
  --#{$CSS_VAR_PFX}toast-animation-show: flatify-slide-up-in-min var(--#{$CSS_VAR_PFX}toast-animation-show-duration)
    ease;
  --#{$CSS_VAR_PFX}toast-animation-hide: flatify-slide-down-out-min var(--#{$CSS_VAR_PFX}toast-animation-hide-duration)
    ease both;
}

.toast-wrapper {
  position: fixed;
  width: 20em;
  max-width: 100vw;
  display: flex;
  flex-direction: column;
  z-index: $ZINDEX_TOAST;

  &.bottom {
    flex-direction: column-reverse;
    bottom: var(--#{$CSS_VAR_PFX}toast-inner-space);
  }
  &.top {
    flex-direction: column;
    top: var(--#{$CSS_VAR_PFX}toast-inner-space);
  }
  &.left {
    left: var(--#{$CSS_VAR_PFX}toast-inner-space);
  }
  &.right {
    right: var(--#{$CSS_VAR_PFX}toast-inner-space);
  }
  &.center {
    left: 0;
    right: 0;
    margin: 0 auto;
  }

  @include break-xs() {
    &.left,
    &.right {
      left: 0;
      right: 0;
      margin: 0 auto;
    }
    --#{$CSS_VAR_PFX}toast-inner-space: 0.5em;
    width: calc(100% - 1em);
  }
}

.toast {
  --#{$CSS_VAR_PFX}local-txt-color: var(--#{$CSS_VAR_PFX}toast-txt-color);
  --#{$CSS_VAR_PFX}local-bg-color: var(--#{$CSS_VAR_PFX}toast-bg-color);
  --#{$CSS_VAR_PFX}local-border-color: var(--#{$CSS_VAR_PFX}toast-border-color);
  overflow: hidden;
  position: relative;
  width: 100%;
  padding: 0.9em;
  margin: 0.25em 0;
  color: var(--#{$CSS_VAR_PFX}local-txt-color);
  background: var(--#{$CSS_VAR_PFX}local-bg-color);
  border: var(--#{$CSS_VAR_PFX}border-width) solid var(--#{$CSS_VAR_PFX}local-border-color);
  box-shadow: inset 0 -0.125em 0 var(--#{$CSS_VAR_PFX}local-border-color);
  border-radius: var(--#{$CSS_VAR_PFX}border-radius);

  &:not(.toast-will-be-removed) {
    animation: var(--#{$CSS_VAR_PFX}toast-animation-show);
  }

  &.toast-will-be-removed {
    animation: var(--#{$CSS_VAR_PFX}toast-animation-hide);
  }

  &:hover {
    .close-button {
      transition-delay: 0.15s;
      transform: scale(1);
    }
  }

  .toast-svg {
    display: inline-block;
    width: 2em;
    max-height: 2em;
    margin-inline-end: 0.32em;
    opacity: 0.75;

    &:not([fill="none"]) {
      fill: currentColor;
    }
  }

  .close-button {
    position: absolute;
    top: 0;
    bottom: 0;
    inset-inline-end: 0.25em;
    font-size: 0.85em;
    margin: auto 0;
    background: var(--#{$CSS_VAR_PFX}local-bg-color);
    box-shadow: 0 0 0.32em 0.32em var(--#{$CSS_VAR_PFX}local-bg-color);
    transform: scale(0);
  }
}
