<?php
// welcome_splash.php - Full‑screen flex overlay (non‑editable)
?>
<style>
/* ========== OVERLAY CONTAINER (fixed, full‑screen) ========== */
.splash-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0f172a 0%, #1e3c72 40%, #2a5298 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    overflow: hidden;
    font-family: 'Inter', sans-serif;
}

/* ========= GLITTER OVERLAY (full screen) ========= */
.splash-overlay .glitter-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    background: repeating-radial-gradient(circle at 20% 30%, rgba(255,215,0,0.08) 0px, rgba(255,215,0,0.08) 2px, transparent 2px, transparent 8px);
    animation: glitterMove 12s linear infinite;
}

@keyframes glitterMove {
    0% { background-position: 0 0; }
    100% { background-position: 200px 200px; }
}

/* ========= SPARKLE PARTICLES ========= */
.splash-overlay .sparkle {
    position: absolute;
    width: 3px;
    height: 3px;
    background: #d4af37;
    border-radius: 50%;
    box-shadow: 0 0 12px #d4af37;
    opacity: 0;
    animation: sparkleAnim 3s ease-in-out infinite;
    pointer-events: none;
    z-index: 2;
}

@keyframes sparkleAnim {
    0% { opacity: 0; transform: scale(0); }
    50% { opacity: 0.8; transform: scale(1); }
    100% { opacity: 0; transform: scale(0); }
}

/* ========= FLOATING BACKGROUND PARTICLES ========= */
.splash-overlay .particles {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 1;
}
.splash-overlay .particle {
    position: absolute; width: 4px; height: 4px;
    background: #d4af37; border-radius: 50%;
    opacity: 0.6; animation: rise 15s infinite ease-in-out;
    box-shadow: 0 0 10px #d4af37;
}
@keyframes rise {
    0% { transform: translateY(100vh) scale(0); opacity: 0; }
    10%, 90% { opacity: 0.8; }
    100% { transform: translateY(-100px) scale(1); opacity: 0; }
}

/* ========= MAIN SPLASH CARD ========= */
.splash-overlay .splash-container {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(20px);
    border-radius: 28px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.45), 0 0 40px rgba(212, 175, 55, 0.25);
    padding: 20px 20px;
    max-width: 750px;
    width: 90%;
    border: 1px solid rgba(212, 175, 55, 0.3);
    position: relative;
    z-index: 10;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    text-align: center;
    animation: fadeInUp 1s ease-out;
}

.splash-overlay .splash-container::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, transparent, #d4af37, #e6c06b, #d4af37, transparent);
    animation: shimmer 2.5s infinite linear;
}

@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(40px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Close button */
.splash-overlay .close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 20;
    border: 1px solid #d4af37;
    color: #d4af37;
    font-size: 20px;
    font-weight: bold;
}
.splash-overlay .close-btn:hover {
    background: rgba(212, 175, 55, 0.8);
    color: #0f172a;
    transform: scale(1.1);
}

/* Corner ornaments */
.splash-overlay .ornament {
    position: absolute; width: 60px; height: 60px; opacity: 0.6; z-index: 1;
}
.splash-overlay .ornament.top-left { top: 20px; left: 20px; border-top: 2px solid #d4af37; border-left: 2px solid #d4af37; border-radius: 8px 0 0 0; }
.splash-overlay .ornament.top-right { top: 20px; right: 20px; border-top: 2px solid #d4af37; border-right: 2px solid #d4af37; border-radius: 0 8px 0 0; }
.splash-overlay .ornament.bottom-left { bottom: 20px; left: 20px; border-bottom: 2px solid #d4af37; border-left: 2px solid #d4af37; border-radius: 0 0 0 8px; }
.splash-overlay .ornament.bottom-right { bottom: 20px; right: 20px; border-bottom: 2px solid #d4af37; border-right: 2px solid #d4af37; border-radius: 0 0 8px 0; }

/* Welcome text */
.splash-overlay .welcome-text {
    font-family: 'Playfair Display', serif;
    font-size: 46px;
    font-weight: 800;
    background: linear-gradient(135deg, #d4af37 0%, #fff4c2 40%, #e6c06b 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0 0 15px rgba(212, 175, 55, 0.6);
    letter-spacing: 1.5px;
    animation: gentleGlow 2.5s ease-in-out infinite alternate;
}
@keyframes gentleGlow {
    from { text-shadow: 0 0 5px rgba(212, 175, 55, 0.4); }
    to { text-shadow: 0 0 25px rgba(212, 175, 55, 0.9); }
}

/* Emblem */
.splash-overlay .emblem {
    width: 130px; height: 130px;
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 12px 40px rgba(30, 60, 114, 0.5), 0 0 0 5px rgba(212, 175, 55, 0.4);
    animation: pulse 2.5s infinite ease-in-out;
    cursor: pointer;
    border: 3px solid rgba(255,255,255,0.9);
}
.splash-overlay .emblem:hover {
    transform: scale(1.1) rotate(3deg);
    box-shadow: 0 18px 55px rgba(30, 60, 114, 0.7), 0 0 0 7px rgba(212, 175, 55, 0.7);
}
.splash-overlay .emblem::after {
    content: '🔍';
    position: absolute;
    bottom: -5px; right: 10px;
    background: #d4af37;
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #0f172a;
    opacity: 0;
    transition: 0.3s;
}
.splash-overlay .emblem:hover::after { opacity: 1; bottom: 0; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.04); } }
.splash-overlay .emblem-image {
    width: 100%; height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255,255,255,0.9);
}

/* Text content */
.splash-overlay .honoree-name {
    font-family: 'Playfair Display', serif;
    font-size: 40px; font-weight: 800;
    background: linear-gradient(135deg, #1e3c72, #2a5298, #e6c06b);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: textGlow 3s ease-in-out infinite alternate;
}
@keyframes textGlow {
    from { text-shadow: 0 2px 10px rgba(0,0,0,0.08); }
    to { text-shadow: 0 4px 20px rgba(212, 175, 55, 0.3); }
}
.splash-overlay .designation {
    color: #2a5298;
    font-size: 21px; font-weight: 600;
    position: relative;
    padding-bottom: 8px;
}
.splash-overlay .designation::after {
    content: ''; position: absolute; bottom: 0; left: 50%;
    transform: translateX(-50%);
    width: 100px; height: 2px;
    background: linear-gradient(90deg, transparent, #d4af37, transparent);
}

/* Visit info (centered) */
.splash-overlay .visit-info {
    color: #1e293b; font-size: 17px; font-weight: 500;
    padding: 24px 30px;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.12), rgba(30, 60, 114, 0.08));
    border-radius: 16px;
    border-left: 4px solid #d4af37; border-right: 4px solid #d4af37;
    width: 100%; max-width: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.splash-overlay .visit-info i {
    color: #d4af37; font-size: 24px;
    animation: bounce 2s infinite;
}
@keyframes bounce {
    0%,20%,50%,80%,100% { transform: translateY(0); }
    40% { transform: translateY(-5px); }
    60% { transform: translateY(-3px); }
}
.splash-overlay .visit-subtext {
    font-size: 15px; color: #64748b;
}
.splash-overlay .divider {
    width: 100px; height: 3px;
    background: linear-gradient(90deg, transparent, #d4af37, #e6c06b, #d4af37, transparent);
    border-radius: 3px;
    overflow: hidden;
}
.splash-overlay .divider::after {
    content: ''; display: block; width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
    animation: dividerShine 2s infinite;
}
@keyframes dividerShine { 100% { transform: translateX(200%); } }

.splash-overlay .footer-text {
    color: #94a3b8;
    font-size: 13px;
    margin-top: auto;
    padding-top: 25px;
}

/* Modal popup (lightbox) */
.splash-overlay .modal {
    display: none;
    position: fixed;
    z-index: 100000;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.94);
    backdrop-filter: blur(12px);
    justify-content: center;
    align-items: center;
}
.splash-overlay .modal.active { display: flex; }
.splash-overlay .modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
}
.splash-overlay .modal-image {
    max-width: 100%;
    max-height: 85vh;
    border-radius: 20px;
    border: 4px solid #d4af37;
}
.splash-overlay .modal-close {
    position: absolute;
    top: -50px;
    right: 0;
    width: 50px; height: 50px;
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    color: white;
    cursor: pointer;
    border: 3px solid #d4af37;
}
.splash-overlay .modal-close:hover {
    background: #d4af37;
    transform: rotate(90deg) scale(1.1);
    color: #0f172a;
}
.splash-overlay .modal-caption {
    text-align: center;
    color: #e6c06b;
    font-family: 'Playfair Display', serif;
    font-size: 18px;
    margin-top: 20px;
}

/* Responsive */
@media (max-width: 768px) {
    .splash-overlay .splash-container { padding: 50px 40px; }
    .splash-overlay .welcome-text { font-size: 28px; }
    .splash-overlay .honoree-name { font-size: 32px; }
    .splash-overlay .emblem { width: 115px; height: 115px; }
}
@media (max-width: 480px) {
    .splash-overlay .splash-container { padding: 40px 25px; }
    .splash-overlay .welcome-text { font-size: 22px; }
    .splash-overlay .honoree-name { font-size: 26px; }
    .splash-overlay .emblem { width: 100px; height: 100px; }
    .splash-overlay .modal-close { top: -40px; width: 42px; height: 42px; font-size: 28px; }
}
</style>

<div class="splash-overlay" id="welcomeSplash">
    <div class="glitter-overlay"></div>
    <div class="particles" id="splashParticles"></div>

    <div class="splash-container">
        <div class="close-btn" id="closeSplashBtn">✕</div>
        <div class="ornament top-left"></div>
        <div class="ornament top-right"></div>
        <div class="ornament bottom-left"></div>
        <div class="ornament bottom-right"></div>

        <div class="welcome-text">✨ We Warmly Welcome ✨</div>

        <div class="emblem" id="splashEmblemTrigger">
            <img src="images/dpi.jpeg" alt="DPI Emblem" class="emblem-image" onerror="this.parentElement.innerHTML='<i class=\'fas fa-graduation-cap\' style=\'font-size:48px;color:white;\'></i>'">
        </div>

        <div class="honoree-name">Mr. Muhammad Shafique Khan</div>
        <div class="designation">Director Public Instructions (E&amp;S Education, AJ&K)</div>

        <div class="visit-info">
            <i class="fas fa-map-marker-alt"></i>
            <div>
                <div>On his visit to District Kotli, AJ&amp;K</div>
                <div class="visit-subtext">Following his appointment as DPI</div>
            </div>
        </div>

        <div class="divider"></div>
        <div class="footer-text">© 2026 E&S Education Department, District Kotli, AJ&amp;K</div>
    </div>

    <!-- Lightbox -->
    <div id="splashModal" class="modal">
        <div class="modal-content">
            <span class="modal-close" id="splashModalClose">&times;</span>
            <img class="modal-image" id="splashModalImage" src="images/dpi.jpeg" alt="Emblem">
            <div class="modal-caption">Director Public Instructions • E&amp;S Education, AJ&amp;K</div>
        </div>
    </div>
</div>

<script>
// Particles and sparkles (inside overlay)
function createSplashParticles() {
    const container = document.getElementById('splashParticles');
    if (!container) return;
    for (let i = 0; i < 30; i++) {
        const p = document.createElement('div');
        p.className = 'particle';
        p.style.width = (Math.random() * 5 + 2) + 'px';
        p.style.height = p.style.width;
        p.style.left = Math.random() * 100 + '%';
        p.style.animationDelay = Math.random() * 15 + 's';
        p.style.animationDuration = Math.random() * 12 + 8 + 's';
        container.appendChild(p);
    }
}
function createSplashSparkles() {
    const overlay = document.querySelector('.splash-overlay');
    for (let i = 0; i < 45; i++) {
        const s = document.createElement('div');
        s.className = 'sparkle';
        s.style.left = Math.random() * 100 + '%';
        s.style.top = Math.random() * 100 + '%';
        s.style.animationDelay = Math.random() * 5 + 's';
        overlay.appendChild(s);
    }
}
// Close overlay (reveals index page)
function closeWelcomeSplash() {
    const splash = document.getElementById('welcomeSplash');
    if (splash) splash.style.display = 'none';
}
// Lightbox functions
const modal = document.getElementById('splashModal');
const modalImg = document.getElementById('splashModalImage');
function openModal(imgSrc) {
    modalImg.src = imgSrc;
    modal.classList.add('active');
    document.body.style.overflow = 'hidden';
}
function closeModal() {
    modal.classList.remove('active');
    document.body.style.overflow = '';
}
// Event listeners
document.getElementById('closeSplashBtn').onclick = closeWelcomeSplash;
const emblemTrigger = document.getElementById('splashEmblemTrigger');
if (emblemTrigger) {
    emblemTrigger.onclick = () => {
        let src = document.querySelector('.emblem-image').src;
        if (!src || src.includes('fa-graduation-cap')) {
            src = 'data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"%3E%3Crect fill="%231e3c72" width="200" height="200"/%3E%3Ctext x="100" y="120" font-family="Arial" font-size="80" fill="%23d4af37" text-anchor="middle"%3E🎓%3C/text%3E%3C/svg%3E';
        }
        openModal(src);
    };
}
document.getElementById('splashModalClose').onclick = closeModal;
modal.onclick = (e) => { if (e.target === modal) closeModal(); };
document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && modal.classList.contains('active')) closeModal(); });
// Staggered entrance
const items = document.querySelectorAll('.splash-container > :not(.close-btn):not(.ornament)');
items.forEach((el, i) => {
    el.style.opacity = '0';
    el.style.transform = 'translateY(20px)';
    setTimeout(() => {
        el.style.transition = 'opacity 0.5s, transform 0.5s';
        el.style.opacity = '1';
        el.style.transform = 'translateY(0)';
    }, 300 + i * 80);
});
// Initialize particles and sparkles
createSplashParticles();
createSplashSparkles();
</script>