/* ANIMASI KUPU-KUPU */
.stage {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    margin: 0 auto;
    height: 100vh;
    width: 100%;
    max-width: 900px;
    overflow: hidden;
    opacity: 1;
    pointer-events: none;
    z-index: 2;
    animation: stage-mariposa 2s ease 2s 1 alternate forwards;
}

@keyframes stage-mariposa {
    0% {
        opacity: 1;
    }

    100% {
        opacity: 1;
    }
}

.butterfly {
    position: absolute;
    margin: auto;
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    width: 200px;
    height: 200px;
    opacity: 0;
    /* start at 0 so they don't appear while loading */
    -webkit-animation-fill-mode: backwards;
    animation-fill-mode: backwards;
    animation: fly 10s 2 linear;
    animation-delay: 10s;
}

.butterfly:nth-child(2) {
    animation-delay: 5s;
}

.butterfly:nth-child(2) .bflyTurn {
    animation-delay: 0.75s;
}

.butterfly:nth-child(2) .bflyTurn .bflyWing {
    transform: scale(0.7) rotateX(65deg);
}

.butterfly:nth-child(3) {
    animation-delay: 3s;
}

.butterfly:nth-child(3) .bflyTurn {
    animation-delay: 1.25s;
}

.butterfly:nth-child(3) .bflyTurn .bflyWing {
    transform: scale(0.3) rotateX(45deg);
}

.butterfly .bflyTurn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 200px;
    height: 150px;
    perspective: 1000px;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    left: 0;
    margin: auto;
    transform-origin: 50% 80%;
    -webkit-animation-fill-mode: both;
    animation-fill-mode: both;
    animation: turn 3s infinite cubic-bezier(0.31, 0.09, 0.77, 1.5);
    transform-style: preserve-3d;
    filter: drop-shadow(50px 30px 10px rgba(0, 0, 0, 0.5));
}

.bflyWing {
    width: 1.5rem;
    height: 6rem;
    position: relative;
    top: 0;
    margin: 0 auto;
    background: url("https://assets.codepen.io/2273448/butterfly-body.png");
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    transform-style: preserve-3d;
    transform: rotateX(25deg) rotateY(5deg);
}

.bflyWing::before,
.bflyWing::after {
    position: absolute;
    top: 5%;
    margin: auto;
    content: "";
    height: 100%;
    width: 250%;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    transform-style: preserve-3d;
    animation-delay: 0;
}

.bflyWing::before {
    background-image: url("https://assets.codepen.io/2273448/butterfly-wing.png");
    transform-origin: 0% 50%;
    animation: flutter-r 0.3s infinite ease-out;
    left: 55%;
}

.bflyWing::after {
    background-image: url("https://assets.codepen.io/2273448/butterfly-wing-l.png");
    transform-origin: 100% 50%;
    animation: flutter-l 0.3s infinite ease-out;
    right: 55%;
}

@keyframes flutter-r {

    0%,
    100% {
        transform: rotateY(0deg);
    }

    50% {
        transform: rotateY(-40deg);
    }
}

@keyframes flutter-l {

    0%,
    100% {
        transform: rotateY(0deg);
    }

    50% {
        transform: rotateY(40deg);
    }
}

@keyframes turn {

    0%,
    100% {
        transform: translateX(-20%) rotateZ(30deg);
    }

    25% {
        transform: translateX(50%) rotateZ(-30deg);
    }

    50% {
        transform: translateX(-80%) rotateZ(30deg);
    }

    75% {
        transform: translateX(30%) rotateZ(-30deg);
    }
}

@keyframes fly {
    0% {
        opacity: 0;
        transform: translateY(70vh);
    }

    3%,
    99% {
        opacity: 1;
    }

    100% {
        transform: translateY(-70vh);
    }
}

/* ANIMASI BOX MELAYANG */
.floatBox {
    display: block;
    position: fixed;
    width: 100%;
    height: 100%;
    background: transparent;
    overflow: visible;
    top: 0;
    margin: 0;
    padding: 0;
    z-index: 1;
    animation: floatingBallBox 5s linear 0s 1 alternate forwards;
}

@keyframes floatingBallBox {
    0% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}

.circles li {
    position: absolute;
    display: block;
    list-style: none;
    width: 20px;
    height: 20px;
    bottom: -150px;
    animation: floatingBall 30s linear infinite;
}


@keyframes floatingBall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
        border-radius: 50%;
        background: #2195f37c;
    }

    100% {
        transform: translateY(-1000px) rotate(720deg);
        opacity: 0;
        border-radius: 50%;
        background: #f3218085;
    }
}

.circles li:nth-child(1) {
    left: 25%;
    width: 80px;
    height: 80px;
    animation-delay: 0s;
}

.circles li:nth-child(2) {
    left: 10%;
    width: 20px;
    height: 20px;
    animation-delay: 2s;
    animation-duration: 12s;
}

.circles li:nth-child(3) {
    left: 70%;
    width: 20px;
    height: 20px;
    animation-delay: 4s;
}

.circles li:nth-child(4) {
    left: 40%;
    width: 60px;
    height: 60px;
    animation-delay: 0s;
    animation-duration: 18s;
}

.circles li:nth-child(5) {
    left: 65%;
    width: 20px;
    height: 20px;
    animation-delay: 0s;
}

.circles li:nth-child(6) {
    left: 75%;
    width: 110px;
    height: 110px;
    animation-delay: 3s;
}

.circles li:nth-child(7) {
    left: 35%;
    width: 150px;
    height: 150px;
    animation-delay: 7s;
}

.circles li:nth-child(8) {
    left: 50%;
    width: 25px;
    height: 25px;
    animation-delay: 15s;
    animation-duration: 45s;
}

.circles li:nth-child(9) {
    left: 20%;
    width: 15px;
    height: 15px;
    animation-delay: 2s;
    animation-duration: 35s;
}

.circles li:nth-child(10) {
    left: 85%;
    width: 150px;
    height: 150px;
    animation-delay: 0s;
    animation-duration: 11s;
}

/* ANIMASI UNTUK TOMBOL BUKA UNDANGAN */
#openBtn {
    display: inline-block;
    padding: 10px 20px;
    margin-top: 5px;
    background-color: #673AB7;
    color: white;
    text-align: center;
    text-decoration: none;
    font-size: 13px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    overflow: hidden;
    position: relative;
}

#openBtn::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.2);
    transform: translateX(-100%) translateY(-50%);
    transition: transform 0.4s;
    z-index: 0;
}

#openBtn:hover::before {
    transform: translateX(100%) translateY(-50%);
}

#openBtn::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 300%;
    height: 300%;
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateX(-50%) translateY(-50%) rotate(45deg);
    transition: width 0.4s, height 0.4s, transform 0.4s;
    z-index: -1;
}

#openBtn:active::after {
    width: 0;
    height: 0;
    transform: translateX(-50%) translateY(-50%) rotate(45deg);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#openBtn {
    animation: fadeIn 0.6s ease-out forwards;
}