<script setup>
import ModalTransition from "./ModalTransition.vue"

defineProps({
  show: false
})

const emit = defineEmits(['close'])
// const emit = defineEmits(['update:show']);

const cancelBtn = () => {
  emit('close')
}

</script>

<template>
  <ModalTransition class="popup" :show="show" name="opacity">
    <div class="home-bg">
      <div class="popup-bg">
        <div class="scene-item item-1">
          <img src="../assets/images/new/demo-img.webp" alt="home">
        </div>
        <div class="scene-item item-2">
          <img src="../assets/images/new/start-1.webp" @click="cancelBtn" alt="立即挑战">
        </div>
        <div class="scene-item item-3">
          <img src="../assets/images/new/close-btn.webp" @click="cancelBtn" alt="关闭">
        </div>
        <div class="scene-item item-4">
          <img src="../assets/images/new/shou.webp" alt="shou">
        </div>
      </div>
    </div>
  </ModalTransition>
</template>

<style scoped>
.home-bg {
  position: absolute;
  top: 0;
  left: 0;
}
.message {
  width: 60vw;
  position: absolute;
  top: 42%;
  color: #774107;
  text-align: center;
}
.popup-bg {
  width: 100vw;
  height: 204vw;
  background-image: url('../assets/images/new/demo-bg.webp');
  background-size: 100% auto;
  background-position: 0 0;
  background-repeat: no-repeat;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
}
.scene-item {
  position: absolute;
  cursor: pointer;
  transition: all 0.4s ease;
  border-radius: 8px;
  overflow: hidden;
  border: 3px solid transparent;
  animation: float 4s ease-in-out infinite;
}

.scene-item:hover {
  transform: scale(1.05);
}
.btn-login {
  text-align: center;
  border-radius: 1vw;
  background-color: #70b2e2;
  margin-top: 4vw;
  padding: 3vw;
  color: #fff;
  position: relative;
}
.item-1 {
  top: 40vw;
  width: 70vw;
}
.item-2 {
  top: 134vw;
  width: 54vw;
}
.item-3 {
  top: 152vw;
  width: 12vw;
}
.item-4 {
  width: 30vw;
  top: 57vw;
  left: 46vw;
}
/* 手指点击动效：轻微下压 + 缩放 */
@keyframes finger-tap {
  0% {
    transform: translateY(0) scale(1);
  }
  30% {
    /* 手指按下：往下移动一点点，略微变小 */
    transform: translateY(2.4vw) scale(0.96);
  }
  60% {
    /* 回弹到原位 */
    transform: translateY(0) scale(1.02);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

/* 给这只手指绑定动画 */
.scene-item.item-4 img {
  animation: finger-tap 1s ease-in-out infinite;
  transform-origin: center bottom; /* 以底部为轴，看起来更像手指按压 */
}
.scene-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.btn-login.disable {
  opacity: .6;
}

.btn-login.subloading {
  opacity: .6;
}

.btn-login.subloading::before {
  content: "";
  position: absolute;
  border: .5vw solid #fff;
  border-color: rgba(255, 255, 255, .8) transparent transparent transparent;
  border-radius: 50%;
  width: 3vw;
  height: 3vw;
  top: 30%;
  left: calc(50% - 14vw);
  animation: loginloading 1s linear infinite;
}

@keyframes loginloading {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}
</style>