// Variables
$primary-color: #ccc !default;
$secondary-color: #eee !default;
$border-radius: 3px !default;
$line-height: 20px !default;
$placeholders-spacing: 20px !default;

@keyframes skeletonAnimation {
	0% {
		transform: translate3d(-30%, 0, 0);
	}

	100% {
		transform: translate3d(100%, 0, 0);
	}
}

@mixin pso-skeleton {
	position: relative;
	overflow: hidden;
	height: $line-height;
	background: $secondary-color;

	.pso-skeleton-is-rounded & {
		border-radius: $border-radius;
	}

	.pso-skeleton-is-centered & {
		margin-left: auto;
		margin-right: auto;
	}

	.pso-skeleton-is-animated &::before {
		content: '';
		position: absolute;
		top: 0;
		left: 0;
		width: 100vw;
		max-width: 1000px;
		height: 100%;
		background: linear-gradient(to right, transparent 0%, darken($secondary-color, 5%) 15%, transparent 30%);
		animation-duration: 1.5s;
		animation-fill-mode: forwards;
		animation-iteration-count: infinite;
		animation-name: skeletonAnimation;
		animation-timing-function: linear;
	}
}

@mixin placeholders-spacing {
	[class^="pso-skeleton-"] + & {
		margin-top: 2 * $placeholders-spacing;
	}
}

.pso-skeleton-heading {
	@include placeholders-spacing;
	display: flex;

	&__img {
		@include pso-skeleton;
		width: 2 * $line-height + 3 * $placeholders-spacing;
		height: 2 * $line-height + 3 * $placeholders-spacing;
		margin-right: 1.5 * $placeholders-spacing;
	}

	&__content {
		display: flex;
		flex: 1;
		flex-direction: column;
		justify-content: center;
	}

	&__title {
		@include pso-skeleton;
		width: 85%;
		margin-bottom: $placeholders-spacing;
		background: $primary-color;
	}

	&__subtitle {
		@include pso-skeleton;
		width: 90%;
	}
}

.pso-skeleton-text {
	@include placeholders-spacing;

	&__line {
		@include pso-skeleton;
		width: 100%;

		& + & {
			margin-top: $placeholders-spacing;
		}

		&:nth-child(4n + 1) {
			width: 80%;
		}

		&:nth-child(4n + 2) {
			width: 100%;
		}

		&:nth-child(4n + 3) {
			width: 70%;
		}

		&:nth-child(4n + 4) {
			width: 85%;
		}
	}
}

.pso-skeleton-img {
	@include pso-skeleton;
	@include placeholders-spacing;
	width: 100%;
	height: 120px;
}
