/*
 * @Author: 焦质晔
 * @Date: 2020-02-28 22:13:07
 * @Last Modified by: 焦质晔
 * @Last Modified time: 2024-11-05 19:36:09
 */
@use '../../style/src/themes' as *;
@use '../../style/src/mixins/reset' as *;
@use './variable' as *;

$prefix: '#{$qm-prefix}-radio';

.#{$prefix}-wrapper {
  @include reset-component();
  display: inline-block;
  cursor: pointer;

  &:hover:not(&-disabled) {
    .#{$prefix}-inner {
      border-color: $v-primary-color;
    }
  }

  .#{$prefix} {
    display: inline-block;
    position: relative;
    top: -0.09em;
    width: 16px;
    height: 16px;
    line-height: 1;
    white-space: nowrap;
    vertical-align: middle;
    outline: none;
    cursor: pointer;

    &-inner {
      display: inline-block;
      position: relative;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      border: 1px solid $border-color-base;
      border-radius: 50%;
      background-color: #fff;
      transition: all 0.3s ease;
      box-sizing: border-box;
      &::after {
        content: ' ';
        display: table;
        position: absolute;
        top: 3px;
        left: 3px;
        width: 8px;
        height: 8px;
        border-radius: 8px;
        border-top: 0;
        border-left: 0;
        background-color: $v-primary-color;
        transform: scale(0);
        opacity: 0;
        transition: all 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
      }
    }

    &-input {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      margin: 0;
      z-index: 1;
      opacity: 0;
      cursor: pointer;
    }

    // &-focus {
    //   box-shadow: 0 0 0 2px rgba($v-primary-color, 0.15);
    // }

    &-disabled {
      cursor: not-allowed;
      .#{$prefix}-input {
        cursor: not-allowed !important;
      }
    }
  }

  // 选中状态
  .#{$prefix}-checked {
    &::after {
      content: ' ';
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      border: 1px solid $v-primary-color;
      border-radius: 50%;
      animation: antRadioEffect 0.36s ease-in-out;
      animation-fill-mode: both;
      box-sizing: border-box;
    }
    .#{$prefix}-inner {
      border-color: $v-primary-color;
      &::after {
        transform: scale(0.875);
        opacity: 1;
        transition: all 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
      }
    }
  }

  // 禁用状态
  .#{$prefix}-disabled {
    cursor: not-allowed;

    &::after {
      animation-name: none;
      display: none;
    }

    .#{$prefix}-inner {
      border-color: $border-color-base !important;
      background-color: $background-color-light !important;
      &::after {
        background-color: $v-font-disabled-color;
      }
    }

    & + span {
      color: $v-font-disabled-color;
    }
  }

  .#{$prefix}-text {
    margin-left: 6px;
  }
}

@keyframes antRadioEffect {
  0% {
    transform: scale(1);
    opacity: 0.5;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}
