.dp-button {
  font-family: $primary-font;
  font-weight: $pf-semi-bold;
  color: $dp-greyscale-00;
  border: 0 solid $dp-sonic-primary;
  border-radius: $rad-size-m-l;

  height: 22px;
  padding-left: 12px;
  padding-right: 12px;
  padding-bottom: 3px;
  padding-top: 1px;
  font-size: $font-size-l;

  background-color: $dp-sonic-primary;
  box-shadow: 0 -2px 0 $dp-sonic-midnight inset;
  mix-blend-mode: multiply;
  transition: all 0.1s linear 0s;

  &:hover {
    background-color: $dp-sonic-secondary;
  }
  &:active {
    background-color: $dp-sonic-tertiary;
    border-color: $dp-sonic-tertiary;
    box-shadow: 0 2px 0 $dp-sonic-midnight inset;
    mix-blend-mode: normal;
  }
  &:focus {
    outline: 0;
    //outline: solid 1px $dp-sonic-primary;
  }
  &:disabled {
    background-color: $dp-greyscale-150;
    border-color: $dp-greyscale-150;
    color: $dp-greyscale-300;
    box-shadow: none;
    .dp-icon {
      color: $dp-greyscale-300;
    }
  }
  &, * {
    box-sizing: border-box;
  }
}

/******************************
    Button sizes
*******************************/
.dp-button--s {
  height: 18px;
  padding: 1px 10px 4px 10px;
  font-size: $font-size-m;
  .dp-icon {
    margin-right: 6px;
    font-size: $icon-size-s;
  }
}

.dp-button--m {
  .dp-icon {
    margin-right: 7px;
    font-size: $icon-size-s;;
  }
}

.dp-button--l {
  height: 34px;
  padding-left: 14px;
  padding-right: 14px;
  font-size: $font-size-xl;
  .dp-icon {
    margin-right: 11px;
    font-size: $icon-size-m;
  }
}

/******************************
    Button types
*******************************/

.dp-button--cta {
  background-color: $dp-emerald-primary;
  border-color: $dp-emerald-primary;
  box-shadow: 0 -2px 0 $dp-emerald-midnight inset;

  &:hover {
    background-color: $dp-emerald-secondary;
  }
  &:active {
    background-color: $dp-emerald-tertiary;
    border-color: $dp-emerald-tertiary;
    box-shadow: 0 2px 0 $dp-emerald-midnight inset;
    mix-blend-mode: normal;
  }
}

.dp-button--cta,
.dp-button--primary {
  .dp-icon {
    color: transparentize($dp-greyscale-00, 0.4);
  }
  &:hover .dp-icon {
    color: transparentize($dp-greyscale-00, 0.2);
  }
  &:active .dp-icon {
    color: transparentize($dp-greyscale-00, 0.4);
  }
}

.dp-button--secondary:not(:disabled) {
  background-color: $dp-greyscale-00;
  border: 1px solid $dp-greyscale-300;
  box-shadow: 0 -1px 0 $dp-greyscale-200 inset;
  color: $dp-greyscale-850;
  height: 22px;
  padding-top: 0;
  &.dp-button--s {
    height: 18px;
    padding: 0 10px 4px 10px;
  }
  &.dp-button--l {
    height: 34px;
    padding: 2px 14px 4px 14px;
  }

  &:hover {
    background-color: $dp-greyscale-00;
    border-color: $dp-sonic-primary;
    color: $dp-sonic-primary;
    box-shadow: 0 -1px 0 $dp-sonic-primary inset;
    .dp-icon {
      color: $dp-sonic-primary;
    }
  }
  &:active {
    background-color: $dp-morning-sky;
    border-color: $dp-sonic-primary;
    color: $dp-sonic-primary;
    box-shadow: 0 1px 0 $dp-sonic-primary inset;
    mix-blend-mode: normal;
    .dp-icon {
      color: $dp-sonic-primary;
    }
  }
  .dp-icon {
    color: $dp-greyscale-450;
  }
}

/// Square button
///

.dp-button--shape-square {
  @include border-radius("s");
  padding: 5px !important;

  .dp-icon {
    margin-right: 0;
    display: block;
    font-size: $icon-size-s;
  }
}

.dp-button--s.dp-button--shape-square {
  width: 23px;
  height: 23px;

  .dp-icon {
    font-size: $icon-size-s;
  }
}

.dp-button--m.dp-button--shape-square {
  width: 28px;
  height: 28px;

  .dp-icon {
    font-size: $icon-size-m;
  }
}

.dp-button--l.dp-button--shape-square {
  width: 29px;
  height: 29px;

  .dp-icon {
    font-size: $icon-size-l;
  }
}


/// Round Button
///

.dp-button--shape-round {
  @extend .dp-button--shape-square;
  @include border-radius("circular");
}

/// Split button
///

.dp-split-button {
  display: inline-block;

  .dp-popper {
    padding: 4px;
  }
}

.dp-split-button__left {
  border-right: 0;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.dp-split-button__right {
  border-left: 0;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;

  .dp-icon {
    margin-right: 0;
  }
}

/// Primary
.dp-button--primary:not(:disabled).dp-split-button__right {
  border: $dp-sonic-tertiary;
  background-color: $dp-sonic-tertiary;

  &:hover,
  &:active {
    color: transparentize($dp-greyscale-00, 0.1);
    background-color: $dp-sonic-secondary;
  }
}

/// Secondary
.dp-button--secondary:not(:disabled).dp-split-button__right {
  @extend .dp-button--secondary;
}

/// CTA
.dp-button--cta:not(:disabled).dp-split-button__right {
  border: $dp-emerald-tertiary;
  background-color: $dp-emerald-tertiary;

  &:hover,
  &:active {
    color: transparentize($dp-greyscale-00, 0.1);
    background-color: $dp-emerald-secondary;
  }
}

/// Dropdown Button
///

.dp-dropdown-button {

  .dp-icon {
    margin-right: 0;
  }

  .dp-popper {
    padding: 4px;
  }
}

/// Small
.dp-button--s.dp-dropdown-button .dp-icon {
  margin-left: 7px;
}

/// Medium
.dp-button--m.dp-dropdown-button .dp-icon {
  margin-left: 9px;
}

/// Large
.dp-button--l.dp-dropdown-button .dp-icon {
  margin-left: 15px;
}


/// Progress Button
///

.dp-progress-button {
  @extend .dp-button;
  @extend .dp-button--secondary;
  padding: 0;
  width: 38px;
  cursor: pointer;
  position: relative;
  display: inline-block;
  background-color: $dp-greyscale-150;
  border-left: 1px solid $dp-greyscale-300;
  font-family: $primary-font;
  font-size: $font-size-s;
  font-weight: $pf-semi-bold;
  color: $dp-greyscale-850;

  &, * {
    box-sizing: border-box;
  }

  .dp-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: $dp-greyscale-00;
    border-bottom-left-radius: $rad-size-m-l;
    border-bottom-right-radius: $rad-size-m-l;
  }
}

.dp-progress-button__label {
  text-align: center;
}

/// Small
.dp-progress-button--s {
  height: 20px;

  .dp-progress-button__label {
    padding: 2px 0;
  }

  .dp-progress {
    height: 2px;
  }
}

/// Medium
.dp-progress-button--m {
  height: 26px;

  .dp-progress-button__label {
    padding: 4px 0;
  }
}

/// Large
.dp-progress-button--l {
  height: 32px;

  .dp-progress-button__label {
    padding: 8px 0;
  }
}

/// Translate Button
///

.dp-translate-button {
  display: inline-flex;
  vertical-align: top;
  border: 1px solid $dp-greyscale-300;
  border-radius: $rad-size-m;
  box-shadow: 0 -1px 0 $dp-greyscale-200 inset;

  &, * {
    box-sizing: border-box;
  }

  .dp-progress-button {
    border: 0;
    border-left: 1px solid $dp-greyscale-300;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
  }

  .dp-icon {
    border: 0;
    width: 30px;
    text-align: center;
    color: $dp-greyscale-450;
  }
}

/// Small
.dp-translate-button--s .dp-icon {
  padding: 4px;
  font-size: $icon-size-s;
}

/// Medium
.dp-translate-button--m .dp-icon {
  padding: 5px;
  font-size: $icon-size-m;
}

/// Large
.dp-translate-button--l .dp-icon {
  padding: 8px;
  font-size: $icon-size-m;
}

/******************************
    Button loading
*******************************/
@keyframes button-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.dp-button--loading {
  position: relative;
  color: transparent!important;
  text-shadow: none!important;
  opacity: 1;
  pointer-events: auto;
  &:before {
    position: absolute;
    content: '';
    top: 50%;
    left: 50%;
    margin: -9px 0 0 -8px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: .2em solid rgba(0,0,0,.15);
  }
  &:after {
    position: absolute;
    content: '';
    top: 50%;
    left: 50%;
    margin: -9px 0 0 -8px;
    width: 10px;
    height: 10px;
    -webkit-animation: button-spin .6s linear;
    animation: button-spin .6s linear;
    -webkit-animation-iteration-count: infinite;
    animation-iteration-count: infinite;
    border-radius: 50%;
    border-color: #fff transparent transparent;
    border-style: solid;
    border-width: .2em;
    box-shadow: 0 0 0 1px transparent;
  }
  &.dp-button--s {
    &:before, &:after {
      width: 7px;
      height: 7px;
      margin: -7px 0 0 -6px;
    }
  }
  &.dp-button--l {
    &:before, &:after {
      width: 15px;
      height: 15px;
      margin: -11px 0 0 -10px;
    }
  }
}