@import "../settings.colors";
@import "../settings.z-index";

$c-control-animation-time: 0.25s;

@mixin c-control--default {
  align-items: center;
  background-color: transparent;
  display: flex;
  height: $c-control-button-size-outer;
  margin: 0;
  overflow: visible;
  border-radius: 2px;
  padding: 0 rem(2);
  position: relative;
  width: auto;
  text-decoration: none;
  transition: opacity $c-control-animation-time ease-out;

  // default button
  .c-control__button {
    @include c-control--button-default;

    // default label
    .c-control__label {
      @include c-control--button-label;
    }

    // default icon
    .c-control__icon {
      @include c-control--button-icon;
    }
  }
}

@mixin c-control--button-default {
  @include font-gm-sans-bold;
  appearance: none;
  background-color: transparent;
  border: none;
  border-radius: rem(2);
  color: $color-white;
  cursor: pointer;
  display: flex;
  align-items: center;
  align-self: center;
  font-size: rem(14);
  margin: 0 auto;
  letter-spacing: rem(1);
  height: $c-control-button-size-inner;
  width: 100%;
  line-height: 1;
  overflow: visible;
  padding: 0 rem(10);
  vertical-align: middle;
  justify-content: center;
  text-decoration: none;
  transition: background-color $c-control-animation-time ease-out;
  position: relative;

  &:hover,
  &:focus {
    z-index: $z-index-focused-button;
  }

  &:active {
    .c-control__icon,
    .c-control__label {
      fill: $color-grey-300;
    }
  }
}

@mixin c-control--button-label {
  vertical-align: middle;
  text-transform: uppercase;
  display: inline-block;
  white-space: nowrap;
  font-size: rem(14);
  width: auto;
  color: $color-white;
  transition: color $c-control-animation-time ease-out;
  text-overflow: ellipsis;
  max-width: rem(600);
  overflow: hidden;
  align-self: center;
}

///////////////////////////////////////////////////
// button icon
///////////////////////////////////////////////////
@mixin c-control--button-icon {
  display: inline-block;
  width: rem(20);
  height: rem(20);
  margin: 0;
  padding: 0;
  fill: $color-white;
  transition: fill $c-control-animation-time ease-out;
  pointer-events: none;
  text-align: center;

  // IE11 hack
  @include modern-browsers {
    margin: 0 auto;
  }
}

@mixin c-control--disabled {
  pointer-events: none;
  user-select: none;

  .c-control__button {
    .c-control__icon,
    .c-control__label {
      color: $color-grey-300 !important;
      fill: $color-grey-300 !important;
    }
  }
}

@mixin c-control--disabled-white {
  pointer-events: none;
  user-select: none;

  .c-control__button {
    .c-control__icon,
    .c-control__label {
      color: $color-grey-200 !important;
      fill: $color-grey-200 !important;
    }
  }
}

@mixin c-control--disabled-red {
  pointer-events: none;
  user-select: none;

  .c-control__button {
    .c-control__icon,
    .c-control__label {
      color: $color-grey-300 !important;
      fill: $color-grey-300 !important;
    }
  }
}

@mixin c-control--red {
  .c-control__button {
    background-color: $color-red-600;
    border: none;

    .c-control__icon,
    .c-control__label {
      color: $color-white;
      fill: $color-white;
    }

    &:hover,
    &:focus {
      background-color: $color-red-700;
    }

    &:active {
      z-index: $z-index-focused-button;
      background-color: $color-red-800;

      .c-control__icon,
      .c-control__label {
        color: $color-grey-300;
        fill: $color-grey-300;
      }
    }
  }
}

@mixin c-control--red-primary {
  .c-control__button {
    background-color: $color-red-500;
    border: none;
  }
}

@mixin c-control--red-primary-border {
  .c-control__button {
    background-color: $color-red-600;
    border: 1px solid $color-grey-300;
  }
}

@mixin c-control--red-secondary {
  .c-control__button {
    background-color: $color-red-600;
    border: none;
  }
}

@mixin c-control--red-secondary-border {
  .c-control__button {
    background-color: $color-red-600;
    border: 1px solid $color-grey-300;
  }
}

@mixin c-control--red-text {
  .c-control__button {
    .c-control__icon,
    .c-control__label {
      color: $color-red-600;
      fill: $color-red-600;

      &:hover,
      &:focus {
        .c-control__icon,
        .c-control__label {
          fill: $color-grey-900;
          color: $color-grey-900;
        }
      }
    }
  }
}

@mixin c-control--dark-text {
  .c-control__button {
    .c-control__icon,
    .c-control__label {
      color: $color-grey-660;
      fill: $color-grey-660;

      &:hover,
      &:focus {
        .c-control__icon,
        .c-control__label {
          fill: $color-grey-900;
          color: $color-grey-900;
        }
      }
    }
  }
}

@mixin c-control--white {
  .c-control__button {
    border: none;

    .c-control__icon,
    .c-control__label {
      color: $color-grey-660;
      fill: $color-grey-660;
    }

    &:hover,
    &:focus {
      background-color: $color-stone-150;

      .c-control__icon,
      .c-control__label {
        color: $color-grey-900;
        fill: $color-grey-900;
      }
    }

    &:active {
      background-color: $color-grey-200;

      .c-control__icon,
      .c-control__label {
        color: $color-grey-900;
        fill: $color-grey-900;
      }
    }
  }
}

@mixin c-control--white-primary {
  .c-control__button {
    background-color: $color-white;
  }
}

@mixin c-control--white-primary-border {
  .c-control__button {
    background-color: $color-white;
    border: 1px solid $color-stone-500;
  }
}

@mixin c-control--white-secondary {
  .c-control__button {
    background-color: $color-stone-100;
  }
}

@mixin c-control--white-secondary-border {
  .c-control__button {
    background-color: $color-stone-100;
    border: 1px solid $color-stone-500;
  }
}

@mixin c-control--grey-700 {
  .c-control__button {
    background-color: $color-grey-700;
    border: none;

    .c-control__icon,
    .c-control__label {
      color: $color-white;
      fill: $color-white;
    }

    &:hover,
    &:focus {
      z-index: $z-index-focused-button;
      background-color: $color-grey-600;
    }

    &:active {
      z-index: $z-index-focused-button;
      background-color: $color-grey-900;

      .c-control__icon,
      .c-control__label {
        color: $color-grey-300;
        fill: $color-grey-300;
      }
    }
  }
}

@mixin c-control--grey-700-border {
  .c-control__button {
    background-color: $color-grey-700;
    border: 1px solid $color-grey-300;

    .c-control__icon,
    .c-control__label {
      color: $color-white;
      fill: $color-white;
    }

    &:hover,
    &:focus {
      z-index: $z-index-focused-button;
      background-color: $color-grey-600;
    }

    &:active {
      z-index: $z-index-focused-button;
      background-color: $color-grey-900;
      border: $color-grey-300;

      .c-control__icon,
      .c-control__label {
        color: $color-grey-300;
        fill: $color-grey-300;
      }
    }
  }
}

@mixin c-control--grey-800 {
  .c-control__button {
    background-color: $color-grey-800;
    border: none;

    .c-control__icon,
    .c-control__label {
      color: $color-white;
      fill: $color-white;
    }

    &:hover,
    &:focus {
      z-index: $z-index-focused-button;
      background-color: $color-grey-600;
    }

    &:active {
      z-index: $z-index-focused-button;
      background-color: $color-grey-900;

      .c-control__icon,
      .c-control__label {
        color: $color-grey-300;
        fill: $color-grey-300;
      }
    }
  }
}

@mixin c-control--grey-800-border {
  .c-control__button {
    background-color: $color-grey-800;
    border: 1px solid $color-grey-300;

    .c-control__icon,
    .c-control__label {
      color: $color-white;
      fill: $color-white;
    }

    &:hover,
    &:focus {
      z-index: $z-index-focused-button;
      background-color: $color-grey-600;
    }

    &:active {
      z-index: $z-index-focused-button;
      background-color: $color-grey-900;
      border: $color-grey-300;

      .c-control__icon,
      .c-control__label {
        color: $color-grey-300;
        fill: $color-grey-300;
      }
    }
  }
}

@mixin c-control--grey-900 {
  .c-control__button {
    background-color: $color-grey-900;
    border: none;

    .c-control__icon,
    .c-control__label {
      color: $color-white;
      fill: $color-white;
    }

    &:hover,
    &:focus {
      z-index: $z-index-focused-button;
      background-color: $color-grey-600;
    }

    &:active {
      z-index: $z-index-focused-button;
      background-color: $color-grey-900;

      .c-control__icon,
      .c-control__label {
        color: $color-grey-300;
        fill: $color-grey-300;
      }
    }
  }
}

@mixin c-control--grey-900-border {
  .c-control__button {
    background-color: $color-grey-900;
    border: 1px solid $color-grey-300;

    .c-control__icon,
    .c-control__label {
      color: $color-white;
      fill: $color-white;
    }

    &:hover,
    &:focus {
      z-index: $z-index-focused-button;
      background-color: $color-grey-600;
    }

    &:active {
      z-index: $z-index-focused-button;
      background-color: $color-grey-900;
      border: $color-grey-300;

      .c-control__icon,
      .c-control__label {
        color: $color-grey-300;
        fill: $color-grey-300;
      }
    }
  }
}

@mixin c-control--accordion-default {
  display: flex;
  height: rem(44);
  width: rem(44);
  margin: 0;
  padding: 0;

  .c-control__button {
    border: none;
    border-radius: 0;
  }
}

@mixin c-control--accordion-top {
  .c-control__button {
    background-color: $color-grey-600;

    .c-control__icon,
    .c-control__label {
      color: $color-white;
      fill: $color-white;
    }

    &:hover,
    &:focus {
      z-index: $z-index-focused-button;
      background-color: $color-grey-800;
    }

    &:active {
      z-index: $z-index-focused-button;
      background-color: $color-grey-900;

      .c-control__icon,
      .c-control__label {
        color: $color-grey-300;
        fill: $color-grey-300;
      }
    }
  }
}

@mixin c-control--accordion-sub {
  .c-control__button {
    background-color: $color-grey-600;

    .c-control__icon,
    .c-control__label {
      color: $color-white;
      fill: $color-white;
    }

    &:hover,
    &:focus {
      z-index: $z-index-focused-button;
      background-color: $color-grey-500;
    }

    &:active {
      z-index: $z-index-focused-button;
      background-color: $color-grey-500;

      .c-control__icon,
      .c-control__label {
        color: $color-grey-900;
        fill: $color-grey-900;
      }
    }
  }
}

@mixin c-control--accordion-sub-2 {
  .c-control__button {
    background-color: $color-grey-200;

    .c-control__icon,
    .c-control__label {
      color: $color-grey-700;
      fill: $color-grey-700;
    }
  }
}

@mixin c-control--accordion-sub-3 {
  .c-control__button {
    background-color: $color-grey-100;

    .c-control__icon,
    .c-control__label {
      color: $color-grey-700;
      fill: $color-grey-700;
    }
  }
}

@mixin c-control--accordion-sub-4 {
  .c-control__button {
    background-color: $color-grey-100;

    .c-control__icon,
    .c-control__label {
      color: $color-grey-700;
      fill: $color-grey-700;
    }
  }
}

@mixin c-control--modal {
  .c-control__button {
    background-color: $color-white;
    padding: 0 rem(10);

    .c-control__icon,
    .c-control__label {
      fill: $color-grey-500;
      color: $color-grey-500;
    }

    &:hover,
    &:focus {
      z-index: $z-index-focused-button;
      background-color: $color-stone-150;
    }

    &:active {
      background-color: $color-stone-150;

      .c-control__icon,
      .c-control__label {
        fill: $color-grey-300;
        color: $color-grey-300;
      }
    }
  }
}

@mixin c-control--arrow {
  display: flex;
  transition: 0.4s ease-out;
  padding: rem(2);
}

@mixin c-control--arrow--dark {
  border-left: 1px solid $color-grey-500;
  border-right: 1px solid $color-grey-500;
}

@mixin c-control--arrow--white {
  border-left: 1px solid $color-stone-150;
  border-right: 1px solid $color-stone-150;
}

@mixin c-control--text-resizer {
  @include c-control--grey-700-border;
  padding: 0;

  .c-control__button.c-control__button--text-resizer {
    @include font-gm-sans;
    display: inline-block;
    border-radius: rem(2);
    border: 1px solid $color-white;
    width: rem(45);
    margin: 0 auto;
    text-align: center;

    &:hover, &:focus, &:active {
      background-color: $color-grey-900;

      &::before {
        visibility: visible;
        transform: scaleX(1);
      }
    }

    &::before {
      content: "";
      position: absolute;
      height: 1px;
      bottom: rem(5);
      left: rem(5);
      right: rem(5);
      background-color: $color-white;
      visibility: hidden;
      transform: scaleX(0);
      transition: all 0.2s ease-out;
    }
  }
}

@mixin c-control--text-resizer-2 {
  .c-control__button {
    font-size: rem(20);
  }
}

@mixin c-control--text-resizer-4 {
  .c-control__button {
    font-size: rem(22);
  }
}

@mixin c-control--text-resizer-6 {
  .c-control__button {
    font-size: rem(24);
  }
}

@mixin c-control--panel {
  .c-control__button {
    max-width: rem(400);
  }
}

@mixin c-control--short {
  .c-control__button {
    width: 100%;
    min-width: rem(44);
    height: rem(34);
  }

  .c-control__label:not(.c-control__label--adchoice) {
    font-size: rem(12);
  }
}

@mixin c-control--tight {
  .c-control__button {
    padding: 0 rem(5);
  }

  .c-control__label:not(.c-control__label--adchoice) {
    font-size: rem(12);
  }
}

@mixin c-control--xs {
  padding: 0;
  margin: 0 rem(3) 0 0;

  &:last-child {
    margin: 0;
  }
}

