.tooltip,
#tooltip {
	$arrow-alignment: 5px;

	--tooltip-foreground-color: var(--foreground-inverted);
	--tooltip-background-color: var(--background-inverted);

	position: absolute;
	top: 0;
	left: 0;
	z-index: 850;
	display: none;
	max-width: 260px;
	padding: 4px 8px;
	color: var(--tooltip-foreground-color);
	word-break: break-word;
	background-color: var(--tooltip-background-color);
	border-radius: 4px;
	transition: opacity 200ms;

	&.inverted {
		--tooltip-foreground-color: var(--theme--foreground);
		--tooltip-background-color: var(--theme--background-subdued);
	}

	&.monospace {
		font-family: var(--theme--fonts--monospace--font-family);
	}

	&.visible {
		display: block;
	}

	&.enter,
	&.leave-active {
		opacity: 0;
	}

	&.enter-active,
	&.leave {
		opacity: 1;
	}

	&::after {
		position: absolute;
		top: -5px;
		left: calc(50% - 6px);
		width: 0;
		height: 0;
		border-right: 6px solid transparent;
		border-bottom: 6px solid var(--tooltip-background-color);
		border-left: 6px solid transparent;
		content: '';
	}

	&.start::after {
		right: $arrow-alignment;
		left: unset;
	}

	&.end::after {
		left: $arrow-alignment;
	}

	&.top::after {
		top: unset;
		bottom: -5px;
		left: calc(50% - 6px);
		border-top: 6px solid var(--tooltip-background-color);
		border-right: 6px solid transparent;
		border-bottom: unset;
		border-left: 6px solid transparent;
	}

	&.top.start::after {
		right: $arrow-alignment;
		left: unset;
	}

	&.top.end::after {
		left: $arrow-alignment;
	}

	&.left::after {
		top: calc(50% - 6px);
		right: -5px;
		left: unset;
		border-top: 6px solid transparent;
		border-right: unset;
		border-bottom: 6px solid transparent;
		border-left: 6px solid var(--tooltip-background-color);
	}

	&.left.start::after {
		top: unset;
		bottom: $arrow-alignment;
	}

	&.left.end::after {
		top: $arrow-alignment;
	}

	&.right::after {
		top: calc(50% - 6px);
		left: -5px;
		border-top: 6px solid transparent;
		border-right: 6px solid var(--tooltip-background-color);
		border-bottom: 6px solid transparent;
		border-left: unset;
	}

	&.right.start::after {
		top: unset;
		bottom: $arrow-alignment;
	}

	&.right.end::after {
		top: $arrow-alignment;
	}
}
