@keyframes shift {
0% {
transform: translate(0, 0);
}
to {
transform: translate(0, 24px);
}
}
@keyframes movedown {
0% {
transform: translate(0, 24px);
}
to {
transform: translate(96px, 288px);
}
}
@keyframes movedown1 {
0% {
transform: translate(0, 24px);
}
to {
transform: translate(-96px, 288px);
}
}
@keyframes movedown2 {
0% {
transform: translate(0, 24px) rotateZ(90deg);
}
to {
transform: translate(24px, 288px) rotateZ(360deg);
}
}
@keyframes movedown3 {
0% {
transform: translate(0, 24px) rotateZ(-270deg);
}
to {
transform: translate(-11px, 276px) rotateZ(270deg);
}
}
@keyframes colortetris {
0% {
background: linear-gradient(to top, var(--border) 0, var(--bg) 24px)
no-repeat;
}
to {
background: linear-gradient(to top, var(--screen) 0%, var(--screen) 24px)
no-repeat;
}
}
/* Block: tetris */
.tetris {
--border: var(--theme-text-color);
--bg: var(--theme-base-color);
--screen: var(--theme-bg-color);
display: block;
position: relative;
height: 288px;
width: 289px;
background: var(--screen);
box-shadow: 0 0 0 1px var(--border) inset;
overflow: hidden;
}
/* Element: tetris__block */
.tetris__block {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: block;
font-size: 1.5em;
text-align: center;
letter-spacing: 0.1em;
line-height: 3;
}
.tetris__block::before {
content: '';
height: 24px;
width: 287px;
position: absolute;
bottom: 0;
left: 1px;
z-index: 1;
}
/* Element: tetris__block-span */
.tetris__block-span {
position: absolute;
top: -24px;
left: 96px;
height: 24px;
width: 96px;
box-shadow: 1px -1px 0 0 var(--border);
background:
repeating-linear-gradient(0deg, var(--border) 0 1px, transparent 1px 24px),
repeating-linear-gradient(90deg, var(--border) 0 1px, transparent 1px 24px)
var(--bg);
}
/* Modifiers for specific spans */
.tetris__block-span:nth-of-type(3) {
width: 72px;
}
.tetris__block-span:nth-of-type(4) {
width: 48px;
}
.tetris__block-span:nth-of-type(3)::before,
.tetris__block-span:nth-of-type(4)::before {
content: '';
height: 24px;
position: absolute;
top: -24px;
background: inherit;
box-shadow: inherit;
}
.tetris__block-span:nth-of-type(3)::before {
width: 24px;
right: 24px;
}
.tetris__block-span:nth-of-type(4)::before {
width: 48px;
left: 24px;
}
/* Animations */
.animation .tetris__block-span:nth-of-type(1) {
animation: movedown 1s steps(11, end) forwards;
}
.animation .tetris__block-span:nth-of-type(2) {
animation: movedown1 1s 1s steps(11, end) forwards;
}
.animation .tetris__block-span:nth-of-type(3) {
animation: movedown2 1s 2s steps(11, end) forwards;
}
.animation .tetris__block-span:nth-of-type(4) {
animation: movedown3 1s 3s steps(11, end) forwards;
}
.animation .tetris__block {
animation: shift 0.5s 4s steps(4, end) forwards;
}
.animation .tetris__block::before {
animation: colortetris 0.1s 4s steps(7) infinite alternate;
}