.maha-medias {
  width: 100%;
}
.maha-media {
  max-width: 325px;
  margin: ~"0.4em calc(0.2em - 1px)";
  width: 100%;
  border: 1px solid fadeout(@black, 90);
  background-color: @white;
  border-radius: 0.5em;
  overflow: hidden;
  display: block;
  cursor: pointer;
  .maha-media-label {
    text-align: center;
    padding: 0.8em;
    color: fadeout(@black, 20);
    font-size: 1em;
    font-weight: bold;
    line-height: 1.6em;
  }
}
.maha-files-file {
  float: left;
  width: 100%;
  max-width: 330px;
}
.maha-gallery {
  overflow: hidden;
  max-width: 330px;
  width: 100%;
  background-color: fadeout(@black, 90);
  border-radius: 0.5em;
  padding: 0.2em;
}
.maha-gallery-photo {
  cursor: pointer;
  float: left;
  padding: 0.2em;
  position: relative;
  .maha-gallery-photo-source {
    position: absolute;
    bottom: 0.5em;
    right: 0.5em;
    width: 12px;
    height: 12px;
  }
  .maha-image {
    overflow: hidden;
    background-color: fadeout(@black, 90);
    padding-bottom: 100%;
    height: 0;
    img {
      width: 100%;
      display: block;
      &:hover {
        .opacity(0.9);
      }
    }
  }
}
.maha-gallery-1 {
  .maha-gallery-photo {
    width: 100%;
    .maha-image {
      border-radius: 0.5em;
    }
  }
}
.maha-gallery-2 {
  .maha-gallery-photo {
    width: ~"calc(100% / 2)";
    &:nth-child(1) .maha-image {
      border-radius: 0.5em 0 0 0.5em;
    }
    &:nth-child(2) .maha-image {
      border-radius: 0 0.5em 0.5em 0;
    }
  }
}
.maha-gallery-3 {
  .maha-gallery-photo {
    &:nth-child(1) .maha-image {
      border-radius: 0.5em 0 0 0.5em;
    }
    &:nth-child(2) .maha-image {
      border-radius: 0 0.5em 0 0;
    }
    &:nth-child(3) .maha-image {
      border-radius: 0 0 0.5em 0;
    }
    &:nth-child(3n + 1) {
      width: ~"calc(100% / 3 * 2)";
    }
    &:nth-child(3n + 2),
    &:nth-child(3n + 3) {
      width: ~"calc(100% / 3)";
    }
  }
}
.maha-gallery-4 {
  .maha-gallery-photo {
    width: ~"calc(100% / 2)";
    &:nth-child(1) .maha-image {
      border-radius: 0.5em 0 0 0;
    }
    &:nth-child(2) .maha-image {
      border-radius: 0 0.5em 0 0;
    }
    &:nth-child(4) .maha-image {
      border-radius: 0 0 0.5em 0;
    }
    &:nth-child(3) .maha-image {
      border-radius: 0 0 0 0.5em;
    }
  }
}

.maha-gallery-5 {
  .maha-gallery-photo {
    &:nth-child(1) .maha-image {
      border-radius: 0.5em 0 0 0;
    }
    &:nth-child(2) .maha-image {
      border-radius: 0 0.5em 0 0;
    }
    &:nth-child(5) .maha-image {
      border-radius: 0 0 0.5em 0;
    }
    &:nth-child(4) .maha-image {
      border-radius: 0 0 0 0.5em;
    }
    &:nth-child(5n + 2),
    &:nth-child(5n + 3) {
      width: ~"calc(100% / 3)";
    }
    &:nth-child(5n + 4),
    &:nth-child(5n + 5) {
      width: ~"calc(100% / 2)";
    }
    &:nth-child(5n + 1) {
      width: ~"calc(100% / 3 * 2)";
    }
  }
}
.maha-gallery-6 {
  .maha-gallery-photo {
    &:nth-child(1) .maha-image {
      border-radius: 0.5em 0 0 0;
    }
    &:nth-child(2) .maha-image {
      border-radius: 0 0.5em 0 0;
    }
    &:nth-child(4) .maha-image {
      border-radius: 0 0 0.5em 0;
    }
    &:nth-child(6) .maha-image {
      border-radius: 0 0 0 0.5em;
    }
    &:nth-child(6n + 4) {
      float: right;
    }
    &:nth-child(6n + 1),
    &:nth-child(6n + 4) {
      width: ~"calc(100% / 3 * 2)";
    }
    &:nth-child(6n + 2),
    &:nth-child(6n + 3),
    &:nth-child(6n + 5),
    &:nth-child(6n + 6) {
      width: ~"calc(100% / 3)";
    }
  }
}
.maha-gallery-7 {
  .maha-gallery-photo {
    &:nth-child(1) .maha-image {
      border-radius: 0.5em 0 0 0;
    }
    &:nth-child(2) .maha-image {
      border-radius: 0 0.5em 0 0;
    }
    &:nth-child(7) .maha-image {
      border-radius: 0 0 0.5em 0;
    }
    &:nth-child(6) .maha-image {
      border-radius: 0 0 0 0.5em;
    }
    &:nth-child(7n + 1) {
      width: ~"calc(100% / 3 * 2)";
    }
    &:nth-child(7n + 2),
    &:nth-child(7n + 3) {
      width: ~"calc(100% / 3)";
    }
    &:nth-child(7n + 4),
    &:nth-child(7n + 5),
    &:nth-child(7n + 6),
    &:nth-child(7n + 7) {
      width: ~"calc(100% / 2)";
    }
  }
}
.maha-gallery-8 {
  .maha-gallery-photo {
    &:nth-child(1) .maha-image {
      border-radius: 0.5em 0 0 0;
    }
    &:nth-child(2) .maha-image {
      border-radius: 0 0.5em 0 0;
    }
    &:nth-child(6) .maha-image {
      border-radius: 0 0 0.5em 0;
    }
    &:nth-child(8) .maha-image {
      border-radius: 0 0 0 0.5em;
    }
    &:nth-child(8n + 6) {
      float: right;
    }
    &:nth-child(8n + 1),
    &:nth-child(8n + 6) {
      width: ~"calc(100% / 3 * 2)";
    }
    &:nth-child(8n + 2),
    &:nth-child(8n + 3),
    &:nth-child(8n + 7),
    &:nth-child(8n + 8) {
      width: ~"calc(100% / 3)";
    }
    &:nth-child(7n + 4),
    &:nth-child(7n + 5) {
      width: ~"calc(100% / 2)";
    }
  }
}
.maha-gallery-9 {
  .maha-gallery-photo {
    &:nth-child(1) .maha-image {
      border-radius: 0.5em 0 0 0;
    }
    &:nth-child(2) .maha-image {
      border-radius: 0 0.5em 0 0;
    }
    &:nth-child(9) .maha-image {
      border-radius: 0 0 0.5em 0;
    }
    &:nth-child(7) .maha-image {
      border-radius: 0 0 0 0.5em;
    }
    &:nth-child(9n + 4) {
      float: right;
    }
    &:nth-child(9n + 1),
    &:nth-child(9n + 4),
    &:nth-child(9n + 7) {
      width: ~"calc(100% / 3 * 2)";
    }
    &:nth-child(9n + 2),
    &:nth-child(9n + 3),
    &:nth-child(9n + 5),
    &:nth-child(9n + 6),
    &:nth-child(9n + 8),
    &:nth-child(9n + 9) {
      width: ~"calc(100% / 3)";
    }
  }
}
