@mixin unselectable {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

%unselectable {
  @include unselectable;
}

// Responsive

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

@mixin until($device) {
  @media screen and (max-width: $device - 1px) {
    @content;
  }
}

@mixin mobile {
  @media screen and (max-width: $tablet - 1px) {
    @content;
  }
}

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

@mixin tablet-only {
  @media screen and (min-width: $tablet) and (max-width: $desktop - 1px) {
    @content;
  }
}

@mixin touch {
  @media screen and (max-width: $desktop - 1px) {
    @content;
  }
}

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

@mixin desktop-only {
  @media screen and (min-width: $desktop) and (max-width: $widescreen - 1px) {
    @content;
  }
}

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

@mixin widescreen-only {
  @media screen and (min-width: $widescreen) and (max-width: $fullhd - 1px) {
    @content;
  }
}

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

@mixin center($width, $height: 0) {
  position: absolute;
  @if $height != 0 {
    left: calc(50% - (#{$width} / 2));
    top: calc(50% - (#{$height} / 2));
  }
  @else {
    left: calc(50% - (#{$width} / 2));
    top: calc(50% - (#{$width} / 2));
  }
}

@mixin buttonHoverColor($color) {
  &:hover,
  &.is-hovered {
    background-color: tint($color, 30%);
    border-color: tint($color, 30%);
  }
}

@mixin buttonOutlined($color) {
  &.is-outlined {
    background-color: transparent;
    border-color: $color;
    color: $color;
  }
}

%hamburger {
  cursor: pointer;
  display: block;
  position: relative;

  span {
    background-color: currentColor;
    display: block;
    position: absolute;
    transform-origin: center;
    transition-duration: $speed;
    transition-property: background-color, opacity, transform;
    transition-timing-function: $easing;
  }
}

@mixin hamburger($dimensions) {
  @extend %hamburger;
  height: $dimensions;
  width: $dimensions;

  span {
    height: 2px;
    left: calc(50% - 8px);
    width: 14px;

    &:nth-child(1) {
      top: calc(50% - 6px);
    }

    &:nth-child(2) {
      top: calc(50%);
    }

    &:nth-child(3) {
      top: calc(50% + 6px);
    }
  }

  // Modifers
  &.is-active {
    span {
      &:nth-child(1) {
        transform: translateY(6px) rotate(45deg);
      }

      &:nth-child(2) {
        opacity: 0;
      }

      &:nth-child(3) {
        transform: translateY(-6px) rotate(-45deg);
      }
    }
  }
}

@mixin hamburger_big($dimensions) {
  @extend %hamburger;
  height: $dimensions;
  width: $dimensions;

  span {
    height: 4px;
    left: calc(50% - 16px);
    width: 32px;

    &:nth-child(1) {
      top: calc(50% - 12px);
    }

    &:nth-child(2) {
      top: calc(50%);
    }

    &:nth-child(3) {
      top: calc(50% + 12px);
    }
  }

  // Modifers
  &.is-active {
    span {
      &:nth-child(1) {
        transform: translateY(12px) rotate(45deg);
      }

      &:nth-child(2) {
        opacity: 0;
      }

      &:nth-child(3) {
        transform: translateY(-12px) rotate(-45deg);
      }
    }
  }
}

@mixin delete {
  @extend %unselectable;
  -moz-appearance: none;
  -webkit-appearance: none;
  background-color: transparent;
  border: none;
  border-radius: $radius-rounded;
  cursor: pointer;
  pointer-events: auto;
  display: inline-block;
  flex-grow: 0;
  flex-shrink: 0;
  font-size: 0;
  height: 24px;
  max-height: 24px;
  max-width: 24px;
  min-height: 24px;
  min-width: 24px;
  outline: none;
  position: relative;
  vertical-align: top;
  width: 20px;

  &::before,
  &::after {
    background-color: $black;
    content: "";
    display: block;
    left: 50%;
    position: absolute;
    top: 50%;
    transform: translateX(-50%) translateY(-50%) rotate(45deg);
    transform-origin: center center;
  }

  &::before {
    height: 2px;
    width: 50%;
  }

  &::after {
    height: 50%;
    width: 2px;
  }

  &:focus,
  &:active {
    background-color: rgba($white, 0.2);
  }

  // Sizes
  //&.is-small {
  //  height: 16px;
  //  max-height: 16px;
  //  max-width: 16px;
  //  min-height: 16px;
  //  min-width: 16px;
  //  width: 16px;
  //}
  //
  //&.is-medium {
  //  height: 24px;
  //  max-height: 24px;
  //  max-width: 24px;
  //  min-height: 24px;
  //  min-width: 24px;
  //  width: 24px;
  //}
  //
  //&.is-large {
  //  height: 32px;
  //  max-height: 32px;
  //  max-width: 32px;
  //  min-height: 32px;
  //  min-width: 32px;
  //  width: 32px;
  //}
}

%delete {
  @include delete;
}

@mixin block {
  &:not(:last-child) {
    margin-bottom: 1.5rem;
  }
}

%block {
  @include block;
}

@mixin overflow-touch {
  -webkit-overflow-scrolling: touch;
}

@mixin placeholder {
  $placeholders: ":-moz" ":-webkit-input" "-moz" "-ms-input";

  @each $placeholder in $placeholders {
    &:#{$placeholder}-placeholder {
      @content;
    }
  }
}

@mixin arrow($color: transparent) {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid $color;
  clear: both;
  content: '';
  display: block;
}

%arrow {
  @include arrow;
}

@mixin loader {
  animation: spinAround 500ms infinite linear;
  border: 2px solid $grey-lighter;
  border-radius: $radius-rounded;
  border-right-color: transparent;
  border-top-color: transparent;
  content: "";
  display: block;
  height: 1em;
  position: relative;
  width: 1em;
}

%loader {
  @include loader;
}
