/* 10 November 2021
 * rewrite: 28 November 2021
 * Infinite portals with finite DIVs
 * second in the Beauty of Nesting series
 * recommended view: Full Page
 * mvp: CSS filter (drop-shadow), pseudo-elements
 */

:root {
	--shadow-blur-size: 1.7vmax;
	--square-length: 110%;

	--stripe-pair-size: 10%;
	--stripe-pair-shift: -22%;
	--stripe-color: fuchsia;

	--rotate-duration: 10s;
	--stripe-duration: 1s;

	--background-color: radial-gradient(circle at center, hsl(300, 100%, 30%), #000);
	--foreground-color: radial-gradient(circle at center, hsl(300, 100%, 50%), transparent 40%);
}

/** relevant portion */
body > div {
	position: absolute;
	left: 50%;
	top: 50%;
	width: var(--square-length);
	height: 0;
	padding: 0 0 var(--square-length) 0;
	transform: translate(-50%, -50%) rotate(0);
	background-color: transparent;
	-webkit-animation: rotate linear var(--rotate-duration) infinite;
	animation: rotate linear var(--rotate-duration) infinite;
	filter: drop-shadow(0 0 var(--shadow-blur-size) var(--stripe-color));
}

div > div {
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	transform: rotate(90deg);
}

div::before,
div::after {
	content: '';
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	-webkit-clip-path: polygon(50% 50%, 0 0, 0 100%);
	clip-path: polygon(50% 50%, 0 0, 0 100%);

	background-image: repeating-linear-gradient(90deg, transparent 0 50%, var(--stripe-color) 50% 100%);
	background-size: var(--stripe-pair-size) 100%;
	background-position: 0% 0%;
	-webkit-animation: shift linear var(--stripe-duration) infinite;
	animation: shift linear var(--stripe-duration) infinite;

	display: block;
}

div::after {
	transform: scaleX(-1);
}

/** keyframes */
@-webkit-keyframes rotate {
	to {
		transform: translate(-50%, -50%) rotate(1turn);
	}
}
@keyframes rotate {
	to {
		transform: translate(-50%, -50%) rotate(1turn);
	}
}

@-webkit-keyframes shift {
	to {
		background-position: var(--stripe-pair-shift) 0;
	}
}

@keyframes shift {
	to {
		background-position: var(--stripe-pair-shift) 0;
	}
}

/** to have things in good shape */
*,
*::before,
*::after {
	box-sizing: border-box;
}

html,
body {
	position: relative;
	width: 100%;
	height: 100%;
	min-height: 100%;
	padding: 0;
	margin: 0;
	display: block;
	overflow: hidden;
}

body {
	background-color: transparent;
}

html {
	background-image: var(--background-color);
	background-size: 100% 100%;
	background-attachment: fixed;
}

html::after {
	content: '';
	position: fixed;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	display: block;
	background-image: var(--foreground-color);
	pointer-events: none;
}
