@use "mixins";
@use "vars";

button {
  background-color: transparent;
  border: 0;
  font-size: 100%;
}

.button  {
  text-decoration: none;
  font-size: 0.85rem;
  line-height: 1.4em;
  padding: vars.$xs*1.3 vars.$m;
  margin-top: vars.$xs;
  margin-bottom: vars.$xs;
  display: inline-block;
  font-weight: 400;
  outline: 0;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color ease-in-out 120ms,
    filter ease-in-out 120ms,
    box-shadow ease-in-out 120ms;
  box-shadow: none;
  background-color: var(--color-primary);
  color: #FFF;
  border: 1px solid var(--color-primary);
  vertical-align: top;
  &:hover, &:focus, &:active {
    background-color: var(--color-primary);
    text-decoration: none;
    color: #FFFFFF;
  }
  &:hover {
    @include mixins.lightDark(box-shadow, vars.$bs-light, vars.$bs-dark);
    filter: brightness(110%);
  }
  &:focus {
    outline: 1px dotted currentColor;
    outline-offset: -(vars.$xs);
    box-shadow: none;
    filter: brightness(90%);
  }
  &:active {
    outline: 0;
  }
}

.button.outline {
  background-color: transparent;
  @include mixins.lightDark(color, #666, #AAA);
  fill: currentColor;
  border: 1px solid;
  @include mixins.lightDark(border-color, #CCC, #666);
  &:hover, &:focus, &:active {
    @include mixins.lightDark(color, #444, #BBB);
    border: 1px solid #CCC;
    box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.1);
    background-color: #F2F2F2;
    @include mixins.lightDark(background-color, #f8f8f8, #444);
    filter: none;
  }
  &:active {
    border-color: #BBB;
    background-color: #DDD;
    color: #666;
    box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.1);
  }
}

.button + .button {
  margin-inline-start: vars.$s;
}

.button.small {
  font-size: 0.75rem;
  padding: vars.$xs*1.2 vars.$s;
}

.text-button {
  cursor: pointer;
  background-color: transparent;
  padding: 0;
  margin: 0;
  border: none;
  user-select: none;
  font-size: 0.75rem;
  line-height: 1.4em;
  color: var(--color-link);
  &:active {
    outline: 0;
  }
  &:hover {
    text-decoration: none;
  }
  &:hover, &:focus {
    color: var(--color-link);
    fill: var(--color-link);
  }
}
.text-button.hover-underline:hover {
  text-decoration: underline;
}

.button.block {
  width: 100%;
  text-align: start;
  display: block;
}

.button.icon, .icon-button, .text-button.icon {
  .svg-icon {
    margin-inline-end: 0;
  }
}

.icon-button {
  text-align: center;
  border: 1px solid transparent;
}
.icon-button:hover {
  background-color: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
  @include mixins.lightDark(border-color, #DDD, #444);
  cursor: pointer;
}

.button.svg {
  display: flex;
  align-items: center;
  padding: vars.$s vars.$m;
  padding-bottom: (vars.$s - 2px);
  width: 100%;
  svg {
    display: inline-block;
    width: 24px;
    height: 24px;
    bottom: auto;
    margin-inline-end: vars.$m;
  }
}

.button[disabled] {
  background-color: #BBB;
  cursor: default;
  border-color: #CCC;
  &:hover {
    background-color: #BBB;
    cursor: default;
    box-shadow: none;
  }
}