@use '../../variables' as *;

$transition: all 0.2s ease-out;

.wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: $space-s;
  width: 100%;
  height: 32px;
  padding: 0;
  color: var(--color-neutral-20);
  background: transparent;
  border: none;
  outline: none;
  opacity: 1;
  transition: $transition;

  view-transition-name: match-element;

  cursor: pointer;

  &:focus {
    outline: none;
  }

  &:focus-visible,
  &:hover {
    color: var(--color-accent-30);

    .background {
      background: rgba(var(--color-accent-30-rgb), 0.08);
      border-color: var(--color-accent-50);
    }

    .key {
      background: rgba(var(--color-accent-30-rgb), 0.16);
      border-color: transparent;
    }
  }
}

.wrapper[data-compressed='true'] {
  width: 32px;
  height: 32px;
}

.wrapper[data-inverted='true'] {
  filter: invert(1) hue-rotate(180deg);
}

.wrapper[data-inverted='true'] .icon i {
  color: var(--color-neutral-20);
}

.wrapper[data-centered='true'] {
  justify-content: center;
  align-items: center;
  text-align: center;
}

.wrapper[data-centered='true'] .label {
  flex: 0;
}

.wrapper[data-centered='true'] .icon {
  width: auto;
}

// Animations
.wrapper:not([data-compressed='true']) {
  &:hover .background {
    transform: scaleY(1.1) scaleX(1.02);
  }

  // Shrink the next sibling when this button is hovered
  &:hover + & .background {
    transform: scaleY(0.9) translateY(1px);
  }

  // Shrink the previous sibling when this button is hovered
  &:has(+ &:hover) .background {
    transform: scaleY(0.9) translateY(-1px);
  }
}

.wrapper[data-compressed='true'] {
  &:hover .background {
    transform: scale(1.1);
  }

  &:hover + & .background {
    transform: scaleX(0.9) translateX(1px);
  }

  &:has(+ &:hover) .background {
    transform: scaleX(0.9) translateX(-1px);
  }
}

.background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.04);
  border-radius: var(--border-radius-small);
  border: 1px solid transparent;
  pointer-events: none;
  transition: $transition;
}

.icon {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;

  i {
    color: var(--color-accent-30);
  }
}

.label {
  flex: 1;
  text-align: left;
  font-weight: 400;
  white-space: nowrap;
}

.shortcut {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: $space-xs;
  padding: 0 6px;
}

.key {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.04);
  border-radius: var(--border-radius-tiny);
  border: 1px solid rgba(0, 0, 0, 0.12);
  font-family: var(--font-family-mono);
  transition: $transition;
}

// Modifiers

.wrapper[data-hidden='true'] {
  opacity: 0;
  visibility: hidden;
}
