.tooltip {
    position: relative;
}

.tooltip::after {
    display: block;
    background-color: var(--lighter-gray);
    border-radius: var(--radius);
    color: var(--fg);
    padding: var(--gap-half) var(--gap);
    position: absolute;
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    content: attr(data-label);
    top: 0;
    left: 50%;
    transition: all 0.07s cubic-bezier(.01,.88,.93,.07);
    transform: translate(-50%, calc(-100% - 10px));
    width: max-content;
}

.tooltip:hover::after {
    opacity: 1;
    pointer-events: all;
}

/* directions */
.tooltip[data-direction='left']::after {
    top: 50%;
    left: 0;
    transform: translate(calc(-100% - 10px), -50%);
}

.tooltip[data-direction='bottom']::after {
    top: 50%;
    left: 0;
    transform: translate(calc(-100% - 10px), 50%);
}

.tooltip[data-direction='top']::after {
    top: 0;
    left: 50%;
    transform: translate(-50%, calc(-100% - 10px));
}

.tooltip[data-direction='right']::after {
    top: 0;
    left: 50%;
    transform: translate(50%, calc(-100% - 10px));
}

/* disable on screenreader */
@media reader, speech, aural {
    .tooltip::after {
        display: none;
        content: '';
    }
}
