.tdbc-button {
  display: inline-flex;
  align-items: center;
  align-self: start;
  justify-content: center;
  min-width: 10ch;
  min-height: 44px;
  padding: 0.25em 1em;
  transition: 180ms ease-in-out;
  transition-property: background, border;
  border-radius: $tdbc-border-radius/2;
  background-color: tdbc-color("primary");
  color: #fff;
  font-size: 1.125rem;
  line-height: 1.1;
  text-align: center;
  text-decoration: none;
  cursor: pointer;

  @media screen and (-ms-high-contrast: active) {
    border: 2px solid currentColor;
  }

  &:focus {
    outline-color: transparent;
    outline-style: solid;
    box-shadow: 0 0 0 3px scale-color(tdbc-color("primary"), $lightness: -30%);
  }

  &--small {
    min-height: 34px;
    font-size: 1rem;
  }

  &--center {
    align-self: center;
    margin-right: auto;
    margin-left: auto;
  }

  &__icon {
    width: 1.5em;
    height: 1.5em;
    margin-right: 0.25em;

    &--end {
      margin-right: 0;
      margin-left: 0.25em;
    }

    // stylelint-disable-next-line  selector-max-type
    svg {
      width: 100%;
      height: 100%;
      fill: currentColor;
    }
  }

  &-outlined {
    border: 2px solid tdbc-color("primary");
    background-color: transparent;
    color: tdbc-color("primary");

    &:hover,
    &:focus {
      background-color: scale-color(tdbc-color("primary"), $lightness: 80%);
    }
  }

  // stylelint-disable max-nesting-depth
  @each $key in $tdbc-button-variants {
    $color: tdbc-color($key);

    @if ($key != "primary") {
      &--#{$key} {
        background-color: $color;

        @if ($key == "light") {
          color: tdbc-color("dark");
        }

        &:focus {
          box-shadow: 0 0 0 3px scale-color($color, $lightness: -30%);
        }
      }

      &-outlined--#{$key} {
        border-color: scale-color($color, $lightness: 30%, $saturation: 15%);
        color: $color;

        &:focus {
          box-shadow: 0 0 0 3px scale-color($color, $lightness: -30%);
        }

        @if ($key == "light") {
          &:hover,
          &:focus {
            background-color: rgba($color, 0.15);
          }
        } @else {
          &:hover,
          &:focus {
            background-color: scale-color($color, $lightness: 90%);
          }
        }
      }
    }
  }
  // stylelint-enable
}

.tdbc-button__icon,
.tdbc-icon-button {
  display: inline-flex;
  position: relative;
  width: 1em;
  height: 1em;
  padding: 0;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  cursor: pointer;

  // stylelint-disable-next-line selector-max-type
  svg {
    flex-shrink: 0;
    width: 100%;
    height: 100%;
  }
}

.tdbc-icon-button {
  // stylelint-disable-next-line selector-max-type
  svg {
    fill: currentColor;
    opacity: 0.7;
  }

  &:focus,
  &:hover {
    outline: none;

    // stylelint-disable-next-line selector-max-type
    svg {
      opacity: 1;
    }
  }

  &:focus {
    &::after {
      position: absolute;
      top: -0.3em;
      right: -0.3em;
      bottom: -0.3em;
      left: -0.3em;
      border: 1px solid currentColor;
      border-radius: 50%;
      content: "";
    }
  }
}
