<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>黄金涵 生日快乐</title>
    <script src="https://cdn.jsdelivr.net/npm/particles.js@2.0.0/particles.min.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: "Microsoft Yahei", sans-serif;
        }
        body {
            overflow: hidden;
            background: #fff;
        }
        .page {
            width: 100vw;
            height: 100vh;
            display: none;
            position: absolute;
            top: 0;
            left: 0;
        }
        .page.active {
            display: flex;
        }

        /* ========== 第一页：密码弹窗 ========== */
        #page1 {
            background: linear-gradient(135deg, #ffe6f2, #fff0f8);
            align-items: center;
            justify-content: center;
        }
        .login-box {
            background: #fff;
            padding: 40px 30px;
            border-radius: 24px;
            box-shadow: 0 8px 24px #ffb8d880;
            text-align: center;
            width: 320px;
            border: 2px solid #ffc8e0;
        }
        .login-box h2 {
            color: #ff6699;
            margin-bottom: 24px;
            font-size: 26px;
        }
        .name-show {
            font-size: 20px;
            color: #ff77aa;
            margin-bottom:16px;
            font-weight: bold;
        }
        .login-box input {
            width: 100%;
            padding:12px 16px;
            border: 2px solid #ffd6e8;
            border-radius:14px;
            font-size:18px;
            outline: none;
            margin-bottom:20px;
        }
        .btn-group {
            display: flex;
            gap:12px;
        }
        button {
            flex:1;
            padding:12px;
            border-radius:12px;
            border:none;
            font-size:17px;
            cursor:pointer;
            transition: 0.2s;
        }
        #okBtn {
            background: linear-gradient(90deg,#ff88bb,#ff6699);
            color:white;
        }
        #cancelBtn {
            background: #f8f8f8;
            color:#777;
        }
        button:active {
            transform: scale(0.96);
        }

        /* ========== 第二页：kitty气泡祝福 ========== */
        #page2 {
            background: linear-gradient(135deg, #fff0f7, #ffe6f2);
            padding:20px;
        }
        .bubble {
            position: absolute;
            padding:12px 16px;
            border-radius: 20px;
            color:#444;
            font-size:15px;
            max-width:220px;
            opacity:0;
            transform: scale(0.4);
            transition: all 0.4s ease-out;
            box-shadow: 0 3px 10px #ffb8d860;
        }
        .bubble.show {
            opacity:1;
            transform: scale(1);
        }
        .bubble:nth-child(odd){
            background: linear-gradient(120deg,#ffd6ec,#ffb8da);
        }
        .bubble:nth-child(even){
            background: linear-gradient(120deg,#ffe6f4,#ffcce5);
        }

        /* ========== 第三页：粒子文字 ========== */
        #page3 {
            background: #0a0a18;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }
        #particles-js {
            width:100%;
            height:100%;
            position:absolute;
        }
        .text-wrap {
            z-index: 2;
            text-align:center;
        }
        .line1 {
            font-size: 48px;
            color:#ffb8dd;
            margin-bottom:12px;
            font-weight:bold;
        }
        .line2 {
            font-size: 42px;
            color:#ffcce6;
        }
    </style>
</head>
<body>

<!-- 页面1 密码登录 -->
<div id="page1" class="page active">
    <div class="login-box">
        <h2>✨ 生日快乐邀请函 ✨</h2>
        <div class="name-show">黄金涵</div>
        <input id="pwdInput" type="password" placeholder="">
        <div class="btn-group">
            <button id="okBtn">确定</button>
            <button id="cancelBtn">取消</button>
        </div>
    </div>
</div>

<!-- 页面2 气泡祝福 -->
<div id="page2" class="page"></div>

<!-- 页面3 粒子汇聚 -->
<div id="page3" class="page">
    <div id="particles-js"></div>
    <div class="text-wrap">
        <div class="line1">聂小静</div>
        <div class="line2">happybirthday</div>
    </div>
</div>

<script>
const page1 = document.getElementById('page1');
const page2 = document.getElementById('page2');
const page3 = document.getElementById('page3');
const pwdInput = document.getElementById('pwdInput');
const okBtn = document.getElementById('okBtn');
const cancelBtn = document.getElementById('cancelBtn');

// 30条给黄金涵的生日祝福
const wishList = [
    "黄金涵！生日快乐天天开心🥰",
    "黄金涵新一岁平安顺遂✨",
    "黄金涵要一直被温柔包围呀🎀",
    "黄金涵所有愿望都实现🎂",
    "黄金涵吃好喝好没有烦恼🍰",
    "黄金涵岁岁无忧，万事胜意💖",
    "黄金涵永远闪闪发光🌟",
    "黄金涵新岁好运源源不断🧸",
    "黄金涵快乐不止今天哦🎈",
    "黄金涵想要的都慢慢来到🥳",
    "黄金涵生活甜甜，万事顺心🍬",
    "黄金涵保持热爱奔赴美好🌷",
    "黄金涵烦恼通通都跑掉💨",
    "黄金涵被爱包围，幸福常在💗",
    "黄金涵每一日都轻松自在☁️",
    "黄金涵前程明亮一路繁花🌸",
    "黄金涵健康平安，喜乐常伴🎁",
    "黄金涵永远可爱永远热烈🎀",
    "黄金涵好事接踵而至🥂",
    "黄金涵日子温柔又闪亮✨",
    "黄金涵遇见所有美好惊喜🎊",
    "黄金涵大胆做喜欢的自己💫",
    "黄金涵三餐温暖四季安康🍛",
    "黄金涵所有努力都有回报📖",
    "黄金涵笑口常开，甜甜蜜蜜🍓",
    "黄金涵永远拥有小幸运🍀",
    "黄金涵新一岁自在随心🌿",
    "黄金涵浪漫和好运全都给你💝",
    "黄金涵永远是最珍贵的存在💎",
    "黄金涵生日快乐，岁岁欢喜🎂"
];

// 密码校验
okBtn.onclick = ()=>{
    if(pwdInput.value === "1012"){
        page1.classList.remove("active");
        page2.classList.add("active");
        startBubble();
    }else{
        alert("密码不对哦");
        pwdInput.value = "";
    }
}
cancelBtn.onclick = ()=>{
    pwdInput.value = "";
}
pwdInput.onkeydown = (e)=>{
    if(e.key === 'Enter') okBtn.click();
}

// 气泡逐个弹出，随机位置，尽量不重叠
function startBubble(){
    let idx = 0;
    const maxW = window.innerWidth - 240;
    const maxH = window.innerHeight - 80;
    const usedPos = [];
    function addOne(){
        if(idx >= wishList.length){
            setTimeout(()=>{
                page2.classList.remove("active");
                page3.classList.add("active");
                initParticle();
            }, 1200);
            return;
        }
        const div = document.createElement('div');
        div.className = "bubble";
        div.innerText = wishList[idx];
        // 找不重叠位置
        let x,y,ok=false,tryCnt=0;
        while(!ok && tryCnt<80){
            x = Math.random()*maxW;
            y = Math.random()*maxH;
            ok = usedPos.every(p=>{
                const dx = Math.abs(p.x - x);
                const dy = Math.abs(p.y - y);
                return dx>230 || dy>90;
            })
            tryCnt++;
        }
        usedPos.push({x,y});
        div.style.left = x + "px";
        div.style.top = y + "px";
        page2.appendChild(div);
        setTimeout(()=> div.classList.add("show"), 50);
        idx++;
        setTimeout(addOne, 380);
    }
    addOne();
}

// 粒子汇聚
function initParticle(){
    if(window.pJSDom && window.pJSDom[0]){
        window.pJSDom[0].pJS.fn.vendors.destroypJS();
    }
    particlesJS("particles-js",{
        "particles":{
            "number":{"value":800,"density":{"enable":true,"value_area":800}},
            "color":{"value":"#ffb8dd"},
            "shape":{"type":"circle"},
            "opacity":{"value":0.7},
            "size":{"value":3},
            "line_linked":{"enable":false},
            "move":{"enable":true,"speed":1.2,"direction":"none","random":true,"straight":false,"out_mode":"out"}
        },
        "interactivity":{"detect_on":"canvas","events":{"onhover":{"enable":false},"onclick":{"enable":false}}},
        "retina_detect":true
    })
}
</script>
</body>
</html>
