@import "tools.mixins";

// ------------------------------------
// Shared
// ------------------------------------

@mixin c-package-story-list-x-column($display: flex, $wrap: wrap, $flow: "") {
  @include flex-display($display, $wrap, $flow);
  justify-content: space-between;
  width: 100%; // Fix for IE11, when package is nested inside of a grid column
}

@mixin c-package-story-list-2-column($margin: rem(20)) {
  .u-wrapper {
    flex-basis: calc(50% - #{$margin * 2});
    margin-right: $margin;
    &:nth-of-type(even) {
      margin-right: 0;
    }
  }
}

@mixin c-package-story-list-3-column($margin: rem(50)) {
  .u-wrapper {
    flex-basis: calc(33% - #{$margin * 2});
    margin-right: $margin;
    &:last-of-type,
    &:nth-of-type(3n) {
      margin-right: 0;
    }
  }
}

@mixin c-package-story-list-4-column($margin: rem(20)) {
  .u-wrapper {
    flex-basis: calc(25% - #{$margin * 2});
    &:nth-of-type(even) {
      margin-right: $margin;
    }
    &:last-of-type,
    &:nth-of-type(4n) {
      margin-right: 0;
    }
  }
}

// ------------------------------------
// Basic
// ------------------------------------

@mixin c-package-story-list-basic-sm {
  .c-package--story-list--basic {
    @include c-package-story-list-x-column;
    @include c-package-story-list-2-column;
  }
}

@mixin c-package-story-list-basic-md {
  .c-package--story-list--basic {
    @include c-package-story-list-4-column;
  }
}

// ------------------------------------
// Numbered
// ------------------------------------

@mixin c-package-story-list-numbered-sm {
  .c-package--story-list--numbered {
    @include c-package-story-list-x-column;
    @include c-package-story-list-2-column;
  }
}

@mixin c-package-story-list-numbered-md {
  .c-package--story-list--numbered {
    @include c-package-story-list-4-column;
  }
}

// ------------------------------------
// Cards
// ------------------------------------

@mixin c-package-story-list-cards-sm {
  .c-package--story-list--cards {
    @include c-package-story-list-x-column($flow: row wrap, $wrap: "");
    @include c-package-story-list-2-column;
  }
}

@mixin c-package-story-list-cards-lg {
  .c-package--story-list--cards {
    @include c-package-story-list-4-column;
  }
}

// ------------------------------------
// A-Stack
// ------------------------------------

@mixin c-package-story-list-a-stack-sm-to-md {
  .c-package--story-list--a-stack {
    @include c-package-story-list-x-column;
    @include c-package-story-list-2-column;
    .u-wrapper:nth-of-type(2) {
      .c-card {
        padding-top: 0;
      }
    }
  }
}

@mixin c-package-story-list-a-stack-md {
  .c-package--story-list--a-stack {
    .u-wrapper {
      &:nth-of-type(2) {
        .c-card {
          padding-top: rem(10);
        }
      }
    }
    .c-card__hed {
      @include font-hed(19, 22);
    }
    .c-image-container {
      display: none;
    }
  }
}

@mixin c-package-story-list-a-stack-lg {
  .c-package--story-list--a-stack {
    .c-card__media {
      width: rem(132);
    }
    .c-image-container {
      display: block;
    }
  }
}

// ------------------------------------
// Engagement
// ------------------------------------

@mixin c-package-story-list-engagement-sm-up {
  .c-package--story-list--engagement {
    @include c-package-story-list-x-column;
  }
}

@mixin c-package-story-list-engagement-sm {
  .c-package--story-list--engagement {
    @include c-package-story-list-2-column($margin: rem(50));
    .u-wrapper {
      &:nth-of-type(2) {
        .c-card {
          display: block;
        }
      }
    }
  }
}

@mixin c-package-story-list-engagement-md {
  .c-package--story-list--engagement {
    @include c-package-story-list-3-column($margin: rem(50));
  }
}

@mixin c-package-story-list-engagement-md-up {
  .c-package--story-list--engagement {
    .u-wrapper {
      &:nth-of-type(2), &:nth-of-type(3) {
        .c-card {
          display: block;
        }
      }
    }
  }
}

@mixin c-package-story-list-engagement-lg-up {
  .c-package--story-list--engagement {
    @include c-package-story-list-3-column($margin: rem(60));
  }
}
