@import './var.less';

:root {
  --van-label-font-size: @label-font-size;
  --van-label-line-height: @label-line-height;
  --van-label-mini-font-size: @label-mini-font-size;
  --van-label-mini-line-height: @label-mini-line-height;
  --van-label-label-color: @label-label-color;
  --van-label-value-color: @label-value-color;
  --van-label-bold-color: @label-bold-color;
  --van-label-link-color: @label-link-color;
  --van-label-same-color: @label-same-color;
  --van-label-gap: @label-gap;
  --van-label-left-icon-gap: @label-left-icon-gap;
  --van-label-tags-gap: @label-tags-gap;
  --van-label-media-gap: @label-media-gap;
  --van-label-media-size: @label-media-size;
  --van-label-mini-media-size: @label-mini-media-size;
  --van-label-media-radius: @label-media-radius;
  --van-label-location-color: @label-location-color;
  --van-label-location-font-size: @label-location-font-size;
  --van-label-location-line-height: @label-location-line-height;
  --van-label-location-icon-size: @label-location-icon-size;
  --van-label-location-gap: @label-location-gap;
  --van-label-ellipsis-label-max-width: @label-ellipsis-label-max-width;
}

.van-label {
  display: flex;
  align-items: flex-start;
  gap: var(--van-label-gap);
  color: var(--van-label-value-color);
  font-size: var(--van-label-font-size);
  line-height: var(--van-label-line-height);

  &--vertical {
    flex-direction: column;
  }

  &--content-right .van-label__value {
    text-align: right;
  }

  &--mini {
    --van-label-font-size: var(--van-label-mini-font-size);
    --van-label-line-height: var(--van-label-mini-line-height);
    --van-label-media-size: var(--van-label-mini-media-size);
  }

  &--ellipsis {
    .van-label__label {
      flex: 0 1 var(--van-label-ellipsis-label-max-width);
      max-width: var(--van-label-ellipsis-label-max-width);
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .van-label__value {
      overflow: hidden;
    }

    .van-label__text,
    .van-label__link {
      display: block;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }

  &__label {
    flex: none;
    color: var(--van-label-label-color);
    white-space: nowrap;
  }

  &__left-icon {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 12px;
    height: var(--van-label-line-height);
    // The parent uses `gap` for label/content. Add only the remaining space
    // here so the icon-to-label distance stays exactly 4px.
    margin-right: calc(var(--van-label-left-icon-gap) - var(--van-label-gap));
    color: var(--van-label-label-color);

    .van-icon {
      width: 12px;
      height: 12px;
      font-size: 12px;
      line-height: 12px;
    }
  }

  &__value {
    flex: 1;
    min-width: 0;
    color: inherit;
    overflow-wrap: anywhere;
  }

  &__text {
    display: block;
  }

  &--multiple-content .van-label__text {
    overflow-wrap: anywhere;
    white-space: normal;
  }

  &--location .van-label__value {
    display: flex;
    flex-direction: column;
    gap: var(--van-label-location-gap);
    width: 100%;
  }

  &--location .van-label__link {
    align-self: flex-start;
    text-align: left;
  }

  &__location {
    display: inline-flex;
    gap: var(--van-label-location-gap);
    align-items: center;
    width: fit-content;
    max-width: 100%;
    color: var(--van-label-location-color);
    font-size: var(--van-label-location-font-size);
    font-weight: normal;
    line-height: var(--van-label-location-line-height);
    overflow-wrap: anywhere;

    .van-icon {
      flex: none;
      font-size: var(--van-label-location-icon-size);
    }
  }

  &--bold .van-label__value {
    color: var(--van-label-bold-color);
    font-weight: var(--van-font-weight-bold);
  }

  &--same-color {
    .van-label__left-icon,
    .van-label__label,
    .van-label__value,
    .van-label__link {
      color: var(--van-label-same-color);
    }
  }

  &__link {
    display: inline;
    padding: 0;
    color: var(--van-label-link-color);
    font: inherit;
    font-weight: var(--van-font-weight-bold);
    text-decoration: none;
    background: transparent;
    border: 0;
    cursor: pointer;
    transition: opacity var(--van-animation-duration-fast);

    &:active {
      opacity: var(--van-active-opacity);
    }
  }

  &__tags,
  &__media {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
  }

  &__tags {
    gap: var(--van-label-tags-gap);
    min-height: var(--van-label-line-height);
    align-items: center;
  }

  &__media {
    gap: var(--van-label-media-gap);
    width: 100%;
  }

  &__media-item {
    position: relative;
    flex: none;
    width: var(--van-label-media-size);
    height: var(--van-label-media-size);
    padding: 0;
    overflow: hidden;
    background: transparent;
    border: 0;
    border-radius: var(--van-label-media-radius);
    cursor: pointer;
    transition: opacity var(--van-animation-duration-fast);

    &:active {
      opacity: var(--van-active-opacity);
    }
  }

  &__media-item .van-image {
    display: block;
    width: 100%;
    height: 100%;
  }

  &__play {
    position: absolute;
    top: 50%;
    left: 50%;
    color: var(--van-white);
    font-size: 24px;
    transform: translate(-50%, -50%);
    text-shadow: 0 1px 2px rgb(0 0 0 / 45%);
  }
}
