<template>
  <Transition name="splash-fade" appear>
    <div v-if="visible" class="splash-screen">
      <!-- Ambient glow -->
      <div class="splash-glow splash-glow-1"></div>
      <div class="splash-glow splash-glow-2"></div>

      <!-- Content -->
      <div class="splash-center">
        <!-- Ripple rings -->
        <div class="splash-rings">
          <div class="ring ring-1"></div>
          <div class="ring ring-2"></div>
          <div class="ring ring-3"></div>

          <!-- Logo -->
          <div class="splash-logo-wrap">
            <img src="/pwa-192x192.png" alt="萌芽小店" class="splash-logo" />
          </div>
        </div>

        <!-- Title -->
        <h1 class="splash-title">萌芽小店</h1>
        <p class="splash-subtitle">加载中</p>

        <!-- Dots loader -->
        <div class="splash-dots">
          <span class="dot dot-1"></span>
          <span class="dot dot-2"></span>
          <span class="dot dot-3"></span>
        </div>
      </div>
    </div>
  </Transition>
</template>

<script setup>
defineProps({
  visible: { type: Boolean, default: true }
})
</script>

<style scoped>
.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #f8f5f2 0%, #e9f0f7 45%, #f4eaf1 100%);
  overflow: hidden;
}

/* Ambient glow blobs */
.splash-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  animation: glow-pulse 3s ease-in-out infinite alternate;
}

.splash-glow-1 {
  width: 420px;
  height: 420px;
  top: -80px;
  left: -100px;
  background: radial-gradient(circle, rgba(180, 154, 203, 0.35) 0%, transparent 70%);
}

.splash-glow-2 {
  width: 380px;
  height: 380px;
  bottom: -60px;
  right: -80px;
  background: radial-gradient(circle, rgba(145, 168, 208, 0.3) 0%, transparent 70%);
  animation-delay: 1.5s;
}

@keyframes glow-pulse {
  from { opacity: 0.6; transform: scale(1); }
  to   { opacity: 1;   transform: scale(1.12); }
}

/* Center content */
.splash-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  position: relative;
  z-index: 1;
}

/* Rings + logo */
.splash-rings {
  position: relative;
  width: 160px;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 28px;
}

.ring {
  position: absolute;
  border-radius: 50%;
  border: 2px solid rgba(180, 154, 203, 0.4);
  animation: ring-expand 2.4s ease-out infinite;
}

.ring-1 { width: 100px; height: 100px; animation-delay: 0s; }
.ring-2 { width: 100px; height: 100px; animation-delay: 0.8s; }
.ring-3 { width: 100px; height: 100px; animation-delay: 1.6s; }

@keyframes ring-expand {
  0%   { width: 88px; height: 88px; opacity: 0.8; border-color: rgba(180, 154, 203, 0.5); }
  100% { width: 200px; height: 200px; opacity: 0; border-color: rgba(180, 154, 203, 0); }
}

/* Logo */
.splash-logo-wrap {
  position: relative;
  z-index: 2;
  animation: logo-float 2.8s ease-in-out infinite;
}

.splash-logo {
  width: 88px;
  height: 88px;
  border-radius: 22px;
  object-fit: cover;
  box-shadow: 0 12px 40px rgba(33, 33, 40, 0.18), 0 2px 8px rgba(180, 154, 203, 0.25);
}

@keyframes logo-float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

/* Title */
.splash-title {
  font-size: 26px;
  font-weight: 800;
  color: #2c2b2d;
  letter-spacing: 2px;
  margin: 0 0 6px;
}

.splash-subtitle {
  font-size: 13px;
  color: #8a8690;
  letter-spacing: 3px;
  margin: 0 0 20px;
}

/* Dots */
.splash-dots {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
}

.dot {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  animation: dot-bounce 1.2s ease-in-out infinite;
}

.dot-1 { animation-delay: 0s; }
.dot-2 { animation-delay: 0.2s; }
.dot-3 { animation-delay: 0.4s; }

@keyframes dot-bounce {
  0%, 60%, 100% { transform: scale(0.7); opacity: 0.5; }
  30%            { transform: scale(1.2); opacity: 1; }
}

/* Exit transition */
.splash-fade-leave-active {
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.splash-fade-leave-to {
  opacity: 0;
  transform: scale(1.04);
}
</style>
