// // --- BREAKPOINT-REFERENCE --- //
// $ta-bp-xs:              0 !default;
// $ta-bp-sm:              600px !default;
// $ta-bp-md:              960px !default;
// $ta-bp-lg:              1440px !default;
// $ta-bp-xl:              1920px !default;

@mixin xs-screen {
  @media (min-width: #{$ta-bp-xs}) and (max-width: #{$ta-bp-sm - 1px}) {
    @content;
  }
}

@mixin sm-screen {
  @media (min-width: #{$ta-bp-sm}) and (max-width: #{$ta-bp-md - 1px}) {
    @content;
  }
}

@mixin md-screen {
  @media (min-width: #{$ta-bp-md}) and (max-width: #{$ta-bp-lg - 1px}) {
    @content;
  }
}

@mixin lg-screen {
  @media (min-width: #{$ta-bp-lg}) and (max-width: #{$ta-bp-xl - 1px}) {
    @content;
  }
}

@mixin xl-screen {
  @media (min-width: #{$ta-bp-xl}) {
    @content;
  }
}

///
/// Generates a media query based on a list of conditions
///
/// $conditions  - Media query conditions
///
/// With a single set breakpoint
///  @include media(">xs") { }
///
/// With two set breakpoints
///  @include media(">xs", "<=lg") { }
///
/// With custom values
///  @include media(">=358px", "<850px") { }
///
/// With set breakpoints with custom values
///  @include media(">md", "<=1350px") { }
///
/// With a static expression
///  @include media("retina2x") { }
///
/// Mix all the things
/// @include media(">=350px", "<lg", "retina3x") { }
///
@mixin ta-media($conditions...) {
  @for $i from 1 through length($conditions) {
    // set-nth documentation: https://sass-lang.com/documentation/functions/list
    $conditions: set-nth($conditions, $i, parse-expression(nth($conditions, $i)));
  }

  $branches: get-query-branches($conditions);
  $query: '';

  @each $branch in $branches {
    @if (str-length($query) != 0) {
      $query: $query + ', ';
    }

    $query: $query + $branch;
  }

  @media #{$query} {
    @content;
  }
}
