@use 'mixins/mixins' as *;
@use 'mixins/var' as *;
@use 'common/var' as *;
@use 'mixins/flex' as *;

@include b(captcha) {
  font-size: var(--lt-font-size-base);
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
  color: var(--lt-text-color-primary);

  @include flex-column;

  width: 320px;
  padding: 12px 16px;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  background-color: var(--lt-fill-color-blank);
  border: 1px solid var(--lt-border-color-lighter);
  border-radius: 4px;
  outline: 0;
  box-shadow: 0 0 6px #dee2e6;

  &-wrapper {
    font-size: var(--lt-font-size-base);
    font-variant-numeric: tabular-nums;
    line-height: 1.5;
    color: #495057;
  }

  &--dragging {
    cursor: move;
  }

  &__image {
    position: relative;
    display: flex;
    width: 100%;
    height: 0;
    padding-top: 60%;
    border: 1px solid var(--lt-border-color-lighter);
    border-radius: 4px;

    &-inner {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      overflow: hidden;
    }
  }

  &--point &__image {
    cursor: pointer;

    &--locked {
      cursor: default;
    }
  }

  &__canvas {
    width: 100%;
    height: 100%;
    pointer-events: none;
  }

  &__sub-image {
    position: absolute;
    inset: 0 16px;
  }

  &__sub-canvas {
    position: absolute;
    top: 0;
    height: 100%;
    will-change: left;
    pointer-events: none;
    transform: translate3d(-50%, 0, 0);
  }

  &__image-tip {
    position: absolute;
    inset: auto 0 0;

    @include flex-center;

    height: 24px;
    color: var(--bg-color-fff);
    white-space: nowrap;
    pointer-events: none;

    &--success {
      background-color: rgba(32, 201, 151, 0.7);
    }

    &--fail {
      background-color: rgba(240, 62, 62, 0.7);
    }
  }

  &__header {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
  }

  &__action {
    display: flex;
    align-items: center;
    padding: 0;
    color: #868e96;
    cursor: pointer;
    background-color: transparent !important;
    border: 0;
    outline: 0;
    transition: color 0.25s ease;

    &:hover,
    &:focus {
      color: var(--lt-button-hover-text-color);
    }

    // &--disabled {
    //   cursor: not-allowed;
    //   &,
    //   &:hover,
    //   &:focus {
    //     color: #adb5bd;
    //   }
    // }
  }

  &__slider {
    font-size: var(--lt-font-size-base);
    font-variant-numeric: tabular-nums;
    position: relative;

    @include flex-center;

    width: 100%;
    height: 30px;
    padding: 0 16px;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;

    .#{$namespace}-captcha__trigger {
      width: 32px;
      height: 32px;
    }

    &--small {
      height: 24px;
      padding: 0 12px;

      .#{$namespace}-captcha__trigger {
        width: 24px;
        height: 24px;
      }
    }

    &--large {
      height: 40px;
      padding: 0 20px;

      .#{$namespace}-captcha__trigger {
        width: 40px;
        height: 40px;
      }
    }

    &--inner {
      height: 26px;
      border-radius: 12px;
      padding: 0 18px;

      .#{$namespace}-captcha__trigger {
        width: 36px;
        height: 36px;
      }
    }

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

  &--slide &__slider {
    margin-top: 16px;
    margin-bottom: 6px;
  }

  &__filler {
    position: absolute;
    inset: 0;
    background-color: rgba(51, 154, 240, 0.7);
    border-radius: 2px;
    will-change: transform;
    transition: background-color 0.25s ease, transform 0ms ease;
    transform: scaleX(0);
    transform-origin: 0 50%;

    &--success {
      background-color: rgba(32, 201, 151, 0.7);
    }
  }

  &--slide &__filler {
    display: none;
  }

  &__tip {
    display: flex;
    align-items: center;
  }

  &__slider &__tip {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    white-space: nowrap;
    background-image: linear-gradient(to right, #495057, #495057 50%, var(--bg-color-fff) 50%);
    background-position: 0%;
    background-clip: text;
    background-size: 200% 100%;
    transition: color 0.25s ease, background-position 0ms ease;
  }

  &--slide &__tip {
    line-height: 1;
    color: #a1adb1;
    background-image: none;
  }

  &__slider--disabled &__tip {
    color: getCssVar('text-color-disabled');
  }

  &__track {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    height: 100%;
  }

  &__trigger {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    // color: #a1adb1;
    color: #777;
    cursor: move;
    background-color: var(--bg-color-fff);
    border-radius: 2px;
    will-change: left;
    outline: 0;
    box-shadow: 0 0 6px #dee2e6;
    transition: color 0.25s ease, left 0ms ease;
    transform: translate3d(-50%, 0, 0);

    &:hover,
    &:focus,
    &--focused {
      color: #339af0;
    }

    &--success {
      cursor: inherit;

      &,
      &:focus,
      &:hover {
        color: #20c997;
      }
    }
  }

  &--slide &__trigger {
    border-radius: 50%;
  }

  &__slider--disabled &__trigger {
    color: #adb5bd;
    cursor: not-allowed;
  }

  &__pointer {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    font-weight: bold;
    line-height: 1;
    color: #339af0;
    background-color: var(--bg-color-fff);
    border: 4px solid #339af0;
    border-radius: 50%;
    box-shadow: 0 0 6px #dee2e6;
    transform: translate(-50%, -50%);
  }

  &__text-list {
    position: relative;
    display: flex;
    align-items: center;
    padding: 2px 0;
    margin-top: 10px;
    line-height: 1;
  }

  &__text {
    display: flex;
    margin-inline-start: 6px;
    font-size: 18px;
    font-weight: bold;
  }

  &__button--success {
    pointer-events: none;
  }
}