
@mixin justify-children($child-selector:'& > *') {
  /* justify children: equally space inline-block'ed child elements.
     optional parameter $child-selector defaults to & > *, i.e., direct
     children of the containing element. */
  text-align: justify;
  #{$child-selector} { display: inline-block; }
  &:after {
    content: ' ';
    display: inline-block;
    width: 100%;
  }
}

$font-size-base: 16px !default;
@function em($pixels, $context: $font-size-base) {
  @return #{($pixels/$context)}em;
}

@mixin baseline($height, $shift) {
  height: $height;
  line-height: calc(2*#{$height} - 1em + #{$shift});
}

@mixin hover-bg-colors($color, $hovercolor) {
  background-color: $color;
  &:hover { background-color: $hovercolor; }
}

@mixin debug($color: #ff8888) {
  background-color: $color;
}

@mixin min-width-query($size) {
   @media screen and (min-width: $size) { @content; }
}

/**
 * Media query shorthand.  Usage:
 *
 * @include mq([condition1], [condition2], [condition3], [...]) {
 *   // the stuff that should happen under the given conditions.
 * }
 *
 * Each condition should be one of:
 * - `sm`, `md`, `lg`: translates to `@media screen and (min-width: size) { ... }`, where
 *   `size` is the Bootstrap-like variable, e.g. `$screen-sm-min`.  Useful
 *   when you're being "mobile-first".
 *
 * - `print`: translates to `@media print`
 *
 * - `too-sm`: translates to `@media screen and (max-width: $screen-sm-min - 1) { ... }`.
 *   Useful when you're being *not* "mobile-first".
 *
 * - an arbitrary media query: just does `@media (condition) { ... }`
 *
 */

$screen-sm-min: 768px !default;
$screen-md-min: 992px !default;
$screen-lg-min: 1200px !default;

@mixin mq($conditions...) {
  @each $condition in $conditions {
    @if $condition == sm {
      @include min-width-query($screen-sm-min) { @content; }
    }
    @else if $condition == md {
      @include min-width-query($screen-md-min) { @content; }
    }
    @else if $condition == lg {
      @include min-width-query($screen-lg-min) { @content; }
    }
    @else if $condition == not-md {
      @media screen and (max-width: ($screen-md-min - 1)) { @content; }
    }
    @else if $condition == too-sm {
      @media screen and (max-width: ($screen-sm-min - 1)) { @content; }
    }
    @else if $condition == print {
      @media print { @content; }
    }
    @else if $condition == retina {
      @media (min--moz-device-pixel-ratio: 1.3),
         (-o-min-device-pixel-ratio: 2.6/2),
         (-webkit-min-device-pixel-ratio: 1.3),
         (min-device-pixel-ratio: 1.3),
         (min-resolution: 1.3dppx) { @content; }
    }
    @else {
      @media ($condition) { @content; }
    }
  }
}


/*! following section from HTML5 Boilerplate v4.3.0 | MIT License | http://h5bp.com/ */

/* ==========================================================================
   Helper classes
   ========================================================================== */

/*
 * Image replacement
 */

%ir {
    background-color: transparent;
    border: 0;
    overflow: hidden;
    /* IE 6/7 fallback */
    *text-indent: -9999px;
}

%ir:before {
    content: "";
    display: block;
    width: 0;
    height: 150%;
}

/*
 * Hide from both screenreaders and browsers: h5bp.com/u
 */

%hidden {
    display: none !important;
    visibility: hidden;
}

/*
 * Hide only visually, but have it available for screenreaders: h5bp.com/v
 */

@mixin visuallyhidden {
  border: 0;
  clip: rect(0 0 0 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
}

%visuallyhidden { @include visuallyhidden; }

/*
 * Extends the .visuallyhidden class to allow the element to be focusable
 * when navigated to via the keyboard: h5bp.com/p
 */

%visuallyhidden.focusable:active,
%visuallyhidden.focusable:focus {
    clip: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    position: static;
    width: auto;
}

/*
 * Hide visually and from screenreaders, but maintain layout
 */

%invisible {
    visibility: hidden;
}

/*
 * Clearfix: contain floats
 *
 * For modern browsers
 * 1. The space content is one way to avoid an Opera bug when the
 *    `contenteditable` attribute is included anywhere else in the document.
 *    Otherwise it causes space to appear at the top and bottom of elements
 *    that receive the `clearfix` class.
 * 2. The use of `table` rather than `block` is only necessary if using
 *    `:before` to contain the top-margins of child elements.
 */

%clearfix:before,
%clearfix:after {
    content: " "; /* 1 */
    display: table; /* 2 */
}

%clearfix:after {
    clear: both;
}

/*
 * For IE 6/7 only
 * Include this rule to trigger hasLayout and contain floats.
 */

%clearfix {
    *zoom: 1;
}
