/* 0.5px边框 mixin（解决移动端 1px 边框在高清屏下显示过粗的问题） */

/*
0.5px 四边框 mixin
@param {Color} $borderColor - 边框颜色，默认值为 $color-border-tertiary
@param {Length} $borderRadius - 边框圆角，默认值为 0

@example
.element::after {
  @include halfBorder();
}

@example 带圆角
.element::after {
  @include halfBorder($borderColor: #ccc, $borderRadius: .16rem);
}
*/
@mixin halfBorder($borderColor: $color-border-tertiary, $borderRadius: 0) {
  position: absolute;
  left: 50%;
  top: 50%;
  content: '';
  width: 200%;
  height: 200%;
  border: 1px solid $borderColor;
  border-radius: calc($borderRadius * 2); // 因为缩放0.5，所以圆角需要*2
  transform: translate(-50%, -50%) scale(.5);
  transform-origin: center;
  pointer-events: none;
  z-index: 33;
}

/*
0.5px 单条边框 mixin
@param {Color} $borderColor - 边框颜色，默认值为 $color-border-tertiary
@param {String} $position - 边框位置，可选值：top, right, bottom, left

@example 底边框
.element::after {
  @include halfBorderLine($position: bottom);
}

@example 顶边框
.element::after {
  @include halfBorderLine($borderColor: #ccc, $position: top);
}
*/
@mixin halfBorderLine($borderColor: $color-border-tertiary, $position: bottom) {
  position: absolute;
  content: '';
  pointer-events: none;
  background-color: $borderColor;

  @if $position == top {
    left: 0;
    top: 0;
    width: 100%;
    height: 1px;
    transform: scaleY(.5);
    transform-origin: 0 0;
  } @else if $position == bottom {
    left: 0;
    bottom: 0;
    width: 100%;
    height: 1px;
    transform: scaleY(.5);
    transform-origin: 0 100%;
  } @else if $position == left {
    left: 0;
    top: 0;
    width: 1px;
    height: 100%;
    transform: scaleX(.5);
    transform-origin: 0 0;
  } @else if $position == right {
    right: 0;
    top: 0;
    width: 1px;
    height: 100%;
    transform: scaleX(.5);
    transform-origin: 100% 0;
  }
}
