File size: 3,761 Bytes
0dae64d
 
fb2810b
 
 
 
 
3e44b29
fb2810b
 
 
3e44b29
 
 
 
 
fb2810b
 
 
0dae64d
fb2810b
 
0dae64d
fb2810b
 
 
 
0dae64d
 
3e44b29
0dae64d
 
fb2810b
0dae64d
fb2810b
0dae64d
fb2810b
0dae64d
 
 
 
 
 
 
 
 
3e44b29
 
 
0dae64d
 
3e44b29
0dae64d
 
 
3e44b29
 
 
 
 
 
 
 
 
 
0dae64d
 
fb2810b
0dae64d
cd457da
3e44b29
0dae64d
3e44b29
 
fb2810b
0dae64d
3e44b29
 
0dae64d
cd457da
 
0dae64d
fb2810b
3e44b29
 
cd457da
 
fb2810b
0dae64d
 
cd457da
 
0dae64d
 
3e44b29
879e4b1
 
 
 
 
 
 
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
// Космический фон на Canvas
const canvas = document.getElementById('cosmo-canvas');
const ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;

const particles = [];
for (let i = 0; i < 250; i++) {
    particles.push({
        x: Math.random() * canvas.width,
        y: Math.random() * canvas.height,
        radius: Math.random() * 5 + 1,
        speedX: Math.random() * 1 - 0.5,
        speedY: Math.random() * 1 - 0.5,
        color: `hsl(${Math.random() * 360}, 100%, 85%)`,
        alpha: Math.random() * 0.6 + 0.4
    });
}

function animateCosmo() {
    ctx.clearRect(0, 0, canvas.width, canvas.height);
    particles.forEach(p => {
        ctx.globalAlpha = p.alpha;
        ctx.beginPath();
        ctx.arc(p.x, p.y, p.radius, 0, Math.PI * 2);
        ctx.fillStyle = p.color;
        ctx.fill();
        p.x += p.speedX;
        p.y += p.speedY;
        p.alpha = Math.sin(Date.now() * 0.002 + p.x) * 0.6 + 0.4;
        if (p.x < 0 || p.x > canvas.width) p.speedX *= -1;
        if (p.y < 0 || p.y > canvas.height) p.speedY *= -1;
    });
    requestAnimationFrame(animateCosmo);
}
animateCosmo();

// Управление продуктом (ПК: мышь, мобильные: сенсор)
const product = document.getElementById('cosmo-product');
if ('ontouchstart' in window) {
    let touchStartX = 0, touchStartY = 0;
    product.addEventListener('touchstart', (e) => {
        touchStartX = e.touches[0].clientX;
        touchStartY = e.touches[0].clientY;
    });
    product.addEventListener('touchmove', (e) => {
        const deltaX = (e.touches[0].clientX - touchStartX) / 8;
        const deltaY = (e.touches[0].clientY - touchStartY) / 8;
        product.style.transform = `perspective(3000px) rotateY(${deltaX}deg) rotateX(${-deltaY}deg)`;
    });
    product.addEventListener('touchend', () => {
        product.style.transform = 'perspective(3000px) rotateY(0deg) rotateX(0deg)';
    });
} else {
    document.addEventListener('mousemove', (e) => {
        const xAxis = (window.innerWidth / 2 - e.pageX) / 8;
        const yAxis = (window.innerHeight / 2 - e.pageY) / 8;
        product.style.transform = `perspective(3000px) rotateY(${xAxis}deg) rotateX(${yAxis}deg)`;
    });
    // Дополнительная анимация при наведении на продукт
    product.addEventListener('mouseenter', () => {
        product.style.filter = 'brightness(1.5)';
    });
    product.addEventListener('mouseleave', () => {
        product.style.filter = 'brightness(1)';
    });
}

// Заказ
function orderNow() {
    document.body.style.transition = 'background 0.8s';
    document.body.style.background = 'radial-gradient(circle, #00ffcc, #ff007a, #000)';
    const title = document.getElementById('cosmo-title');
    title.style.transform = 'scale(1.2)';
    setTimeout(() => {
        document.body.style.background = '#000';
        title.style.transform = 'scale(1)';
    }, 1500);
    alert('Revolut запущен. Твоя кожа — космос!');
}

// Эффекты подов
function podEffect(element) {
    element.style.transform = 'translateY(-40px) scale(1.25) translateZ(40px)';
    element.style.boxShadow = '0 0 60px rgba(0, 255, 204, 1)';
}

function podReset(element) {
    element.style.transform = 'translateY(0) scale(1) translateZ(0)';
    element.style.boxShadow = 'none';
}

function podTouch(element) {
    element.classList.add('active');
    setTimeout(() => element.classList.remove('active'), 800);
}

// Обновление размеров Canvas при изменении окна
window.addEventListener('resize', () => {
    canvas.width = window.innerWidth;
    canvas.height = window.innerHeight;
});