@import './token.less';
@import './images.less';

.@{ns}-Images {
  display: flex;
  flex-wrap: wrap;
  margin: calc(@spacing-2 * -1);

  &-item {
    display: flex;
    margin: @spacing-2;
  }
}

@keyframes disappear {
  to {
    opacity: 0;
  }
}

@keyframes appear {
  from {
    opacity: 0;
  }
}

.@{ns}-ImageGallery {
  display: flex;
  flex-direction: column;
  background: transparent;
  border: none;
  border-radius: 0;
  max-width: 1010px !important;
  overflow: visible !important;
  .@{ns}-Modal-content {
    display: flex;
    flex-direction: column;
    overflow: visible;
  }

  &-close {
    position: absolute;
    right: -30px;
    top: 0;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;

    &:hover {
      color: #fff;
    }

    > svg {
      width: 16px;
      height: 16px;
    }
  }

  &-title {
    height: 30px;
    vertical-align: top;
    line-height: 30px;
    font-size: 12px;
    color: var(--color-white);
    text-align: center;
  }

  &-main {
    background: #000;
    flex-basis: 0;
    flex-grow: 1;
    flex: 1;
    overflow: hidden;
    position: relative;
    display: flex;
    user-select: none;
    &-img {
      height: 100%;
      width: 100%;
      overflow: auto;
      display: flex;
      justify-content: center;
      align-items: center;
      > img {
        display: block;
        margin: auto;
        max-width: 100%;
        max-height: 100%;
        transition: transform @animation-duration-3;
        transform-origin: center center;
      }
    }
  }

  &-prevBtn,
  &-nextBtn {
    > svg {
      width: 48px;
      height: 48px;
    }

    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #999;
    text-shadow: rgba(0, 0, 0, 0.3) 0px 0px 4px;

    &:hover {
      color: #fff;
      text-shadow: rgba(0, 0, 0, 0.5) 0px 0px 4px;
    }
    animation-name: disappear;
    animation-delay: @animation-duration-3;
    animation-duration: @animation-duration-3;
    animation-fill-mode: both;

    &.is-disabled {
      pointer-events: none;
    }
  }

  &-main:hover &-prevBtn,
  &-main:hover &-nextBtn {
    animation-name: appear;
    animation-delay: 0s;
    animation-duration: @animation-duration-3;
  }

  &-prevBtn {
    left: @spacing-2;
  }

  &-nextBtn {
    right: @spacing-2;
  }

  &-footer {
    height: 74px;
    background: #222;
    display: flex;
    flex-direction: row;
    user-select: none;
  }

  &-prevList,
  &-nextList {
    width: @spacing-2;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;

    background: rgba(0, 0, 0, 0.3);
    color: #fff;

    &.is-disabled {
      background: rgba(0, 0, 0, 0.3);
      color: rgba(255, 255, 255, 0.1);
      pointer-events: none;
    }

    &:hover {
      background: rgba(0, 0, 0, 1);
      color: #fff;
    }
  }

  &-itemsWrap {
    flex-grow: 1;
    flex-basis: 0;
    width: 0;
    overflow: hidden;
    align-items: center;
    justify-content: center;
    display: flex;
  }

  &-items {
    display: inline-block;
    white-space: nowrap;
  }

  &-item {
    margin: 10px 5px;
    width: 54px;
    height: 54px;
    display: inline-flex;
    position: relative;
    border: 1px solid #666;
    justify-content: center;
    align-items: center;
    cursor: pointer;

    > img {
      display: block;
      max-width: 100%;
      max-height: 100%;
    }

    @supports (object-fit: cover) {
      > img {
        width: 100%;
        height: 100%;
        object-fit: cover;
      }
    }

    &:after {
      position: absolute;
      content: '';
      display: block;
      background: rgba(0, 0, 0, 0.5);
      z-index: 1;
      left: 0;
      top: 0;
      width: 100%;
      height: 100%;
    }

    &:hover {
      border: 1px solid #e5e5e5;
      &:after {
        display: none;
      }
    }

    &.is-active {
      border: 1px solid #108cee;
      &:after {
        display: none;
      }
    }
  }

  // 工具
  &-toolbar {
    background-color: var(--color-bg-white);
    border-radius: 4px;
    display: flex;
    align-items: flex-start;
    padding: 4px 16px;
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-flow: row nowrap;
    justify-content: space-between;
    align-items: center;

    &-action {
      padding: 13px;
      border-radius: 4px;
      width: 40px;
      height: 40px;
      cursor: pointer;
      display: flex;
      justify-content: center;
      align-items: center;

      &-icon {
        display: block;
        color: var(--color-text-1);

        & > svg {
          fill: var(--color-text-1);
        }
      }

      &.is-disabled {
        cursor: not-allowed;
        color: var(--color-text-3);

        .@{ns}-ImageGallery-toolbar-action-icon {
          color: var(--color-text-3);

          & > svg {
            color: var(--color-text-3);
          }
        }
      }

      &:hover {
        background-color: #f2f3f5;

        .@{ns}-ImageGallery-toolbar-action-icon {
          color: var(--primary);

          & > svg {
            fill: var(--primary);
          }
        }
      }
    }
  }
}
