<template>
  <section class="scene-section end-section" :class="{ 'active': isActive }">
    <!-- 背景图片层 -->
    <div class="background-layer">
      <img src="/static/bg/bg_finish.jpg" alt="结束页背景" class="background-image" />
    </div>
    
    <!-- 内容层 -->
    <div class="content-layer">
      <div class="end-page-content">
        <h1 class="end-title">🎉 {{ title }} 🎉</h1>
        <div class="end-buttons">
          <button class="function-btn lottery-btn" @click="handleLottery">🎁 参与抽奖</button>
          <button class="function-btn couplet-btn" @click="handleCouplet">✍️ AI春联</button>
        </div>

      </div>
    </div>
  </section>
</template>

<script setup>
const props = defineProps({
  isActive: {
    type: Boolean,
    default: false
  },
  title: {
    type: String,
    required: true
  },
  collectionProgress: {
    type: Number,
    default: 0
  },
  collectedCount: {
    type: Number,
    default: 0
  },
  totalCount: {
    type: Number,
    default: 1
  }
})

const emit = defineEmits(['lottery', 'couplet', 'restart'])

const handleLottery = () => {
  emit('lottery')
}

const handleCouplet = () => {
  emit('couplet')
}

const handleRestart = () => {
  emit('restart')
}
</script>

<style scoped>
.scene-section {
  position: relative;
  width: 100%;
  height: 100vh; /* 直接使用 100vh 确保完整一屏显示 */
  min-height: 100vh; /* 确保最小高度 */
  max-height: 100vh; /* 确保最大高度 */
  overflow: hidden; /* 防止出现滚动条 */
}

.scene-section.active {
  /* 当前活动场景样式 */
}

/* 背景图片层 */
.background-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.background-image {
  width: 100%;
  height: 100%;
  object-fit: cover; /* 使用裁切方式展示，保持图片比例 */
  object-position: center center; /* 从中心开始裁切 */
}

/* 内容层 */
.content-layer {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.end-page-content {
  width: 100%;
  max-width: 640px;
  padding: 20px;
  box-sizing: border-box;
  text-align: center;
}

.end-title {
  font-size: 32px;
  color: #FF6B35;
  margin-bottom: 30px;
}

.seal-collection-section {
  margin-bottom: 40px;
}

.section-title {
  font-size: 24px;
  color: #333;
  margin-bottom: 20px;
}

.collection-progress {
  margin-bottom: 20px;
}

.progress-bar {
  width: 100%;
  height: 10px;
  background-color: #ddd;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-fill {
  height: 100%;
  background-color: #FF6B35;
  transition: width 0.5s ease;
}

.progress-text {
  font-size: 16px;
  color: #666;
  margin: 0;
}

.end-buttons {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin-bottom: 30px;
}

.function-btn {
  padding: 15px 30px;
  font-size: 18px;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.3s ease;
  min-width: 150px;
}

.lottery-btn {
  background-color: #FFD700;
  color: #333;
}

.lottery-btn:hover {
  background-color: #FFC107;
  transform: translateY(-2px);
}

.couplet-btn {
  background-color: #4CAF50;
  color: white;
}

.couplet-btn:hover {
  background-color: #45a049;
  transform: translateY(-2px);
}

.restart-btn-container {
  margin-top: 20px;
}

.restart-btn {
  padding: 10px 20px;
  font-size: 16px;
  background-color: #999;
  color: white;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.restart-btn:hover {
  background-color: #777;
}

/* 响应式设计 */
@media (max-width: 480px) {
  .end-title {
    font-size: 28px;
  }
  
  .end-buttons {
    flex-direction: column;
    align-items: center;
  }
  
  .function-btn {
    width: 200px;
  }
}
</style>
