@import url(../var.less);

@image-prefix: ~"@{prefix}image";
@image-viewer-prefix: ~"@{prefix}image-viewer";

.size {
  width: 100%;
  height: 100%;
}

.@{image-prefix}{
  position: relative;
  display: inline-block;
  overflow: hidden;
  background-color: @image-background-color;

  &__inner {
    &:extend(.size);
    vertical-align: top;

    &--center {
      position: relative;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      display: block;
    }
  }

  &__placeholder {
    &:extend(.size);
    display: flex;
    align-items: center;
    justify-content: center;
    background: @image-background-color;
    color: @placeholder-text-color;
    .w-icon {
      font-size: 20px;
    }
  }

  &__error {
    &:extend(.size);
    padding: 10px;
    display: flex;
    font-size: 14px;
    background: @image-background-color;
    color: @placeholder-text-color;
    vertical-align: middle;
    .w-icon {
      font-size: 20px;
    }
  }

  &__preview {
    cursor: pointer;
  }

  &:hover .@{image-prefix}__mask{
    opacity: 1;
  }

  &__mask {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: rgba(0,0,0,.5);
    cursor: pointer;
    opacity: 0;
    transition: opacity .3s;
    
    &--icon {
      font-size: 24px;
    }
  }
}

.@{image-viewer-prefix}{
  &__wrapper {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
  }

  &__btn {
    position: absolute;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    opacity: .8;
    cursor: pointer;
    box-sizing: border-box;
    user-select: none;
  }

  &__close {
    top: 40px;
    right: 40px;
    width: 40px;
    height: 40px;
    font-size: 24px;
    color: #fff;
    background-color: #606266;
  }

  &__canvas {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  &__actions {
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%);
    width: 282px;
    height: 44px;
    padding: 0 23px;
    background-color: #606266;
    border-color: #fff;
    border-radius: 22px;

    &__inner {
      width: 100%;
      height: 100%;
      text-align: justify;
      cursor: default;
      font-size: 23px;
      color: #fff;
      display: flex;
      align-items: center;
      justify-content: space-around;
    }
  }

  &__prev {
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    font-size: 24px;
    color: #fff;
    background-color: #606266;
    border-color: #fff;
    left: 40px;
  }

  &__next {
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    font-size: 24px;
    color: #fff;
    background-color: #606266;
    border-color: #fff;
    right: 40px;
    text-indent: 2px;
  }

  &__mask {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: .5;
    background: #000;
  }

}

.viewer-fade-enter-active {
  animation: viewer-fade-in .3s;
}

.viewer-fade-leave-active {
  animation: viewer-fade-out .3s;
}

@keyframes viewer-fade-in {
  0% {
    transform: translate3d(0, -20px, 0);
    opacity: 0;
  }
  100% {
    transform: translate3d(0, 0, 0);
    opacity: 1;
  }
}

@keyframes viewer-fade-out {
  0% {
    transform: translate3d(0, 0, 0);
    opacity: 1;
  }
  100% {
    transform: translate3d(0, -20px, 0);
    opacity: 0;
  }
}