// BuddyPress Tooltips
// @version 3.0.0

@import "vendors/hint/hint";

//
// Mixins
// -----------------------------------------

@mixin svg-arrow ($color, $position: up) {

	$degrees: 0;
	$height:  6px;
	$width:   18px;

	@if ($position == down) {
		$degrees: 180 18 6;
	} @else if ($position == left) {
		$degrees: -90 18 18;
		$width: 6px;
		$height: 18px;
	} @else if ($position == right) {
		$degrees: 90 6 6;
		$width: 6px;
		$height: 18px;
	}

	background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%22#{$width * 2}%22%20height%3D%22#{$height * 2}%22%3E%3Cpath%20fill%3D%22#{$color}%22%20transform%3D%22rotate(#{$degrees})%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
	background-size: 100% auto;
	width: $width;
	height: $height;
}

@mixin transition ($args...) {
	transition: $args;
}

@mixin transform ($val) {
	transform: $val;
}

@mixin transform-origin ($val) {
	transform-origin: $val;
}

@mixin opacity ($trans) {
	opacity: $trans;
}

@mixin base-effects () {
	pointer-events: none;

	@include opacity(0);
	@include transition(all 0.18s ease-out 0.18s);
}

@mixin no-effects () {

	@include transition(none);
}

@mixin normalized-text() {
	font-weight: 500;
	font-size: 13px;
	letter-spacing: -0.24px;
}

//
// Styles
// -----------------------------------------

// IE 11 button bugfix
button[data-bp-tooltip] {
	overflow: visible;
}

[data-bp-tooltip] {
	position: relative; // alt. absolute or fixed

	// Fixing iOS Safari event issue. More info at: https://goo.gl/w8JF4W
	cursor: pointer;
	display: block;

	&:after {

		@include base-effects();
		@include normalized-text();

		background: $tooltip-background;
		border-radius: 4px;
		box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.22);
		color: $white;
		content: attr(data-bp-tooltip);
		line-height: 1.3;
		padding: 7px 15px;
		position: absolute;
		white-space: nowrap;
		z-index: 10;
	}

	&:before {

		@include svg-arrow($tooltip-background);
		@include base-effects();

		content: "";
		position: absolute;
		z-index: 10;
	}

	&:hover,
	&[data-bp-tooltip-visible] {

		&:before,
		&:after {

			@include opacity(1);
			pointer-events: auto;
		}
	}

	&.font-awesome:after {
		font-family: FontAwesome;
	}

	&[data-bp-tooltip-break] {

		&:after {
			white-space: pre;
		}
	}

	&[data-bp-tooltip-blunt] {

		&:before,
		&:after {

			@include no-effects();
		}
	}

	&[data-bp-tooltip-pos="up"] {

		&:after {
			bottom: 100%;
			left: 50%;
			margin-bottom: 5px + $tooltip-arrow-height;

			@include transform(translate(-50%, 10px));
			@include transform-origin(top);
		}

		&:before {
			bottom: 100%;
			left: 50%;
			margin-bottom: 5px;

			@include transform(translate(-50%, 10px));
			@include transform-origin(top);
		}

		&:hover,
		&[data-bp-tooltip-visible] {

			&:after {

				@include transform(translate(-50%, 0));
			}

			&:before {

				@include transform(translate(-50%, 0));
			}
		}
	}

	&[data-bp-tooltip-pos="up-left"] {

		&:after {
			bottom: 100%;
			left: 0;
			margin-bottom: 5px + $tooltip-arrow-height;

			@include transform(translate(0, 10px));
			@include transform-origin(top);
		}

		&:before {
			bottom: 100%;
			left: 5px;
			margin-bottom: 5px;

			@include transform(translate(0, 10px));
			@include transform-origin(top);
		}

		&:hover,
		&[data-bp-tooltip-visible] {

			&:after {

				@include transform(translate(0, 0));
			}

			&:before {

				@include transform(translate(0, 0));
			}
		}
	}

	&[data-bp-tooltip-pos="up-right"] {

		&:after {
			bottom: 100%;
			right: 0;
			margin-bottom: 5px + $tooltip-arrow-height;

			@include transform(translate(0, 10px));
			@include transform-origin(top);
		}

		&:before {
			bottom: 100%;
			right: 5px;
			margin-bottom: 5px;

			@include transform(translate(0, 10px));
			@include transform-origin(top);
		}

		&:hover,
		&[data-bp-tooltip-visible] {

			&:after {

				@include transform(translate(0, 0));
			}

			&:before {

				@include transform(translate(0, 0));
			}
		}
	}

	&[data-bp-tooltip-pos="down"] {

		&:after {
			left: 50%;
			margin-top: 5px + $tooltip-arrow-height;
			top: 100%;

			@include transform(translate(-50%, -10px));
		}

		&:before {
			left: 50%;
			margin-top: 5px;
			top: 100%;

			@include svg-arrow($tooltip-background, "down");
			@include transform(translate(-50%, -10px));
		}

		&:hover,
		&[data-bp-tooltip-visible] {

			&:after {

				@include transform(translate(-50%, 0));
			}

			&:before {

				@include transform(translate(-50%, 0));
			}
		}
	}

	&[data-bp-tooltip-pos="down-left"] {

		&:after {
			left: 0;
			margin-top: 5px + $tooltip-arrow-height;
			top: 100%;

			@include transform(translate(0, -10px));
		}

		&:before {
			left: 5px;
			margin-top: 5px;
			top: 100%;

			@include svg-arrow($tooltip-background, "down");
			@include transform(translate(0, -10px));
		}

		&:hover,
		&[data-bp-tooltip-visible] {

			&:after {

				@include transform(translate(0, 0));
			}

			&:before {

				@include transform(translate(0, 0));
			}
		}
	}

	&[data-bp-tooltip-pos="down-right"] {

		&:after {
			right: 0;
			margin-top: 5px + $tooltip-arrow-height;
			top: 100%;

			@include transform(translate(0, -10px));
		}

		&:before {
			right: 5px;
			margin-top: 5px;
			top: 100%;

			@include svg-arrow($tooltip-background, "down");
			@include transform(translate(0, -10px));
		}

		&:hover,
		&[data-bp-tooltip-visible] {

			&:after {

				@include transform(translate(0, 0));
			}

			&:before {

				@include transform(translate(0, 0));
			}
		}
	}

	&[data-bp-tooltip-pos="left"] {

		&:after {
			margin-right: 5px + $tooltip-arrow-height;
			right: 100%;
			top: 50%;

			@include transform(translate(10px, -50%));
		}

		&:before {
			margin-right: 5px;
			right: 100%;
			top: 50%;

			@include svg-arrow($tooltip-background, "left");
			@include transform(translate(10px, -50%));
		}

		&:hover,
		&[data-bp-tooltip-visible] {

			&:after {

				@include transform(translate(0, -50%));
			}

			&:before {

				@include transform(translate(0, -50%));
			}
		}
	}

	&[data-bp-tooltip-pos="right"] {

		&:after {
			left: 100%;
			margin-left: 5px + $tooltip-arrow-height;
			top: 50%;

			@include transform(translate(-10px, -50%));
		}

		&:before {
			left: 100%;
			margin-left: 5px;
			top: 50%;

			@include svg-arrow($tooltip-background, "right");
			@include transform(translate(-10px, -50%));
		}

		&:hover,
		&[data-bp-tooltip-visible] {

			&:after {

				@include transform(translate(0, -50%));
			}

			&:before {

				@include transform(translate(0, -50%));
			}
		}
	}

	&[data-bp-tooltip-length="small"] {

		&:after {
			white-space: normal;
			width: 80px;
		}
	}

	&[data-bp-tooltip-length="medium"] {

		&:after {
			white-space: normal;
			width: 150px;
		}
	}

	&[data-bp-tooltip-length="large"] {

		&:after {
			white-space: normal;
			width: 260px;
		}
	}

	&[data-bp-tooltip-length="xlarge"] {

		&:after {
			white-space: normal;
			width: 380px;

			@media screen and (max-width: 768px) {
				white-space: normal;
				width: 90vw;
			}
		}
	}

	&[data-bp-tooltip-length="fit"] {

		&:after {
			white-space: normal;
			width: 100%;
		}
	}
}

.post-emoji.bp-tooltip.active {

	&[data-bp-tooltip] {

		&:after,
		&:before {
			display: none;
		}
	}
}
