@import '../../style/themes/index';
@import '../../style/mixins/index';

@yee-tooltip-prefix-cls: ~'@{yee-prefix}-tooltip';

@yee-tooltip-arrow-shadow-width: 3px;

@yee-tooltip-arrow-rotate-width: sqrt(@yee-tooltip-arrow-width * @yee-tooltip-arrow-width * 2) +
  @yee-tooltip-arrow-shadow-width * 2;

@yee-tooltip-arrow-offset-vertical: 5px; // 8 - 3px
@yee-tooltip-arrow-offset-horizontal: 13px; // 16 - 3px

// Base class
.@{yee-tooltip-prefix-cls} {
  .yee-reset-component;

  position: absolute;
  z-index: @yee-zindex-tooltip;
  display: block;
  max-width: @yee-tooltip-max-width;
  visibility: visible;

  &-hidden {
    display: none;
  }

  &-placement-top,
  &-placement-topLeft,
  &-placement-topRight {
    padding-bottom: @yee-tooltip-distance;
  }

  &-placement-right,
  &-placement-rightTop,
  &-placement-rightBottom {
    padding-left: @yee-tooltip-distance;
  }

  &-placement-bottom,
  &-placement-bottomLeft,
  &-placement-bottomRight {
    padding-top: @yee-tooltip-distance;
  }

  &-placement-left,
  &-placement-leftTop,
  &-placement-leftBottom {
    padding-right: @yee-tooltip-distance;
  }

  // Wrapper for the tooltip content
  &-inner {
    min-width: 30px;
    min-height: 32px;
    padding: 6px 8px;
    color: @yee-tooltip-color;
    text-align: left;
    text-decoration: none;
    word-wrap: break-word;
    background-color: @yee-tooltip-bg;
    border-radius: @yee-border-radius-base;
    box-shadow: @yee-box-shadow-base;
  }

  // Arrows
  &-arrow {
    position: absolute;
    display: block;
    width: @yee-tooltip-arrow-rotate-width;
    height: @yee-tooltip-arrow-rotate-width;
    overflow: hidden;
    background: transparent;
    pointer-events: none;

    &::before {
      position: absolute;
      top: 0;
      right: 0;
      bottom: 0;
      left: 0;
      display: block;
      width: @yee-tooltip-arrow-width;
      height: @yee-tooltip-arrow-width;
      margin: auto;
      background-color: @yee-tooltip-bg;
      content: '';
      pointer-events: auto;
    }
  }

  &-placement-top &-arrow,
  &-placement-topLeft &-arrow,
  &-placement-topRight &-arrow {
    bottom: @yee-tooltip-distance - @yee-tooltip-arrow-rotate-width;

    &::before {
      box-shadow: @yee-tooltip-arrow-shadow-width @yee-tooltip-arrow-shadow-width 7px fade(@yee-black, 7%);
      transform: translateY(-@yee-tooltip-arrow-rotate-width / 2) rotate(45deg);
    }
  }

  &-placement-top &-arrow {
    left: 50%;
    transform: translateX(-50%);
  }

  &-placement-topLeft &-arrow {
    left: @yee-tooltip-arrow-offset-horizontal;
  }

  &-placement-topRight &-arrow {
    right: @yee-tooltip-arrow-offset-horizontal;
  }

  &-placement-right &-arrow,
  &-placement-rightTop &-arrow,
  &-placement-rightBottom &-arrow {
    left: @yee-tooltip-distance - @yee-tooltip-arrow-rotate-width;

    &::before {
      box-shadow: -@yee-tooltip-arrow-shadow-width @yee-tooltip-arrow-shadow-width 7px fade(@yee-black, 7%);
      transform: translateX(@yee-tooltip-arrow-rotate-width / 2) rotate(45deg);
    }
  }

  &-placement-right &-arrow {
    top: 50%;
    transform: translateY(-50%);
  }

  &-placement-rightTop &-arrow {
    top: @yee-tooltip-arrow-offset-vertical;
  }

  &-placement-rightBottom &-arrow {
    bottom: @yee-tooltip-arrow-offset-vertical;
  }

  &-placement-left &-arrow,
  &-placement-leftTop &-arrow,
  &-placement-leftBottom &-arrow {
    right: @yee-tooltip-distance - @yee-tooltip-arrow-rotate-width;

    &::before {
      box-shadow: @yee-tooltip-arrow-shadow-width -@yee-tooltip-arrow-shadow-width 7px fade(@yee-black, 7%);
      transform: translateX(-@yee-tooltip-arrow-rotate-width / 2) rotate(45deg);
    }
  }

  &-placement-left &-arrow {
    top: 50%;
    transform: translateY(-50%);
  }

  &-placement-leftTop &-arrow {
    top: @yee-tooltip-arrow-offset-vertical;
  }

  &-placement-leftBottom &-arrow {
    bottom: @yee-tooltip-arrow-offset-vertical;
  }

  &-placement-bottom &-arrow,
  &-placement-bottomLeft &-arrow,
  &-placement-bottomRight &-arrow {
    top: @yee-tooltip-distance - @yee-tooltip-arrow-rotate-width;

    &::before {
      box-shadow: -@yee-tooltip-arrow-shadow-width -@yee-tooltip-arrow-shadow-width 7px fade(@yee-black, 7%);
      transform: translateY(@yee-tooltip-arrow-rotate-width / 2) rotate(45deg);
    }
  }

  &-placement-bottom &-arrow {
    left: 50%;
    transform: translateX(-50%);
  }

  &-placement-bottomLeft &-arrow {
    left: @yee-tooltip-arrow-offset-horizontal;
  }

  &-placement-bottomRight &-arrow {
    right: @yee-tooltip-arrow-offset-horizontal;
  }
}
