@import '../../style/themes/index';
@import '../../style/mixins/index';

@yee-badge-prefix-cls: ~'@{yee-prefix}-badge';
@yee-number-prefix-cls: ~'@{yee-prefix}-scroll-number';

.@{yee-badge-prefix-cls} {
  .yee-reset-component;

  position: relative;
  display: inline-block;
  color: unset;
  line-height: 1;

  &-count {
    min-width: @yee-badge-height;
    height: @yee-badge-height;
    padding: 0 6px;
    color: @yee-badge-text-color;
    font-weight: @yee-badge-font-weight;
    font-size: @yee-badge-font-size;
    line-height: @yee-badge-height;
    white-space: nowrap;
    text-align: center;
    background: @yee-highlight-color;
    border-radius: @yee-badge-height / 2;
    box-shadow: 0 0 0 1px @yee-shadow-color-inverse;
    a,
    a:hover {
      color: @yee-badge-text-color;
    }
  }

  &-multiple-words {
    padding: 0 8px;
  }

  &-dot {
    width: @yee-badge-dot-size;
    height: @yee-badge-dot-size;
    background: @yee-highlight-color;
    border-radius: 100%;
    box-shadow: 0 0 0 1px @yee-shadow-color-inverse;
  }

  &-count,
  &-dot,
  .@{yee-number-prefix-cls}-custom-component {
    position: absolute;
    top: 0;
    right: 0;
    z-index: @yee-zindex-badge;
    transform: translate(50%, -50%);
    transform-origin: 100% 0%;
  }

  &-status {
    line-height: inherit;
    vertical-align: baseline;

    &-dot {
      position: relative;
      top: -1px;
      display: inline-block;
      width: @yee-badge-status-size;
      height: @yee-badge-status-size;
      vertical-align: middle;
      border-radius: 50%;
    }
    &-success {
      background-color: @yee-success-color;
    }
    &-processing {
      position: relative;
      background-color: @yee-processing-color;
      &::after {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border: 1px solid @yee-processing-color;
        border-radius: 50%;
        animation: antStatusProcessing 1.2s infinite ease-in-out;
        content: '';
      }
    }
    &-default {
      background-color: @yee-normal-color;
    }
    &-error {
      background-color: @yee-error-color;
    }
    &-warning {
      background-color: @yee-warning-color;
    }

    // mixin to iterate over colors and create CSS class for each one
    .yee-make-color-classes(@i: length(@yee-preset-colors)) when (@i > 0) {
      .yee-make-color-classes(@i - 1);
      @yee-color: extract(@yee-preset-colors, @i);
      @yee-darkColor: '@{yee-color}-6';
      &-@{yee-color} {
        background: @yee-darkColor;
      }
    }
    .yee-make-color-classes();

    &-text {
      margin-left: 8px;
      color: @yee-text-color;
      font-size: @yee-font-size-base;
    }
  }

  &-zoom-appear,
  &-zoom-enter {
    animation: antZoomBadgeIn 0.3s @yee-ease-out-back;
    animation-fill-mode: both;
  }

  &-zoom-leave {
    animation: antZoomBadgeOut 0.3s @yee-ease-in-back;
    animation-fill-mode: both;
  }

  &-not-a-wrapper {
    &:not(.@{yee-badge-prefix-cls}-status) {
      vertical-align: middle;
    }

    .@{yee-prefix}-scroll-number {
      position: relative;
      top: auto;
      display: block;
    }

    .@{yee-badge-prefix-cls}-count {
      transform: none;
    }
  }
}

@keyframes antStatusProcessing {
  0% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  100% {
    transform: scale(2.4);
    opacity: 0;
  }
}

.@{yee-number-prefix-cls} {
  overflow: hidden;
  &-only {
    display: inline-block;
    height: @yee-badge-height;
    transition: all 0.3s @yee-ease-in-out;
    > p.@{yee-number-prefix-cls}-only-unit {
      height: @yee-badge-height;
      margin: 0;
    }
  }

  &-symbol {
    vertical-align: top;
  }
}

@keyframes antZoomBadgeIn {
  0% {
    transform: scale(0) translate(50%, -50%);
    opacity: 0;
  }
  100% {
    transform: scale(1) translate(50%, -50%);
  }
}

@keyframes antZoomBadgeOut {
  0% {
    transform: scale(1) translate(50%, -50%);
  }
  100% {
    transform: scale(0) translate(50%, -50%);
    opacity: 0;
  }
}
