//
// Popovers
// --------------------------------------------------

.popover {
  position: absolute;
  top: 0;
  left: 0;
  z-index: $zindex-popover;
  display: none;
  padding: 1px;

  // Our parent element can be arbitrary since popovers 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;

  background-clip: padding-box;
  border-radius: $border-radius-new-medium;
  font-size: $font-size-base;
  line-height: $grid-unit-y * 2;
  font-weight: $font-weight-medium;

  @include box-shadow-themes(popover-box-shadow);
  @include themes(color, color-new-heading);
  @include themes(background-color, popover-bg);

  // Offset the popover to account for the popover arrow
  &.top {
    margin-top: -$popover-arrow-width;
  }
  &.right {
    margin-left: $popover-arrow-width;
  }
  &.bottom {
    margin-top: $popover-arrow-width;
  }
  &.left {
    margin-left: -$popover-arrow-width;
  }

  // Arrows
  // .arrow is outer, .arrow:after is inner
  > .arrow {
    border-width: $popover-arrow-outer-width;

    &,
    &:after {
      position: absolute;
      display: block;
      width: 0;
      height: 0;
      border-color: transparent;
      border-style: solid;
    }

    &:after {
      content: "";
      border-width: $popover-arrow-width;
    }
  }

  &.top > .arrow {
    bottom: -$popover-arrow-outer-width;
    left: 50%;
    margin-left: -$popover-arrow-outer-width;
    border-top-width: 0;
    border-bottom-width: 0;

    &:after {
      bottom: 1px;
      margin-left: -$popover-arrow-width;
      content: " ";
      border-bottom-width: 0;

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

  &.right > .arrow {
    top: 50%;
    left: -$popover-arrow-outer-width;
    margin-top: -$popover-arrow-outer-width;
    border-right-width: 0;
    border-left-width: 0;

    &:after {
      bottom: -$popover-arrow-width;
      left: 1px;
      content: " ";
      border-left-width: 0;

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

  &.bottom > .arrow {
    top: -$popover-arrow-outer-width;
    left: 50%;
    margin-left: -$popover-arrow-outer-width;
    border-top-width: 0;
    border-bottom-width: 0;

    &:after {
      top: 1px;
      margin-left: -$popover-arrow-width;
      content: " ";
      border-top-width: 0;

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

  &.left > .arrow {
    top: 50%;
    right: -$popover-arrow-outer-width;
    margin-top: -$popover-arrow-outer-width;
    border-right-width: 0;
    border-left-width: 0;

    &:after {
      right: 1px;
      bottom: -$popover-arrow-width;
      content: " ";
      border-right-width: 0;

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

  &-title {
    padding: $padding-base-horizontal $padding-base-horizontal;
    margin: 0;
    border-radius: ($border-radius-large - 1) ($border-radius-large - 1) 0 0;
    line-height: $grid-unit-y * 3;

    @include text-responsive($font-size-h4);

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

  &-content {
    padding: $padding-base-horizontal $padding-base-horizontal;
    overflow-y: hidden;

    @include styled-scroll-vert();
  }

  &-offset {
    margin: -$padding-base-horizontal;
  }

  .list-group {
    @include popover-list-group();
  }
}
