AnesKAM commited on
Commit
2c70f8f
·
verified ·
1 Parent(s): e2dc412

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +246 -228
index.html CHANGED
@@ -61,7 +61,6 @@
61
  .bg-mesh::after { content: ''; position: absolute; bottom: -15%; left: -10%; width: 45vw; height: 45vw; background: radial-gradient(circle, rgba(224, 66, 122, 0.1) 0%, transparent 70%); border-radius: 50%; animation: drift 22s ease-in-out infinite alternate-reverse; }
62
  @keyframes drift { from { transform: translate(0, 0) scale(1); } to { transform: translate(4%, 3%) scale(1.06); } }
63
 
64
- /* ===== NAVBAR ===== */
65
  .navbar {
66
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%); width: 95%; max-width: 1280px;
67
  height: auto; min-height: 68px; background: var(--bg-nav); backdrop-filter: blur(28px) saturate(1.6);
@@ -85,7 +84,6 @@
85
  #theme-toggle { background: var(--bg-input); border: 1.5px solid var(--border); color: var(--text-sub); cursor: pointer; width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: var(--transition); }
86
  #theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
87
 
88
- /* ===== TABS ===== */
89
  .tabs-bar {
90
  position: fixed; top: 98px; left: 50%; transform: translateX(-50%); width: 95%; max-width: 1280px;
91
  display: flex; gap: 6px; z-index: 999; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none;
@@ -95,7 +93,6 @@
95
  .tab-pill:hover { border-color: var(--border-hover); color: var(--accent); }
96
  .tab-pill.active { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 4px 16px var(--accent-glow); }
97
 
98
- /* ===== LAYOUT ===== */
99
  .page-wrapper { position: relative; z-index: 1; max-width: 1280px; margin: 170px auto 60px; padding: 0 16px; display: flex; flex-direction: column; gap: 24px; }
100
  .results-area { min-width: 0; width: 100%; }
101
 
@@ -103,7 +100,6 @@
103
  #loading-text.spinning::before { content: ''; display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
104
  @keyframes spin { to { transform: rotate(360deg); } }
105
 
106
- /* ===== STANDARD RESULTS ===== */
107
  .search-result { background: var(--bg-card); border: 1.5px solid var(--border); border-radius: var(--radius-card); padding: 18px 20px; margin-bottom: 12px; transition: var(--transition); box-shadow: var(--shadow-card); display: flex; gap: 14px; align-items: flex-start; animation: fadeSlideIn 0.35s ease both; }
108
  @keyframes fadeSlideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
109
  .search-result:hover { border-color: var(--border-hover); box-shadow: var(--shadow-hover); transform: translateY(-2px); }
@@ -115,30 +111,27 @@
115
  .result-title:hover { color: var(--accent-2) !important; }
116
  .result-snippet { font-size: 13.5px; color: var(--text-sub); line-height: 1.65; }
117
 
118
- /* ========================================= */
119
  /* ===== RICH RESULTS (KNOWLEDGE GRAPH) ===== */
120
- /* ========================================= */
121
  .rich-graph-container { display: flex; flex-direction: column; gap: 16px; margin-bottom: 24px; animation: fadeSlideIn 0.35s ease both; }
122
-
123
- /* 1. Images Row */
124
- .rich-images-row { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 5px; }
125
  .rich-images-row::-webkit-scrollbar { display: none; }
126
- .rich-img-card { display: block; height: 160px; border-radius: 14px; overflow: hidden; flex-shrink: 0; background: var(--bg-input); border: 1px solid var(--border); box-shadow: var(--shadow-card); transition: var(--transition); }
127
  .rich-img-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: var(--border-hover); }
128
  .rich-img-card img { height: 100%; width: auto; object-fit: cover; display: block; }
 
 
129
  .rich-img-skeleton { height: 160px; width: 140px; border-radius: 14px; background: linear-gradient(90deg, var(--bg-input) 25%, var(--border) 50%, var(--bg-input) 75%); background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite; flex-shrink: 0; }
 
130
 
131
- /* 2. Wiki/Main Card */
132
  .wiki-card { margin-bottom: 0 !important; }
133
  .wiki-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
134
  .wiki-domain { font-size: 13px; font-weight: bold; color: var(--text-main); }
135
  .wiki-url { font-size: 11px; color: var(--text-faint); text-decoration: none; }
136
 
137
- /* 3. Section Titles */
138
  .rich-section-title { font-size: 18px; font-weight: 700; margin: 10px 0; color: var(--text-main); display: flex; align-items: center; gap: 8px; }
139
  .rich-section-title i { font-size: 14px; color: var(--text-faint); margin-right: auto; }
140
 
141
- /* 4. Videos Row */
142
  .rich-videos-row { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 10px; scrollbar-width: none; }
143
  .rich-videos-row::-webkit-scrollbar { display: none; }
144
  .rich-vid-card { flex: 0 0 240px; text-decoration: none; background: var(--bg-card); border-radius: 14px; overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow-card); transition: var(--transition); }
@@ -149,24 +142,21 @@
149
  .rich-vid-info { padding: 12px; }
150
  .rich-vid-title { font-size: 13px; font-weight: 600; color: var(--text-main); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.5; }
151
  .rich-vid-meta { font-size: 11px; color: var(--text-faint); margin-top: 6px; display: flex; align-items: center; gap: 4px; }
152
- .rich-vid-meta img { width: 14px; height: 14px; border-radius: 50%; }
153
 
154
- /* 5. Discover Bubbles */
155
  .discover-bubbles { display: flex; flex-direction: column; gap: 8px; }
156
- .discover-bubble { background: var(--bg-card); border: 1.5px solid var(--border); border-radius: var(--radius-pill); padding: 14px 20px; display: flex; align-items: center; gap: 14px; cursor: pointer; transition: var(--transition); font-family: 'Tajawal', sans-serif; font-size: 15px; font-weight: 500; color: var(--text-main); text-align: right; box-shadow: var(--shadow-card); }
157
  .discover-bubble i { color: var(--text-faint); font-size: 15px; }
158
  .discover-bubble:hover { background: var(--bg-input-focus); border-color: var(--accent); color: var(--accent); transform: translateX(-5px); }
159
 
160
- /* ========================================= */
161
-
162
- /* ===== GRID LAYOUTS (For pure Images/Videos tabs) ===== */
163
  .images-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; width: 100%; }
164
- .image-card { background: var(--bg-card); border: 1.5px solid var(--border); border-radius: var(--radius-card); overflow: hidden; transition: var(--transition); box-shadow: var(--shadow-card); animation: fadeSlideIn 0.35s ease both; display: flex; flex-direction: column; }
165
  .image-card:hover { border-color: var(--border-hover); box-shadow: var(--shadow-hover); transform: translateY(-5px); }
166
  .image-card-link { display: block; width: 100%; height: 170px; overflow: hidden; background: var(--bg-input); position: relative; }
167
  .image-card-link img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; display: block; }
168
  .image-card:hover .image-card-link img { transform: scale(1.06); }
169
  .image-info { padding: 9px 10px; font-size: 11.5px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-top: 1px solid var(--border); background: var(--bg-card); }
 
 
170
 
171
  .videos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 20px; width: 100%; }
172
  .video-card { background: var(--bg-card); border: 1.5px solid var(--border); border-radius: var(--radius-card); overflow: hidden; transition: var(--transition); box-shadow: var(--shadow-card); animation: fadeSlideIn 0.35s ease both; }
@@ -177,7 +167,6 @@
177
  .video-details { padding: 12px; }
178
  .video-title { font-size: 14px; font-weight: 700; color: var(--text-main); text-decoration: none; display: block; margin-bottom: 5px; line-height: 1.4; }
179
 
180
- /* ===== AI WIDGET ===== */
181
  .sidebar { width: 100%; order: 2; margin-top: 12px; }
182
  .ai-widget-wrap { position: relative; border-radius: var(--radius-card); }
183
  .ai-glow-ring { position: absolute; inset: -2px; border-radius: calc(var(--radius-card) + 2px); background: conic-gradient(from var(--angle, 0deg), var(--accent), var(--accent-2), #a78bfa, var(--accent), var(--accent-2), var(--accent)); z-index: 0; animation: spin-glow 4s linear infinite; filter: blur(1px); }
@@ -191,12 +180,12 @@
191
  .ai-answer-body { font-size: 13.5px; color: var(--text-sub); line-height: 1.75; min-height: 60px; }
192
  .ai-skeleton { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--bg-input) 25%, var(--border) 50%, var(--bg-input) 75%); background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite; margin-bottom: 8px; }
193
  .ai-widget-footer { font-size: 10.5px; color: var(--text-faint); margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 5px; }
194
-
195
  .ai-mobile-wrap { display: none; position: relative; border-radius: var(--radius-card); margin-bottom: 16px; }
196
 
197
  .empty-state { text-align: center; padding: 60px 20px; color: var(--text-sub); }
198
  .empty-state i { font-size: 40px; margin-bottom: 16px; color: var(--text-faint); display: block; }
199
-
200
  .results-meta { font-size: 12px; color: var(--text-faint); margin-bottom: 14px; display: flex; align-items: center; gap: 6px; }
201
  .results-meta span { color: var(--accent); font-weight: 600; }
202
 
@@ -208,6 +197,7 @@
208
  .sidebar { display: none !important; }
209
  .ai-mobile-wrap { display: block; }
210
  .rich-img-card { height: 120px; }
 
211
  }
212
  @media (min-width: 768px) {
213
  .navbar { flex-wrap: nowrap; padding: 0 22px; height: 68px; gap: 0; }
@@ -288,232 +278,260 @@
288
  </div>
289
 
290
  <script>
291
- (function() {
292
- const SEARXNG_URL = "https://cjj-on-hf-searxng.hf.space/search";
293
-
294
- // Theme
295
- const themeBtn = document.getElementById('theme-toggle');
296
- function setTheme(t) {
297
- document.documentElement.setAttribute('data-theme', t);
298
- localStorage.setItem('surfgo-theme', t);
299
- themeBtn.innerHTML = t === 'dark' ? '<i class="fa-solid fa-sun"></i>' : '<i class="fa-solid fa-moon"></i>';
300
- }
301
- setTheme(localStorage.getItem('surfgo-theme') || 'light');
302
- themeBtn.addEventListener('click', () => setTheme(document.documentElement.getAttribute('data-theme') === 'dark' ? 'light' : 'dark'));
303
-
304
- // State
305
- const params = new URLSearchParams(window.location.search);
306
- let query = params.get('q') || '';
307
- let currentTab = params.get('tab') || 'all';
308
- let allResults =[];
309
-
310
- const inputEl = document.getElementById('main-input');
311
- const resultsEl = document.getElementById('results-container');
312
- const loadingEl = document.getElementById('loading-text');
313
- const metaEl = document.getElementById('results-meta');
314
-
315
- function setActiveTab(tab) {
316
- document.querySelectorAll('.tab-pill').forEach(btn => btn.classList.toggle('active', btn.dataset.tab === tab));
317
- }
318
- setActiveTab(currentTab);
319
-
320
- // Helpers
321
- function escapeHTML(str) { return str ? str.replace(/[&<>'"]/g, t => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', "'": '&#39;', '"': '&quot;' }[t] || t)) : ''; }
322
- function getDomain(url) { try { return new URL(url).hostname.replace('www.', ''); } catch { return url || ''; } }
323
- function proxyImage(url) { return url && !url.startsWith('data:') ? `https://wsrv.nl/?url=${encodeURIComponent(url)}&output=webp&maxage=7d&default=placeholder` : url; }
324
- function faviconURL(domain) { return `https://www.google.com/s2/favicons?domain=${domain}&sz=32`; }
325
- function getBestImageUrl(r) {
326
- const candidates =[r.img_src, r.thumbnail_src, r.thumbnail, r.image, r.url, r.img];
327
- for (const c of candidates) if (c && typeof c === 'string' && c.match(/\.(jpg|jpeg|png|gif|webp)/i)) return c;
328
- return candidates.find(c => c && typeof c === 'string' && c.startsWith('http'));
329
- }
330
 
331
- // Dummy AI Fallback
332
- function runAI(q, results) {
333
- const els = [document.getElementById('ai-answer-body'), document.getElementById('ai-answer-body-mobile')];
334
- els.forEach(el => { if(el) el.innerHTML = '<div class="ai-skeleton"></div><div class="ai-skeleton"></div>'; });
335
- setTimeout(() => {
336
- const text = results[0] ? `بناءً على البحث، ${results[0].content.slice(0, 150)}...` : 'لا توجد معلومات كافية.';
337
- els.forEach(el => { if(el) el.textContent = text; });
338
- }, 1500);
339
- }
340
 
341
- // Search Trigger
342
- async function performSearch(q, tab = 'all') {
343
- resultsEl.innerHTML = ''; metaEl.style.display = 'none';
344
- loadingEl.style.display = 'flex'; loadingEl.classList.add('spinning');
345
- const category = { all: 'general', news: 'news', images: 'images', videos: 'videos' }[tab] || 'general';
346
-
347
- try {
348
- const response = await fetch(`${SEARXNG_URL}?q=${encodeURIComponent(q)}&format=json&categories=${category}&language=ar&safesearch=1`, { signal: AbortSignal.timeout(15000) });
349
- const data = await response.json();
350
- allResults = data.results ||[];
351
- loadingEl.style.display = 'none';
352
-
353
- if (allResults.length > 0) {
354
- metaEl.style.display = 'flex'; metaEl.innerHTML = `تقريباً <span>${allResults.length}</span> نتيجة`;
355
- runAI(q, allResults);
356
-
357
- if (tab === 'images') renderImages(allResults);
358
- else if (tab === 'videos') renderVideos(allResults);
359
- else renderWeb(q, allResults);
360
- } else {
361
- resultsEl.innerHTML = `<div class="empty-state"><i class="fa-solid fa-face-frown"></i><p>لا توجد نتائج لـ "${escapeHTML(q)}"</p></div>`;
362
- }
363
- } catch (error) {
364
- loadingEl.style.display = 'none';
365
- resultsEl.innerHTML = `<div class="empty-state"><i class="fa-solid fa-triangle-exclamation"></i><p>تعذّر الاتصال بالمحرك.</p></div>`;
366
  }
 
 
 
367
  }
 
 
 
 
 
 
 
 
 
 
368
 
369
- // --- RICH RESULTS INJECTION (Knowledge Graph Style) ---
370
- function renderWeb(q, results) {
371
- resultsEl.innerHTML = '';
372
-
373
- // 1. استخراج نتيجة ويكيبيديا أو أول نتيجة لتكون البطاقة الرئيسية
374
- let mainCard = results.find(r => r.url.includes('wikipedia.org'));
375
- if (!mainCard) mainCard = results.find(r => !r.url.includes('youtube.com')); // Fallback
376
-
377
- // 2. استخراج الفيديوهات من النتائج العامة
378
- const ytResults = results.filter(r => r.url.includes('youtube.com/watch')).slice(0, 4);
379
-
380
- // حاوية النتائج الغنية
381
- const richContainer = document.createElement('div');
382
- richContainer.className = 'rich-graph-container';
383
-
384
- // -- أ. شريط الصور العلوي (يتم جلبه في الخلفية) --
385
- const imagesRow = document.createElement('div');
386
- imagesRow.className = 'rich-images-row';
387
- imagesRow.innerHTML = `<div class="rich-img-skeleton"></div><div class="rich-img-skeleton"></div><div class="rich-img-skeleton"></div><div class="rich-img-skeleton"></div>`;
388
- richContainer.appendChild(imagesRow);
389
-
390
- fetch(`${SEARXNG_URL}?q=${encodeURIComponent(q)}&format=json&categories=images&language=ar`)
391
- .then(res => res.json())
392
- .then(data => {
393
- if (data.results && data.results.length > 0) {
394
- imagesRow.innerHTML = data.results.slice(0, 6).map(r => {
395
  const imgUrl = proxyImage(getBestImageUrl(r));
396
- return `<a href="${imgUrl}" target="_blank" class="rich-img-card"><img src="${imgUrl}" alt="صورة" loading="lazy" /></a>`;
 
 
 
397
  }).join('');
398
- } else { imagesRow.style.display = 'none'; }
399
- }).catch(() => imagesRow.style.display = 'none');
400
-
401
- // -- ب. بطاقة المعرفة (ويكيبيديا غالباً) --
402
- if (mainCard) {
403
- const dmn = getDomain(mainCard.url);
404
- const isWiki = dmn.includes('wikipedia');
405
- richContainer.innerHTML += `
406
- <div class="wiki-card search-result">
407
- <div class="wiki-header">
408
- <img src="${faviconURL(dmn)}" class="favicon-wrap" style="width:24px;height:24px;border-radius:4px" />
409
- <div>
410
- <div class="wiki-domain">${isWiki ? 'ويكيبيديا' : escapeHTML(dmn)}</div>
411
- <a href="${mainCard.url}" target="_blank" class="wiki-url">${mainCard.url}</a>
412
- </div>
413
- </div>
414
- <a href="${mainCard.url}" target="_blank" class="result-title" style="font-size:20px;">${escapeHTML(mainCard.title)}</a>
415
- <p class="result-snippet">${escapeHTML(mainCard.content)}</p>
416
- </div>
417
- `;
418
- }
419
 
420
- // -- ج. الفيديوهات --
421
- if (ytResults.length > 0) {
422
- richContainer.innerHTML += `
423
- <h3 class="rich-section-title">فيديوهات لـ ${escapeHTML(q)} <i class="fa-solid fa-chevron-left"></i></h3>
424
- <div class="rich-videos-row">
425
- ${ytResults.map(r => {
426
- const vidMatch = r.url.match(/v=([^&]+)/);
427
- const thumb = vidMatch ? \`https://img.youtube.com/vi/\${vidMatch[1]}/mqdefault.jpg\` : proxyImage(r.thumbnail);
428
- return \`<a href="\${r.url}" target="_blank" class="rich-vid-card">
429
- <div class="rich-vid-thumb">
430
- <img src="\${thumb}" alt="thumb" loading="lazy" />
431
- <div class="rich-vid-play"><i class="fa-solid fa-play"></i></div>
432
- </div>
433
- <div class="rich-vid-info">
434
- <div class="rich-vid-title">\${escapeHTML(r.title)}</div>
435
- <div class="rich-vid-meta"><img src="\${faviconURL('youtube.com')}" /> YouTube</div>
436
- </div>
437
- </a>\`;
438
- }).join('')}
439
  </div>
440
- `;
441
- }
 
 
 
442
 
443
- // -- د. استكشف بالتفصيل (أزرار البحث) --
444
- const discoverQueries =[`${q} جميلة جدا`, `أنواع ${q}`, `صور ${q}`, `فيديوهات ${q}`, `معلومات عن ${q}`];
445
  richContainer.innerHTML += `
446
- <h3 class="rich-section-title">استكشف ${escapeHTML(q)} بالتفصيل</h3>
447
- <div class="discover-bubbles">
448
- ${discoverQueries.map(dq => \`
449
- <button class="discover-bubble" onclick="document.getElementById('main-input').value='\${dq}'; document.getElementById('search-form').dispatchEvent(new Event('submit'));">
450
- <i class="fa-solid fa-magnifying-glass"></i> \${dq}
451
- </button>
452
- \`).join('')}
 
 
 
 
 
 
 
 
 
453
  </div>
454
  `;
455
-
456
- resultsEl.appendChild(richContainer);
457
-
458
- // --- 3. عرض باقي النتائج العادية تحته ---
459
- results.filter(r => r !== mainCard && !ytResults.includes(r)).forEach(r => {
460
- const domain = getDomain(r.url);
461
- const article = document.createElement('article');
462
- article.className = 'search-result';
463
- article.innerHTML = `
464
- <div class="favicon-wrap"><img src="${faviconURL(domain)}" loading="lazy"></div>
465
- <div class="result-content">
466
- <div class="result-domain"><i class="fa-solid fa-link"></i> ${escapeHTML(domain)}</div>
467
- <a class="result-title" href="${escapeHTML(r.url)}" target="_blank">${escapeHTML(r.title)}</a>
468
- <p class="result-snippet">${escapeHTML(r.content)}</p>
469
- </div>`;
470
- resultsEl.appendChild(article);
471
- });
472
  }
473
 
474
- // Normal Render functions for other tabs
475
- function renderImages(results) {
476
- const wrap = document.createElement('div'); wrap.className = 'images-grid';
477
- results.forEach(r => {
478
- const img = proxyImage(getBestImageUrl(r));
479
- if(!img) return;
480
- wrap.innerHTML += `<div class="image-card">
481
- <a class="image-card-link" href="${r.url}" target="_blank"><img src="${escapeHTML(img)}" loading="lazy"></a>
482
- <div class="image-info">${escapeHTML(r.title)}</div>
483
- </div>`;
 
 
 
 
 
 
 
 
 
 
 
 
 
484
  });
485
- resultsEl.appendChild(wrap);
486
- }
487
 
488
- function renderVideos(results) {
489
- const wrap = document.createElement('div'); wrap.className = 'videos-grid';
490
- results.forEach(r => {
491
- wrap.innerHTML += `<div class="video-card">
492
- <a href="${r.url}" target="_blank" class="video-thumb-wrap">
493
- <img src="${proxyImage(r.thumbnail)}" loading="lazy"><div class="play-overlay"><i class="fa-solid fa-play"></i></div>
494
- </a>
495
- <div class="video-details"><a class="video-title" href="${r.url}" target="_blank">${escapeHTML(r.title)}</a></div>
 
 
 
 
 
 
 
496
  </div>`;
497
- });
498
- resultsEl.appendChild(wrap);
499
- }
500
 
501
- // Events
502
- if (query) { inputEl.value = query; performSearch(query, currentTab); }
503
- document.getElementById('search-form').addEventListener('submit', (e) => {
504
- e.preventDefault(); const q = inputEl.value.trim(); if (!q) return;
505
- const url = new URL(window.location); url.searchParams.set('q', q); url.searchParams.set('tab', currentTab);
506
- window.history.pushState({}, '', url); query = q; performSearch(q, currentTab);
 
 
 
 
 
 
 
507
  });
508
- document.querySelectorAll('.tab-pill').forEach(btn => {
509
- btn.addEventListener('click', () => {
510
- const tab = btn.dataset.tab; if (tab === currentTab) return;
511
- currentTab = tab; setActiveTab(tab);
512
- const url = new URL(window.location); url.searchParams.set('tab', tab); if (query) url.searchParams.set('q', query);
513
- window.history.pushState({}, '', url); if (query) performSearch(query, tab);
514
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
515
  });
516
- })();
 
517
  </script>
518
  </body>
519
  </html>
 
61
  .bg-mesh::after { content: ''; position: absolute; bottom: -15%; left: -10%; width: 45vw; height: 45vw; background: radial-gradient(circle, rgba(224, 66, 122, 0.1) 0%, transparent 70%); border-radius: 50%; animation: drift 22s ease-in-out infinite alternate-reverse; }
62
  @keyframes drift { from { transform: translate(0, 0) scale(1); } to { transform: translate(4%, 3%) scale(1.06); } }
63
 
 
64
  .navbar {
65
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%); width: 95%; max-width: 1280px;
66
  height: auto; min-height: 68px; background: var(--bg-nav); backdrop-filter: blur(28px) saturate(1.6);
 
84
  #theme-toggle { background: var(--bg-input); border: 1.5px solid var(--border); color: var(--text-sub); cursor: pointer; width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: var(--transition); }
85
  #theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
86
 
 
87
  .tabs-bar {
88
  position: fixed; top: 98px; left: 50%; transform: translateX(-50%); width: 95%; max-width: 1280px;
89
  display: flex; gap: 6px; z-index: 999; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none;
 
93
  .tab-pill:hover { border-color: var(--border-hover); color: var(--accent); }
94
  .tab-pill.active { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 4px 16px var(--accent-glow); }
95
 
 
96
  .page-wrapper { position: relative; z-index: 1; max-width: 1280px; margin: 170px auto 60px; padding: 0 16px; display: flex; flex-direction: column; gap: 24px; }
97
  .results-area { min-width: 0; width: 100%; }
98
 
 
100
  #loading-text.spinning::before { content: ''; display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
101
  @keyframes spin { to { transform: rotate(360deg); } }
102
 
 
103
  .search-result { background: var(--bg-card); border: 1.5px solid var(--border); border-radius: var(--radius-card); padding: 18px 20px; margin-bottom: 12px; transition: var(--transition); box-shadow: var(--shadow-card); display: flex; gap: 14px; align-items: flex-start; animation: fadeSlideIn 0.35s ease both; }
104
  @keyframes fadeSlideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
105
  .search-result:hover { border-color: var(--border-hover); box-shadow: var(--shadow-hover); transform: translateY(-2px); }
 
111
  .result-title:hover { color: var(--accent-2) !important; }
112
  .result-snippet { font-size: 13.5px; color: var(--text-sub); line-height: 1.65; }
113
 
 
114
  /* ===== RICH RESULTS (KNOWLEDGE GRAPH) ===== */
 
115
  .rich-graph-container { display: flex; flex-direction: column; gap: 16px; margin-bottom: 24px; animation: fadeSlideIn 0.35s ease both; }
116
+
117
+ .rich-images-row { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 5px; min-height: 160px; align-items: center; }
 
118
  .rich-images-row::-webkit-scrollbar { display: none; }
119
+ .rich-img-card { display: block; height: 160px; border-radius: 14px; overflow: hidden; flex-shrink: 0; background: var(--bg-input); border: 1px solid var(--border); box-shadow: var(--shadow-card); transition: var(--transition); position: relative; }
120
  .rich-img-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: var(--border-hover); }
121
  .rich-img-card img { height: 100%; width: auto; object-fit: cover; display: block; }
122
+ .rich-img-card .img-error { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: var(--bg-input); color: var(--text-faint); font-size: 12px; flex-direction: column; gap: 4px; }
123
+ .rich-img-card .img-error i { font-size: 20px; }
124
  .rich-img-skeleton { height: 160px; width: 140px; border-radius: 14px; background: linear-gradient(90deg, var(--bg-input) 25%, var(--border) 50%, var(--bg-input) 75%); background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite; flex-shrink: 0; }
125
+ @keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
126
 
 
127
  .wiki-card { margin-bottom: 0 !important; }
128
  .wiki-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
129
  .wiki-domain { font-size: 13px; font-weight: bold; color: var(--text-main); }
130
  .wiki-url { font-size: 11px; color: var(--text-faint); text-decoration: none; }
131
 
 
132
  .rich-section-title { font-size: 18px; font-weight: 700; margin: 10px 0; color: var(--text-main); display: flex; align-items: center; gap: 8px; }
133
  .rich-section-title i { font-size: 14px; color: var(--text-faint); margin-right: auto; }
134
 
 
135
  .rich-videos-row { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 10px; scrollbar-width: none; }
136
  .rich-videos-row::-webkit-scrollbar { display: none; }
137
  .rich-vid-card { flex: 0 0 240px; text-decoration: none; background: var(--bg-card); border-radius: 14px; overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow-card); transition: var(--transition); }
 
142
  .rich-vid-info { padding: 12px; }
143
  .rich-vid-title { font-size: 13px; font-weight: 600; color: var(--text-main); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.5; }
144
  .rich-vid-meta { font-size: 11px; color: var(--text-faint); margin-top: 6px; display: flex; align-items: center; gap: 4px; }
 
145
 
 
146
  .discover-bubbles { display: flex; flex-direction: column; gap: 8px; }
147
+ .discover-bubble { background: var(--bg-card); border: 1.5px solid var(--border); border-radius: var(--radius-pill); padding: 14px 20px; display: flex; align-items: center; gap: 14px; cursor: pointer; transition: var(--transition); font-family: 'Tajawal', sans-serif; font-size: 15px; font-weight: 500; color: var(--text-main); text-align: right; box-shadow: var(--shadow-card); width: 100%; }
148
  .discover-bubble i { color: var(--text-faint); font-size: 15px; }
149
  .discover-bubble:hover { background: var(--bg-input-focus); border-color: var(--accent); color: var(--accent); transform: translateX(-5px); }
150
 
 
 
 
151
  .images-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; width: 100%; }
152
+ .image-card { background: var(--bg-card); border: 1.5px solid var(--border); border-radius: var(--radius-card); overflow: hidden; transition: var(--transition); box-shadow: var(--shadow-card); animation: fadeSlideIn 0.35s ease both; display: flex; flex-direction: column; position: relative; }
153
  .image-card:hover { border-color: var(--border-hover); box-shadow: var(--shadow-hover); transform: translateY(-5px); }
154
  .image-card-link { display: block; width: 100%; height: 170px; overflow: hidden; background: var(--bg-input); position: relative; }
155
  .image-card-link img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; display: block; }
156
  .image-card:hover .image-card-link img { transform: scale(1.06); }
157
  .image-info { padding: 9px 10px; font-size: 11.5px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-top: 1px solid var(--border); background: var(--bg-card); }
158
+ .img-load-error { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: var(--bg-input); color: var(--text-faint); flex-direction: column; gap: 6px; font-size: 12px; }
159
+ .img-load-error i { font-size: 24px; }
160
 
161
  .videos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 20px; width: 100%; }
162
  .video-card { background: var(--bg-card); border: 1.5px solid var(--border); border-radius: var(--radius-card); overflow: hidden; transition: var(--transition); box-shadow: var(--shadow-card); animation: fadeSlideIn 0.35s ease both; }
 
167
  .video-details { padding: 12px; }
168
  .video-title { font-size: 14px; font-weight: 700; color: var(--text-main); text-decoration: none; display: block; margin-bottom: 5px; line-height: 1.4; }
169
 
 
170
  .sidebar { width: 100%; order: 2; margin-top: 12px; }
171
  .ai-widget-wrap { position: relative; border-radius: var(--radius-card); }
172
  .ai-glow-ring { position: absolute; inset: -2px; border-radius: calc(var(--radius-card) + 2px); background: conic-gradient(from var(--angle, 0deg), var(--accent), var(--accent-2), #a78bfa, var(--accent), var(--accent-2), var(--accent)); z-index: 0; animation: spin-glow 4s linear infinite; filter: blur(1px); }
 
180
  .ai-answer-body { font-size: 13.5px; color: var(--text-sub); line-height: 1.75; min-height: 60px; }
181
  .ai-skeleton { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--bg-input) 25%, var(--border) 50%, var(--bg-input) 75%); background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite; margin-bottom: 8px; }
182
  .ai-widget-footer { font-size: 10.5px; color: var(--text-faint); margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 5px; }
183
+
184
  .ai-mobile-wrap { display: none; position: relative; border-radius: var(--radius-card); margin-bottom: 16px; }
185
 
186
  .empty-state { text-align: center; padding: 60px 20px; color: var(--text-sub); }
187
  .empty-state i { font-size: 40px; margin-bottom: 16px; color: var(--text-faint); display: block; }
188
+
189
  .results-meta { font-size: 12px; color: var(--text-faint); margin-bottom: 14px; display: flex; align-items: center; gap: 6px; }
190
  .results-meta span { color: var(--accent); font-weight: 600; }
191
 
 
197
  .sidebar { display: none !important; }
198
  .ai-mobile-wrap { display: block; }
199
  .rich-img-card { height: 120px; }
200
+ .rich-img-skeleton { height: 120px; width: 100px; }
201
  }
202
  @media (min-width: 768px) {
203
  .navbar { flex-wrap: nowrap; padding: 0 22px; height: 68px; gap: 0; }
 
278
  </div>
279
 
280
  <script>
281
+ (function() {
282
+ const SEARXNG_URL = "https://cjj-on-hf-searxng.hf.space/search";
283
+
284
+ // Theme
285
+ const themeBtn = document.getElementById('theme-toggle');
286
+ function setTheme(t) {
287
+ document.documentElement.setAttribute('data-theme', t);
288
+ localStorage.setItem('surfgo-theme', t);
289
+ themeBtn.innerHTML = t === 'dark' ? '<i class="fa-solid fa-sun"></i>' : '<i class="fa-solid fa-moon"></i>';
290
+ }
291
+ setTheme(localStorage.getItem('surfgo-theme') || 'light');
292
+ themeBtn.addEventListener('click', () => setTheme(document.documentElement.getAttribute('data-theme') === 'dark' ? 'light' : 'dark'));
293
+
294
+ // State
295
+ const params = new URLSearchParams(window.location.search);
296
+ let query = params.get('q') || '';
297
+ let currentTab = params.get('tab') || 'all';
298
+ let allResults = [];
299
+
300
+ const inputEl = document.getElementById('main-input');
301
+ const resultsEl = document.getElementById('results-container');
302
+ const loadingEl = document.getElementById('loading-text');
303
+ const metaEl = document.getElementById('results-meta');
304
+
305
+ function setActiveTab(tab) {
306
+ document.querySelectorAll('.tab-pill').forEach(btn => btn.classList.toggle('active', btn.dataset.tab === tab));
307
+ }
308
+ setActiveTab(currentTab);
309
+
310
+ // Helpers
311
+ function escapeHTML(str) { return str ? str.replace(/[&<>'"]/g, t => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', "'": '&#39;', '"': '&quot;' }[t] || t)) : ''; }
312
+ function getDomain(url) { try { return new URL(url).hostname.replace('www.', ''); } catch { return url || ''; } }
313
+ function proxyImage(url) { return url && !url.startsWith('data:') ? `https://wsrv.nl/?url=${encodeURIComponent(url)}&output=webp&maxage=7d&default=placeholder` : url; }
314
+ function faviconURL(domain) { return `https://www.google.com/s2/favicons?domain=${domain}&sz=32`; }
315
+ function getBestImageUrl(r) {
316
+ const candidates = [r.img_src, r.thumbnail_src, r.thumbnail, r.image, r.url, r.img];
317
+ for (const c of candidates) if (c && typeof c === 'string' && c.match(/\.(jpg|jpeg|png|gif|webp)/i)) return c;
318
+ return candidates.find(c => c && typeof c === 'string' && c.startsWith('http'));
319
+ }
320
 
321
+ // AI Fallback
322
+ function runAI(q, results) {
323
+ const els = [document.getElementById('ai-answer-body'), document.getElementById('ai-answer-body-mobile')];
324
+ els.forEach(el => { if (el) { el.classList.add('loading'); el.innerHTML = '<div class="ai-skeleton"></div><div class="ai-skeleton"></div>'; } });
325
+ setTimeout(() => {
326
+ const text = results[0] ? `بناءً على البحث، ${results[0].content.slice(0, 150)}...` : 'لا توجد معلومات كافية.';
327
+ els.forEach(el => { if (el) { el.classList.remove('loading'); el.textContent = text; } });
328
+ }, 1500);
329
+ }
330
 
331
+ // Search Trigger
332
+ async function performSearch(q, tab = 'all') {
333
+ resultsEl.innerHTML = ''; metaEl.style.display = 'none';
334
+ loadingEl.style.display = 'flex'; loadingEl.classList.add('spinning');
335
+ const category = { all: 'general', news: 'news', images: 'images', videos: 'videos' }[tab] || 'general';
336
+
337
+ try {
338
+ const response = await fetch(`${SEARXNG_URL}?q=${encodeURIComponent(q)}&format=json&categories=${category}&language=ar&safesearch=1`, { signal: AbortSignal.timeout(15000) });
339
+ const data = await response.json();
340
+ allResults = data.results || [];
341
+ loadingEl.style.display = 'none';
342
+
343
+ if (allResults.length > 0) {
344
+ metaEl.style.display = 'flex'; metaEl.innerHTML = `تقريباً <span>${allResults.length}</span> نتيجة`;
345
+ runAI(q, allResults);
346
+
347
+ if (tab === 'images') renderImages(allResults);
348
+ else if (tab === 'videos') renderVideos(allResults);
349
+ else renderWeb(q, allResults);
350
+ } else {
351
+ resultsEl.innerHTML = `<div class="empty-state"><i class="fa-solid fa-face-frown"></i><p>لا توجد نتائج لـ "${escapeHTML(q)}"</p></div>`;
 
 
 
 
352
  }
353
+ } catch (error) {
354
+ loadingEl.style.display = 'none';
355
+ resultsEl.innerHTML = `<div class="empty-state"><i class="fa-solid fa-triangle-exclamation"></i><p>تعذّر الاتصال بالمحرك.</p></div>`;
356
  }
357
+ }
358
+
359
+ // --- RICH RESULTS (Knowledge Graph) ---
360
+ function renderWeb(q, results) {
361
+ resultsEl.innerHTML = '';
362
+
363
+ let mainCard = results.find(r => r.url.includes('wikipedia.org'));
364
+ if (!mainCard) mainCard = results.find(r => !r.url.includes('youtube.com'));
365
+
366
+ const ytResults = results.filter(r => r.url.includes('youtube.com/watch')).slice(0, 4);
367
 
368
+ const richContainer = document.createElement('div');
369
+ richContainer.className = 'rich-graph-container';
370
+
371
+ // -- أ. شريط الصور العلوي --
372
+ const imagesRow = document.createElement('div');
373
+ imagesRow.className = 'rich-images-row';
374
+ imagesRow.innerHTML = `<div class="rich-img-skeleton"></div><div class="rich-img-skeleton"></div><div class="rich-img-skeleton"></div><div class="rich-img-skeleton"></div>`;
375
+ richContainer.appendChild(imagesRow);
376
+
377
+ fetch(`${SEARXNG_URL}?q=${encodeURIComponent(q)}&format=json&categories=images&language=ar`)
378
+ .then(res => res.json())
379
+ .then(data => {
380
+ if (data.results && data.results.length > 0) {
381
+ const validImages = data.results.filter(r => getBestImageUrl(r)).slice(0, 6);
382
+ if (validImages.length > 0) {
383
+ imagesRow.innerHTML = validImages.map(r => {
 
 
 
 
 
 
 
 
 
 
384
  const imgUrl = proxyImage(getBestImageUrl(r));
385
+ return `<a href="${escapeHTML(r.url || '#')}" target="_blank" class="rich-img-card">
386
+ <img src="${escapeHTML(imgUrl)}" alt="صورة" loading="lazy" onerror="this.style.display='none';this.nextElementSibling.style.display='flex'" />
387
+ <div class="img-error"><i class="fa-solid fa-image-slash"></i> تعذّر التحميل</div>
388
+ </a>`;
389
  }).join('');
390
+ } else {
391
+ imagesRow.style.display = 'none';
392
+ }
393
+ } else {
394
+ imagesRow.style.display = 'none';
395
+ }
396
+ }).catch(() => { imagesRow.style.display = 'none'; });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
397
 
398
+ // -- ب. بطاقة المعرفة --
399
+ if (mainCard) {
400
+ const dmn = getDomain(mainCard.url);
401
+ const isWiki = dmn.includes('wikipedia');
402
+ richContainer.innerHTML += `
403
+ <div class="wiki-card search-result">
404
+ <div class="wiki-header">
405
+ <img src="${faviconURL(dmn)}" style="width:24px;height:24px;border-radius:4px" />
406
+ <div>
407
+ <div class="wiki-domain">${isWiki ? 'ويكيبيديا' : escapeHTML(dmn)}</div>
408
+ <a href="${escapeHTML(mainCard.url)}" target="_blank" class="wiki-url">${escapeHTML(mainCard.url)}</a>
409
+ </div>
 
 
 
 
 
 
 
410
  </div>
411
+ <a href="${escapeHTML(mainCard.url)}" target="_blank" class="result-title" style="font-size:20px;">${escapeHTML(mainCard.title)}</a>
412
+ <p class="result-snippet">${escapeHTML(mainCard.content)}</p>
413
+ </div>
414
+ `;
415
+ }
416
 
417
+ // -- ج. الفيديوهات --
418
+ if (ytResults.length > 0) {
419
  richContainer.innerHTML += `
420
+ <h3 class="rich-section-title">فيديوهات لـ ${escapeHTML(q)} <i class="fa-solid fa-chevron-left"></i></h3>
421
+ <div class="rich-videos-row">
422
+ ${ytResults.map(r => {
423
+ const vidMatch = r.url.match(/v=([^&]+)/);
424
+ const thumb = vidMatch ? `https://img.youtube.com/vi/${vidMatch[1]}/mqdefault.jpg` : proxyImage(r.thumbnail);
425
+ return `<a href="${escapeHTML(r.url)}" target="_blank" class="rich-vid-card">
426
+ <div class="rich-vid-thumb">
427
+ <img src="${escapeHTML(thumb)}" alt="thumb" loading="lazy" onerror="this.style.display='none'" />
428
+ <div class="rich-vid-play"><i class="fa-solid fa-play"></i></div>
429
+ </div>
430
+ <div class="rich-vid-info">
431
+ <div class="rich-vid-title">${escapeHTML(r.title)}</div>
432
+ <div class="rich-vid-meta"><img src="${faviconURL('youtube.com')}" /> YouTube</div>
433
+ </div>
434
+ </a>`;
435
+ }).join('')}
436
  </div>
437
  `;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
438
  }
439
 
440
+ // -- د. استكشف --
441
+ const discoverQueries = [`${q} جميلة جدا`, `أنواع ${q}`, `صور ${q}`, `فيديوهات ${q}`, `معلومات عن ${q}`];
442
+ richContainer.innerHTML += `
443
+ <h3 class="rich-section-title">استكشف ${escapeHTML(q)} بالتفصيل</h3>
444
+ <div class="discover-bubbles">
445
+ ${discoverQueries.map(dq => `
446
+ <button class="discover-bubble" data-query="${escapeHTML(dq)}">
447
+ <i class="fa-solid fa-magnifying-glass"></i> ${escapeHTML(dq)}
448
+ </button>
449
+ `).join('')}
450
+ </div>
451
+ `;
452
+
453
+ resultsEl.appendChild(richContainer);
454
+
455
+ // ربط أزرار الاستكشاف
456
+ richContainer.querySelectorAll('.discover-bubble').forEach(btn => {
457
+ btn.addEventListener('click', () => {
458
+ const newQuery = btn.dataset.query;
459
+ if (newQuery) {
460
+ inputEl.value = newQuery;
461
+ document.getElementById('search-form').dispatchEvent(new Event('submit'));
462
+ }
463
  });
464
+ });
 
465
 
466
+ // --- باقي النتائج ---
467
+ const usedUrls = new Set();
468
+ if (mainCard) usedUrls.add(mainCard.url);
469
+ ytResults.forEach(r => usedUrls.add(r.url));
470
+
471
+ results.filter(r => !usedUrls.has(r.url)).forEach(r => {
472
+ const domain = getDomain(r.url);
473
+ const article = document.createElement('article');
474
+ article.className = 'search-result';
475
+ article.innerHTML = `
476
+ <div class="favicon-wrap"><img src="${faviconURL(domain)}" loading="lazy" onerror="this.style.display='none'" /></div>
477
+ <div class="result-content">
478
+ <div class="result-domain"><i class="fa-solid fa-link"></i> ${escapeHTML(domain)}</div>
479
+ <a class="result-title" href="${escapeHTML(r.url)}" target="_blank">${escapeHTML(r.title)}</a>
480
+ <p class="result-snippet">${escapeHTML(r.content)}</p>
481
  </div>`;
482
+ resultsEl.appendChild(article);
483
+ });
484
+ }
485
 
486
+ function renderImages(results) {
487
+ const wrap = document.createElement('div'); wrap.className = 'images-grid';
488
+ results.forEach(r => {
489
+ const rawImg = getBestImageUrl(r);
490
+ if (!rawImg) return;
491
+ const img = proxyImage(rawImg);
492
+ wrap.innerHTML += `<div class="image-card">
493
+ <a class="image-card-link" href="${escapeHTML(r.url)}" target="_blank">
494
+ <img src="${escapeHTML(img)}" alt="${escapeHTML(r.title)}" loading="lazy" onerror="this.style.display='none';this.nextElementSibling.style.display='flex'" />
495
+ <div class="img-load-error"><i class="fa-solid fa-image-slash"></i> تعذّر التحميل</div>
496
+ </a>
497
+ <div class="image-info">${escapeHTML(r.title)}</div>
498
+ </div>`;
499
  });
500
+ resultsEl.appendChild(wrap);
501
+ }
502
+
503
+ function renderVideos(results) {
504
+ const wrap = document.createElement('div'); wrap.className = 'videos-grid';
505
+ results.forEach(r => {
506
+ wrap.innerHTML += `<div class="video-card">
507
+ <a href="${escapeHTML(r.url)}" target="_blank" class="video-thumb-wrap">
508
+ <img src="${proxyImage(r.thumbnail)}" alt="thumbnail" loading="lazy" onerror="this.style.display='none'" />
509
+ <div class="play-overlay"><i class="fa-solid fa-play"></i></div>
510
+ </a>
511
+ <div class="video-details"><a class="video-title" href="${escapeHTML(r.url)}" target="_blank">${escapeHTML(r.title)}</a></div>
512
+ </div>`;
513
+ });
514
+ resultsEl.appendChild(wrap);
515
+ }
516
+
517
+ // Init
518
+ if (query) { inputEl.value = query; performSearch(query, currentTab); }
519
+
520
+ document.getElementById('search-form').addEventListener('submit', (e) => {
521
+ e.preventDefault(); const q = inputEl.value.trim(); if (!q) return;
522
+ const url = new URL(window.location); url.searchParams.set('q', q); url.searchParams.set('tab', currentTab);
523
+ window.history.pushState({}, '', url); query = q; performSearch(q, currentTab);
524
+ });
525
+
526
+ document.querySelectorAll('.tab-pill').forEach(btn => {
527
+ btn.addEventListener('click', () => {
528
+ const tab = btn.dataset.tab; if (tab === currentTab) return;
529
+ currentTab = tab; setActiveTab(tab);
530
+ const url = new URL(window.location); url.searchParams.set('tab', tab); if (query) url.searchParams.set('q', query);
531
+ window.history.pushState({}, '', url); if (query) performSearch(query, tab);
532
  });
533
+ });
534
+ })();
535
  </script>
536
  </body>
537
  </html>