@import "./abstracts/variable";
@import "./abstracts/mixin";

@include b(grid-item) {
  height: 100%;
  font-size: $-grid-item-fs;
  box-sizing: border-box;
  background-color: $-grid-item-bg;

  position: relative;
  float: left;

  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  overflow: hidden;

  @include when(border) {
    &::before {
      content: "";
      position: absolute;
      width: 100%;
      height: 1px;
      transform: scaleY(0.5);
      background-color: $-grid-item-border-color;
      top: 0;
      left: 0;
      z-index: 100;
    }
    &::after {
      content: "";
      position: absolute;
      width: 1px;
      transform: scaleX(0.5);
      height: 100%;
      background-color: $-grid-item-border-color;
      bottom: 0;
      right: 0;
      z-index: 100;
    }
  }

  // 第一行元素
  @include when(first-line) {
    &::after {
      content: "";
      position: absolute;
      width: 1px;
      transform: scaleX(0.5);
      height: 100%;
      background-color: $-grid-item-border-color;
      bottom: 0;
      right: 0;
      z-index: 100;
    }
  }

  // 每行右侧的元素
  @include when(right) {
    &::after {
      display: none;
    }
  }

  &:last-child {
    &::after {
      display: none;
    }
  }

  @include e(content) {
    height: 100%;
    background-color: $-grid-item-bg;
    padding: $-grid-item-padding;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;

    @include when(square) {
      box-sizing: border-box;
      position: absolute;
      top: 0;
      right: 0;
      left: 0;
      padding: 0;
      height: auto;
    }

    @include when(round) {
      &::after {
        content: " ";
        position: absolute;
        top: 0;
        left: 0;
        width: 200%;
        height: 200%;
        border: 1px solid $-grid-item-border-color;
        transform-origin: top left;
        transform: scale(0.5);
        box-sizing: border-box;
      }
    }
  }

  @include e(text) {
    margin-top: 8px;
    font-size: $-grid-item-fs;
    line-height: $-grid-item-fs;
    @include lineEllipsis;
  }
}
