@charset "UTF-8";

///
/// Modular Scale
/// Mixins for modular scaling, a unitless system for returning font sizes or spacing (padding or margin) values.
/// Our modular spacing system does not use the Bourbon modular-scale mixin. Instead we use a manual scale defined in variables/core/_modular-spacing.scss for finetuning.
/// A mixin for adding spacing (margin or padding) between elements or between an
/// element and the edge of its container. The amount of spacing is returned
/// using a unitless scaling system with a curated scale.
/// Please see core/scss/utilities/variables/core/_modular-spacing.scss for
/// variable maps.
///
/// @name modular-spacing
///
/// @example scss
///   @include modular-spacing('padding', 2 null);
///   @include modular-spacing('margin', 0 -4 1 2);
///
/// @param {string} $type  Spacing type, either 'padding' or 'margin'.
/// @param {list} $steps - List (1 to 4 values): Either integer (from -4 to 9 including 0) or null. Follows the shorthand notation of padding/margin. Use null to skip a side. A value of 0 returns the modular spacing base value for that breakpoint.
///
/// @deprecated modular-spacing mixin has been deprecated font will be removed in Decanter Version 7. Please replace with responsive-spacing instead.
///
/// @group mixin
@mixin modular-spacing($type: 'padding', $steps: 0, $grid: $su-grid-media) {

  @warn "modular-spacing mixin has been deprecated font will be removed in Decanter Version 7. Please replace with responsive-spacing instead.";

  /// Get a list of all breakpoint keys in $grid.
  $bp-list: map-keys($grid);
  /// Find total number of breakpoints in our grid.
  $number-bp: length($bp-list);

  @for $i from 1 through $number-bp {
    /// Get modular-spacing base value for current breakpoint.
    $current-base: get-modular-spacing-base(nth($bp-list, $i));
    /// Initialize $previous_base.
    $previous-base: null;

    /// If $i is not 1, replace $previous_base with modular-spacing base value for previous breakpoint.
    @if $i != 1 {
      $previous-base: get-modular-spacing-base(nth($bp-list, $i - 1));
    }

    /// Only write media query if $i = 1 or if $current_base is different from $previous_base.
    @if $current-base != $previous-base {
      $key: nth($bp-list, $i);

      @include grid-media($key) {
        @if length($steps) == 1 {
          #{$type}: (calculate-modular-spacing($steps, $key));
        }
        @else if length($steps) == 2 {
          @if nth($steps, 1) != null {
            #{$type}-top: (calculate-modular-spacing(nth($steps, 1), $key));
            #{$type}-bottom: (calculate-modular-spacing(nth($steps, 1), $key));
          }

          @if nth($steps, 2) != null {
            #{$type}-left: (calculate-modular-spacing(nth($steps, 2), $key));
            #{$type}-right: (calculate-modular-spacing(nth($steps, 2), $key));
          }
        }
        @else if length($steps) == 3 {
          @if nth($steps, 1) != null {
            #{$type}-top: (calculate-modular-spacing(nth($steps, 1), $key));
          }

          @if nth($steps, 2) != null {
            #{$type}-right: (calculate-modular-spacing(nth($steps, 2), $key));
            #{$type}-left: (calculate-modular-spacing(nth($steps, 2), $key));
          }

          @if nth($steps, 3) != null {
            #{$type}-bottom: (calculate-modular-spacing(nth($steps, 3), $key));
          }
        }
        @else if length($steps) == 4 {
          @if nth($steps, 1) != null {
            #{$type}-top: (calculate-modular-spacing(nth($steps, 1), $key));
          }

          @if nth($steps, 2) != null {
            #{$type}-right: (calculate-modular-spacing(nth($steps, 2), $key));
          }

          @if nth($steps, 3) != null {
            #{$type}-bottom: (calculate-modular-spacing(nth($steps, 3), $key));
          }

          @if nth($steps, 4) != null {
            #{$type}-left: (calculate-modular-spacing(nth($steps, 4), $key));
          }
        }
        @else if length($steps) > 4 or length($steps) == 0 {
          @error '$steps should have 1 to 4 values';
        }
      }
    }
  }
}
