@use "variables";

// Tooltips
.tooltip {
  position: relative;
  &::after {
    background: rgba(variables.$dark-color, .95);
    border-radius: variables.$border-radius;
    bottom: 100%;
    color: variables.$light-color;
    content: attr(data-tooltip);
    display: block;
    font-size: variables.$font-size-sm;
    left: 50%;
    max-width: variables.$control-width-sm;
    opacity: 0;
    overflow: hidden;
    padding: variables.$unit-1 variables.$unit-2;
    pointer-events: none;
    position: absolute;
    text-overflow: ellipsis;
    transform: translate(-50%, variables.$unit-2);
    transition: opacity .2s, transform .2s;
    white-space: pre;
    z-index: variables.$zindex-3;
  }
  &:focus,
  &:hover {
    &::after {
      opacity: 1;
      transform: translate(-50%, -(variables.$unit-1));
    }
  }
  &[disabled],
  &.disabled {
    pointer-events: auto;
  }

  &.tooltip-right {
    &::after {
      bottom: 50%;
      left: 100%;
      transform: translate(-(variables.$unit-1), 50%);
    }
    &:focus,
    &:hover {
      &::after {
        transform: translate(variables.$unit-1, 50%);
      }
    }
  }

  &.tooltip-bottom {
    &::after {
      bottom: auto;
      top: 100%;
      transform: translate(-50%, -(variables.$unit-2));
    }
    &:focus,
    &:hover {
      &::after {
        transform: translate(-50%, variables.$unit-1);
      }
    }
  }
  
  &.tooltip-left {
    &::after {
      bottom: 50%;
      left: auto;
      right: 100%;
      transform: translate(variables.$unit-2, 50%);
    }
    &:focus,
    &:hover {
      &::after {
        transform: translate(-(variables.$unit-1), 50%);
      }
    }
  }
}
