*,
*::after,
*::before {
	box-sizing: border-box;
}

body {
	/* Grid gap */
	--gap: 25px;
}

@media only screen and (min-width: 1300px) {
	body {
		--gap: 30px;
	}
}


.hidden {
	position: absolute;
	overflow: hidden;
	width: 0;
	height: 0;
	pointer-events: none;
}

/* Icons */
.icon {
	display: block;
	width: 1.5em;
	height: 1.5em;
	margin: 0 auto;
	fill: currentColor;
}

/* Page Loader */
.loading::before {
	content: '';
	position: fixed;
	z-index: 10000;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: #ccd8e4;
	background: var(--body-bg);
}

.loading::after {
	content: '';
	position: fixed;
	z-index: 10000;
	top: 50%;
	left: 50%;
	width: 80px;
	height: 80px;
	margin: -40px 0 0 -40px;
	pointer-events: none;
	background: #333;
	background: var(--body-text);
	transform-origin: 0% 50%;
	animation: loaderAnim 1.5s linear infinite alternate forwards;
}

@keyframes loaderAnim {
	0% {
		transform: scale3d(0,1,1);
		transform-origin: 0% 50%;
	}
	50% {
		transform: scale3d(1,1,1);
		transform-origin: 0% 50%;
	}
	51% {
		transform: scale3d(1,1,1);
		transform-origin: 100% 50%;
	}
	100% {
		transform: scale3d(0,1,1);
		transform-origin: 100% 50%;
	}
}

/* Frame */
.frame {
	top: 0;
	left: 0;
	position: fixed;
	display: grid;
	width: 100%;
	height: 100vh;
	z-index: 100;
	pointer-events: none;
	padding: 2em;
	grid-template-columns: 50% 50%;
	grid-template-rows: auto auto 4em;
	grid-template-areas: 	"header header"
							"... ..."
							"... demos";
}

.no-js .frame {
	position: relative;
	display: block;
	height: auto;
}

.frame a {
	pointer-events: auto;
}

.message {
	background: #333;
	background: var(--body-text);
	color: #ccd8e4;
	color: var(--body-bg);
	text-align: center;
	padding: 1em;
	display: none;
}

/* Header */
.codrops-header {
	position: relative;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	z-index: 100;
	grid-area: header;
	align-self: start;
}

.codrops-header__title {
	font-size: 1em;
	margin: 0;
	font-weight: 400;
}

.no-js .codrops-header {
	flex-direction: column;
}

.no-js .codrops-header__title {
	padding: 1em 0;
}

.github {
	margin: 0 0 0 auto;
}

/* Top Navigation Style */
.codrops-links {
	position: relative;
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin: 0 0.5em 0 0;
	text-align: center;
	white-space: nowrap;
}

.codrops-icon {
	display: inline-block;
	margin: 0 0.25em;
	padding: 0 0.25em;
}

/* Demos */
.demos {
	grid-area: demos;
	align-self: end;
	justify-self: end;
	display: block;
	text-align: center;
}


/* Grid */
.grid {
	display: grid;
	width: calc(100% - 6em);
	height: calc(100vh - 6em);
	grid-auto-rows: calc((calc(100vh - 6em) / 30) - var(--gap));
	grid-auto-columns: calc((calc(100% - 6em) / 30) - var(--gap));
	justify-content: center;
	align-content: center;
	grid-gap: var(--gap);
	pointer-events: none;
}

.no-js .grid {
	margin: 0 0 15vh;
}

.grid {
	position: absolute;
	top: 3em;
	left: 3em;
	opacity: 0;
}

.grid--current {
	opacity: 1;
	pointer-events: auto;
}

.grid__item {
	position: relative;
	padding: 1em;
	background-repeat: no-repeat;
	background-position: 50% 50%;
	background-size: cover;
	/*transition: transform 0.2s ease-out;*/
}

.grid__item--name,
.grid__item--title,
.grid__item--text {
	pointer-events: none;
	padding: 0;
	margin: 0;
}

.grid__item--name,
.grid__item--title {
	text-transform: uppercase;
	line-height: 0.8;
	font-family: 'Kanit', sans-serif;
}

.grid__item--name {
	font-size: 7vw;
	color: #ef3b3b;
	color: var(--grid-name-text);
}

.grid__item--title {
	font-size: 3.5vh;
	text-transform: uppercase;
	-webkit-writing-mode: vertical-lr;
	writing-mode: vertical-lr;
	text-align: right;
	display: flex;
	justify-content: flex-end;
	color: #ef3b3b;
	color: var(--grid-title-text);
}

.grid__item--text {
	font-size: 0.85em;
	line-height: 1.2;
	display: flex;
	color: inherit;
	color: var(--grid-text);
}

.grid__item--nav {
	background: #442ef4;
	background: var(--grid-nav-bg);
	color: #fff;
	color: var(--grid-nav-text);
	display: flex;
	align-items: center;
	cursor: pointer;
}

.grid__item--nav:hover {
	background: #1f1f1f;
	background: var(--grid-nav-bg-hover);
	color: #fff;
	color: var(--grid-nav-text-hover);
}

.grid__item--nav-next .icon--nav-arrow {
	margin: 0 0 0 auto;
}

.grid__item--nav-prev .icon--nav-arrow {
	transform: rotate(180deg);
	margin: 0;
}

.no-js .grid__item--nav {
	display: none;
}

.grid__item--animateOut {
	animation: animateOut 0.8s cubic-bezier(0.7,0,0.3,1) forwards;
}

@keyframes animateOut {
	to {
		opacity: 0;
	}
}

.grid__item--animateIn {
	animation: animateIn 0.8s cubic-bezier(0.7,0,0.3,1) forwards;
}

@keyframes animateIn {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}


.demo-2 .revealer--hideX,
.demo-2 .revealer--hideY,
.demo-2 .revealer--showX,
.demo-2 .revealer--showY,
.demo-2 .grid__item--animateOut,
.demo-2 .grid__item--animateIn {
	animation-duration: 0.6s;
}

.demo-3 .grid:not(.grid--animating) div.grid__item:not(.grid__item--nav):hover::after {
	opacity: 1;
}

@media screen and (max-width: 60em) {
	html {
		min-height: 1200px;
	}
	.message {
		display: block;
	}
	.frame {
		display: block;
		height: auto;
		position: relative;
		text-align: center;
	}
	.codrops-header {
		flex-direction: column;
	}
	.codrops-header__title {
		padding: 1em 0;
	}
	.github {
		margin: 0 auto;
	}
	.demos {
		padding: 1em 0 0;
	}
	.demo {
		margin: 0 0.5em;
	}
	main .grid {
		height: auto;
		top: auto !important;
		width: 100%;
		left: auto !important;
		padding: 0 2em;
		grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
		grid-auto-rows: auto !important;
		grid-auto-columns: auto !important;
		grid-gap: 1vw;
	}

	.grid__item {
		min-height: 50px;
		/* grid-area: auto !important; */
	}

	.grid__item br {
		content: '';
		display: none;
	}

	.grid__item--name,
	.grid__item--title,
	.grid__item--text {
		grid-column: 1 / -1 !important;
		justify-content: flex-start;
		min-height: 0;
		padding: 1vh 0;
		text-align: left !important;
	}

	.grid__item--name {
		grid-row: 1 / -1 !important;
	}

	.grid .grid__item--title {
		-webkit-writing-mode: horizontal-tb;
		writing-mode: horizontal-tb;
	}
}
