@use 'papa-ui-theme/src/mixins.scss' as *;
:root {
  --pp-icon-inner-padding: 10px;
  --pp-icon-model-type: 1;
  --pp-model-type: 1;
}

$padding: var(--pp-icon-inner-padding);
$model: var(--pp-icon-model-type);
$types: var(--pp-model-type);

@mixin lastChild($types) {
  &:last-child {
    position: absolute;
    @content;

    .more {
      position: absolute;
      width: 100%;
      height: 100%;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      color: #fff;
      font-weight: bold;
      font-size: 26px;
      z-index: 10;
      background-color: rgba($color: #222222, $alpha: 0.4);
    }
  }
}

@mixin modelThree($type) {
  .item-image {
    width: 50%;
    height: 50%;
    box-sizing: border-box;

    @if $type==1 {
      &:first-child {
        // float: left;
        height: 100%;
        padding-right: $padding;
      }
      &:nth-child(2) {
        position: absolute;
        top: 0;
        right: 0;
      }
      @include lastChild($types) {
        bottom: 0;
        right: 0;
        padding-top: $padding;
      }
    } @else if $type==2 {
      &:first-child {
        width: 100%;
        padding-bottom: $padding;
      }
      &:nth-child(2) {
        float: left;
        padding-right: $padding;
      }
      @include lastChild($types) {
        bottom: 0;
        right: 0;
      }
    } @else if $type==3 {
      &:first-child {
        padding-bottom: $padding;
      }
      @include lastChild($types) {
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        height: 100%;
        padding-left: $padding;
      }
    } @else if $type==4 {
      &:first-child {
        float: left;
        padding-right: $padding;
      }

      @include lastChild($types) {
        width: 100%;
        padding-top: $padding;
      }
    }
  }
}

@mixin modelFour($type) {
  .item-image {
    width: 50%;
    height: 50%;
    box-sizing: border-box;
    @if $type==1 {
      &:first-child {
        padding-bottom: $padding;
      }
      &:nth-child(2) {
        position: absolute;
        top: 0;
        right: 0;
        padding-bottom: $padding;
      }
      &:nth-child(2n + 1) {
        padding-right: calc($padding/2);
      }
      &:nth-child(2n) {
        padding-left: calc($padding/2);
      }

      @include lastChild($types) {
        bottom: 0;
        right: 0;
      }
    } @else if $type==2 {
      flex: 1;
      width: calc((100% - ($padding)) / 3);
      box-sizing: content-box;
      &:nth-child(2) {
        padding: 0 $padding;
      }
      @include lastChild($types) {
        bottom: 0;
        width: 100%;
        padding-top: $padding;
        box-sizing: border-box;
      }
    } @else if $type==3 {
      flex: 1;
      height: calc((100% - ($padding * 2)) / 3);
      &:nth-child(2) {
        padding: $padding 0;
        box-sizing: content-box;
      }
      @include lastChild($types) {
        top: 0;
        right: 0;
        height: 100%;
        padding-left: $padding;
      }
    }
  }
}

@mixin modelFive($type) {
  .item-image {
    width: 50%;
    height: 50%;

    @if $type==1 {
      box-sizing: border-box;

      &:first-child {
        float: left;
        padding-right: calc($padding/2);
        padding-bottom: $padding;
      }
      &:nth-child(2) {
        float: right;
        padding-left: calc($padding/2);
        padding-bottom: $padding;
      }
      &:nth-child(n + 3) {
        width: calc((100% - ($padding * 2)) / 3);
        box-sizing: content-box;
        float: left;
      }
      &:nth-child(4) {
        padding: 0 $padding;
      }
    } @else if $type==2 {
      width: calc((100% - ($padding)) / 3);
      box-sizing: border-box;

      &:first-child {
        float: left;
        padding: 0 calc($padding/2) calc($padding/2) 0;
      }
      &:nth-child(2) {
        float: left;
        padding: 0 0 calc($padding/2) calc($padding/2);
      }
      &:nth-child(3) {
        float: left;
        clear: both;
        padding: calc($padding/2) calc($padding/2) 0 0;
      }
      &:nth-child(4) {
        float: left;
        padding: calc($padding/2) 0 0 calc($padding/2);
      }
      @include lastChild($types) {
        position: absolute;
        right: 0;
        top: 0;
        height: 100%;
      }
    } @else if $type==3 {
      box-sizing: border-box;
      position: absolute;
      &:first-child {
        left: 0;
        top: 0;
        width: 66%;
        height: 34%;
        padding-right: $padding;
        padding-bottom: $padding;
      }

      &:nth-child(2) {
        right: 0;
        top: 0;
        width: 34%;
        height: 66%;
        padding-left: $padding;
        padding-bottom: $padding;
      }

      &:nth-child(3) {
        bottom: 0;
        left: 0;
        height: 66%;
        width: 34%;
        padding-right: $padding;
        padding-top: $padding;
      }

      &:nth-child(4) {
        top: 50%;
        left: 50%;
        width: 32%;
        height: 32%;
        transform: translate(-50%, -50%);
        padding: $padding;
      }

      @include lastChild($types) {
        right: 0;
        bottom: 0;
        width: 66%;
        height: 34%;
        padding-top: $padding;
        padding-left: $padding;
      }
    }
  }
}

$width: calc(100% / 3);
@mixin modelSix($type) {
  .item-image {
    width: $width;
    height: $width;
    @if $type==1 {
      &:first-child {
        width: calc($width * 2);
        height: calc($width * 2);
        float: left;
        padding-right: $padding;
        box-sizing: border-box;
      }

      &:nth-child(2),
      &:nth-child(3) {
        float: left;
        box-sizing: border-box;
      }
      &:nth-child(2){
        padding-bottom: $padding;
      }

      &:nth-child(n + 4) {
        width: $width;
        padding-top: $padding;
        padding-right: $padding;
        float: left;
        box-sizing: border-box;
      }
      @include lastChild($types) {
        bottom: 0;
        right: 0;
        padding-right: 0;
      }
    } @else {
      float: left;
      padding-right: $padding;
      box-sizing: border-box;

      &:nth-child(3) {
        padding: 0;
      }

      @if $type==2 {
        &:nth-child(4),
        &:nth-child(5) {
          clear: both;
          padding-top: $padding;
          padding-right: $padding;
        }

        @include lastChild($types) {
          position: absolute;
          right: 0;
          bottom: 0;
          width: calc($width * 2);
          height: calc($width * 2);
          padding-top: $padding;
          padding-right: 0;
        }
      } @else if $type==3 {
        &:nth-child(4) {
          height: calc($width * 2);
          float: left;
          padding-top: $padding;
          padding-right: $padding;
        }

        &:nth-child(5),
        &:nth-child(6) {
          width: calc($width * 2);
          padding-top: $padding;
          padding-right: 0;
        }
        @include lastChild($types) {
          bottom: 0;
          right: 0;
        }
      }
    }
  }
}

.papa-ui-images {
  width: auto;
  // height: 375px;
  margin-top: $padding;

  &:first-child {
    margin-top: 0;
  }

  &.pp-image-1 {
    // width: auto !important;
    // height: auto !important;
    .item-image {
      width: 100%;
      height:100%;
      @include lastChild($types) {
        position: static;
      }
    }
  }

  &.pp-image-2 {
    display: flex;
    align-items: center;
    position: relative;

    .item-image {
      width: 50%;
      height: 100%;
      box-sizing: border-box;

      &:first-child {
        padding-right: $padding;
      }

      @include lastChild($types) {
        top: 0;
        right: 0;
        padding-left: $padding;
      }
    }
  }

  &.pp-image-3 {
    @for $i from 1 through 4 {
      &-#{$i} {
        position: relative;
        @include modelThree($i);
      }
    }
  }

  &.pp-image-4 {
    @for $i from 1 through 3 {
      &-#{$i} {
        @if $i==2 {
          display: flex;
        }
        position: relative;
        @include modelFour($i);
      }
    }
  }

  &.pp-image-5 {
    @for $i from 1 through 3 {
      &-#{$i} {
        position: relative;
        @include modelFive($i);
      }
    }
  }

  &.pp-image-6 {
    @for $i from 1 through 3 {
      &-#{$i} {
        position: relative;
        @include modelSix($i);
      }
    }
  }
}
