@import 'variables'; // colors, fonts etc...
@import 'mixins'; // custom mixins
@import 'layout'; // responsive grid and media queries



.cd-horizontal-timeline {
	opacity: 0;
	margin: 2em auto;
	@include transition(opacity .2s);

	&::before {
		/* never visible - this is used in jQuery to check the current MQ */
		content: 'mobile';
		display: none;
	}

	&.loaded {
		/* show the timeline after events position has been set (using JavaScript) */
		opacity: 1;
	}

	.timeline {
		position: relative;
		height: 100px;
		width: 90%;
		max-width: 800px;
		margin: 0 auto;
	}

	.events-wrapper {
		position: relative;
		height: 100%;
		margin: 0 40px;
		overflow: hidden;

		&::after, &::before {
			/* these are used to create a shadow effect at the sides of the timeline */
			content: '';
			position: absolute;
			z-index: 2;
			top: 0;
			height: 100%;
			width: 20px;
		}

		&::before {
			left: 0;
	    	@include background-image(linear-gradient(to right,$color-4, rgba($color-4, 0)));
		}

		&::after {
			right: 0;
			@include background-image(linear-gradient(to left,$color-4, rgba($color-4, 0)));
		}
	}

	.events {
		/* this is the grey line/timeline */
		position: absolute;
		z-index: 1;
		left: 0;
		top: 49px;
		height: 2px;
		/* width will be set using JavaScript */
		background: darken($color-4, 10%);
		@include transition(transform .4s);
	}

	.filling-line {
		/* this is used to create the green line filling the timeline */
		position: absolute;
		z-index: 1;
		left: 0;
		top: 0;
		height: 100%;
		width: 100%;
		background-color: $color-2;
		@include transform(scaleX(0));
		@include transform-origin(left center);
		@include transition(transform .3s);
	}

	.events a {
		position: absolute;
		bottom: 0;
		z-index: 2;
		text-align: center;
		font-size: 1.3rem;
		padding-bottom: 15px;
		color: $color-1;
		/* fix bug on Safari - text flickering while timeline translates */
		@include transform(translateZ(0));

		&::after {
			/* this is used to create the event spot */
			content: '';
			position: absolute;
			@include center(x);
			bottom: -5px;
			height: 12px;
			width: 12px;
			border-radius: 50%;
			border: 2px solid darken($color-4, 10%);
			background-color: $color-4;
			@include transition(background-color .3s, border-color .3s);
		}

		.no-touch &:hover::after {
			background-color: $color-2;
			border-color: $color-2;
		}

		&.selected {
			pointer-events: none;

			&::after {
				background-color: $color-2;
				border-color: $color-2;
			}
		}

		&.older-event::after {
			border-color: $color-2;
		}
	}

	@include MQ(L) {
		margin: 6em auto;
		
		&::before {
			/* never visible - this is used in jQuery to check the current MQ */
			content: 'desktop';
		}
	}
	.events-content {
		position: relative;
		width: 100%;
		margin: 2em 0;
		overflow: hidden;
		@include transition(height .4s);

		li {
			position: absolute;
			z-index: 1;
			width: 100%;
			left: 0;
			top: 0;
			@include transform(translateX(-100%));
			padding: 0 5%;
			opacity: 0;
			@include animation-duration(.4s);
			@include animation-timing-function(ease-in-out);

			&.selected {
				/* visible event content */
				position: relative;
				z-index: 2;
				opacity: 1;
				@include transform(translateX(0));
			}

			&.enter-right, &.leave-right {
				@include animation-name(cd-enter-right);
			}

			&.enter-left,  &.leave-left {
				@include animation-name(cd-enter-left);
			}
			
			&.leave-right, &.leave-left {
				@include animation-direction(reverse);
			}
		}
		
		li > * {
			max-width: 800px;
			margin: 0 auto;
		}

		h2 {
			font-weight: bold;
			font-size: 2.6rem;
			font-family: $secondary-font;
			font-weight: 700;
			line-height: 1.2;
		}

		em {
			display: block;
			font-style: italic;
			margin: 10px auto;

			&::before {
				content: '- ';
			}
		}

		p {
			font-size: 1.4rem;
			color: shade($color-4, 40%);
		}

		em, p {
			line-height: 1.6;
		}

		@include MQ(M) {

			h2 {
				font-size: 7rem;
			}

			em {
				font-size: 2rem;
			}

			p {
				font-size: 1.8rem;
			}
		}
		
	}
	.cd-timeline-navigation a {
		/* these are the left/right arrows to navigate the timeline */
		position: absolute;
		z-index: 1;
		@include center(y);
		height: 34px;
		width: 34px;
		border-radius: 50%;
		border: 2px solid darken($color-4, 10%);
		/* replace text with an icon */
		overflow: hidden;
		color: transparent;
		text-indent: 100%;
		white-space: nowrap;
		@include transition(border-color .3s);
		
		&::after {
			/* arrow icon */
			content: '';
			position: absolute;
			height: 16px;
			width: 16px;
			@include center;
			background: url(../img/cd-arrow.svg) no-repeat 0 0;
		}

		&.prev {
			left: 0;
			@include transform(translateY(-50%) rotate(180deg));
		}

		&.next {
			right: 0;
		}

		.no-touch &:hover {
			border-color: $color-2;
		}

		&.inactive {
			cursor: not-allowed;

			&::after {
				background-position: 0 -16px;
			}

			.no-touch &:hover {
				border-color: darken($color-4, 10%);
			}
		}
	}
}

@include keyframes(cd-enter-right) {
	0% {
		opacity: 0;
		@include transform(translateX(100%));
	}

	100% {
		opacity: 1;
		@include transform(translateX(0%));
	}
}

@include keyframes(cd-enter-left) {
	0% {
		opacity: 0;
		@include transform(translateX(-100%));
	}

	100% {
		opacity: 1;
		@include transform(translateX(0%));
	}
}
