-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
246 lines (221 loc) · 10.2 KB
/
index.html
File metadata and controls
246 lines (221 loc) · 10.2 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Countdown — March 5 at 12:00 (Europe/Madrid)</title>
<meta name="description" content="Live countdown timer to March 5 at 12:00 in the Europe/Madrid time zone, with confetti celebration at zero." />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&display=swap" rel="stylesheet">
<style>
:root {
--bg: #0b1020;
--card: #121832;
--accent: #7aa2ff;
--muted: #9aa3b2;
--text: #e8edf7;
--success: #7cffc4;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
margin: 0;
font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji";
color: var(--text);
background: radial-gradient(1200px 800px at 20% 10%, #19234a 0%, transparent 50%),
radial-gradient(1000px 600px at 80% 80%, #0f1736 0%, transparent 50%),
var(--bg);
display: grid;
place-items: center;
padding: 24px;
overflow-x: hidden;
}
.wrap { width: min(100%, 980px); text-align: center; position: relative; z-index: 1; }
header { margin-bottom: 24px; }
h1 {
font-size: clamp(28px, 4vw, 44px);
font-weight: 800;
margin: 0 0 8px 0;
letter-spacing: -0.02em;
}
.sub { color: var(--muted); font-size: clamp(14px, 1.6vw, 16px); }
.timer { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 16px; margin: 24px 0 16px; }
.unit {
background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02));
border: 1px solid rgba(255,255,255,0.12);
border-radius: 20px;
padding: 20px 12px;
box-shadow: 0 10px 30px rgba(0,0,0,0.25);
backdrop-filter: blur(6px);
transform: translateZ(0);
}
.num { font-variant-numeric: tabular-nums; font-size: clamp(36px, 8vw, 64px); font-weight: 800; line-height: 1; letter-spacing: 0.02em; }
.label { margin-top: 6px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.18em; }
.note { margin-top: 14px; color: var(--muted); font-size: 13px; }
footer { margin-top: 18px; color: var(--muted); font-size: 12px; }
.done { font-size: clamp(24px, 4vw, 32px); font-weight: 800; color: var(--success); margin: 16px 0 0; opacity: 0; transform: scale(0.9); }
@keyframes popIn { to { opacity: 1; transform: scale(1); } }
@keyframes glow {
0% { text-shadow: 0 0 0 rgba(124,255,196,0); }
50% { text-shadow: 0 0 24px rgba(124,255,196,0.6); }
100% { text-shadow: 0 0 0 rgba(124,255,196,0); }
}
.celebrate { animation: popIn 400ms ease-out forwards, glow 1.8s ease-in-out 2; }
.tick { animation: tick 200ms ease-out; }
@keyframes tick { from { transform: translateY(-2px); } to { transform: translateY(0); } }
@media (max-width: 640px) { .timer { grid-template-columns: repeat(2, 1fr); } }
canvas#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.replay {
margin-top: 12px; border: 1px solid rgba(255,255,255,0.2); background: rgba(255,255,255,0.05);
color: var(--text); border-radius: 999px; padding: 8px 14px; cursor: pointer; font-weight: 600;
transition: transform .15s ease, background .2s ease;
}
.replay:hover { transform: translateY(-1px); background: rgba(255,255,255,0.08); }
</style>
</head>
<body>
<canvas id="confetti"></canvas>
<div class="wrap">
<header>
<h1>Countdown to March 5 — 12:00 Madrid time</h1>
<div class="sub">Time zone: <strong>Europe/Madrid</strong></div>
</header>
<section id="countdown" aria-live="polite">
<div class="timer" role="group" aria-label="Time remaining">
<div class="unit"><div class="num" id="days">–</div><div class="label">Days</div></div>
<div class="unit"><div class="num" id="hours">–</div><div class="label">Hours</div></div>
<div class="unit"><div class="num" id="minutes">–</div><div class="label">Minutes</div></div>
<div class="unit"><div class="num" id="seconds">–</div><div class="label">Seconds</div></div>
</div>
<p class="note" id="note"></p>
<p class="done" id="done" hidden>It's 12:00 on March 5 in Madrid 🎉</p>
<button id="replay" class="replay" hidden>Replay celebration</button>
</section>
</div>
<script>
function getTimeZoneOffsetMs(date, timeZone) {
const dtf = new Intl.DateTimeFormat('en-US', {
timeZone,
year: 'numeric', month: '2-digit', day: '2-digit',
hour: '2-digit', minute: '2-digit', second: '2-digit',
hour12: false
});
const parts = dtf.formatToParts(date);
const map = Object.fromEntries(parts.map(p => [p.type, p.value]));
const asUTC = Date.UTC(
parseInt(map.year, 10),
parseInt(map.month, 10) - 1,
parseInt(map.day, 10),
parseInt(map.hour, 10),
parseInt(map.minute, 10),
parseInt(map.second, 10)
);
return asUTC - date.getTime();
}
function zonedTimeToUtc(year, month, day, hour, minute, second, timeZone) {
const guess = new Date(Date.UTC(year, month - 1, day, hour, minute, second));
const offset = getTimeZoneOffsetMs(guess, timeZone);
return new Date(guess.getTime() - offset);
}
const TARGET_TZ = 'Europe/Madrid';
const now = new Date();
const targetUTC = zonedTimeToUtc(now.getFullYear(), 3, 5, 12, 0, 0, TARGET_TZ);
const $d = document.getElementById('days');
const $h = document.getElementById('hours');
const $m = document.getElementById('minutes');
const $s = document.getElementById('seconds');
const $note = document.getElementById('note');
const $done = document.getElementById('done');
const $replay = document.getElementById('replay');
function format(n) { return String(Math.max(0, n)).padStart(2, '0'); }
const confettiCanvas = document.getElementById('confetti');
const ctx = confettiCanvas.getContext('2d');
let pixels = [];
let confettiRunning = false;
function resizeCanvas() { confettiCanvas.width = window.innerWidth; confettiCanvas.height = window.innerHeight; }
window.addEventListener('resize', resizeCanvas, { passive: true }); resizeCanvas();
function spawnConfetti(count) {
const w = confettiCanvas.width, h = confettiCanvas.height;
for (let i = 0; i < count; i++) {
const angle = Math.random() * Math.PI - Math.PI/2;
pixels.push({
x: w/2 + (Math.random() - 0.5) * 200,
y: h/2,
vx: Math.cos(angle) * (2 + Math.random() * 6),
vy: - (4 + Math.random() * 10),
s: 4 + Math.random() * 6,
r: Math.random() * Math.PI,
vr: (Math.random() - 0.5) * 0.2,
shape: Math.random() < 0.5 ? 'rect' : 'circle',
alpha: 1,
});
}
}
function drawConfetti() {
ctx.clearRect(0,0,confettiCanvas.width, confettiCanvas.height);
for (const p of pixels) {
ctx.save(); ctx.globalAlpha = p.alpha; ctx.translate(p.x, p.y); ctx.rotate(p.r);
if (p.shape === 'rect') { ctx.fillRect(-p.s, -p.s/2, p.s*2, p.s); }
else { ctx.beginPath(); ctx.arc(0,0,p.s,0,Math.PI*2); ctx.fill(); }
ctx.restore();
}
}
function stepConfetti() {
const g = 0.15; const drag = 0.995; const fade = 0.0045;
for (const p of pixels) {
p.vx *= drag; p.vy = p.vy * drag + g; p.x += p.vx; p.y += p.vy; p.r += p.vr; p.alpha -= fade;
}
pixels = pixels.filter(p => p.alpha > 0 && p.y < confettiCanvas.height + 40);
}
function rafLoop() {
if (!confettiRunning) return;
stepConfetti(); drawConfetti(); requestAnimationFrame(rafLoop);
}
function celebrate(durationMs = 6000) {
if (confettiRunning) return;
confettiRunning = true;
const bursts = [0, 200, 400, 600, 900, 1200, 1500];
bursts.forEach((t, i) => setTimeout(() => spawnConfetti(80 - i * 8), t));
const sprinkle = setInterval(() => {
const w = confettiCanvas.width;
const x = Math.random() * w;
pixels.push({ x, y: -20, vx: (Math.random()-0.5)*1.5, vy: 2+Math.random()*2, s: 3+Math.random()*4, r: 0, vr: (Math.random()-0.5)*0.2, shape: Math.random()<0.5?'rect':'circle', alpha: 1 });
}, 60);
requestAnimationFrame(rafLoop);
setTimeout(() => { confettiRunning = false; clearInterval(sprinkle); }, durationMs);
}
function update() {
const nowUTC = Date.now();
let diff = targetUTC.getTime() - nowUTC;
if (diff <= 0) {
document.getElementById('countdown').setAttribute('aria-label', 'Countdown complete');
$d.textContent = '00'; $h.textContent = '00'; $m.textContent = '00'; $s.textContent = '00';
$note.textContent = '';
if ($done.hidden) {
$done.hidden = false; $done.classList.add('celebrate'); celebrate(); $replay.hidden = false;
}
return;
}
const seconds = Math.floor(diff / 1000) % 60;
const minutes = Math.floor(diff / (1000 * 60)) % 60;
const hours = Math.floor(diff / (1000 * 60 * 60)) % 24;
const days = Math.floor(diff / (1000 * 60 * 60 * 24));
$d.textContent = String(days).padStart(2, '0');
$h.textContent = format(hours);
$m.textContent = format(minutes);
$s.textContent = format(seconds);
[$d,$h,$m,$s].forEach(el => { el.classList.remove('tick'); void el.offsetWidth; el.classList.add('tick'); });
const targetLocal = new Date(targetUTC);
$note.textContent = `Reaches 12:00 on March 5 in Madrid (your local: ${targetLocal.toLocaleString([], { dateStyle: 'medium', timeStyle: 'medium' })}).`;
}
update();
let interval = setInterval(update, 1000);
$replay.addEventListener('click', () => { celebrate(); });
document.addEventListener('visibilitychange', () => {
if (document.hidden) { clearInterval(interval); }
else { update(); interval = setInterval(update, 1000); }
});
</script>
</body>
</html>