@use '@style/theme/index.scss' as theme;
@use 'sass:string';
@use '@components/rate/style/token.scss' as *;

$rate-prefix-cls: string.unquote('#{theme.$prefix}-rate');

.#{$rate-prefix-cls} {
  display: inline-flex;
  align-items: center;
  min-height: $rate-min-height;
  font-size: $rate-font-size;
  line-height: 1;
  user-select: none;

  &-disabled {
    cursor: not-allowed;
  }

  &-character {
    position: relative;
    color: $rate-color-bg_default;
    transition: transform theme.$transition-duration-2 theme.$transition-timing-function-standard;

    &:not(:last-child) {
      margin-right: $rate-gap-size;
    }

    &-left,
    &-right {
      transition: inherit;

      // float 消除 inline-block 导致的父元素被多撑开几个像素
      > * {
        float: left;
      }
    }

    &-left {
      position: absolute;
      top: 0;
      left: 0;
      width: 50%;
      overflow: hidden;
      white-space: nowrap;
      opacity: 0;
    }

    &-scale {
      animation: #{theme.$prefix}-rate-scale theme.$transition-duration-4
        theme.$transition-timing-function-standard;
    }

    &-full &-right {
      color: $rate-color-bg_active;
    }

    &-half &-left {
      color: $rate-color-bg_active;
      opacity: 1;
    }

    &-disabled {
      cursor: not-allowed;
    }
  }

  &:not(#{&}-readonly, &-disabled) &-character {
    cursor: pointer;

    &:hover,
    &:focus {
      transform: scale($rate-scale_active);
    }
  }
}

@keyframes #{theme.$prefix}-rate-scale {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale($rate-scale_active);
  }

  100% {
    transform: scale(1);
  }
}
