@use 'variables' as *;
@use '@xui/theme-core' as core;

@mixin theme() {
  .x-tooltip {
    position: relative;
    max-width: 500px;
    padding: 6px 12px;
    margin: 7px; // margin for the arrows

    @include core.border-radius($border-radius);
    @include core.fill(tertiary);
    @include core.elevate(medium);
    @include core.typography-level(body-2);

    font-weight: 500;
  }

  .x-tooltip-top::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;

    margin-left: -5px;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 7px solid var(--color-bg-tertiary);
  }

  .x-tooltip-bottom::after {
    content: '';
    position: absolute;
    top: -7px;
    left: 50%;

    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 7px solid var(--color-bg-tertiary);
  }

  .x-tooltip-right::after {
    content: '';
    position: absolute;
    top: 50%;
    left: -7px;
    margin-top: -4px;

    border-top: 5px solid transparent;
    border-right: 7px solid var(--color-bg-tertiary);
    border-bottom: 5px solid transparent;
  }

  .x-tooltip-left::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -7px;
    margin-top: -4px;

    border-top: 5px solid transparent;
    border-left: 7px solid var(--color-bg-tertiary);
    border-bottom: 5px solid transparent;
  }

  .x-tooltip-show {
    animation: x-tooltip-show 150ms cubic-bezier(0, 0, 0.2, 1) forwards;
  }

  .x-tooltip-hide {
    animation: x-tooltip-hide 75ms cubic-bezier(0.4, 0, 1, 1) forwards;
  }

  @keyframes x-tooltip-show {
    0% {
      opacity: 0;
      transform: scale(0.8);
    }

    100% {
      opacity: 1;
      transform: scale(1);
    }
  }

  @keyframes x-tooltip-hide {
    0% {
      opacity: 1;
      transform: scale(1);
    }

    100% {
      opacity: 0;
      transform: scale(0.8);
    }
  }
}
