@import 'mixins/mixins';
@import 'common/var';

@include b(popper) {
  position: absolute;
  border-radius: $--popover-border-radius;
  padding: 10px;
  z-index: 2000;
  font-size: 12px;
  line-height: 1.2;
  min-width: 10px;
  word-wrap: break-word;
  visibility: visible;

  $arrow-selector: #{& + '__arrow'};

  @include when(dark) {
    color: $--color-white;
    background: $--color-text-primary;
    #{$arrow-selector}::before {
      background: $--color-text-primary;
      right: 0;
    }
  }

  @include when(light) {
    background: $--color-white;
    border: 1px solid $--border-color-light;

    #{$arrow-selector}::before {
      border: 1px solid $--border-color-light;
      background: $--color-white;
      right: 0;
    }
  }

  @include when(pure) {
    padding: 0;
  }

  @include e(arrow) {
    position: absolute;
    width: 10px;
    height: 10px;
    z-index: -1;

    &::before {
      position: absolute;
      width: 10px;
      height: 10px;
      z-index: -1;
      content: ' ';
      transform: rotate(45deg);
      background: $--color-text-primary;
      box-sizing: border-box;
    }
  }

  $placements: (
    'top': 'bottom',
    'bottom': 'top',
    'left': 'right',
    'right': 'left',
  );

  @each $placement, $opposite in $placements {
    &[data-popper-placement^='#{$placement}'] > #{$arrow-selector} {
      #{$opposite}: -5px;
    }
  }

  @each $placement,
    $adjacency
      in ('top': 'left', 'bottom': 'right', 'left': 'bottom', 'right': 'top')
  {
    &.is-light[data-popper-placement^='#{$placement}'] {
      #{$arrow-selector}::before {
        border-#{$placement}-color: transparent;
        border-#{$adjacency}-color: transparent;
      }
    }
  }
}
