
// Coloring support
// ============================================================

@mixin lui_nguibs_tooltip_coloring($scheme) {
	> [class*="-inner"] {
		background-color: map-get($scheme, color);
		color: map-get($scheme, text);
		@if map-get($scheme, lod) {
			text-shadow: 1px 0 1px darken(map-get($scheme, color), 5);
		}
	}
	&.left > [class*="arrow"] { border-left-color: map-get($scheme, color); }
	&.top > [class*="arrow"] { border-top-color: map-get($scheme, color); }
	&.right > [class*="arrow"] { border-right-color: map-get($scheme, color); }
	&.bottom > [class*="arrow"] { border-bottom-color: map-get($scheme, color); }
};

@if map-get($pluginVars, enabled) {
	@at-root #{$namespace} {

		#{$prefix}.tooltip {
			position: absolute;
			z-index: map-gets($pluginVars, tooltip, zIndex);
			pointer-events: none;

			& {
				$shadow: unquote(luiTheme(adjective, raised, default, filter));
				-webkit-filter: drop-shadow($shadow);
				filter: drop-shadow($shadow);
			}

			> .tooltip-inner {
				max-width: map-gets($pluginVars, tooltip, maxWidth);
			}

			> [class*="-inner"] {
				padding: map-gets($pluginVars, tooltip, verticalPadding) map-gets($pluginVars, tooltip, horizontalPadding);
				border-radius: map-gets($pluginVars, tooltip, borderRadius);
			}

			// Animations
			&:not(.in) { @include lui_is_animated("up fade out"); }
			&.fade.in { @include lui_is_animated("up fade in"); }

			// Arrow
			> [class*="arrow"] {
				width: 0; height: 0;
				position: absolute;
			}

			& {
				$triangle: 4px;

				&.left > [class*="arrow"],
				&.right > [class*="arrow"] { top: 50%; transform: translateY(-50%); }

				&.left { margin-right: (2 * $triangle); }
				&.left > [class*="arrow"] {  @include lui_points_towards(right, #CCC, $triangle); left: 100%!important; right: auto!important; }

				&.right { margin-left: (2 * $triangle); }
				&.right > [class*="arrow"] {  @include lui_points_towards(left, #CCC, $triangle); left: auto!important; right: 100% !important; }

				&.top > [class*="arrow"],
				&.bottom > [class*="arrow"] { left: 50%; transform: translateX(-50%); }

				&.top { margin-bottom: (2 * $triangle); }
				&.top > [class*="arrow"] {  @include lui_points_towards(bottom, #CCC, $triangle); bottom: auto!important; top: 100%!important; }

				&.bottom { margin-top: (2 * $triangle); }
				&.bottom > [class*="arrow"] {  @include lui_points_towards(top, #CCC, $triangle); top: auto!important; bottom: 100%!important; }
			}

			// Extras!
			&.topleft, &.top-left, &.bottomleft, &.bottom-left {
				> [class*="arrow"] {
					left: 0; right: auto;
					transform: translateX(50%);
				}
			}
			&.topright, &.top-right, &.bottomright, &.bottom-right {
				> [class*="arrow"] {
					left: auto; right: 0;
					transform: translateX(-50%);
				}
			}
			&.leftTop, &.left-top, &.rightTop, &.right-top {
				> [class*="arrow"] {
					top: 0; bottom: auto;
					transform: translateY(50%);
				}
			}
			&.leftBottom, &.left-bottom, &.rightBottom, &.right-bottom {
				> [class*="arrow"] {
					bottom: 0; top: auto;
					transform: translateY(-50%);
				}
			}
		}


		// Coloring support
		// ============================================================

		#{$prefix}.tooltip {
			@include lui_nguibs_tooltip_coloring(map-gets($pluginVars, tooltip, defaultColoring));

			@each $name, $scheme in luiPalettes() {
				&.#{map-get($scheme, class)} {
					@include lui_nguibs_tooltip_coloring($scheme);
				}
			}
		}
	}
}
