/*
    These styles extend and modify the existing Bootstrap popover styles.
    The Bootstrap library uses PopoverJS, a third party dependency, to create
    and display popovers.
    Popovers are written with HTML, CSS, JS. As previously stated MMUI popover styles
    are located in this document. The remainder can be found in the Bootstrap and
    PopoverJS source files.
 */
$mmui-popover-arrow-height: 16px;
$mmui-popover-arrow-width: 25px;

.mmui-popover-icon {
  color: $mm-core-digital-blue-70;
  font-size: 16px;
  cursor: pointer;
  margin-left: 8px;
  &:hover {
    color: $mm-core-digital-blue-80;
  }
}

.mmui-popover {
  padding: 16px;
  border: 0 none;
  border-radius: 0;
  box-shadow: $mm-boxshadow;
  max-width: 245px;
  .arrow {
    width: $mmui-popover-arrow-width;
    height: $mmui-popover-arrow-height;
    &::before,
    &::after {
      content: '';
      position: absolute;
      bottom: 100%;
      left: 40%;
      margin-left: -5px;
      border-width: 5px;
      border-style: solid;
      border-color: transparent transparent black transparent;
    }
  }

  .popover-body {
    color: $mm-neutral-gray-80;
    font-size: 1.4rem;
    line-height: 1.67;
    font-weight: 400;
    padding: 0;
  }

  // Offset the popover to account for the popover arrow
  .popover-header {
    background: inherit;
    border: 0 none;
    padding: 0;
    margin-bottom: 10px;

    color: $mm-neutral-gray-80;
    font-size: 1.4rem;
    line-height: 0.86;
    font-weight: 500;
    text-transform: uppercase;

    &:empty {
      display: none;
    }
  }
}

.bs-popover-top {
  margin-bottom: $mmui-popover-arrow-height;

  .arrow {
    bottom: calc(
      (#{$mmui-popover-arrow-height} + #{$popover-border-width}) * -1
    );
  }

  .arrow::before,
  .arrow::after {
    border-width: $mmui-popover-arrow-height ($mmui-popover-arrow-width / 2) 0;
  }

  .arrow::before {
    bottom: 0;
    border-top-color: $mm-neutral-white;
  }

  .arrow::after {
    bottom: $popover-border-width;
    border-top-color: $mm-neutral-white;
  }
}

.bs-popover-right {
  margin-left: $mmui-popover-arrow-height;

  .arrow {
    left: calc((#{$mmui-popover-arrow-height} + #{$popover-border-width}) * -1);
    width: $mmui-popover-arrow-height;
    height: $mmui-popover-arrow-width;
    margin: $border-radius-lg 0; // make sure the arrow does not touch the popover's rounded corners
  }

  .arrow::before,
  .arrow::after {
    border-width: ($mmui-popover-arrow-width / 2) $mmui-popover-arrow-height
      ($mmui-popover-arrow-width / 2) 0;
  }

  .arrow::before {
    left: 0;
    border-right-color: $mm-neutral-white;
  }

  .arrow::after {
    left: $popover-border-width;
    border-right-color: $mm-neutral-white;
  }
}

.bs-popover-bottom {
  margin-top: $mmui-popover-arrow-height;

  .arrow {
    top: calc((#{$mmui-popover-arrow-height} + #{$popover-border-width}) * -1);
  }

  .arrow::before,
  .arrow::after {
    border-width: 0 ($mmui-popover-arrow-width / 2) $mmui-popover-arrow-height
      ($mmui-popover-arrow-width / 2);
  }

  .arrow::before {
    top: 0;
    border-bottom-color: $mm-neutral-white;
  }

  .arrow::after {
    top: $popover-border-width;
    border-bottom-color: $mm-neutral-white;
  }

  // This will remove the popover-header's border just below the arrow
  .popover-header::before {
    position: absolute;
    top: 0;
    left: 50%;
    display: block;
    width: $mmui-popover-arrow-width;
    margin-left: ($mmui-popover-arrow-width / -2);
    content: '';
    border-bottom: $popover-border-width solid $popover-header-bg;
  }
}

.bs-popover-left {
  margin-right: $mmui-popover-arrow-height;

  .arrow {
    right: calc(
      (#{$mmui-popover-arrow-height} + #{$popover-border-width}) * -1
    );
    width: $mmui-popover-arrow-height;
    height: $mmui-popover-arrow-width;
    margin: $border-radius-lg 0; // make sure the arrow does not touch the popover's rounded corners
  }

  .arrow::before,
  .arrow::after {
    border-width: ($mmui-popover-arrow-width / 2) 0
      ($mmui-popover-arrow-width / 2) $mmui-popover-arrow-height;
  }

  .arrow::before {
    right: 0;
    border-left-color: $mm-neutral-white;
  }

  .arrow::after {
    right: $popover-border-width;
    border-left-color: $mm-neutral-white;
  }
}
