//
// hr
// -------------------------------------------
$hr-border-class:             $hr-border !default;
$hr-margin-class:             get-side($hr-margin, bottom) !default;
$hr-padding-class:            $hr-margin-class;
$hr-vertical-height:          auto !default;
$hr-vertical-margin-top:      get-side($hr-margin, top) !default;
$hr-vertical-margin-bottom:   get-side($hr-margin, bottom) !default;
$hr-vertical-border:          $hr-border !default;

@mixin style-hr($position: bottom) {
  clear: both;
  border-left: 0;
  border-right: 0;

  @if ($position == bottom) {
    margin-bottom: $hr-margin-class;
    border-bottom: $hr-border-class;
  }

  @if ($position == top) {
    padding-top: $hr-padding-class;
    border-top: $hr-border-class;
  }

  .cell & {
    margin-left: 0;
    margin-right: 0;
  }
}

@mixin style-hr-vertical() {
  width: 1px;
  height: $hr-vertical-height;
  margin: auto;
  margin-top: $hr-vertical-margin-top;
  margin-bottom: $hr-vertical-margin-bottom;
  border: 0;
  border-left: $hr-vertical-border;

  .cell & {
    height: calc(100% - #{($hr-vertical-margin-top + $hr-vertical-margin-bottom) / 2});
  }
}

@mixin style-hr-margin($factor: 1, $important: false) {

  @if ($important == true) {
    margin-bottom: ($factor * $hr-margin-class) !important;
  }
  @else {
    margin-bottom: ($factor * $hr-margin-class);
  }
}

@mixin style-hr-padding($factor: 1, $important: false) {

  @if ($important == true) {
    padding-top: ($factor * $hr-padding-class) !important;
  }
  @else {
    padding-top: ($factor * $hr-padding-class);
  }
}

.hr,
.hr-bottom {
  @include style-hr(bottom);
}

.hr-top {
  @include style-hr(top);
}

.no-hr {
  border-top: 0 !important;
  border-bottom: 0 !important;
}

.hr-vertical {
  @include style-hr-vertical;
}

.hr-vertical-left {
  border: 0;
  border-left: $hr-vertical-border;

  &:not(.cell) {
    padding-left: $hr-padding-class / 2;
  }
}

.hr-vertical-right {
  border: 0;
  border-right: $hr-vertical-border;

  &:not(.cell) {
    padding-right: $hr-padding-class / 2;
  }
}

.hr-margin {
  @include style-hr-margin(1, true);

  @for $i from 2 through 4 {
    &.hr-#{$i}x {
      @include style-hr-margin($i, true);
    }
  }

  @for $i from 2 through 4 {
    &.hr-margin-#{$i}x {
      @include style-hr-margin($i, true);
    }
  }
}

.hr-padding {
  @include style-hr-padding(1, true);

  @for $i from 2 through 4 {
    &.hr-#{$i}x {
      @include style-hr-padding($i, true);
    }
  }

  @for $i from 2 through 4 {
    &.hr-padding-#{$i}x {
      @include style-hr-padding($i, true);
    }
  }
}
