@import './../common/abstracts/_mixin';
@import './../common/abstracts/variable';

@include b(img-cropper) {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 1);

  // 裁剪框包裹器
  @include e(wrapper) {
    position: relative;
    background: rgba(0, 0, 0, 0.45);
  }

  @include e(cut) {
    position: absolute;
    z-index: 9;
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    pointer-events: none;

    .wd-img-cropper__cut--top,
    .wd-img-cropper__cut--bottom,
    .wd-img-cropper__cut--left,
    .wd-img-cropper__cut--right {
      // 拖动中背景蒙层为0 拖动结束为0.85
      background-color: rgba(0, 0, 0, 0.85);
      transition: background 0.2s;

      @include when(hightlight) {
        background-color: rgba(0, 0, 0, 0);
      }
    }

    .wd-img-cropper__cut--bottom,
    .wd-img-cropper__cut--right {
      flex: auto;
    }

    @include m(middle) {
      display: flex;
    }

    @include m(body) {
      position: relative;
      // 若需要变化窗体大小，支持控制窗体的大小来控制下方所有对应的展示
      background-color: transparent;

      // 节选框的窗体最外部边缘线
      &::before {
        position: absolute;
        top: -50%;
        left: -50%;
        width: calc(200% - 1px);
        height: calc(200% - 1px);
        content: '';
        border: 1px solid #fff;
        transform: scale(0.5) translate(-1px, -1px);
      }

      // 结算框对角尺寸
      $border-size: 2px;

      // 节选框的四个角
      .is-left-top,
      .is-left-bottom,
      .is-right-top,
      .is-right-bottom {
        &::before {
          position: absolute;
          width: $border-size;
          height: 20px;
          content: '';
          background-color: #fff;
        }

        &::after {
          position: absolute;
          width: 20px;
          height: $border-size;
          content: '';
          background-color: #fff;
        }
      }

      .is-left-top {
        &::before,
        &::after {
          top: -$border-size;
          left: -$border-size;
        }
      }

      .is-left-bottom {
        &::before,
        &::after {
          bottom: -$border-size;
          left: -$border-size;
        }
      }

      .is-right-top {
        &::before,
        &::after {
          top: -$border-size;
          right: -$border-size;
        }
      }

      .is-right-bottom {
        &::before,
        &::after {
          right: -$border-size;
          bottom: -$border-size;
        }
      }

      // 内部网格线
      .is-gridlines-x,
      .is-gridlines-y {
        position: absolute;
        top: 0;
        left: 0;
        display: flex;
        width: 100%;
        height: 100%;
      }

      .is-gridlines-x {
        justify-content: center;

        &::before {
          display: inline-block;
          width: 66.66%;
          height: 200%;
          content: '';
          border: 1px solid #fff;
          border-top: none;
          border-bottom: none;
          transform: scale(0.5) translate(0, -50%);
        }
      }

      // 内部网格线 - y轴
      .is-gridlines-y {
        align-items: center;

        &::after {
          display: inline-block;
          flex-shrink: 0;
          width: 200%;
          height: 66.66%;
          content: '';
          border: 1px solid #fff;
          border-right: none;
          border-left: none;
          transform: scale(0.5) translate(-50%, 0);
        }
      }
    }
  }

  @include e(img) {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    width: 100%;
    border: none;
    transform-origin: center;
    backface-visibility: hidden;
  }

  @include e(canvas) {
    position: fixed;
    top: -200%;
    z-index: 10;
    width: 150px;
    height: 150px;
    pointer-events: none;
    background: white;
  }

  @include e(footer) {
    position: fixed;
    bottom: 10px;
    z-index: 10;
    width: 100%;
    height: 15vh;
    text-align: center;

    @include m(button) {
      position: relative;
      // line-height: 32px;
      box-sizing: border-box;
      padding-top: 4vh;
      margin: 0 20px;
      text-align: left;

      .is-cancel {
        display: inline-block;
        font-size: 16px;
        color: #fff;
      }

      .is-confirm {
        position: absolute;
        right: 0;
        // height: 32px;
        width: 56px;
        font-size: 16px;
        border-radius: 16px;
      }
    }
  }

  @include edeep(rotate) {
    font-size: $-img-cropper-icon-size;
    color: $-img-cropper-icon-color;
  }
}
