:root {
    --primary-color: hsl(60, 2%, 82%);
    --secondary-color: hsl(348, 4%, 26%);
    --tertiary-color: hsl(72, 3%, 61%);
    --nes-red: hsl(6, 70%, 47%);
    --nes-white: hsl(60, 2%, 80%);
    --nes-black: hsl(150, 2%, 23%);

    /* Normal size: 123.4mm x 53.2mm x 17.5mm */
    /* Dimensies bron: https://www.dimensions.com/element/nes-controller */
    --nes-width: 740.4px;
    --nes-height: 319.2px;
    --nes-depth: 112.5px;

    --font-family: "Nes-Font", sans-serif;
}

#scene {
    perspective: 1000px;
    cursor: grab;

    &:active {
        cursor: grabbing;
    }
}

#nes-controller {
    position: relative;
    width: var(--nes-width);
    height: var(--nes-height);
    transform-style: preserve-3d;
    transform: rotateX(-20deg) rotateY(-30deg);

    >div {
        position: absolute;
        background-color: var(--primary-color);
    }
}

#nes-left,
#nes-right {
    width: var(--nes-depth);
    height: var(--nes-height);
}

#nes-top,
#nes-bottom {
    width: var(--nes-width);
    height: var(--nes-depth);
}

#nes-back {
    width: var(--nes-width);
    height: var(--nes-height);
}

#nes-front {
    transform: translateZ(calc(var(--nes-depth) / 2));
}

#nes-back {
    transform: rotateY(180deg) translateZ(calc(var(--nes-depth) / 2));
}

#nes-left {
    transform: rotateY(-90deg) translateZ(calc(var(--nes-depth) / 2));
    left: 0;
}

#nes-right {
    transform: rotateY(90deg) translateZ(calc(var(--nes-width) - var(--nes-depth) / 2));
}

#nes-top {
    transform: rotateX(90deg) translateZ(calc(var(--nes-depth) / 2));
    top: 0;
}

#nes-bottom {
    transform: rotateX(-90deg) translateZ(calc(var(--nes-depth) / 2));
    bottom: 0;
}

hr {
    border: 1px solid var(--secondary-color);
    position: absolute;
}

#nes-top {
    hr {
        width: 100%;
        top: 35%;
    }

    &::after {
        content: "";
        position: absolute;
        width: 30px;
        height: 5px;
        background: var(--tertiary-color);
        bottom: 0;
        left: 25%;
    }

    &::before {
        content: "";
        position: absolute;
        width: 30px;
        height: 5px;
        background: var(--tertiary-color);
        top: 0;
        left: 25%;
    }
}

#nes-bottom {
    hr {
        width: 100%;
        bottom: 35%;
    }
}

#nes-left {
    hr {
        height: 100%;
        left: 35%;
    }
}

#nes-right {
    hr {
        height: 100%;
        right: 35%;
    }
}

#nes-back {

    ul {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(2, 1fr);
        padding: 2rem;
        width: 100%;
        height: 100%;
        list-style: none;

        li {
            width: 20px;
            height: 20px;
            background: var(--nes-black);
            border-radius: 50%;
            margin-right: 15px;

            &::after {
                content: "";
                position: absolute;
                width: 18px;
                margin-top: 8px;
                margin-left: 1px;
                height: 3px;
                background: black;
                border-radius: 2px;            
            }

            &::before {
                content: "";
                position: absolute;
                width: 18px;
                margin-top: 8px;
                margin-left: 1px;
                height: 3px;
                background: black;
                border-radius: 2px; 
                transform: rotate(90deg);           
            }
        }

        li:nth-of-type(3n - 1) {
            justify-self: center;
        }

        li:nth-of-type(3n) {
            justify-self: end;
        }

        li:nth-of-type(1n + 4) {
            align-self: end;
        }

        li:nth-of-type(5) {
            margin-left: 50px;
        }
    }

    .text-container {
        width: 40%;
        position: absolute;
        top: 50%;
        right: 7%;
        transform: translateY(-50%);
        background: hsl(60, 4%, 73%);
        padding: 5px 3rem;
        color: var(--primary-color);
        font-family: "Nintendo-Font", sans-serif;

        p {
            font-size: 1.2rem;
        }

        hr {
            width: 50%;
            border: 1px solid var(--primary-color);
        }

        p:not(:first-of-type) {
            text-transform: uppercase;
            font-family: "Nes-Font", sans-serif;
            font-size: 1.2rem;

        }
    }

    ;

    &::before {
        content: "";
        position: absolute;
        width: 15px;
        height: 15px;
        border-radius: 50%;
        background: var(--tertiary-color);
        bottom: 50%;
        right: 50%;
        transform: translate(-50%, -50%);
    }

    &::after {
        content: "";
        position: absolute;
        width: 30px;
        height: 15px;
        background: var(--tertiary-color);
        top: 0;
        right: 25%;
    }
}

#nes-front {
    width: var(--nes-width);
    height: var(--nes-height);

    &::after {
        content: "";
        position: absolute;
        width: 30px;
        height: 15px;
        background: var(--tertiary-color);
        top: 0;
        left: 25%;
    }
}

#nes-controller-black {
    background: var(--secondary-color);
    height: 80%;
    width: 95%;
    margin: 6% auto 0 auto;
    border-radius: 10px;
    display: flex;

    #nes-left-half {
        height: 100%;

    }

    #nes-dpad {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(3, 1fr);
        width: 150px;
        aspect-ratio: 1;
        margin: 65px 35px;
        position: relative;

        &::after {
            content: "";
            position: absolute;
            inset: 0;
            border: 3px solid white;
            corner-shape: notch;
            border-radius: calc(105% / 3.5);
            scale: 110%;
        }

        button {
            aspect-ratio: 1;
            border: none;
            background: black;
            color: white;
            position: relative;
            display: block;
            z-index: 10;

            i {
                font-size: 20px;
                color: var(--nes-black);
            }
        }

        #nes-dpad-up {
            grid-area: 1 / 2;
            border-radius: 5px 5px 0 0;
        }

        #nes-dpad-left {
            grid-area: 2 / 1;
            border-radius: 5px 0 0 5px;
        }

        div {
            grid-column: 2;
            grid-row: 2;
            background: black;
        }

        #nes-dpad-right {
            grid-area: 2 / 3;
            border-radius: 0 5px 5px 0;

        }

        #nes-dpad-down {
            grid-area: 3 / 2;
            border-radius: 0 0 5px 5px;
        }
    }

    #nes-grey-blocks {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        height: 100%;
        letter-spacing: 2px;

        div {
            background: var(--tertiary-color);
            height: 40px;
            border-radius: 5px;
            width: 200px;
        }

        div:first-of-type {
            border-radius: 0 0 5px 5px;
        }

        /* Select / Start Texts */
        div:nth-of-type(3) {
            position: relative;
            font-family: "Nes-Font", sans-serif;
            font-weight: bold;
            display: flex;
            justify-content: space-evenly;
            align-items: center;
            font-size: 20px;


            &:before,
            &:after {
                text-transform: uppercase;
                color: var(--nes-red);

            }

            &:before {
                content: "Github";
            }

            &:after {
                content: "Website";
            }
        }

        /* Select / Start buttons */
        div:nth-of-type(4) {
            display: flex;
            justify-content: space-evenly;
            align-items: center;
            height: 60px;
            background: var(--nes-white);
            position: relative;
            padding: 10px;

            &::after {
                content: "";
                border: 4px solid var(--tertiary-color);
                border-radius: 5px;
                inset: 3px;
                position: absolute;
            }

            a {
                width: 50px;
                height: 20px;
                border-radius: 10px;
                border: none;
                background: var(--nes-black);
                position: relative;
                display: block;
                z-index: 10;
            }
        }

        div:last-of-type {
            height: 30px;
            border-radius: 5px 5px 0 0;
        }
    }

    #nes-right-half {
        display: flex;
        flex-direction: column;
        color: var(--nes-red);
        height: 100%;
        width: 100%;
        justify-content: space-around;
        align-items: center;

        p {
            font-family: "Nintendo-Font", sans-serif;
            font-size: 18px;
        }

        #nes-ab-container {
            display: flex;
            gap: 15px;

            div {
                width: 80px;
                aspect-ratio: 1;
                background: var(--nes-white);
                display: flex;
                justify-content: center;
                align-items: center;
                border-radius: 5px;

                button {
                    width: 65px;
                    aspect-ratio: 1;
                    background: var(--nes-red);
                    border: none;
                    border-radius: 50%;
                    position: relative;
                    display: block;
                    z-index: 10;

                    &::after {
                        content: "";
                        position: absolute;
                        font-family: "Nes-Font", sans-serif;
                        color: var(--nes-red);
                        right: 0;
                        bottom: -35px;
                        font-size: 35px;
                    }
                }

                &:first-of-type button::after {
                    content: "B";
                }

                &:last-of-type button::after {
                    content: "A";
                }
            }
        }
    }
}