@import '../../styles/basis.less';
@import '../../styles/mixin.less';

.yk-image {
  position: relative;
  display: inline-block;
  border-radius: @radius-s;
  line-height: 1;

  &__with-loading &__img,
  &__with-error &__img {
    visibility: hidden;
  }

  &__img {
    border-radius: inherit;
    vertical-align: middle;
  }

  &__overlay-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
  }

  &__overlay--error {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    box-sizing: border-box;

    width: 100%;
    height: 100%;
    gap: @space-s;
    color: @font-color-ss;
    background-color: @bg-color-s;

    & .icon {
      width: 50px;
      max-width: 100%;
      height: 50px;
      max-height: 100%;
    }

    & .icon svg {
      width: 100%;
      height: 100%;
    }

    & .alt {
      font-size: @size-s;
    }
  }

  &__overlay--loading {
    width: 100%;
    height: 100%;
    background: linear-gradient(
        100deg,
        rgba(255, 255, 255, 0) 40%,
        rgba(255, 255, 255, 0.5) 50%,
        rgba(255, 255, 255, 0) 60%
      )
      @bg-color-s;
    background-size: 400% 100%;
    animation: shimmer 1.5s ease infinite;
  }

  &__footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;

    padding: 6px 12px 12px;
    line-height: @size-m;
    width: 100%;

    & .title {
      margin-bottom: @space-s;
      font-size: @size-m;
    }

    & .description {
      font-size: @size-s;
    }

    &--inner {
      position: absolute;
      bottom: 0;
      color: @white;
    }

    &--outer .description {
      color: rgb(134, 144, 156);
    }
  }
}

@keyframes shimmer {
  0% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0 50%;
  }
}

// 预览组件样式（全量/按需样式入口都会经过 index.less，避免遗漏）
@import './preview.less';
