.tooltip {
  user-select: none; // 同步悬浮需要点击链接，因此不能使用  pointer-events: none;
  position: fixed;
  z-index: 1000000;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: normal;
  -webkit-font-smoothing: subpixel-antialiased;
  color: var(--b3-tooltips-color);
  word-wrap: break-word;
  background-color: var(--b3-tooltips-background);
  border-radius: var(--b3-border-radius);
  line-height: 17px;
  max-width: 320px;
  animation-duration: 150ms;
  animation-fill-mode: both;
  animation-name: zoomIn;
  max-height: 90vh;
  overflow: auto;
  box-sizing: border-box;
  white-space: break-spaces;

  a {
    color: var(--b3-theme-secondary);

    &:hover {
      text-decoration: underline;
    }
  }

  &--error {
    background: var(--b3-theme-error);
  }

  .ft__on-surface {
    color: var(--b3-tooltips-second-color);
  }
}

.b3-tooltips {
  position: relative;
  cursor: pointer;
  overflow: hidden;

  &::after {
    z-index: 1000000;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: normal;
    -webkit-font-smoothing: subpixel-antialiased;
    color: var(--b3-tooltips-color);
    word-wrap: break-word;
    white-space: pre;
    content: attr(aria-label);
    background-color: var(--b3-tooltips-background);
    border-radius: var(--b3-border-radius);
    line-height: 17px;
    transform: scale(.8);
    max-width: 60vw;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
    box-shadow: var(--b3-tooltips-shadow);
    font-family: var(--b3-font-family);
  }

  &::before {
    z-index: 1000001;
    width: 0;
    height: 0;
    content: "";
    border: 5px solid transparent;
    transform: scale(1.54);
  }

  &::after,
  &::before {
    pointer-events: none;
    position: absolute;
    opacity: 0;
    transition: opacity 150ms 0ms cubic-bezier(0, 0, .2, 1), transform 150ms 0ms cubic-bezier(0, 0, .2, 1);
  }

  &:hover,
  &:focus-within {
    overflow: initial;
  }

  &:hover::before,
  &:hover::after {
    display: inline-block;
    opacity: 1;
    transform: scale(1);
  }

  &__s::after,
  &__se::after,
  &__sw::after {
    top: 100%;
    right: 50%;
    margin-top: 5px
  }

  &__s::before,
  &__se::before,
  &__sw::before {
    top: auto;
    right: 50%;
    bottom: -5px;
    margin-right: -5px;
    border-bottom-color: var(--b3-tooltips-background)
  }

  &__se::after {
    right: auto;
    left: 50%;
    margin-left: -15px
  }

  &__sw::after {
    margin-right: -15px
  }

  &__n::after,
  &__ne::after,
  &__nw::after {
    right: 50%;
    bottom: 100%;
    margin-bottom: 5px
  }

  &__n::before,
  &__ne::before,
  &__nw::before {
    top: -5px;
    right: 50%;
    bottom: auto;
    margin-right: -5px;
    border-top-color: var(--b3-tooltips-background)
  }

  &__ne::after {
    right: auto;
    left: 50%;
    margin-left: -15px
  }

  &__nw::after {
    margin-right: -15px
  }

  &__s::after,
  &__n::after {
    transform: translateX(50%) scale(.8);
  }

  &__s:hover::after,
  &__n:hover::after {
    transform: translateX(50%) scale(1);
  }

  &__w::after {
    right: 100%;
    bottom: 50%;
    margin-right: 5px;
    transform: translateY(50%) scale(.8);
  }

  &__w::before {
    top: 50%;
    bottom: 50%;
    left: -5px;
    margin-top: -5px;
    border-left-color: var(--b3-tooltips-background);
  }

  &__e::after {
    bottom: 50%;
    left: 100%;
    margin-left: 5px;
    transform: translateY(50%) scale(.8);
  }

  &__e:hover::after,
  &__w:hover::after {
    transform: translateY(50%) scale(1);
  }


  &__e::before {
    top: 50%;
    right: -5px;
    bottom: 50%;
    margin-top: -5px;
    border-right-color: var(--b3-tooltips-background);
  }
}

@media screen and (max-width: 520px) {
  .b3-tooltips::before,
  .b3-tooltips::after {
    content: none;
  }
}
