//
// Tooltips
// --------------------------------------------------

.tooltip {
  position: absolute;
  z-index: $zindex-tooltip;
  display: block;

  // Our parent element can be arbitrary since tooltips are by default inserted as a sibling of their target element.
  // So reset our font and text properties to avoid inheriting weird values.
  @include reset-text;

  font-size: $tooltip-font-size;
  font-family: $font-family-proxima-sbold;

  @include opacity(0);

  &.in {
    @include opacity($tooltip-opacity);
  }
  &.top {
    padding: $tooltip-arrow-width 0;
    margin-top: -3px;
  }
  &.right {
    padding: 0 $tooltip-arrow-width;
    margin-left: 3px;
  }
  &.bottom {
    padding: $tooltip-arrow-width 0;
    margin-top: 3px;
  }
  &.left {
    padding: 0 $tooltip-arrow-width;
    margin-left: -3px;
  }

  &-inner {
    max-width: $tooltip-max-width;
    text-align: center;
    border-radius: $tooltip-border-radius;
    padding: $padding-xs-vertical $padding-small-horizontal;
    line-height: $grid-unit-y * 2;

    @include box-shadow-themes(popover-box-shadow);

    @include themes(color, tooltip-color);
    @include themes(background-color, tooltip-bg);
  }

  &-arrow {
    position: absolute;
    width: 0;
    height: 0;
    border-color: transparent;
    border-style: solid;
  }

  // Note: Deprecated .top-left, .top-right, .bottom-left, and .bottom-right as of v3.3.1
  &.top .tooltip-arrow {
    bottom: 0;
    left: 50%;
    margin-left: -$tooltip-arrow-width;
    border-width: $tooltip-arrow-width $tooltip-arrow-width-2 0;

    @include themes(border-top-color, tooltip-arrow-color);
  }

  &.top-left .tooltip-arrow {
    right: $tooltip-arrow-width;
    bottom: 0;
    margin-bottom: -$tooltip-arrow-width;
    border-width: $tooltip-arrow-width $tooltip-arrow-width-2 0;

    @include themes(border-top-color, tooltip-arrow-color);
  }

  &.top-right .tooltip-arrow {
    bottom: 0;
    left: $tooltip-arrow-width;
    margin-bottom: -$tooltip-arrow-width;
    border-width: $tooltip-arrow-width $tooltip-arrow-width-2 0;

    @include themes(border-top-color, tooltip-arrow-color);
  }

  &.right .tooltip-arrow {
    top: 50%;
    left: 0;
    margin-top: -$tooltip-arrow-width-2;
    border-width: $tooltip-arrow-width-2 $tooltip-arrow-width
      $tooltip-arrow-width-2 0;

    @include themes(border-right-color, tooltip-arrow-color);
  }

  &.left .tooltip-arrow {
    top: 50%;
    right: 0;
    margin-top: -$tooltip-arrow-width-2;
    border-width: $tooltip-arrow-width-2 0 $tooltip-arrow-width-2
      $tooltip-arrow-width;

    @include themes(border-left-color, tooltip-arrow-color);
  }

  &.bottom .tooltip-arrow {
    top: 0;
    left: 50%;
    margin-left: -$tooltip-arrow-width;
    border-width: 0 $tooltip-arrow-width-2 $tooltip-arrow-width;

    @include themes(border-bottom-color, tooltip-arrow-color);
  }

  &.bottom-left .tooltip-arrow {
    top: 0;
    right: $tooltip-arrow-width;
    margin-top: -$tooltip-arrow-width;
    border-width: 0 $tooltip-arrow-width-2 $tooltip-arrow-width;

    @include themes(border-bottom-color, tooltip-arrow-color);
  }

  &.bottom-right .tooltip-arrow {
    top: 0;
    left: $tooltip-arrow-width;
    margin-top: -$tooltip-arrow-width;
    border-width: 0 $tooltip-arrow-width-2 $tooltip-arrow-width;

    @include themes(border-bottom-color, tooltip-arrow-color);
  }

  // Color variation
  // ----------------------

  &-light {
    .tooltip-inner {
      background-color: $color-white;
      color: $color-text-dark;

      @include themes(background-color, tooltip-light-bg);
      @include themes(color, tooltip-light-color);

      @include box-shadow-themes(popover-box-shadow);
    }

    &.top .tooltip-arrow {
      @include themes(border-top-color, tooltip-light-arrow-color);
    }

    &.top-left .tooltip-arrow {
      @include themes(border-top-color, tooltip-light-arrow-color);
    }

    &.top-right .tooltip-arrow {
      @include themes(border-top-color, tooltip-light-arrow-color);
    }

    &.right .tooltip-arrow {
      @include themes(border-right-color, tooltip-light-arrow-color);
    }

    &.left .tooltip-arrow {
      @include themes(border-left-color, tooltip-light-arrow-color);
    }

    &.bottom .tooltip-arrow {
      @include themes(border-bottom-color, tooltip-light-arrow-color);
    }

    &.bottom-left .tooltip-arrow {
      @include themes(border-bottom-color, tooltip-light-arrow-color);
    }

    &.bottom-right .tooltip-arrow {
      @include themes(border-bottom-color, tooltip-light-arrow-color);
    }
  }
}
