﻿:root {
    --crystal-col-1: rgb(67, 13, 92); /* dark purple*/
    --crystal-col-2: rgb(155, 89, 182); /*light purple*/
    --crystal-max-width: 100%;
}

.crystal-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    perspective: 800px;
}

    /* left crystal rotates clockwise */
    .crystal-container.crystal-container-left .crystal {
        animation: crystal-rotation 15s linear infinite;
    }

    /* right crystal rotates counter-clockwise */
    .crystal-container.crystal-container-right .crystal {
        animation: crystal-rotation 15s linear infinite reverse;
    }

.scene {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    transform-style: preserve-3d;
    animation: crystal-bounce 6s linear infinite !important;
}

.crystal {
    top: 0%;
    left: 0%;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
}

.crystal-quarter {
    position: absolute;
    top: 0%;
    left: 0%;
    width: 100%;
    max-width: 100%;
    height: 100%;
    transform-style: preserve-3d;
}

.crystal-quarter-front {
    transform: rotateY(90deg)
}

.crystal-quarter-right {
    transform: rotateY(180deg)
}

.crystal-quarter-back {
    transform: rotateY(270deg)
}

.xyplane {
    position: absolute;
    top: 0%;
    left: 0%;
    width: 50%;
    height: 50%;
    background: rgba(0, 150, 255, 0.2);
    border: 1px solid rgba(0,150,255,0.5);
    transform: translate(50%, 50%) rotateX(90deg);
}

.vline {
    position: relative;
    bottom: 0;
    left: 50%;
    width: 2px;
    height: 100%;
    background: red;
    transform: translateX(-50%);
}

/* Wrapper for pyramid triangle responsible for translation */
.crystal-triangle-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    aspect-ratio: 1 / 1;
    width: var(--crystal-max-width);
    height: auto;
    transform-style: preserve-3d;
}

/* Pyramid face */
.crystal-triangle {
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 70%, var(--crystal-col-2) 2%, var(--crystal-col-1) 20%, var(--crystal-col-2) 100%);
    clip-path: polygon(50% -3%, -3% 103%, 103% 103%);
    transform-origin: 50% 100%;
    transform: rotateX(-30deg);
    opacity: 90%
}

.crystal-triangle-top {
    transform: translate(-100%, -149%) rotateY(90deg);
}

.crystal-triangle-bottom {
    transform: translate(-100%, 49%) rotateX(180deg) rotateY(90deg);
}

.crystal-rectangle {
    position: absolute;
    top: 50%;
    left: 50%;
    aspect-ratio: 1 / 1;
    width: var(--crystal-max-width);
    height: auto;
    background: radial-gradient(var(--crystal-col-2), 10%, var(--crystal-col-1), 90%, var(--crystal-col-2));
    transform: translate(-100%, -50%) rotateY(-90deg);
    opacity: 90%
}

/* Animation */

@keyframes crystal-rotation {
    0% {
        transform: rotateY(0deg);
    }

    25% {
        transform: rotateY(90deg);
    }

    50% {
        transform: rotateY(180deg);
    }

    75% {
        transform: rotateY(270deg);
    }

    100% {
        transform: rotateY(360deg);
    }
}

@keyframes crystal-bounce {
    0% {
        transform: translateY(0);
    }

    25% {
        transform: translateY(-5%);
    }

    50% {
        transform: translateY(0);
    }

    75% {
        transform: translateY(5%);
    }

    100% {
        transform: translateY(0);
    }
}
