/* Buttons. One element, variants via data-* attributes rather than a class per combination, so a
   variant and a size compose without a `.btn-primary-small` explosion. */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-md);
  background-color: var(--color-canvas-default);
  color: var(--color-fg-default);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow-resting-xs);
  transition: background-color 0.08s ease, border-color 0.08s ease;

  &:hover:not(:disabled) {
    background-color: var(--color-canvas-subtle);
    border-color: var(--color-border-strong);
    text-decoration: none;
  }

  &:active:not(:disabled) {
    background-color: var(--color-canvas-inset);
  }

  &:focus-visible {
    outline: 2px solid var(--color-accent-emphasis);
    outline-offset: 1px;
  }

  &:disabled,
  &[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
  }
}

/* The one action a screen most wants you to take. At most one per header. */
.btn[data-variant="primary"] {
  background-color: var(--color-accent-emphasis);
  border-color: var(--color-accent-emphasis);
  color: var(--color-fg-on-emphasis);

  &:hover:not(:disabled) {
    filter: brightness(1.08);
    background-color: var(--color-accent-emphasis);
    border-color: var(--color-accent-emphasis);
  }
}

/* Posting, voiding, deleting - anything that cannot be undone by pressing it again. */
.btn[data-variant="danger"] {
  color: var(--color-danger-fg);

  &:hover:not(:disabled) {
    background-color: var(--color-danger-emphasis);
    border-color: var(--color-danger-emphasis);
    color: var(--color-fg-on-emphasis);
  }
}

/* No chrome until hovered - for the third and fourth action in a row, where four bordered buttons
   would read as four equally important choices. */
.btn[data-variant="ghost"] {
  border-color: transparent;
  background-color: transparent;
  box-shadow: none;
  color: var(--color-fg-muted);

  &:hover:not(:disabled) {
    background-color: var(--color-neutral-subtle);
    border-color: transparent;
    color: var(--color-fg-default);
  }
}

.btn[data-size="small"] {
  height: 24px;
  padding: 0 8px;
  font-size: 12px;
}

.btn[data-size="large"] {
  height: 36px;
  padding: 0 18px;
  font-size: 14px;
}

.btn[data-block="true"] {
  width: 100%;
}

/* A square icon-only button, sized to match a small button's height. */
.btn[data-icon-only="true"] {
  width: 30px;
  padding: 0;

  &[data-size="small"] {
    width: 24px;
  }
}

/* A row of buttons welded into one control - report period presets, a view switcher. */
.btn-group {
  display: inline-flex;

  & .btn {
    border-radius: 0;
    margin-left: -1px;
    box-shadow: none;

    &:first-child {
      border-radius: var(--radius-md) 0 0 var(--radius-md);
      margin-left: 0;
    }

    &:last-child {
      border-radius: 0 var(--radius-md) var(--radius-md) 0;
    }

    &[aria-pressed="true"] {
      background-color: var(--color-accent-subtle);
      border-color: var(--color-accent-emphasis);
      color: var(--color-accent-fg);
      font-weight: 600;
      z-index: 1;
    }
  }
}

/* A button whose menu opens below it - the export menu, a row's overflow actions. */
.btn-menu {
  position: relative;
  display: inline-flex;
}
