<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Wedding Wishes | Kartik & Thana</title>

<link href="https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;1,400&family=Inter:wght@300;400;600&display=swap" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/canvas-confetti@1.6.0/dist/confetti.browser.min.js"></script>

<style>
body{
    margin:0;
    font-family: 'Inter', sans-serif;
    background:#000;
    color:#fff;
    overflow:hidden;
}

/* VIDEO BACKGROUND */
.video-container{
    position:fixed;
    inset:0;
}
video{
    width:100%;
    height:100%;
    object-fit:cover;
}

/* DARK OVERLAY BLUR */
.dim{
    position:fixed;
    inset:0;
    background:rgba(0,0,0,0.4);
    backdrop-filter: blur(8px);
    opacity:0;
    pointer-events:none;
    transition:.5s ease;
    z-index:800;
}
.dim.show{ opacity:1; }

/* ULTRA-BRIGHT PREMIUM BUTTON */
.wish-btn{
    position:absolute;
    bottom:14vh;
    left:50%;
    transform:translateX(-50%);
    padding:22px 65px;
    border:none;
    border-radius:60px;
    background: linear-gradient(180deg, #ffffff 0%, #fff9e3 45%, #f7d774 100%);
    font-family: 'Inter', sans-serif;
    font-weight:900;
    font-size:16px;
    text-transform: uppercase;
    letter-spacing:3px;
    color: #4a3b00;
    cursor:pointer;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.7), 0 10px 30px rgba(0,0,0,0.5);
    animation: brightPulse 2s infinite ease-in-out;
    z-index: 10;
    overflow: hidden; 
    border: 1px solid rgba(255,255,255,0.8);
    transition: transform 0.1s ease; /* Added for haptic feel */
}

/* MOBILE TOUCH FEEDBACK */
.wish-btn:active {
    transform: translateX(-50%) scale(0.92);
}

.wish-btn::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -120%;
    width: 60%;
    height: 200%;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 1), transparent);
    transform: rotate(25deg);
    animation: flashMove 2.5s infinite;
}

@keyframes flashMove {
    0% { left: -120%; }
    15% { left: 150%; }
    100% { left: 150%; }
}

@keyframes brightPulse{
    0%{ transform:translateX(-50%) scale(1); }
    50%{ transform:translateX(-50%) scale(1.06); box-shadow: 0 0 40px rgba(255, 255, 255, 0.9); }
    100%{ transform:translateX(-50%) scale(1); }
}

/* BRIGHT PREMIUM FORM BOX */
.overlay{
    position:fixed;
    inset:0;
    display:none;
    justify-content:center;
    align-items:center;
    z-index:900;
    padding: 20px;
}

.box{
    width:100%;
    max-width:420px;
    padding:45px 35px;
    border-radius:30px;
    background: rgba(255, 255, 255, 0.95); 
    backdrop-filter: blur(10px);
    border: 2px solid #f7d774;
    color:#333; 
    text-align:center;
    box-shadow: 0 30px 60px rgba(0,0,0,0.5);
    transform: scale(0.9) translateY(30px);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.19, 1, 0.22, 1);
}

.overlay.active .box{ 
    transform: scale(1) translateY(0); 
    opacity: 1;
}

/* PREMIUM ADDON: STAGGERED ENTRANCE */
.box > div > * {
    opacity: 0;
    transform: translateY(15px);
    transition: 0.5s ease-out;
}
.overlay.active .box > div > * {
    opacity: 1;
    transform: translateY(0);
}
.overlay.active h2 { transition-delay: 0.1s; }
.overlay.active input { transition-delay: 0.2s; }
.overlay.active textarea { transition-delay: 0.3s; }
.overlay.active .send-btn { transition-delay: 0.4s; }

.box h2{
    font-family: 'Playfair Display', serif;
    font-size:32px;
    font-weight: 700;
    color: #b8860b; 
    margin-bottom:30px;
}

/* BRIGHT INPUTS */
input, textarea {
    width:100%;
    box-sizing: border-box;
    padding:18px;
    margin-bottom:18px;
    border-radius:15px;
    border: 1px solid #ddd;
    background: #fdfdfd;
    color: #111; 
    font-size: 16px;
    font-family: 'Inter', sans-serif;
    transition: 0.3s;
}

input:focus, textarea:focus {
    outline: none;
    border-color: #f7d774;
    box-shadow: 0 0 10px rgba(247, 215, 116, 0.4);
}

input::placeholder, textarea::placeholder {
    color: #999;
}

.send-btn{
    width:100%;
    padding:18px;
    border:none;
    border-radius:15px;
    background: linear-gradient(135deg, #d4af37, #b8860b);
    color:#fff;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing:3px;
    cursor:pointer;
    box-shadow: 0 5px 15px rgba(184, 134, 11, 0.3);
}

.success{ display:none; }
.success h3 { color: #b8860b; font-family: 'Playfair Display', serif; font-size: 28px; }
.success p { color: #555; font-size: 18px; }

canvas.confetti-canvas{
    position:fixed !important;
    inset:0;
    z-index:2000 !important;
    pointer-events:none;
}

/* PREMIUM ADDON: FLOATING HEARTS ANIMATION */
.bg-hearts {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 5;
}
.heart-float {
    position: absolute;
    bottom: -50px;
    color: rgba(255, 255, 255, 0.3);
    font-size: 20px;
    animation: floatUp 6s linear infinite;
}
@keyframes floatUp {
    0% { transform: translateY(0) rotate(0deg); opacity: 0; }
    50% { opacity: 0.5; }
    100% { transform: translateY(-100vh) rotate(360deg); opacity: 0; }
}
</style>
</head>

<body>

<div class="bg-hearts" id="heartsContainer"></div>
<div class="dim" id="dimBg"></div>

<div class="video-container">
    <video autoplay muted loop playsinline>
        <source src="assets/video/qr.mp4" type="video/mp4">
    </video>
    <button class="wish-btn" onclick="openWish()">Leave a Wish ✨</button>
</div>

<div class="overlay" id="wishOverlay">
    <div class="box">
        <div id="formBox">
            <h2>Share Your Blessings</h2>
            <input id="name" placeholder="Your Name">
            <textarea id="message" placeholder="Your Wishes"></textarea>
            <button class="send-btn" onclick="sendWish()">Send Wish</button>
        </div>

        <div class="success" id="successBox">
            <h3>✨ With Gratitude</h3>
            <p>Your lovely wishes have been received with love.</p>
        </div>
    </div>
</div>

<script>
// Premium Heart Generator
function createHeart() {
    const container = document.getElementById('heartsContainer');
    const heart = document.createElement('div');
    heart.innerHTML = '❤';
    heart.className = 'heart-float';
    heart.style.left = Math.random() * 100 + 'vw';
    heart.style.animationDuration = (Math.random() * 3 + 4) + 's';
    heart.style.opacity = Math.random();
    container.appendChild(heart);
    setTimeout(() => heart.remove(), 6000);
}
setInterval(createHeart, 800);

function openWish(){
    const overlay = document.getElementById('wishOverlay');
    const dim = document.getElementById('dimBg');
    overlay.style.display="flex";
    dim.classList.add("show");
    setTimeout(()=>overlay.classList.add("active"),10);
}

function sendWish(){
    const name = document.getElementById('name').value.trim();
    const msg  = document.getElementById('message').value.trim();

    if(!name || !msg){
        alert("Please enter your name and wishes 😊");
        return;
    }

    const fd = new FormData();
    fd.append("name", name);
    fd.append("message", msg);
    fd.append("source", "QR Scan");

    fetch("api/save_wish.php",{method:"POST",body:fd}).then(()=>{
        document.getElementById('dimBg').classList.remove("show");
        document.getElementById('formBox').style.display="none";
        document.getElementById('successBox').style.display="block";

        // HIGH VELOCITY CONFETTI
        const duration = 2 * 1000;
        const end = Date.now() + duration;

        (function frame() {
            confetti({
                particleCount: 10,
                angle: 60,
                spread: 80,
                origin: { x: 0, y: 0.8 },
                colors: ['#f7d774', '#ffffff', '#ff69b4'],
                startVelocity: 70
            });
            confetti({
                particleCount: 10,
                angle: 120,
                spread: 80,
                origin: { x: 1, y: 0.8 },
                colors: ['#f7d774', '#ffffff', '#ff69b4'],
                startVelocity: 70
            });

            if (Date.now() < end) {
                requestAnimationFrame(frame);
            }
        }());

        setTimeout(()=>{
            const overlay = document.getElementById('wishOverlay');
            overlay.classList.remove("active");
            setTimeout(()=>{
                overlay.style.display="none";
                document.getElementById('formBox').style.display="block";
                document.getElementById('successBox').style.display="none";
                document.getElementById('name').value="";
                document.getElementById('message').value="";
            },450);
        },4000);
    });
}
</script>

</body>
</html>