<script setup lang="ts">
interface HomeBannerSlide {
  title?: string
  eyebrow?: string
  pill?: string
  badge?: string
  tone?: string
  image_url?: string
}

interface Props {
  banners: HomeBannerSlide[]
}

defineProps<Props>()
</script>

<template>
  <section class="hero-board">
    <el-carousel height="240px" indicator-position="outside" :interval="3600">
      <el-carousel-item v-for="slide in banners" :key="slide.title || slide.image_url">
        <div
          class="hero-slide"
          :class="[`tone-${slide.tone}`, { 'has-image': slide.image_url }]"
        >
          <img
            v-if="slide.image_url"
            :src="slide.image_url"
            :alt="slide.title || slide.eyebrow || '首页轮播'"
          />
          <div class="hero-copy">
            <span v-if="slide.eyebrow">{{ slide.eyebrow }}</span>
            <h1 v-if="slide.title">{{ slide.title }}</h1>
            <p v-if="slide.pill">{{ slide.pill }}</p>
          </div>
          <em v-if="slide.badge">{{ slide.badge }}</em>
        </div>
      </el-carousel-item>
    </el-carousel>
  </section>
</template>

<style scoped>
.hero-board {
  min-width: 0;
  border-radius: 16px;
  overflow: hidden;
  background: #ffffff;
}

.hero-board :deep(.el-carousel) {
  min-width: 0;
}

.hero-board :deep(.el-carousel__container) {
  height: 240px;
  overflow: hidden;
}

.hero-board :deep(.el-carousel__item) {
  height: 100%;
}

.hero-slide {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 40px;
  overflow: hidden;
  color: #17233d;
  background: linear-gradient(135deg, #eff6ff 0%, #ffffff 58%, #fff7ed 100%);
}

.hero-slide.tone-blue {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 56%, #fff7ed 100%);
}

.hero-slide.tone-orange {
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
}
.hero-slide.tone-green {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
}

.hero-slide img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-slide.has-image::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(15, 23, 42, 0.74) 0%, rgba(15, 23, 42, 0.24) 62%, transparent 100%);
}

.hero-copy {
  position: relative;
  z-index: 1;
  max-width: 480px;
}

.hero-copy span {
  color: #ff6a00;
  font-size: 13px;
  font-weight: 900;
}

.hero-slide.has-image .hero-copy {
  color: #ffffff;
}

.hero-slide.has-image .hero-copy span {
  color: #fed7aa;
}

.hero-copy h1 {
  margin: 12px 0;
  font-size: 32px;
  font-weight: 900;
  line-height: 1.2;
}

.hero-copy p {
  display: inline-block;
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  color: #1e293b;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(4px);
  font-size: 14px;
  font-weight: 800;
}

.hero-slide em {
  position: absolute;
  top: 22px;
  right: 24px;
  z-index: 1;
  padding: 6px 10px;
  border-radius: 999px;
  color: #ffffff;
  background: #ff6a00;
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}
</style>
