////
/// Originally Seen on Jeet.gs
/// @author mojotech
/// @link http://jeet.gs/
////

/// Center an element on either or both axes.
/// Parent container must have `position: relative` to work
/// @group layout
/// @parameter {string} $direction [both] - Specify which axes to center the element on.
///
/// @example scss Input
///   .aligned-both {
///     @include align();
///   }
///
///   .aligned-vertical {
///     @include align(vertical);
///   }
///
///   .aligned-horizontal {
///    @include align(horizontal);
///   }
///
/// @example css Output
///   .aligned-both {
///     position: absolute;
///     transform-style: preserve-3d;
///     top: 50%;
///     left: 50%;
///     transform: translate(-50%, -50%); }
///
///   .aligned-vertical {
///     position: absolute;
///     transform-style: preserve-3d;
///     top: 50%;
///     transform: translateY(-50%); }
///
///   .aligned-horizontal {
///     position: absolute;
///     transform-style: preserve-3d;
///     left: 50%;
///     transform: translateX(-50%); }

@mixin align($direction: both) {
  position: absolute;
  transform-style: preserve-3d;

  @if index("horizontal" "h", $direction) {
    left: 50%;
    transform: translateX(-50%);
  }
  @else if index("vertical" "v", $direction) {
    top: 50%;
    transform: translateY(-50%);
  }
  @else {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
}
