@use 'variables' as *;
@use 'mixins';

// Resets button styles
button {
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: 14px;
  appearance: none;
  vertical-align: baseline;

  &:focus {
    outline: none;
  }

  &:focus-visible {
    outline: $focus-outline;
  }

  svg {
    cursor: pointer;
  }
}

// Generic button base class
// Can be used by itself, or in conjunction with the .button-* modifier classes
.button {
  cursor: pointer;
  display: inline-block;
  white-space: nowrap;
  text-overflow: ellipsis;
  margin: 0;
  overflow: hidden;
  text-decoration: none;
  vertical-align: top;
  transition: $anim-fast;
  -webkit-tap-highlight-color: transparent;
  background: transparent;
  border-color: var(--tertiary-accent-color);
  border-style: solid;
  border-width: 2px;
  color: var(--tertiary-accent-color);
  font-size: 14px;
  line-height: 1.5;
  font-weight: $bold;
  border-radius: $border-radius;
  padding: 8px 12px;

  &:active,
  &.active {
    background: var(--primary-button-bg-color);
    color: var(--primary-button-fg-color);
  }

  &[disabled],
  &:disabled {
    opacity: 0.5;
  }
}

// Primary buttons. Solid buttons.
.button-primary {
  background: var(--primary-button-bg-color);
  border-color: var(--secondary-color);
  color: var(--primary-button-fg-color);
}

// Compact buttons. Use to make buttons smaller.
.button-compact {
  padding: 0.3em 18px;
  line-height: 1.25em;
  font-size: 90%;
}

// Danger buttons
.button-danger {
  color: var(--tertiary-highlight-color);
  border-color: var(--tertiary-highlight-color);

  &:active {
    background: var(--tertiary-highlight-color);
    color: var(--background-color);
  }
}

// Borderless buttons don't have a border or background. Use it for icon or text buttons.
.button-borderless {
  border-width: 0;
  background: transparent;

  svg[class^='icon-'] {
    transition: $anim-fast;
  }
}

.button-borderless.button-danger {
  &:active {
    color: var(--tertiary-highlight-color);
  }
}

// Segmented control wrapper
.segmented-control {
  display: flex;
  flex-direction: row;

  // Individual segmented control buttons
  .button-segmented-control {
    border-radius: 0;
    border-left-width: 0;
    padding-left: 0;
    padding-right: 0;

    &:first-child {
      border-left-width: 2px;
      border-radius: $border-radius 0 0 $border-radius;
    }

    &:last-child {
      border-radius: 0 $border-radius $border-radius 0;
    }
  }
}
