Spaces:
Running

File size: 10,128 Bytes
643e111
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
// Bike Data
const bikes = [
    {
        id: 1,
        name: "Thunder Beast X1",
        category: "Sport",
        price: "$24,999",
        engine: "1000cc",
        power: "200 HP",
        image: "http://static.photos/technology/640x360/101"
    },
    {
        id: 2,
        name: "Cruiser Deluxe Pro",
        category: "Cruiser",
        price: "$19,999",
        engine: "1200cc",
        power: "150 HP",
        image: "http://static.photos/technology/640x360/102"
    },
    {
        id: 3,
        name: "Adventure Rider 500",
        category: "Adventure",
        price: "$22,499",
        engine: "850cc",
        power: "120 HP",
        image: "http://static.photos/technology/640x360/103"
    },
    {
        id: 4,
        name: "Urban Street Fighter",
        category: "Street",
        price: "$16,999",
        engine: "750cc",
        power: "110 HP",
        image: "http://static.photos/technology/640x360/104"
    },
    {
        id: 5,
        name: "Electric E-Storm",
        category: "Electric",
        price: "$28,999",
        engine: "Electric",
        power: "250 HP",
        image: "http://static.photos/technology/640x360/105"
    },
    {
        id: 6,
        name: "Classic Vintage 900",
        category: "Classic",
        price: "$18,499",
        engine: "900cc",
        power: "95 HP",
        image: "http://static.photos/technology/640x360/106"
    }
];

// Initialize Page
document.addEventListener('DOMContentLoaded', function() {
    // Hide loader
    setTimeout(() => {
        const loader = document.getElementById('loader');
        loader.classList.add('hidden');
        setTimeout(() => {
            loader.style.display = 'none';
        }, 500);
    }, 1500);

    // Load bikes
    loadBikes();
    
    // Initialize counters
    initCounters();
    
    // Setup form submission
    setupContactForm();
    
    // Setup scroll effects
    setupScrollEffects();
});

// Load Bikes
function loadBikes() {
    const bikesGrid = document.getElementById('bikesGrid');
    
    bikes.forEach((bike, index) => {
        const bikeCard = document.createElement('div');
        bikeCard.className = 'bike-card bg-primary-800 rounded-xl overflow-hidden shadow-xl hover:shadow-2xl cursor-pointer';
        bikeCard.innerHTML = `
            <div class="relative overflow-hidden h-48">
                <img src="${bike.image}" alt="${bike.name}" class="bike-image w-full h-full object-cover">
                <div class="absolute top-4 right-4 bg-accent-500 text-white px-3 py-1 rounded-full text-sm font-bold">
                    ${bike.category}
                </div>
            </div>
            <div class="p-6">
                <h3 class="text-2xl font-bold mb-2">${bike.name}</h3>
                <div class="flex justify-between items-center mb-4">
                    <span class="text-3xl font-bold text-accent-500">${bike.price}</span>
                    <div class="flex space-x-2">
                        <span class="text-sm text-primary-400">${bike.engine}</span>
                        <span class="text-sm text-primary-400">•</span>
                        <span class="text-sm text-primary-400">${bike.power}</span>
                    </div>
                </div>
                <button onclick="viewBikeDetails(${bike.id})" class="w-full px-4 py-2 bg-primary-700 hover:bg-accent-500 text-white font-bold rounded-lg transition-all duration-300">
                    View Details
                </button>
            </div>
        `;
        
        bikesGrid.appendChild(bikeCard);
        
        // Animate cards on scroll
        setTimeout(() => {
            bikeCard.style.opacity = '0';
            bikeCard.style.transform = 'translateY(20px)';
            bikeCard.style.transition = 'all 0.5s ease';
            
            setTimeout(() => {
                bikeCard.style.opacity = '1';
                bikeCard.style.transform = 'translateY(0)';
            }, 100 * index);
        }, 100);
    });
}

// View Bike Details
function viewBikeDetails(bikeId) {
    const bike = bikes.find(b => b.id === bikeId);
    if (bike) {
        showNotification(`Viewing details for ${bike.name}`);
        // In a real app, this would navigate to a details page or open a modal
    }
}

// Initialize Counter Animation
function initCounters() {
    const counters = document.querySelectorAll('.counter');
    const speed = 200;
    
    const observerOptions = {
        threshold: 0.5
    };
    
    const observer = new IntersectionObserver((entries) => {
        entries.forEach(entry => {
            if (entry.isIntersecting) {
                const counter = entry.target;
                const target = +counter.getAttribute('data-target');
                const increment = target / speed;
                
                const updateCounter = () => {
                    const current = +counter.innerText;
                    
                    if (current < target) {
                        counter.innerText = Math.ceil(current + increment);
                        setTimeout(updateCounter, 10);
                    } else {
                        counter.innerText = target;
                    }
                };
                
                updateCounter();
                observer.unobserve(counter);
            }
        });
    }, observerOptions);
    
    counters.forEach(counter => {
        observer.observe(counter);
    });
}

// Setup Contact Form
function setupContactForm() {
    const form = document.getElementById('contactForm');
    if (form) {
        form.addEventListener('submit', function(e) {
            e.preventDefault();
            
            // Show success notification
            showNotification('Message sent successfully! We\'ll get back to you soon.');
            
            // Reset form
            form.reset();
        });
    }
}

// Setup Scroll Effects
function setupScrollEffects() {
    let lastScroll = 0;
    const navbar = document.querySelector('nav');
    
    window.addEventListener('scroll', () => {
        const currentScroll = window.pageYOffset;
        
        // Add shadow on scroll
        if (currentScroll > 10) {
            navbar.classList.add('shadow-lg', 'navbar-scrolled');
        } else {
            navbar.classList.remove('shadow-lg', 'navbar-scrolled');
        }
        
        lastScroll = currentScroll;
    });
}

// Smooth Scroll to Section
function scrollToSection(sectionId) {
    const section = document.getElementById(sectionId);
    if (section) {
        section.scrollIntoView({ behavior: 'smooth', block: 'start' });
    }
}

// Show Notification
function showNotification(message) {
    // Create notification element
    const notification = document.createElement('div');
    notification.className = 'fixed bottom-4 right-4 bg-accent-500 text-white px-6 py-3 rounded-lg shadow-lg z-50 transform translate-y-20 transition-transform duration-300';
    notification.textContent = message;
    
    document.body.appendChild(notification);
    
    // Show notification
    setTimeout(() => {
        notification.style.transform = 'translateY(0)';
    }, 100);
    
    // Hide notification after 3 seconds
    setTimeout(() => {
        notification.style.transform = 'translateY(20px)';
        setTimeout(() => {
            document.body.removeChild(notification);
        }, 300);
    }, 3000);
}

// Filter Bikes by Category
function filterBikes(category) {
    const filteredBikes = category === 'all' 
        ? bikes 
        : bikes.filter(bike => bike.category.toLowerCase() === category.toLowerCase());
    
    const bikesGrid = document.getElementById('bikesGrid');
    bikesGrid.innerHTML = '';
    
    filteredBikes.forEach((bike, index) => {
        const bikeCard = document.createElement('div');
        bikeCard.className = 'bike-card bg-primary-800 rounded-xl overflow-hidden shadow-xl hover:shadow-2xl cursor-pointer';
        bikeCard.innerHTML = `
            <div class="relative overflow-hidden h-48">
                <img src="${bike.image}" alt="${bike.name}" class="bike-image w-full h-full object-cover">
                <div class="absolute top-4 right-4 bg-accent-500 text-white px-3 py-1 rounded-full text-sm font-bold">
                    ${bike.category}
                </div>
            </div>
            <div class="p-6">
                <h3 class="text-2xl font-bold mb-2">${bike.name}</h3>
                <div class="flex justify-between items-center mb-4">
                    <span class="text-3xl font-bold text-accent-500">${bike.price}</span>
                    <div class="flex space-x-2">
                        <span class="text-sm text-primary-400">${bike.engine}</span>
                        <span class="text-sm text-primary-400">•</span>
                        <span class="text-sm text-primary-400">${bike.power}</span>
                    </div>
                </div>
                <button onclick="viewBikeDetails(${bike.id})" class="w-full px-4 py-2 bg-primary-700 hover:bg-accent-500 text-white font-bold rounded-lg transition-all duration-300">
                    View Details
                </button>
            </div>
        `;
        
        bikesGrid.appendChild(bikeCard);
    });
}

// Add to Cart (for future implementation)
function addToCart(bikeId) {
    const bike = bikes.find(b => b.id === bikeId);
    if (bike) {
        showNotification(`${bike.name} added to wishlist!`);
    }
}

// Search Bikes
function searchBikes(query) {
    const filteredBikes = bikes.filter(bike => 
        bike.name.toLowerCase().includes(query.toLowerCase()) ||
        bike.category.toLowerCase().includes(query.toLowerCase())
    );
    
    if (filteredBikes.length === 0) {
        showNotification('No bikes found matching your search.');
    } else {
        // Update the grid with filtered results
        const bikesGrid = document.getElementById('bikesGrid');
        bikesGrid.innerHTML = '';
        filteredBikes.forEach((bike, index) => {
            // Reuse the bike card creation logic
        });
    }
}