@use "@gloria/layout/_mixins.scss" as *;

.c-tooltip-popover {
	--tooltip-background-color: var(--color-secondary-600);
	--tooltip-text-color: var(--color-gray-100);

	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--spacing-2);
	position: absolute;
	background-color: var(--tooltip-background-color);
	color: var(--tooltip-text-color);
	padding: var(--spacing-0-5) var(--spacing-2);
	margin: 0;
	border-radius: var(--radius-1);
	line-height: var(--font-size-2xl);
	font-size: var(--font-size-xs);
	z-index: var(--z-index-tooltip);
	opacity: 0;
	visibility: hidden;
	max-width: 22rem;
	min-height: 36px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	transform: translateY(-4px);
	pointer-events: none;
	will-change: transform, opacity, visibility;
	transition:
		opacity var(--duration-normal) var(--cbuc-cubic-out),
		visibility var(--duration-normal) var(--cbuc-cubic-out),
		transform var(--duration-normal) var(--cbuc-cubic-out);

	@include mobile {
		&[data-disable-on-mobile="true"] {
			display: none;
		}
	}

	&:has(.c-tooltip-popover__icon) {
		padding: var(--spacing-1) var(--spacing-3);
	}

	&::before {
		content: '';
		position: absolute;
		top: -10px;
		left: -10px;
		right: -10px;
		bottom: -10px;
		z-index: -1;
	}

	.c-icon {
		position: relative;
		top: -0.5px;
	}

	&__icon {
		display: inline-flex;
		padding: 3px;
		aspect-ratio: 1;
		color: var(--tooltip-text-color);
		border: 1px solid currentColor;
		border-radius: 100%;
		flex-shrink: 0;
	}

	&__text {
		flex-grow: 1;
		line-height: 1.1rem;
	}

	&__close-button {
		display: flex;
		align-items: center;
		justify-content: center;
		min-width: var(--spacing-4);
		height: var(--spacing-4);
		font-size: var(--font-size-xs);
		background: none;
		border: none;
		padding: 0;
		cursor: pointer;
		color: var(--tooltip-text-color);
		opacity: 1;
		transition: opacity var(--duration-normal) ease;
		margin-left: auto;
		flex-shrink: 0;

		&:hover,
		&:focus {
			opacity: 0.7;
		}
	}

	&__arrow {
		position: absolute;
		width: 0;
		height: 0;
		border-style: solid;
	}

	&:not(.is-mounted) {
		width: 0;
		height: 0;
		padding: 0;
	}

	&.is-visible {
		opacity: 1;
		visibility: visible;
		transform: translateY(0);
		pointer-events: auto;
	}

	&--top {
		margin-bottom: 8px;
		transform: translateY(4px);

		.c-tooltip-popover__arrow {
			bottom: -7px;
			left: 50%;
			transform: translateX(-50%);
			border-width: 8px 8px 0 8px;
			border-color: var(--tooltip-background-color) transparent transparent transparent;
		}
	}

	&--bottom {
		margin-top: 8px;
		transform: translateY(-4px);

		.c-tooltip-popover__arrow {
			top: -7px;
			left: 50%;
			transform: translateX(-50%);
			border-width: 0 8px 8px 8px;
			border-color: transparent transparent var(--tooltip-background-color) transparent;
		}
	}

	&--top-start {
		margin-bottom: 8px;
		transform: translateY(4px);

		.c-tooltip-popover__arrow {
			bottom: -7px;
			border-width: 8px 8px 0 8px;
			border-color: var(--tooltip-background-color) transparent transparent transparent;
		}
	}

	&--bottom-start {
		margin-top: 8px;
		transform: translateY(-4px);

		.c-tooltip-popover__arrow {
			top: -7px;
			border-width: 0 8px 8px 8px;
			border-color: transparent transparent var(--tooltip-background-color) transparent;
		}
	}

	&--top-end {
		margin-bottom: 8px;
		transform: translateY(4px);

		.c-tooltip-popover__arrow {
			bottom: -7px;
			border-width: 8px 8px 0 8px;
			border-color: var(--tooltip-background-color) transparent transparent transparent;
		}
	}

	&--bottom-end {
		margin-top: 8px;
		transform: translateY(-4px);

		.c-tooltip-popover__arrow {
			top: -7px;
			border-width: 0 8px 8px 8px;
			border-color: transparent transparent var(--tooltip-background-color) transparent;
		}
	}

	&--dark {
		--tooltip-background-color: var(--color-secondary-700);
		--tooltip-text-color: var(--color-common-white);

		.c-tooltip-popover__icon {
			color: var(--color-warning-light);
		}
	}
}
