<template>
    <div class="interactive-container">
        <!-- 顶部区域 -->
        <div class="top-section">
            <!-- 主标题 -->
            <div class="main-title">
                <img src="@/assets/img/zhongchou/助力美股享实时数据.png" alt="">
                <div class="activity-period">活动时间：{{ activityPeriod }}</div>
            </div>

            <!-- 活动规则按钮 -->
            <div class="rules-btn" @click="showRulesFunc">
                <img src="@/assets/img/zhongchou/活动需知.png" alt="活动规则" />
                <span class="rules-text">活动规则</span>
            </div>
        </div>

        <!-- 主要交互区域 -->
        <div class="main-interactive-area">
            <!-- 左侧美股区域 -->
            <div class="stock-area left-area" :class="{ active: activeArea === 'us', 'side': activeArea === 'hk' }">
                <div class="stock-content">
                    <div class="stock-card us-card">
                        <div class="card-content us-content">
                            <!-- 周年庆装饰元素 -->
                            <div class="anniversary-decoration"></div>
                            <div class="progress-section">
                                <div class="progress-bar">
                                    <div class="progress-fill"></div>
                                </div>
                                <!-- 美股区域刻度 -->
                                <div class="time-markers">
                                    <div class="marker marker-text" v-for="time in timeMarkers" :key="time" :class="{
                                        'reached': (15 - usUsedTime) <= time,
                                        'gold': (15 - usUsedTime) > time
                                    }">
                                        {{ time }}
                                    </div>
                                </div>
                            </div>

                            <!-- 美股剩余时间显示 -->
                            <div class="stock-info" :class="{ 'time-almost-up': isTimeAlmostUp }">
                                <h3>距{{ marketName }}实时数据</h3>
                                <h3>还剩{{ numberToChinese(usDisplayTime) }}分钟</h3>
                            </div>
                        </div>
                    </div>
                    <!-- 美股助力按钮和底座 -->
                    <div class="boost-section">
                        <div class="boost-btn us-boost-btn" :class="{ 'boosted': usBoostStatus }"
                            @click.stop="handleBoostClick('us')"></div>
                        <div class="base-image">
                            <img src="@/assets/img/zhongchou/底座.png" alt="底座" />
                        </div>
                    </div>
                </div>
            </div>

            <!-- 中央火箭区域 -->
            <div class="rocket-area" :class="{ hidden: activeArea !== null }">
                <div class="rocket-container">
                    <div class="rocket-body">
                        <img src="@/assets/img/zhongchou/火箭.png" alt="火箭" />
                    </div>
                </div>
            </div>

            <!-- 助力成功提示 -->
            <transition name="fade" appear>
                <div class="boost-success-container" v-if="showBoostSuccess">
                    <img src="@/assets/img/zhongchou/助力成功.png" alt="助力成功" />
                </div>
            </transition>

            <!-- 右侧港股区域 -->
            <!-- <div class="stock-area right-area" @click="handleAreaClick('hk')"
                :class="{ active: activeArea === 'hk', 'side': activeArea === 'us' }">
                <div class="stock-content">
                    <div class="stock-card hk-card">
                        <div class="card-content hk-content">
                            <div class="stock-info">
                                <h3>距港股实时数据</h3>
                                <h3>还剩{{ numberToChinese(hkDisplayTime) }}分钟</h3>
                            </div>

                            <div class="progress-section">
                                <div class="progress-bar">
                                    <div class="progress-fill"></div>
                                </div>
                                <div class="time-markers">
                                    <div class="marker marker-text" v-for="time in timeMarkers" :key="time" :class="{
                                        'reached': (15 - hkUsedTime) <= time,
                                        'gold': (15 - hkUsedTime) > time
                                    }">
                                        {{ time }}
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="boost-section">
                        <div class="boost-btn hk-boost-btn" :class="{ 'boosted': hkBoostStatus }"
                            @click.stop="handleBoostClick('hk')"></div>
                        <div class="base-image">
                            <img src="@/assets/img/zhongchou/底座.png" alt="底座" />
                        </div>
                    </div>
                </div>
            </div> -->
        </div>

        <!-- 活动规则弹窗 -->
        <div v-if="showRulesModal" class="modal-overlay" @click="hideRules">
            <div class="modal-content" @click.stop>
                <div class="modal-background">
                    <div class="modal-text">
                        <div class="rules-list">
                            <p>1. 活动时间为{{ activityPeriod }}。</p>
                            <p>2. 每人每天可以参与一次。</p>
                            <p>3. 初始时间为15分钟，每一百人参与助力，即可扣减一分钟！</p>
                            <p>4. 助力成功后，对应股票市场将开放实时数据！</p>
                            <p>5. 实时数据众筹上线后，您助力的次数会转化成对应天数的实时数据体验卡。</p>
                        </div>
                    </div>
                    <div class="close-btn" @click="hideRules"></div>
                </div>
            </div>
        </div>
    </div>
</template>
<script setup>
import { addRecordAPI, getActivity1API } from '../../api/zhongchouApi'
import { ref, computed, onMounted, nextTick, watch } from 'vue'

// 活动时间显示
const activityPeriod = ref('加载中...')
// 添加响应式变量存储活动ID和市场ID
const activityId = ref(null)
const usMarketId = ref(null)
// 格式化日期函数
const formatDate = (dateString) => {
    if (!dateString) return ''
    const date = new Date(dateString)
    const year = date.getFullYear()
    const month = String(date.getMonth() + 1).padStart(2, '0')
    const day = String(date.getDate()).padStart(2, '0')
    return `${year}/${month}/${day}`
}

// 在组件中使用
async function fetchActivity() {
    try {
        const response = await getActivity1API()
        if (response.code === 200) {
            console.log('活动数据:', response.data)

            // 处理返回的数据
            const { activityId: id, data, startTime, endTime, totalcount } = response.data

            // 存储活动ID
            activityId.value = id

            if (startTime && endTime) {
                const formattedStartTime = formatDate(startTime)
                const formattedEndTime = formatDate(endTime)
                activityPeriod.value = `${formattedStartTime}~${formattedEndTime}`
            } else {
                activityPeriod.value = '时间待定'
            }

            // 处理市场数据
            if (data && data.length > 1) { // 确保至少有两个元素
                // 使用数组中的第二个元素（索引为1）
                const item = data[0] // 使用第二个数据
                
                // 存储市场ID
                usMarketId.value = item.marketId
                
                // 存储市场名称
                marketName.value = item.market

                // 根据marketStatus设置助力状态
                if (item.marketStatus === '已助力') {
                    usBoostStatus.value = true
                } else {
                    usBoostStatus.value = false
                }

                // 根据marketCount计算进度和剩余时间
                if (item.marketCount !== undefined) {
                    const totalPeople = 1500 // 总人数1500人
                    const currentCount = item.marketCount || 0 // 当前助力人数

                    // 计算进度百分比 (0-100)
                    const progressPercent = Math.min((currentCount / totalPeople) * 100, 100)

                    // 根据进度计算剩余时间 (15分钟对应100%进度)
                    const usedTime = (progressPercent / 100) * 15
                    const remainingTime = Math.max(0, 15 - usedTime)

                    usRemainingTime.value = Math.round(remainingTime)
                    console.log(`${marketName.value}助力人数: ${currentCount}/${totalPeople}, 进度: ${progressPercent.toFixed(1)}%, 剩余时间: ${remainingTime.toFixed(1)}分钟`)

                    // 更新进度条高度
                    nextTick(() => {
                        updateProgressDisplay()
                    })
                }
            }
        } else {
            console.error('获取活动失败:', response.message)
            activityPeriod.value = '获取失败'
        }
    } catch (error) {
        console.error('请求错误:', error)
        activityPeriod.value = '网络错误'
    }
}


const numberToChinese = (num) => {
    const chineseNumbers = ['零', '一', '两', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二', '十三', '十四', '十五']
    return chineseNumbers[num] || num.toString()
}
// 进度条高度动态获取
const progressBarRef = ref(null)
const progressBarHeight = ref(0)

// 更新进度条高度的函数
const updateProgressBarHeight = () => {
    if (progressBarRef.value) {
        progressBarHeight.value = progressBarRef.value.offsetHeight
    }
}

// 时间刻度标记 - 从小到大排列（0在顶部，15在底部）
const timeMarkers = computed(() => {
    return [0, 3, 6, 9, 12, 15]
})

// 获取进度条高度百分比 - 配合刻度逻辑
const getProgressHeight = (remainingMinutes, totalMinutes = 15) => {
    // 剩余时间越少，进度条越满（从底部向上填充）
    // remainingMinutes = totalMinutes 时，返回 0%（空的，刚开始）
    // remainingMinutes = 0 时，返回 100%（满的，时间用完）
    const usedMinutes = totalMinutes - remainingMinutes
    return Math.max((usedMinutes / totalMinutes) * 100, 0)
}

// 添加活动规则弹窗状态
const showRules = ref(false)

// 原有的组件状态
const activeArea = ref(null)
const usBoostStatus = ref(false)
// const hkBoostStatus = ref(false)
const showRulesModal = ref(false)
// 添加助力成功提示状态
const showBoostSuccess = ref(false)
// 剩余时间数据 - 从接口获取marketTwoCount计算
const marketName = ref('美股') // 默认值为美股，将由API返回的数据更新
const usRemainingTime = ref(15) // 美股剩余分钟，初始值15分钟
// const hkRemainingTime = ref(6)  // 港股剩余分钟
const usTotalTime = ref(15)     // 美股总时间15分钟
// const hkTotalTime = ref(15)     // 港股总时间15分钟

// 计算属性：根据剩余时间计算进度条高度
const usProgressHeight = computed(() => {
    return getProgressHeight(usRemainingTime.value, usTotalTime.value)
})

// const hkProgressHeight = computed(() => {
//     return getProgressHeight(hkRemainingTime.value, hkTotalTime.value)
// })

// 计算属性：显示的剩余时间
const usDisplayTime = computed(() => {
    return Math.max(0, usRemainingTime.value)
})

// 计算属性：判断剩余时间是否小于等于3分钟
const isTimeAlmostUp = computed(() => {
    return usRemainingTime.value <= 3
})

// const hkDisplayTime = computed(() => {
//     return Math.max(0, hkRemainingTime.value)
// })

// 计算已使用时间用于刻度显示
const usUsedTime = computed(() => {
    return usTotalTime.value - usRemainingTime.value
})

// const hkUsedTime = computed(() => {
//     return hkTotalTime.value - hkRemainingTime.value
// })

// 监听剩余时间变化，更新进度条
watch([usRemainingTime], () => {
    nextTick(() => {
        updateProgressDisplay()
    })
})

// 更新进度条显示
const updateProgressDisplay = () => {
    // 更新美股进度条
    const usFill = document.querySelector('.us-content .progress-fill')
    if (usFill) {
        usFill.style.height = `${usProgressHeight.value}%`
    }

    // 更新港股进度条
    // const hkFill = document.querySelector('.hk-content .progress-fill')
    // if (hkFill) {
    //     hkFill.style.height = `${hkProgressHeight.value}%`
    // }
}
const getQueryVariable = (variable) => {
    const query = window.location.search.substring(1)
    const vars = query.split('&')
    for (let i = 0; i < vars.length; i++) {
        const pair = vars[i].split('=')
        if (pair[0] === variable) {
            return pair[1]
        }
    }
    return ''
}
// 组件挂载时初始化
onMounted(() => {
    showRulesModal.value = true
    nextTick(() => {
        // 页面加载时自动获取活动数据
        fetchActivity()
        updateProgressBarHeight()
        updateProgressDisplay()
        let token = '';
        token = getQueryVariable('token')
        localStorage.setItem('localToken', token);
        // 添加窗口大小改变监听
        window.addEventListener('resize', () => {
            nextTick(() => {
                updateProgressBarHeight()
            })
        })
    })
})


// const handleAreaClick = (area) => {
//     if (activeArea.value === area) {
//         activeArea.value = null
//     } else {
//         activeArea.value = area
//     }
// }

const handleBoostClick = async (area) => {
    if (area === 'us' && !usBoostStatus.value) {
        try {
            // 检查是否已获取到活动ID和市场ID
            if (!activityId.value || !usMarketId.value) {
                console.error('活动ID或市场ID未获取，请先获取活动数据')
                return
            }

            // 调用助力API，使用动态获取的值
            const response = await addRecordAPI({
                "activityId": activityId.value,
                "marketSign": usMarketId.value
            });

            if (response.code === 200) {
                console.log(`${marketName.value}助力成功：`, response.message)

                // 显示助力成功提示
                showBoostSuccess.value = true
                //助力成功动画1s
                setTimeout(() => {
                    showBoostSuccess.value = false
                }, 1000)

                // 重新获取活动数据以更新按钮状态和进度
                await fetchActivity()
                console.log(`${marketName.value}已助力状态：`, usBoostStatus.value, '剩余时间：', usRemainingTime.value)
            } else {
                console.error(`${marketName.value}助力失败：`, response.message)
            }
        } catch (error) {
            console.error(`${marketName.value}助力请求失败：`, error)
        }
    }
}

const showRulesFunc = () => {
    showRulesModal.value = true
}

const hideRules = () => {
    showRulesModal.value = false
}
</script>
<style scoped>
/* 禁用页面滚动 */
:global(html, body) {
    overflow: hidden;
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
}

:global(#app) {
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

.interactive-container {
    width: 100vw;
    height: 100vh;
    background: url('@/assets/img/zhongchou/bg.png') no-repeat center center;
    background-size: 100% 100%;
    position: fixed;
    top: 0;
    left: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* 顶部区域样式 */
.top-section {
    display: flex;
    width: 100%;
}

/* 主标题样式 */
.main-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 10px;
    margin-left: 70px;
}

/* 主标题图片响应式样式 */
.main-title img {
    max-width: 100%;
    height: auto;
    width: auto;
    max-height: 80px;
    object-fit: contain;
}

/* 活动规则按钮样式 */
.rules-btn {
    display: flex;
    flex-direction: column;
    margin-right: 3%;
    cursor: pointer;
    /* 确保按钮在屏幕缩放时保持比例 */
    transform-origin: center;
    transition: transform 0.2s ease;
}

.rules-btn img {
    width: auto;
    height: 45px;
    margin-bottom: 5px;
    object-fit: contain;
    /* 确保图片在屏幕缩放时保持比例 */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    transform-origin: center;
}

.rules-text {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
}

.rules-btn:hover {
    transform: scale(1.1);
}

.main-title h1 {
    font-size: 3rem;
    color: #fff;
    margin: 0;
    text-shadow: 0 0 20px rgba(0, 150, 255, 0.8);
    background: linear-gradient(45deg, #00aaff, #0066cc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.activity-period {
    background-image: url("@/assets/img/zhongchou/时间边框.png");
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
    font-size: 1.4rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.9);
    display: inline-block;
    padding: 10px 20px;
    min-width: fit-content;
    /* 确保文字始终在容器内 */
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
    max-width: 100%;
}



/* 主要交互区域 */
.main-interactive-area {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 700px;
    position: relative;
    /* perspective: 1200px; */
    transform-style: preserve-3d;
}

/* 股票区域基础样式 */
.stock-area {
    position: absolute;
    width: 48vw;
    height: 38vw;
    min-width: 560px;
    min-height: 480px;
    max-width: 900px;
    max-height: 800px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 1s ease;
    transform-style: preserve-3d;
    transform-origin: center center;
}

/* 为所有图片添加渲染优化 */
/* .stock-card img,
.rocket-body img,
.base-image img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
} */
/* 美股卡片默认位置 - 居中显示，移除放大效果 */
.left-area {
    transform: translateX(0) rotateY(0deg);
    z-index: 15;
}

/* 港股卡片默认位置 - 火箭右侧，向内倾斜 */
/* .right-area {
    transform: translateX(25vw) rotateY(-25deg) scale(1.5);
} */

/* 美股hover效果 - 移除放大效果，仅保持轻微上移 */
.left-area:hover:not(.active):not(.side) {
    transform: translateX(0) rotateY(0deg) translateY(-10px);
    transition: transform 0.3s ease;
}

/* 港股hover效果 - 在原有倾斜基础上轻微上移 */
/* .right-area:hover:not(.active):not(.side) {
    transform: translateX(25vw) rotateY(-35deg) translateY(-10px) scale(1.55);
    transition: transform 0.3s ease;
} */

/* 美股激活时 - 移动到页面中心并取消倾斜，移除放大效果 */
.left-area.active {
    transform: translateX(0) rotateY(0deg);
    z-index: 20;
}

/* 港股激活时 - 移动到页面中心并取消倾斜 */
/* .right-area.active {
    transform: translateX(0) rotateY(0deg) scale(1.6);
    z-index: 20;
} */

/* 美股在港股激活时 - 移动到后面并保持倾斜 */
/* .left-area.side {
    transform: translateX(-35vw) rotateY(25deg) scale(0.9) !important;
    z-index: 1 !important;
    opacity: 0.4;
} */

/* 港股在美股激活时 - 移动到后面并保持倾斜 */
/* .right-area.side {
    transform: translateX(35vw) rotateY(-25deg) scale(0.9) !important;
    z-index: 1 !important;
    opacity: 0.4;
} */

/* 火箭区域 - 位于美股卡片右边，不覆盖卡片 */
.rocket-area {
    position: absolute;
    z-index: 1;
    /* 位置调整到美股卡片右边，确保不覆盖 */
    top: 35%;
    /* 垂直居中 */
    left: calc(50% + 25vw);
    /* 美股卡片右边位置，增加间距 */
    transform: translate(0, -50%) translateZ(0);
    /* 左对齐，垂直居中 */
}

.rocket-area.hidden {
    opacity: 0.3;
}

/* 股票卡片样式 */
.stock-card {
    width: 100%;
    height: 55vh;
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
}

/* 美股卡片背景 */
.us-card {
    background-image: url('@/assets/img/zhongchou/美股.png');
    position: relative;
    /* 确保子元素可以相对于它进行绝对定位 */
}

/* 周年庆装饰元素 */
.anniversary-decoration {
    position: absolute;
    right: -150px;
    bottom: -90px;
    width: 30vw;
    /* 调整宽度 */
    height: 30vh;
    /* 调整高度 */
    background-image: url('@/assets/img/zhongchou/周年庆装饰.png');
    /* 图片名称中有空格 */
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 100;
    /* 确保浮现于最上层 */
    animation: float 3s ease-in-out infinite;
    /* 添加浮动动画 */
    pointer-events: none;
    /* 确保不会影响鼠标事件 */
}

/* 港股卡片背景 */
/* .hk-card {
    background-image: url('@/assets/img/zhongchou/港股.png') !important;
} */

.card-content {
    width: 100%;
    height: auto;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 20px;
    padding: 20px 20px 20px 20px;
    box-sizing: border-box;
}

/* 港股内容布局 - 进度条在右边 */
/* .hk-content {
    flex-direction: row;
} */

/* 股票信息 */
.stock-info {
    text-align: center;
    color: #fff;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* 剩余时间小于等于3分钟时的样式 */
.time-almost-up h3 {
    color: #ff0000;
}

/* 股票信息标题样式 */
.stock-info h3 {
    margin: 5px 0;
    font-size: 2rem;
    line-height: 1.2;
    word-wrap: break-word;
    /* 允许长单词换行 */
    overflow-wrap: break-word;
    /* 现代浏览器支持 */
    hyphens: auto;
    /* 自动断字 */
}

/* 通用进度条区域样式 */
.progress-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.us-content .progress-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-direction: row-reverse;
    /* 刻度在左，进度条在右 */
}

/* 港股内容布局 - 进度条在左边，刻度在右边 */
/* .hk-content {
    flex-direction: row;
}

.hk-content .progress-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-direction: row;
    /* 进度条在左，刻度在右 */
/* } */

/* 默认进度条容器样式 */
.progress-bar {
    width: 100%;
    height: auto;
    border-radius: 10px;
    position: relative;
    overflow: visible;
    min-width: 20px;
    /* 更改为响应式高度 */
    min-height: 50vh;
}

/* 美股进度条容器 - 蓝色主题背景 */
.us-content .progress-bar {
    background: linear-gradient(to top,
            rgba(79, 195, 247, 0.2),
            rgba(41, 182, 246, 0.3),
            rgba(2, 136, 209, 0.4));
    border: 1px solid rgba(41, 182, 246, 0.5);
    box-shadow: 0 0 10px rgba(41, 182, 246, 0.3);
}

/* 港股进度条容器 - 红色主题背景 */
/* .hk-content .progress-bar {
    background: linear-gradient(to top,
            rgba(255, 138, 128, 0.2),
            rgba(255, 87, 34, 0.3),
            rgba(211, 47, 47, 0.4));
    border: 1px solid rgba(255, 87, 34, 0.5);
    box-shadow: 0 0 10px rgba(255, 87, 34, 0.3);
} */

.time-markers {
    display: flex;
    flex-direction: column;
    height: auto;
    justify-content: space-between;
    align-items: center;
    /* 更改为响应式高度 */
    min-height: 50vh;
}

/* 股票内容容器 */
.stock-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: auto
}

/* 助力按钮区域样式 */
.boost-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    width: 100%;
}

/* 助力按钮样式 */
.boost-btn {
    border: none;
    cursor: pointer;
    transition: transform 0.3s ease;
    z-index: 2;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    width: 240px;
    height: 80px;
    margin-top: -30px;
}

/* 美股助力按钮 */
.us-boost-btn {
    background-image: url('@/assets/img/zhongchou/助力美股.png');
}

/* 美股已助力状态 */
.us-boost-btn.boosted {
    background-image: url('@/assets/img/zhongchou/美股已助力.png');
}

/* 港股助力按钮 */
/* .hk-boost-btn {
    background-image: url('@/assets/img/zhongchou/助力港股.png');
}

/* 港股已助力状态 */
/* .hk-boost-btn.boosted {
    background-image: url('@/assets/img/zhongchou/港股已助力.png');
} */

/* 底座样式 */
.base-image {
    margin-top: -65px;
    z-index: 1;
}

.base-image img {
    width: auto;
    height: 130px;
    display: block;
}

/* 默认进度条填充样式 */
.progress-fill {
    position: absolute;
    bottom: 0;
    width: 100%;
    border-radius: 10px;
    transition: height 0.8s ease;
}

/* 美股进度条填充 - 蓝色系渐变 */
.us-content .progress-fill {
    background: linear-gradient(to top, #4FC3F7, #29B6F6, #0288D1);
}

/* 港股进度条填充 - 红色系渐变 */
/* .hk-content .progress-fill {
    background: linear-gradient(to top, #FF8A80, #FF5722, #D32F2F);
} */

/* 在进度条填充部分顶部添加火箭gif */
.progress-fill::after {
    content: '';
    position: absolute;
    top: -25px;
    /* 火箭位置在填充部分顶部上方 */
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 100px;
    background-image: url('@/assets/img/zhongchou/rocket.gif');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 10;
}

.marker {
    position: relative;
    color: #FFD700;
    /* 默认金色 */
    font-size: 1.4rem;
    font-weight: 700;
    font-family: 'Microsoft YaHei', 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
    transition: all 0.5s ease;
    letter-spacing: 0.5px;
    text-rendering: optimizeLegibility;
    text-align: center;
    min-width: 30px;
}

/* 为刻度数字添加连接线 */
.marker::before {
    content: '';
    position: absolute;
    top: 50%;
    width: 15px;
    height: 1px;
    background-color: currentColor;
    opacity: 0.6;
    transition: all 0.5s ease;
}

/* 美股刻度连接线 - 从右侧连接到进度条 */
.us-content .marker::before {
    right: -13px;
    background-color: #00BFFF;
    /* 蓝色 */
    box-shadow: 0 0 4px rgba(0, 191, 255, 0.5);
}

/* 港股刻度连接线 - 从左侧连接到进度条 */
/* .hk-content .marker::before {
    left: -20px;
    background-color: #FF4444;
    /* 红色 */
/* box-shadow: 0 0 4px rgba(255, 68, 68, 0.5);
} */

/* 美股激活刻度 */
.us-content .marker.reached {
    color: #00BFFF !important;
}

/* 港股激活刻度 */
/* .hk-content .marker.reached {
    color: #FF4444 !important;
    text-shadow: 0 0 10px rgba(255, 68, 68, 0.8) !important;
} */

/* 刻度字体增强样式 */
/* .marker-text {
    font-weight: bold;
    font-family: 'Arial Black', sans-serif;
    color: transparent;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-stroke: 1.5px rgba(255, 255, 255, 0.6);
    text-stroke: 1.5px rgba(255, 255, 255, 0.6);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3), 0 0 20px rgba(255, 255, 255, 0.2);
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.2));
    isolation: isolate;
    z-index: 17;
    position: relative;
} */
.us-btn {
    background: linear-gradient(45deg, #0066cc, #0099ff);
    color: white;
    box-shadow: 0 5px 15px rgba(0, 100, 255, 0.4);
}

/* .hk-btn {
    background: linear-gradient(45deg, #cc3333, #ff6666);
    color: white;
    box-shadow: 0 5px 15px rgba(255, 50, 50, 0.4);
} */

.boost-btn:hover {
    background-size: 110%;
}



.rocket-container {
    position: relative;
    width: 100%;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* .rocket-glow {
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: radial-gradient(circle,
            rgba(0, 150, 255, 0.3) 0%,
            rgba(0, 100, 255, 0.2) 30%,
            transparent 70%);
    animation: pulse 2s ease-in-out infinite;
} */

.rocket-body {
    position: relative;
    z-index: 2;
    animation: float 3s ease-in-out infinite;
}

.rocket-body img {
    width: 15vw;
    height: auto;
    min-width: 100px;
    max-width: 250px;
}

/* 动画效果 */
@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.7;
    }

    50% {
        transform: scale(1.1);
        opacity: 1;
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* 响应式设计 - 针对不同屏幕尺寸优化 */
/* @media (max-width: 1200px) {
    .main-title img {
        max-height: 70px;
    }
} */

@media (max-width: 768px) {

    /* 平板端周年庆装饰元素 */
    .anniversary-decoration {
        width: 40vw;
        /* 调整手机版宽度 */
        height: 40vh;
        /* 调整手机版高度 */
        right: -20px;
        bottom: -100px;
        background-image: url('@/assets/img/zhongchou/手机周年庆装饰.png');
        /* 需要准备此图片资源 */
    }

    .main-title img {
        max-height: 60px;
    }

    .main-interactive-area {
        flex-direction: column;
        gap: 30px;
    }

    /* 股票信息标题样式 */
    .stock-info h3 {
        margin: 5px 0;
        font-size: 1.7rem;
        line-height: 1.2;
        word-wrap: break-word;
        /* 允许长单词换行 */
        overflow-wrap: break-word;
        /* 现代浏览器支持 */
        hyphens: auto;
        /* 自动断字 */
    }

    .stock-area {
        width: 50vw;
        /* 从58vw调整为50vw */
        height: 40vw;
        /* 从50vw调整为40vw */
        min-width: 350px;
        /* 从480px降低到350px */
        min-height: 300px;
        /* 从440px降低到300px */
    }

    .left-area {
        transform: translateX(0) rotateY(0deg);
    }

    /* 移动端火箭位置调整 - 确保不覆盖卡片 */
    .rocket-area {
        left: calc(50% + 30vw);
        top: 50%;
        transform: translate(0, -50%) translateZ(0);
    }

    /* 移动端规则按钮适配 */
    .rules-btn img {
        height: 35%;
        /* 移动端适当缩小图片尺寸 */
    }

    .rules-text {
        font-size: 0.9rem;
        /* 移动端适当缩小文字尺寸 */
    }

    /* 移动端活动时间容器适配 */
    .activity-period {
        font-size: 1.1rem;
        padding: 8px 15px;
        max-width: 90vw;
        /* 确保在小屏幕上不会超出视口 */
    }

    /* .right-area {
        transform: translateX(40vw) rotateY(-25deg) scale(1.3);
    } */
}

@media (max-width: 480px) {
    .rules-btn {
        display: flex;
        flex-direction: column;
        margin-right: 3%;
        cursor: pointer;
        /* 确保按钮在屏幕缩放时保持比例 */
        transform-origin: center;
        transition: transform 0.2s ease;
        margin-top: 35px;
    }

    /* 助力按钮区域样式 */
    .boost-section {
        display: flex;
        flex-direction: column;
        align-items: center;
        position: relative;
        width: 100%;
        margin-top: 20px;
    }

    .interactive-container {
        width: 100vw;
        height: 100vh;
        background: url('@/assets/img/zhongchou/手机bg.png') no-repeat center center;
        background-size: 100% 100%;
        position: fixed;
        top: 0;
        left: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    .main-title {
        margin-left: 12%;
        text-align: center;
        justify-content: center;
        align-items: center;
        margin-top: -10px;
        padding-bottom: 30px;
    }

    .main-title img {
        max-width: 100%;
        height: auto;
        width: auto;
        max-height: 15vh;
        object-fit: contain;
        content: url('@/assets/img/zhongchou/手机助力美股享实时数据.png');
        margin-top: 50px;
    }

    .rules-btn img {
        height: 30px;
    }

    .rules-text {
        font-size: 0.8rem;
    }

    /* 手机端股票卡片背景替换 */
    .us-card {
        background-image: url('@/assets/img/zhongchou/手机组2.png');
    }

    /* 手机端周年庆装饰元素 */
    .anniversary-decoration {
        width: 60vw;
        /* 调整手机版宽度 */
        height: 60vh;
        /* 调整手机版高度 */
        right: 5px;
        bottom: -210px;
        background-image: url('@/assets/img/zhongchou/手机周年庆装饰.png');
        /* 需要准备此图片资源 */
    }


    /* 手机端隐藏火箭图片 */
    .rocket-body img {
        display: none;
    }

    /* 极小屏幕活动时间容器适配 */
    .activity-period {
        font-size: 0.9rem;
        padding: 6px 12px;
        max-width: 85vw;

        /* 在极小屏幕上进一步缩小 */
    }
}

/* 弹窗样式 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    position: relative;
    width: 620px;
    height: 450px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-background {
    width: 100%;
    height: auto;
    background-image: url('@/assets/img/zhongchou/框.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 50px 40px 40px 40px;
    box-sizing: border-box;
}

.modal-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #fff;
    text-align: left;
    width: 100%;
}

.rules-list {
    width: 100%;
    line-height: 1.6; /* 增加行高 */
    margin-top: 10%;
    margin-left: 10%; /* 减少左边距 */
    padding-right: 5%; /* 添加右边距 */
}

.rules-list p {
    margin: 10px 0;
    font-size: 16px;
    color: #fff;
    font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif; /* 使用更清晰的中文字体 */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    line-height: 1.7;
}

.close-btn {
    background-image: url('@/assets/img/zhongchou/知道了.png');
    background-size: 100%;
    background-repeat: no-repeat;
    background-position: center;
    width: 160px;
    height: 60px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.close-btn:hover {
    transform: scale(1.05);
}

/* 助力成功提示样式 */
.boost-success-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    /* 确保显示在最上层 */
    pointer-events: none;
    /* 允许点击穿透 */
}

.boost-success-container img {
    max-width: 300px;
    height: auto;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.5));
}

/* 增强的淡入淡出动画 */
.fade-enter-active {
    animation: bounce-in 0.6s ease-out;
}

.fade-leave-active {
    animation: bounce-out 0.5s ease-in;
}

@keyframes bounce-in {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }

    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.05);
    }

    70% {
        transform: translate(-50%, -50%) scale(0.95);
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes bounce-out {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.05);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
}
</style>
