<script setup lang="ts">
import { useRouter, useRoute } from "vue-router";

import KLogo from "../../assets/promo/logo.svg";
import { useItem } from "../../stores/item";

const router = useRouter()
const route = useRoute()
const page = useItem()

const startColor = `hsl(${(Math.random() * 360).toFixed()}, 100%, 50%)`
const endColor = `hsl(${(Math.random() * 360).toFixed()}, 100%, 50%)`

await page.load(route.params)
</script>
<template>
    <div class="main">
        <div class="pin" @click="router.push(`/${page.slug}/${page.scene_3d}`)">
            <KLogo />
        </div>
        <Gallery :files="page.images" />
    </div>
</template>
<style scoped lang="scss">
* {
    --logo-start-color: v-bind(startColor);
    --logo-end-color: v-bind(endColor);
    --anim-time: 4s;
}

.main {
    width: 100vw;
    height: 100vh;

    background-image: url(../../assets/promo/map.png);
    background-position: 50% 100%;
    background-size: auto 100%;
    overflow: hidden;
}

.pin {
    cursor: pointer;

    border-radius: 0.25rem;
    overflow: hidden;

    position: absolute;
    bottom: 20vh;
    left: calc(50% - 1vw);

    color: white;

    width: 2rem;
    height: 2rem;
    padding: 0.25rem;

    animation: bounce2 var(--anim-time) ease infinite;
    transition: all 300ms linear;

    &::before {
        content: '';
        position: absolute;
        top: -1rem;
        right: -1rem;
        bottom: -1rem;
        left: -1rem;
        background-image: linear-gradient(var(--logo-start-color), var(--logo-end-color));
        animation: bounce2grad var(--anim-time) ease infinite;
        z-index: -1;
    }

    svg {
        max-width: 100%;
        max-height: 100%;
        color: #fff;
        fill: currentColor;
    }

    &:hover {
        // animation-play-state: paused;
        animation: none;
        transform: scale(1.5);

        &::before {
            // animation-play-state: paused;
        }
    }

}

@keyframes bounce2grad {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: rotate(90deg)
    }

    40% {
        transform: rotate(60deg);
    }

    60% {
        transform: rotate(20deg);
    }
}

@keyframes bounce2 {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0) scale(1.5);
    }

    40% {
        transform: translateY(-2rem);
    }

    60% {
        transform: translateY(-1rem);
    }
}
</style>