<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Just Wallpapers</title>
    <style>
        /* Reset and base styles */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background-color: #f5f5f5;
            color: #333;
            line-height: 1.6;
        }
        
        header {
            background: linear-gradient(135deg, #3a1c71, #d76d77, #ffaf7b);
            color: white;
            text-align: center;
            padding: 2rem 1rem;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }
        
        h1 {
            font-size: 2.5rem;
            margin-bottom: 0.5rem;
        }
        
        .subtitle {
            font-size: 1rem;
            opacity: 0.9;
        }
        
        .categories {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            gap: 10px;
            margin: 1.5rem 0;
            padding: 0 1rem;
        }
        
        .category-btn {
            background-color: rgba(255, 255, 255, 0.25);
            border: 2px solid rgba(255, 255, 255, 0.5);
            color: white;
            padding: 8px 16px;
            border-radius: 50px;
            cursor: pointer;
            transition: all 0.3s ease;
            font-weight: 500;
        }
        
        .category-btn:hover, .category-btn.active {
            background-color: rgba(255, 255, 255, 0.4);
            transform: translateY(-2px);
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 2rem 1rem;
        }
        
        .wallpaper-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
            gap: 1.5rem;
        }
        
        .wallpaper-card {
            background-color: white;
            border-radius: 12px;
            overflow: hidden;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
            transition: transform 0.3s ease;
            position: relative;
        }
        
        .wallpaper-card:hover {
            transform: translateY(-5px);
        }
        
        .thumbnail-container {
            position: relative;
            padding-bottom: 56.25%; /* 16:9 aspect ratio */
            height: 0;
            overflow: hidden;
        }
        
        .thumbnail {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            object-fit: cover;
            transition: all 0.3s ease;
        }
        
        .wallpaper-card:hover .thumbnail {
            transform: scale(1.05);
        }
        
        /* Removed wallpaper info styles */
        
        .download-btn {
            position: absolute;
            right: 15px;
            bottom: 15px;
            background-color: #3a1c71;
            color: white;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            display: flex;
            justify-content: center;
            align-items: center;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
            opacity: 1; /* Always visible */
        }
        
        .wallpaper-card:hover .download-btn {
            transform: translateY(-5px);
        }
        
        .download-btn:hover {
            background-color: #d76d77;
            transform: scale(1.1) translateY(-5px);
        }
        
        .download-icon {
            width: 18px;
            height: 18px;
            fill: white;
        }
        
        /* Modal styles */
        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.85);
            z-index: 100;
            justify-content: center;
            align-items: center;
            overflow: auto;
        }
        
        .modal-content {
            position: relative;
            max-width: 90%;
            max-height: 90%;
            animation: zoom 0.3s ease;
        }
        
        .full-wallpaper {
            max-width: 100%;
            max-height: 85vh;
            border-radius: 8px;
            box-shadow: 0 5px 25px rgba(0, 0, 0, 0.5);
        }
        
        .close-modal {
            position: absolute;
            top: 15px;
            right: 15px;
            color: white;
            font-size: 30px;
            cursor: pointer;
            background-color: rgba(0, 0, 0, 0.5);
            width: 40px;
            height: 40px;
            border-radius: 50%;
            display: flex;
            justify-content: center;
            align-items: center;
            transition: all 0.3s ease;
        }
        
        .close-modal:hover {
            background-color: rgba(215, 109, 119, 0.8);
            transform: rotate(90deg);
        }
        
        .modal-download-btn {
            position: absolute;
            bottom: 20px;
            right: 20px;
            background-color: #3a1c71;
            color: white;
            padding: 12px 24px;
            border-radius: 50px;
            display: flex;
            align-items: center;
            gap: 8px;
            cursor: pointer;
            transition: all 0.3s ease;
            font-weight: 600;
        }
        
        .modal-download-btn:hover {
            background-color: #d76d77;
            transform: translateY(-2px);
        }
        
        @keyframes zoom {
            from {transform: scale(0.8); opacity: 0;}
            to {transform: scale(1); opacity: 1;}
        }
        
        /* Search bar styles */
        .search-container {
            max-width: 500px;
            margin: 0 auto 2rem;
            position: relative;
        }
        
        .search-input {
            width: 100%;
            padding: 12px 20px;
            border-radius: 50px;
            border: 2px solid rgba(0, 0, 0, 0.1);
            font-size: 1rem;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
            transition: all 0.3s ease;
        }
        
        .search-input:focus {
            outline: none;
            border-color: #d76d77;
            box-shadow: 0 2px 15px rgba(215, 109, 119, 0.2);
        }
        
        .search-icon {
            position: absolute;
            right: 15px;
            top: 50%;
            transform: translateY(-50%);
            color: #777;
        }
        
        /* Responsive styles */
        @media (max-width: 768px) {
            header {
                padding: 1.5rem 1rem;
            }
            
            h1 {
                font-size: 2rem;
            }
            
            .wallpaper-grid {
                grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
                gap: 1rem;
            }
            
            .modal-content {
                width: 95%;
            }
            
            .full-wallpaper {
                max-height: 70vh;
            }
        }
        
        @media (max-width: 480px) {
            .wallpaper-grid {
                grid-template-columns: 1fr;
            }
            
            .categories {
                flex-wrap: nowrap;
                overflow-x: auto;
                padding-bottom: 10px;
                justify-content: flex-start;
            }
            
            .category-btn {
                flex-shrink: 0;
            }
        }
        
        /* Loading animation */
        .loading {
            display: none;
            text-align: center;
            padding: 2rem;
        }
        
        .loading-spinner {
            display: inline-block;
            width: 50px;
            height: 50px;
            border: 5px solid rgba(215, 109, 119, 0.3);
            border-radius: 50%;
            border-top-color: #d76d77;
            animation: spin 1s ease-in-out infinite;
        }
        
        @keyframes spin {
            to { transform: rotate(360deg); }
        }
        
        /* No results message */
        .no-results {
            display: none;
            text-align: center;
            padding: 2rem;
            font-size: 1.2rem;
            color: #777;
        }
    </style>

    <!-- Pixel Code - https://app.usermetric.io/ -->
    <script defer src="https://app.usermetric.io/pixel/lgWyPB0Anlzc2n47"></script>
    <!-- END Pixel Code -->
</head>
<body>
    <header>
        <h1>Just Wallpapers</h1>
        <p class="subtitle">High-quality wallpapers for your desktop</p>
        <div class="categories">
            <button class="category-btn active" data-category="all">All</button>
            <button class="category-btn" data-category="nature">Nature</button>
            <button class="category-btn" data-category="abstract">Abstract</button>
            <button class="category-btn" data-category="space">Space</button>
            <button class="category-btn" data-category="minimal">Minimal</button>
            <button class="category-btn" data-category="cityscape">Cityscape</button>
        </div>
    </header>
    
    <div class="container">
        <div class="search-container">
            <input type="text" class="search-input" placeholder="Search wallpapers...">
            <span class="search-icon">🔍</span>
        </div>
        
        <div class="wallpaper-grid" id="wallpaper-grid">
            <!-- Wallpapers will be inserted here by JavaScript -->
        </div>
        
        <div class="loading" id="loading">
            <div class="loading-spinner"></div>
            <p>Loading wallpapers...</p>
        </div>
        
        <div class="no-results" id="no-results">
            <p>No wallpapers found matching your search.</p>
        </div>
    </div>
    
    <!-- Modal for viewing wallpaper -->
    <div class="modal" id="wallpaper-modal">
        <span class="close-modal" id="close-modal">&times;</span>
        <div class="modal-content">
            <img class="full-wallpaper" id="full-wallpaper" src="" alt="Full size wallpaper">
            <div class="modal-download-btn" id="modal-download">
                <svg class="download-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
                    <path fill="currentColor" d="M12 16l-5-5 1.41-1.41L11 12.17V4h2v8.17l2.59-2.58L17 11l-5 5zm-6 4h12v-2H6v2z"/>
                </svg>
                Download Wallpaper
            </div>
        </div>
    </div>
    
    <script>
        // Wallpaper data
        const wallpapers = [
            {
                id: 15,
                title: "",
                category: "nature",
                resolution: "",
                thumbnail: "/thumbnails/15.jpg",
                fullImage: "/wallpapers/15.jpg"
            },
            {
                id: 14,
                title: "",
                category: "nature",
                resolution: "",
                thumbnail: "/thumbnails/14.jpg",
                fullImage: "/wallpapers/14.jpg"
            },
            {
                id: 13,
                title: "",
                category: "nature",
                resolution: "",
                thumbnail: "/thumbnails/13.jpg",
                fullImage: "/wallpapers/13.jpg"
            },
            {
                id: 12,
                title: "",
                category: "nature",
                resolution: "",
                thumbnail: "/thumbnails/12.jpg",
                fullImage: "/wallpapers/12.jpg"
            },
            {
                id: 11,
                title: "",
                category: "nature",
                resolution: "",
                thumbnail: "/thumbnails/11.jpg",
                fullImage: "/wallpapers/11.jpg"
            },
            {
                id: 10,
                title: "",
                category: "nature",
                resolution: "",
                thumbnail: "/thumbnails/10.jpg",
                fullImage: "/wallpapers/10.jpg"
            },
            {
                id: 9,
                title: "",
                category: "nature",
                resolution: "",
                thumbnail: "/thumbnails/9.jpg",
                fullImage: "/wallpapers/9.jpg"
            },
            {
                id: 8,
                title: "",
                category: "nature",
                resolution: "",
                thumbnail: "/thumbnails/8.jpg",
                fullImage: "/wallpapers/8.jpg"
            },
            {
                id: 7,
                title: "",
                category: "nature",
                resolution: "",
                thumbnail: "/thumbnails/7.jpg",
                fullImage: "/wallpapers/7.jpg"
            },
            {
                id: 6,
                title: "",
                category: "nature",
                resolution: "",
                thumbnail: "/thumbnails/6.jpg",
                fullImage: "/wallpapers/6.jpg"
            },
            {
                id: 5,
                title: "",
                category: "nature",
                resolution: "",
                thumbnail: "/thumbnails/5.jpg",
                fullImage: "/wallpapers/5.jpg"
            },
            {
                id: 4,
                title: "",
                category: "nature",
                resolution: "",
                thumbnail: "/thumbnails/4.jpg",
                fullImage: "/wallpapers/4.jpg"
            },
            {
                id: 3,
                title: "",
                category: "nature",
                resolution: "",
                thumbnail: "/thumbnails/3.jpg",
                fullImage: "/wallpapers/3.jpg"
            },
            {
                id: 2,
                title: "",
                category: "nature",
                resolution: "",
                thumbnail: "/thumbnails/2.jpg",
                fullImage: "/wallpapers/2.jpg"
            },
            {
                id: 1,
                title: "",
                category: "nature",
                resolution: "",
                thumbnail: "/thumbnails/1.jpg",
                fullImage: "/wallpapers/1.jpg"
            }
        ];
        
        // DOM elements
        const wallpaperGrid = document.getElementById('wallpaper-grid');
        const categoryButtons = document.querySelectorAll('.category-btn');
        const searchInput = document.querySelector('.search-input');
        const modal = document.getElementById('wallpaper-modal');
        const fullWallpaper = document.getElementById('full-wallpaper');
        const closeModal = document.getElementById('close-modal');
        const modalDownload = document.getElementById('modal-download');
        const loadingElement = document.getElementById('loading');
        const noResultsElement = document.getElementById('no-results');
        
        let currentWallpaper = null;
        let activeCategory = 'all';
        let searchTerm = '';
        
        // Initialize the page
        window.addEventListener('DOMContentLoaded', () => {
            renderWallpapers();
            setupEventListeners();
        });
        
        // Render wallpapers to the grid
        function renderWallpapers() {
            showLoading();
            
            setTimeout(() => {
                // Filter wallpapers based on category and search term
                const filteredWallpapers = wallpapers.filter(wallpaper => {
                    const matchesCategory = activeCategory === 'all' || wallpaper.category === activeCategory;
                    const matchesSearch = wallpaper.title.toLowerCase().includes(searchTerm.toLowerCase());
                    return matchesCategory && matchesSearch;
                });
                
                // Clear the current grid
                wallpaperGrid.innerHTML = '';
                
                if (filteredWallpapers.length === 0) {
                    hideLoading();
                    showNoResults();
                    return;
                }
                
                hideNoResults();
                
                // Add wallpapers to the grid
                filteredWallpapers.forEach(wallpaper => {
                    const wallpaperCard = createWallpaperCard(wallpaper);
                    wallpaperGrid.appendChild(wallpaperCard);
                });
                
                hideLoading();
            }, 500); // Simulate loading delay
        }
        
        // Create a wallpaper card element
        function createWallpaperCard(wallpaper) {
            const card = document.createElement('div');
            card.className = 'wallpaper-card';
            card.dataset.id = wallpaper.id;
            
            card.innerHTML = `
                <div class="thumbnail-container">
                    <img src="${wallpaper.thumbnail}" alt="${wallpaper.title}" class="thumbnail">
                    <div class="download-btn" title="Download">
                        <svg class="download-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
                            <path fill="currentColor" d="M12 16l-5-5 1.41-1.41L11 12.17V4h2v8.17l2.59-2.58L17 11l-5 5zm-6 4h12v-2H6v2z"/>
                        </svg>
                    </div>
                </div>
                <!-- Removed wallpaper info section -->
            `;
            
            // Add event listeners to the card
            card.querySelector('.thumbnail-container').addEventListener('click', () => {
                openModal(wallpaper);
            });
            
            card.querySelector('.download-btn').addEventListener('click', (e) => {
                e.stopPropagation();
                downloadWallpaper(wallpaper);
            });
            
            return card;
        }
        
        // Set up event listeners
        function setupEventListeners() {
            // Category filter buttons
            categoryButtons.forEach(button => {
                button.addEventListener('click', () => {
                    // Update active button
                    categoryButtons.forEach(btn => btn.classList.remove('active'));
                    button.classList.add('active');
                    
                    // Update active category and re-render
                    activeCategory = button.dataset.category;
                    renderWallpapers();
                });
            });
            
            // Search input
            searchInput.addEventListener('input', () => {
                searchTerm = searchInput.value;
                renderWallpapers();
            });
            
            // Modal close button
            closeModal.addEventListener('click', () => {
                modal.style.display = 'none';
            });
            
            // Modal download button
            modalDownload.addEventListener('click', () => {
                if (currentWallpaper) {
                    downloadWallpaper(currentWallpaper);
                }
            });
            
            // Close modal when clicking outside the content
            window.addEventListener('click', (e) => {
                if (e.target === modal) {
                    modal.style.display = 'none';
                }
            });
            
            // Close modal with Escape key
            window.addEventListener('keydown', (e) => {
                if (e.key === 'Escape' && modal.style.display === 'flex') {
                    modal.style.display = 'none';
                }
            });
        }
        
        // Open modal with selected wallpaper
        function openModal(wallpaper) {
            currentWallpaper = wallpaper;
            fullWallpaper.src = wallpaper.fullImage;
            fullWallpaper.alt = wallpaper.title;
            modal.style.display = 'flex';
        }
        
        // Download wallpaper function
        function downloadWallpaper(wallpaper) {
            // Create a temporary anchor element to trigger the download
            const downloadLink = document.createElement('a');
            downloadLink.href = wallpaper.fullImage; // Use the full-size image
            downloadLink.download = `wallpaper-${wallpaper.id}.jpg`; // Set filename
            
            // Append to the document, trigger click, and remove
            document.body.appendChild(downloadLink);
            downloadLink.click();
            document.body.removeChild(downloadLink);
        }
        
        // Show loading spinner
        function showLoading() {
            loadingElement.style.display = 'block';
            wallpaperGrid.style.display = 'none';
        }
        
        // Hide loading spinner
        function hideLoading() {
            loadingElement.style.display = 'none';
            wallpaperGrid.style.display = 'grid';
        }
        
        // Show no results message
        function showNoResults() {
            noResultsElement.style.display = 'block';
        }
        
        // Hide no results message
        function hideNoResults() {
            noResultsElement.style.display = 'none';
        }
    </script>
</body>
</html>