/**
 * @date: 2024/2/19
 * @author: 小红
 * @fileName: components
 * @Description:小组件
 */

@use "../core/util";

//文章列表
@mixin essayList() {
  .essay {
    .item {
      @include util.flex-center;
      overflow: hidden;

      > .cover {
        position: relative;
        overflow: hidden;

        &.top:before {
          content: '置顶';
          position: absolute;
          left: 0;
          background: linear-gradient(135deg, #fd7a64 10%, #fb2d2d 100%);
          color: #fff;
          top: 20px;
          font-size: .8em;
          z-index: 50;
          padding: 0 7px;
          line-height: 2;
          border-radius: 0 50px 50px 0;
        }


        > .img {
          @include util.wh100;
          object-fit: cover;

          &[data-ll-status=loaded]:hover {
            transform: scale(1.1);
          }
        }
      }

      > .info {

        > .data {
          margin: 6px 0;

          > .row {
            @include util.text-overflow;
          }

          .wp {
            &:not(:last-child):after {
              content: "|";
              margin: 0 4px 0 2px;
              font-weight: bold;
            }

            .link:not(:last-child):after {
              content: "•";
              font-weight: bold;
              margin: 0 5px;
            }
          }
        }

      }
    }

    &.list {
      > .item {
        height: 16rem;
        position: relative;

        &:not(:first-child) {
          margin-top: 18px;
        }

        > .cover {
          width: 40%;
          height: 100%;

          @include util.useResponsive($width: util.$w-md,) {
            width: 100%;
            height: 200px;
          }
        }

        > .info {
          width: 60%;
          padding: 0 40px;

          > .title {
            font-size: 1.6rem;
            line-height: 1.4;
            @include util.text-clamp(2);

            @include util.useResponsive($width: util.$w-md) {
              font-size: 1.3rem;
            }
          }

          > .data {
            font-size: 90%;
            @include util.useResponsive($width: util.$w-md) {
              font-size: 88%;
            }
          }

          > .excerpt {
            line-height: 1.8;
            @include util.text-clamp(2);

            @include util.useResponsive($width: util.$w-md) {
              @include util.text-clamp(1);
            }
          }

          @include util.useResponsive($width: util.$w-md) {
            padding: 20px 20px 30px;
            width: 100%;
          }
        }

        @include util.useResponsive($width: util.$w-md) {
          flex-direction: column;
          height: auto;
        }
      }
    }

    &.tile {
      display: grid;
      grid-template-columns: repeat(3, 1fr); /* 创建3列 */
      grid-auto-rows: minmax(100px, auto); /* 自动调整行高 */
      gap: 20px; /* 网格项之间的间隔 */

      > .item {
        height: 20rem;
        flex-direction: column;

        > .cover {
          width: 100%;
          height: 65%;
        }

        > .info {
          width: 100%;
          padding: 20px 30px 15px;
          height: 35%;


          > .title {
            font-size: 1.2rem;
            line-height: 1.2;
            @include util.text-clamp(1);
          }

          > .data {
            font-size: 80%;
          }
        }
      }


      @include util.useResponsive($width: 1200px) {
        grid-template-columns: repeat(2, 1fr); /* 创建2列 */
      }

      @include util.useResponsive($width: util.$w-md, $level: '#&') {
        grid-template-columns: repeat(1, 1fr); /* 创建1列 */
      }
    }
  }
}

// 页码  分页
@mixin pagination {
  .pagination {
    margin-top: 20px;
    @include util.flex-center;

    > .page, .next, .prev {
      display: block;
      border-radius: 8px;
      box-shadow: var(--card-box-shadow);
      background-color: var(--card-background-color);
      margin: 0 6px;
      width: 35px;
      height: 35px;
      text-align: center;
      line-height: 35px;
      transition: .3s;

      &:hover {
        background-color: var(--theme);
        color: #fff;
      }
    }

    > .current {
      background-color: var(--theme);
      color: #fff;
    }

  }
}

