.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip:before, .tooltip:after {
  position: absolute;
  opacity: 0;
  clip: rect(0 0 0 0);
  -webkit-clip-path: inset(100%);
  clip-path: inset(100%);
  transition: all 0.3s;
  z-index: 1010;
  left: 50%;
}

.tooltip:not(.bottom):before, .tooltip:not(.bottom):after {
  bottom: 75%;
}

.tooltip.bottom:before, .tooltip.bottom:after {
  top: 75%;
}

.tooltip:hover:before, .tooltip:hover:after, .tooltip:focus:before, .tooltip:focus:after {
  opacity: 1;
  clip: auto;
  -webkit-clip-path: inset(0%);
  clip-path: inset(0%);
}

.tooltip:before {
  content: '';
  background: transparent;
  border: 0.5rem solid transparent;
  left: calc(50% - 0.5rem);
}

.tooltip:not(.bottom):before {
  border-top-color: #212121;
}

.tooltip.bottom:before {
  border-bottom-color: #212121;
}

.tooltip:after {
  content: attr(aria-label);
  color: #fafafa;
  background: #212121;
  border-radius: 0.125rem;
  padding: 0.5rem;
  white-space: nowrap;
  transform: translateX(-50%);
}

.tooltip:not(.bottom):after {
  margin-bottom: 1rem;
}

.tooltip.bottom:after {
  margin-top: 1rem;
}
