<template>

<div :class="['road-event', scene]">
  <div v-if="EVENT_TYPE[event]" class="chip">
    <div class="text">{{ EVENT_TYPE[event] || '' }}</div>
    <div :class="['type-icon', `type-${event}`]"></div>
  </div>
  <img :src="EVENT_IMAGE" />
</div>

</template>

<script lang='ts' setup>

import { EVENT_TYPE } from '@/config/enum'
import EVENT_IMAGE from '@/assets/images/event/event.png'

defineProps<{
  event: any,
  scene: string
}>()

</script>

<style lang='scss' scoped>

$base-event: '@/assets/images/event/';

.road-event {
  width: 90px;
  height: 90px;
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 0;
  opacity: 0;

  &.panorama {
    animation-name: showup-panorama;
    animation-duration: 6.6s;
    animation-fill-mode: forwards;
    animation-timing-function: ease-in-out;
  }

  &.section {
    animation-name: showup-section;
    animation-duration: 6.6s;
    animation-fill-mode: forwards;
    animation-timing-function: ease-in-out;
  }

  img {
    display: block;
    width: 100%;
    height: 100%;
  }
  .chip {
    position: absolute;
    top: -34px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation-name: wave;
    animation-duration: 1.85s;
    animation-fill-mode: forwards;
    animation-iteration-count: infinite;

    .text {
      font-size: 12px;
      background: #772727;
      border: 1px solid rgba(238, 89, 97, 0.8);
      padding: 2px 4px;
      border-radius: 2px;
      white-space: nowrap;
      color: white;
      margin-bottom: 4px;
    }

    .type-icon {
      width: 24px;
      height: 24px;
    }

    .type-0,
    .type-1,
    .type-2,
    .type-3,
    .type-4,
    .type-8 {
      background: url($base-event + 'event_01.png') no-repeat;
      background-size: cover;
    }
  }
  
}

@keyframes wave {
  0% {
    transform: translate(-50%, 0px);
  }
  25% {
    transform: translate(-50%, 5px);
  }
  50% {
    transform: translate(-50%, 0px);
  }
  75% {
    transform: translate(-50%, 5px);
  }
  100% {
    transform: translate(-50%, 0px);
  }
}

@keyframes showup-section {
  0% {
    opacity: 0;
    transform: translate(-50%, -30%) scale(0.8);
  }
  4.5% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  95.5% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -30%) scale(0.8);
  }
}

@keyframes showup-panorama {
  0% {
    opacity: 0;
    transform: translate(-50%, -45%) scale(0.4);
  }
  4.5% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.6);
  }
  95.5% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.6);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -45%) scale(0.4);
  }
}

</style>