/**
 * =============================================================================
 * ************   Grid 网格系统   ************
 * 来自：https://raw.githubusercontent.com/zdhxiong/pp/v1/src/styles/grid.less
 * =============================================================================
 */

@_screen-col-1: 8.333333%;
@_screen-col-2: 16.666667%;
@_screen-col-3: 25%;
@_screen-col-4: 33.333333%;
@_screen-col-5: 41.666667%;
@_screen-col-6: 50%;
@_screen-col-7: 58.333333%;
@_screen-col-8: 66.666667%;
@_screen-col-9: 75%;
@_screen-col-10: 83.333333%;
@_screen-col-11: 91.666667%;
@_screen-col-12: 100%;

// 等分列
@_screen-average-1: 100%;
@_screen-average-2: 50%;
@_screen-average-3: 33.333333%;
@_screen-average-4: 25%;
@_screen-average-5: 20%;
@_screen-average-6: 16.666667%;
@_screen-average-7: 14.285714%;
@_screen-average-8: 12.5%;
@_screen-average-9: 11.111111%;
@_screen-average-10: 10%;
@_screen-average-11: 9.090909%;
@_screen-average-12: 8.333333%;

//间隔
@grid-gap-8: 8px;
@grid-gap-16: 16px;
@grid-gap-24: 24px;
@grid-gap-40: 40px;

// 生成列、列偏移
._grid_col_loop(@cols, @screen) when (@cols > 0) {
  ._grid_col_loop((@cols - 1), @screen);

  @widthName: '_screen-col-@{cols}';

  // 列宽度
  .pp-col-@{screen}-@{cols} {
    float: left;
    width: @@widthName;
  }

  // 列偏移
  .pp-col-offset-@{screen}-@{cols} {
    margin-left: @@widthName;
  }

  // 等分列
  @averageName: '_screen-average-@{cols}';
  .pp-row-@{screen}-@{cols} .pp-col {
    float: left;
    width: @@averageName;
  }
}

.pp-container,
.pp-container-fluid {
  box-sizing: border-box;
  margin-right: auto;
  margin-left: auto;
  padding-right: @grid-gap-16 / 2;
  padding-left: @grid-gap-16 / 2;

  &::after {
    display: table;
    clear: both;
    content: '';
  }
}

.pp-container {
  width: 96%;
  max-width: 1280px;
  @media (min-width: @screen-sm-min) {
    width: 94%;
  }
  @media (min-width: @screen-md-min) {
    width: 92%;
  }
}

.pp-row,
[class*="pp-row-"] {
  margin-right: -@grid-gap-16 / 2;
  margin-left: -@grid-gap-16 / 2;

  &::after {
    display: table;
    clear: both;
    content: '';
  }
}

[class*="pp-col-xs-"],
[class*="pp-col-sm-"],
[class*="pp-col-md-"],
[class*="pp-col-lg-"],
[class*="pp-col-xl-"],
.pp-col {
  position: relative;
  box-sizing: border-box;
  min-height: 1px;
  padding-right: @grid-gap-16 / 2;
  padding-left: @grid-gap-16 / 2;
}

/* 取消列间距 */
.pp-row-gapless {
  .pp-col,
  [class*="pp-col-xs-"],
  [class*="pp-col-sm-"],
  [class*="pp-col-md-"],
  [class*="pp-col-lg-"],
  [class*="pp-col-xl-"] {
    padding-right: 0;
    padding-left: 0;
  }

  // 嵌套元素的内补
  .pp-row,
  [class*="pp-row-"] {
    margin-right: 0;
    margin-left: 0;
  }
}

._grid_col_loop(12, ~"xs");

@media (min-width: @screen-sm-min) {
  ._grid_col_loop(12, ~"sm");
}

@media (min-width: @screen-md-min) {
  ._grid_col_loop(12, ~"md");
}

@media (min-width: @screen-lg-min) {
  ._grid_col_loop(12, ~"lg");
}

@media (min-width: @screen-xl-min) {
  ._grid_col_loop(12, ~"xl");
}