/* Animated background from trivelta: aurora orbs plus a particle constellation. */ (function () { var reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches; var root = document.createElement('div'); root.className = 'ambient-bg'; root.setAttribute('aria-hidden', 'true'); root.innerHTML = '' + '
' + '
' + '
' + '
' + '
' + '
'; document.body.insertBefore(root, document.body.firstChild); var canvas = root.querySelector('.ambient-bg__canvas'); if (reduceMotion || window.innerWidth < 900) { canvas.remove(); return; } var ctx = canvas.getContext('2d'); var width = 0; var height = 0; var dpr = 1; var points = []; function resize() { dpr = Math.min(window.devicePixelRatio || 1, 2); width = canvas.width = window.innerWidth * dpr; height = canvas.height = window.innerHeight * dpr; canvas.style.width = window.innerWidth + 'px'; canvas.style.height = window.innerHeight + 'px'; var count = Math.min(70, Math.floor(window.innerWidth / 22)); points = []; for (var i = 0; i < count; i++) { points.push({ x: Math.random() * width, y: Math.random() * height, vx: (Math.random() - 0.5) * 0.12 * dpr, vy: (Math.random() - 0.5) * 0.12 * dpr }); } } function loop() { ctx.clearRect(0, 0, width, height); for (var i = 0; i < points.length; i++) { var point = points[i]; point.x += point.vx; point.y += point.vy; if (point.x < 0 || point.x > width) point.vx *= -1; if (point.y < 0 || point.y > height) point.vy *= -1; } for (var a = 0; a < points.length; a++) { for (var b = a + 1; b < points.length; b++) { var dx = points[a].x - points[b].x; var dy = points[a].y - points[b].y; var distance = Math.hypot(dx, dy); var maxDistance = 150 * dpr; if (distance < maxDistance) { ctx.strokeStyle = 'rgba(79, 184, 255, ' + (0.16 * (1 - distance / maxDistance)) + ')'; ctx.lineWidth = dpr; ctx.beginPath(); ctx.moveTo(points[a].x, points[a].y); ctx.lineTo(points[b].x, points[b].y); ctx.stroke(); } } ctx.fillStyle = 'rgba(120, 170, 255, 0.5)'; ctx.beginPath(); ctx.arc(points[a].x, points[a].y, 1.4 * dpr, 0, Math.PI * 2); ctx.fill(); } window.requestAnimationFrame(loop); } resize(); window.addEventListener('resize', resize); window.requestAnimationFrame(loop); }());