@mixin box-fixed-height(
    $header-selector: "",
    $header-height: auto,
    $footer-selector: "",
    $footer-height: auto,
    $content-selector: "",
    $reset: false
  ) {

  @if $reset != true {
    &,
    #{$header-selector},
    #{$footer-selector} {
      @include box-sizing(border-box);
    }

    #{$header-selector},
    #{$footer-selector} {
      overflow: auto;
    }

    @if $content-selector != "" {
      #{$content-selector} {
        height: 100%;
        overflow: auto;
        @include box-sizing(border-box);
      }
    }
  }

  @if $header-height != auto {
    padding-top: $header-height;

    #{$header-selector} {
      height: $header-height;
      margin-top: -$header-height;
    }
  }

  @if $footer-height != auto {
    padding-bottom: $footer-height;

    #{$footer-selector} {
      height: $footer-height;
      margin-bottom: -$footer-height;
    }
  }

  @content;
}

// Sandwich
// ==========
// An instance of Sticky Footer

@mixin layout-sandwich(
    $header-height: auto,
    $header-selector: ".Layout-header",
    $footer-height: auto,
    $footer-selector: ".Layout-footer",
    $content-selector: ".Layout-content"
  ) {

  &,
  body {
    height: 100%;
  }

  // Main area of page
  // <main class="Layout-content"></main>
  #{$content-selector} {
    min-height: 100%;

    &:before,
    &:after {
      content: "\0020";
      display: block;
      position: relative;
      z-index: -999999999;
      background: transparent none;
      visibility: hidden;
    }
  }

  // Header of page
  @if $header-height != auto {
    #{$header-selector} {
      height: $header-height;
      margin-bottom: -$header-height;
    }
  }

  // Footer of page
  @if $footer-height != auto {
    #{$footer-selector} {
      height: $footer-height;
      margin-top: -$footer-height;
    }
  }

  @if $header-height != auto or $footer-height != auto {
    #{$content-selector} {
      @if $header-height != auto {
        &:before {
          height: $header-height;
        }
      }

      @if $footer-height != auto {
        &:after {
          height: $footer-height;
        }
      }
    }
  }
}

// Frameset

@mixin layout-frameset(
    $sidebar-width: auto,
    $sidebar-pos: left,
    $sidebar-selector: ".Layout-sidebar",
    $header-height: 0,
    $header-selector: ".Layout-header",
    $footer-height: 0,
    $footer-selector: ".Layout-footer",
    $content-selector: ".Layout-content"
  ) {

  &,
  body {
    width: 100%;
    height: 100%;
    min-height: 0;
    zoom: 1;
  }

  body {
    overflow-y: hidden;
    @include box-fixed-height(
      $header-selector, $header-height,
      $footer-selector, $footer-height,
      join($content-selector, $sidebar-selector, comma));
  }

  #{$sidebar-selector} {
    width: $sidebar-width;
    float: $sidebar-pos;
  }
}

// Scroll

@mixin layout-scroll(
    $sidebar-width: auto,
    $sidebar-minHeight: 0,
    $sidebar-selector: ".Layout-sidebar",
    $content-selector: ".Layout-content"
  ) {

  &,
  #{join(body, ($sidebar-selector, $content-selector), comma)} {
    height: 100%;
  }

  body {
    @include pie-clearfix;
  }

  #{$sidebar-selector} {
    width: $sidebar-width;
    float: left;
    min-height: $sidebar-minHeight;
    overflow: hidden;
  }

  #{$content-selector} {
    overflow: auto;
  }
}
