<template>
  <div class="module-card" :style="{ width: moduleWidth, height: moduleHeight }">
    <!-- 背景图片 -->
    <div class="module-background" :style="{ backgroundImage: `url(${backgroundImage})` }"></div>

    <!-- 标题区域 -->
    <div
      class="module-header"
      :style="{ height: headerHeight, backgroundImage: `url(${titleBackgroundImage})` }"
    >
      <div class="module-title">{{ title }}</div>
    </div>

    <!-- 内容区域 -->
    <div class="module-content">
      <slot></slot>
    </div>
  </div>
</template>

<script setup lang="ts">
import module_bg1 from '@/assets/images/module_bg1.png'
import module_bg2 from '@/assets/images/module_bg2.png'
import module_title_bg1 from '@/assets/images/module_title_bg1.png'
import module_title_bg2 from '@/assets/images/module_title_bg2.png'
import { computed } from 'vue'

// Props
const props = withDefaults(
  defineProps<{
    title: string
    size?: 'default' | 'large'
  }>(),
  {
    size: 'default',
  }
)

// 计算属性
const isLarge = computed(() => props.size === 'large')
const moduleWidth = computed(() => (isLarge.value ? '1842px' : '704px'))
const moduleHeight = computed(() => (isLarge.value ? '550px' : '910px'))
const headerHeight = computed(() => (isLarge.value ? '84px' : '100px'))
const backgroundImage = computed(() => (isLarge.value ? module_bg2 : module_bg1))
const titleBackgroundImage = computed(() => (isLarge.value ? module_title_bg2 : module_title_bg1))
</script>

<style lang="scss" scoped>
// SCSS变量定义
$neon-cyan: rgba(1, 255, 230, 0.8);
$transition-speed: 0.3s ease;

.module-card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;

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

  // 标题区域
  .module-header {
    position: relative;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 30px;
    background-size: cover;
    background-position: center;

    // 标题
    .module-title {
      font-size: 44px;
      font-weight: bold;
      color: $neon-cyan;
      line-height: 56px;
      letter-spacing: 2px;
    }
  }

  // 内容区域
  .module-content {
    flex: 1;
    position: relative;
    z-index: 10;
    overflow: hidden;
  }
}
</style>
