@use 'sass:math';

$info-icon-size: 0.5625rem;
$info-tooltip-arrow-size: 0.625rem;
$info-tooltip-center: calc(50% - #{math.div($info-icon-size, 2)});

.Tooltip {
  position: relative;
  display: inline-block;

  &:hover {
    cursor: pointer;
    .tooltip-content {
      transition: opacity 250ms;
      opacity: 1;
      pointer-events: auto;
    }
    // Bridging the gap to the tooltip to keep it hovered
    &:after {
      content: "";
      width: #{$info-tooltip-arrow-size + 0.75rem};
      position: absolute;
      left: 100%;
      height: 100%;
    }
  }

  .tooltip-content {
    font-size: 1rem;
    line-height: 1.4375rem;
    transition: opacity 250ms;
    opacity: 0;
    pointer-events: none;
    position: absolute;
    left: calc(100% + #{$info-tooltip-arrow-size + 0.75rem});
    bottom: $info-tooltip-center;
    transform: translateY($info-tooltip-center);
    padding: 1rem 1.25rem 1rem;
    background: rgba($martinique, 0.95);
    border-radius: 0.75rem;
    width: max-content;
    max-width: 15rem;
    @include medium {
      max-width: 30vw;
    }
    color: $white;
    z-index: 2;
    &:before {
      content: "";
      width: 0;
      height: 0;
      border-top: $info-tooltip-arrow-size solid transparent;
      border-bottom: $info-tooltip-arrow-size solid transparent;
      border-right: $info-tooltip-arrow-size solid rgba($martinique, 0.95);
      position: absolute;
      left: -$info-tooltip-arrow-size;
      bottom: $info-tooltip-center;
      transform: translateY($info-tooltip-center);
    }
    a {
      color: $cyan;
    }
  }

  &.right {
    &:hover {
      &:after {
        left: -100%;
      }
    }

    .tooltip-content {
      right: calc(-100% + #{$info-tooltip-arrow-size + 1.5rem});
      left: auto;
      &:before {
        right: -$info-tooltip-arrow-size;
        left: auto;
        border-top: $info-tooltip-arrow-size solid transparent;
        border-bottom: $info-tooltip-arrow-size solid transparent;
        border-left: $info-tooltip-arrow-size solid rgba($martinique, 0.95);
        border-right: none;
      }
    }
  }
}
