-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
458 lines (417 loc) · 24.7 KB
/
Copy pathindex.html
File metadata and controls
458 lines (417 loc) · 24.7 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
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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PrismaX ID Card Generator</title>
<link href="https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700;900&family=Bebas+Neue&family=Lato:wght@300;400;700&display=swap" rel="stylesheet">
<style>
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0;}
:root{
--gold:#c9a96e;--gold2:#e8d5b0;--dark:#1a1008;--cream:#f5f0e8;
}
body{
min-height:100vh;font-family:'Lato',sans-serif;
color:#333;overflow-x:hidden;background:#e4dfd6;
}
/* ── PAGE BG ── */
.page-bg{position:fixed;inset:0;z-index:0;background:#e4dfd6;overflow:hidden;}
.page-bg::before{content:'';position:absolute;top:-30%;left:-15%;width:75%;height:160%;
background:linear-gradient(180deg,#fff 0%,#f7f4f0 100%);
transform:skewX(-10deg);box-shadow:6px 0 40px rgba(0,0,0,.07);}
.page-bg::after{content:'';position:absolute;top:-30%;left:5%;width:60%;height:160%;
background:linear-gradient(180deg,#fcfaf8 0%,#f0ece6 100%);
transform:skewX(-10deg);box-shadow:6px 0 30px rgba(0,0,0,.05);}
.bp{position:fixed;z-index:0;pointer-events:none;top:-30%;height:160%;}
.bp1{left:22%;width:48%;background:linear-gradient(180deg,#faf8f5,#ede9e3);transform:skewX(-10deg);box-shadow:6px 0 24px rgba(0,0,0,.04);}
.bp2{left:36%;width:38%;background:linear-gradient(180deg,#f8f6f2,#eae5de);transform:skewX(-10deg);}
.bp3{left:48%;width:28%;background:linear-gradient(180deg,#f5f3ef,#e8e2da);transform:skewX(-10deg);}
/* ── LAYOUT ── */
.page-inner{position:relative;z-index:2;min-height:100vh;display:flex;flex-direction:column;align-items:center;padding:40px 20px 160px;}
/* ── HEADER ── */
.site-header{display:flex;align-items:center;gap:13px;margin-bottom:6px;}
.px-logo-h{width:50px;height:50px;background:rgba(26,16,8,.06);border:1.5px solid rgba(201,169,110,.5);border-radius:11px;display:flex;align-items:center;justify-content:center;}
h1{font-family:'Playfair Display',serif;font-size:clamp(2rem,5vw,3rem);font-weight:900;color:#1a1008;letter-spacing:.05em;}
.subtitle{color:rgba(26,16,8,.38);font-size:.72rem;letter-spacing:.15em;text-transform:uppercase;margin-bottom:32px;text-align:center;}
/* ── FORM ── */
.form-wrap{width:100%;max-width:500px;background:rgba(255,255,255,.72);border:1px solid rgba(201,169,110,.28);border-radius:18px;padding:28px 26px;backdrop-filter:blur(14px);box-shadow:0 6px 36px rgba(0,0,0,.07);margin-bottom:38px;}
.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:13px;}
.full{grid-column:1/-1;}
label{display:block;font-size:.67rem;font-weight:700;text-transform:uppercase;letter-spacing:.1em;color:rgba(26,16,8,.45);margin-bottom:4px;}
input[type=text],input[type=date],select{width:100%;background:rgba(255,255,255,.92);border:1px solid rgba(201,169,110,.35);border-radius:8px;padding:9px 12px;color:#1a1008;font-family:'Lato',sans-serif;font-size:.9rem;outline:none;transition:border-color .2s,box-shadow .2s;-webkit-appearance:none;}
input:focus,select:focus{border-color:var(--gold);box-shadow:0 0 0 3px rgba(201,169,110,.12);}
input::placeholder{color:rgba(26,16,8,.22);}
select option{background:#fff;color:#1a1008;}
.photo-row{display:flex;align-items:center;gap:10px;}
.preview-img{width:58px;height:58px;border-radius:8px;object-fit:cover;border:2px solid var(--gold);display:none;flex-shrink:0;}
.preview-img.robot-border{border-color:#3a7bd5;}
.upload-btn{flex:1;padding:9px 14px;background:rgba(201,169,110,.08);border:1.5px dashed var(--gold);border-radius:8px;color:#8b6914;font-weight:700;font-size:.8rem;cursor:pointer;text-align:center;transition:background .2s;display:block;user-select:none;}
.upload-btn:hover{background:rgba(201,169,110,.18);}
.upload-btn.robot-style{border-color:#3a7bd5;color:#1a4fa0;background:rgba(58,123,213,.07);}
.upload-btn.robot-style:hover{background:rgba(58,123,213,.14);}
.gen-btn{width:100%;margin-top:20px;padding:13px;background:linear-gradient(90deg,#5c3f0a,#c9a96e,#e8d5b0,#c9a96e,#5c3f0a);background-size:200% auto;border:none;border-radius:10px;color:#fff;font-family:'Bebas Neue',sans-serif;font-size:1.12rem;letter-spacing:.16em;cursor:pointer;animation:shimmer 3s linear infinite;box-shadow:0 5px 22px rgba(201,169,110,.38);transition:transform .15s;}
.gen-btn:hover{transform:translateY(-2px);}
@keyframes shimmer{to{background-position:200% center;}}
/* ── CARD SECTION ── */
#card-section{display:none;flex-direction:column;align-items:center;gap:20px;}
#card-section.visible{display:flex;}
/* ── THE CARD ── */
#id-card{position:relative;width:500px;max-width:94vw;height:280px;border-radius:16px;overflow:hidden;
box-shadow:0 0 0 1px rgba(201,169,110,.4),0 20px 60px rgba(0,0,0,.45),0 4px 14px rgba(0,0,0,.25),inset 0 1px 0 rgba(255,255,255,.08);}
.card-bg{position:absolute;inset:0;background:radial-gradient(ellipse at 25% 30%,#5e3a20 0%,#3d2510 50%,#291507 100%);}
.card-arc{position:absolute;right:-40px;top:-40px;width:240px;height:240px;border-radius:50%;border:28px solid rgba(201,169,110,.07);z-index:1;pointer-events:none;}
.card-arc2{position:absolute;right:-10px;top:-10px;width:170px;height:170px;border-radius:50%;border:18px solid rgba(201,169,110,.05);z-index:1;pointer-events:none;}
.card-arc3{position:absolute;left:-60px;bottom:-60px;width:200px;height:200px;border-radius:50%;border:22px solid rgba(201,169,110,.04);z-index:1;pointer-events:none;}
.card-vignette{position:absolute;inset:0;pointer-events:none;z-index:2;background:linear-gradient(110deg,transparent 45%,rgba(100,60,20,.25) 100%);}
.card-glow-top{position:absolute;top:0;left:0;right:0;height:1.5px;z-index:5;background:linear-gradient(90deg,transparent 0%,var(--gold) 25%,#f5e8c0 50%,var(--gold) 75%,transparent 100%);}
.card-inner{position:relative;z-index:4;width:100%;height:100%;padding:14px 18px 13px;display:grid;grid-template-rows:auto 1fr auto;gap:6px;}
.card-top{display:flex;justify-content:space-between;align-items:center;}
.brand-block{display:flex;align-items:center;gap:9px;}
.px-logo-c{width:28px;height:28px;background:rgba(245,240,232,.06);border:1px solid rgba(201,169,110,.4);border-radius:6px;display:flex;align-items:center;justify-content:center;flex-shrink:0;}
.brand-name{font-family:'Bebas Neue',sans-serif;font-size:1.5em;letter-spacing:.12em;background:linear-gradient(90deg,#c9a96e,#f0deb0,#c9a96e);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text;line-height:1;white-space:nowrap;}
.card-id-num{font-family:'Lato',sans-serif;font-size:.58em;font-weight:700;letter-spacing:.2em;color:rgba(201,169,110,.4);}
.card-mid{display:flex;gap:13px;align-items:center;}
.card-photo-box{width:96px;height:96px;border-radius:10px;border:1.5px solid var(--gold);background:rgba(201,169,110,.07);overflow:hidden;flex-shrink:0;box-shadow:0 4px 18px rgba(0,0,0,.45),0 0 20px rgba(201,169,110,.14);}
.card-photo-box img{width:100%;height:100%;object-fit:cover;}
.card-info{flex:1;display:flex;flex-direction:column;gap:3px;justify-content:center;}
.card-name{font-family:'Playfair Display',serif;font-size:1.28em;font-weight:700;color:var(--cream);line-height:1;margin-bottom:5px;letter-spacing:.02em;}
.info-divider{width:100%;height:1px;background:linear-gradient(90deg,rgba(201,169,110,.55),transparent);margin-bottom:4px;}
.info-line{display:flex;align-items:center;gap:6px;font-size:.58em;line-height:1.4;}
.info-label{color:rgba(201,169,110,.62);font-weight:700;letter-spacing:.09em;text-transform:uppercase;min-width:46px;}
.info-val{color:rgba(245,240,232,.82);font-weight:400;}
.info-dot{width:3px;height:3px;border-radius:50%;background:var(--gold);flex-shrink:0;}
.card-qr{width:72px;height:72px;background:#fff;border-radius:8px;padding:4px;flex-shrink:0;align-self:flex-start;box-shadow:0 4px 18px rgba(0,0,0,.5),0 0 0 1px rgba(201,169,110,.18);}
.card-qr canvas{width:100%;height:100%;display:block;}
/* ── CARD BOTTOM: barcode left + big logo right ── */
.card-bot{display:flex;justify-content:space-between;align-items:flex-end;padding-top:4px;border-top:1px solid rgba(201,169,110,.1);}
.card-barcode{display:flex;flex-direction:column;gap:3px;}
.barcode-lines{display:flex;gap:1.5px;align-items:flex-end;height:18px;}
.barcode-lines span{display:block;width:1.8px;background:rgba(201,169,110,.45);border-radius:1px;}
.barcode-txt{font-family:'Bebas Neue',sans-serif;font-size:.48em;letter-spacing:.16em;color:rgba(201,169,110,.3);}
/* Big PrismaX logo bottom-right */
.card-logo-big{display:flex;flex-direction:column;align-items:flex-end;gap:1px;opacity:.72;}
.card-logo-big .logo-px{font-family:'Playfair Display',serif;font-size:2.6em;font-weight:900;line-height:.85;background:linear-gradient(135deg,#c9a96e 0%,#f0deb0 50%,#c9a96e 100%);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text;letter-spacing:.02em;}
.card-logo-big .logo-sub{font-family:'Bebas Neue',sans-serif;font-size:.52em;letter-spacing:.3em;color:rgba(201,169,110,.5);text-align:right;}
/* ── ROBOT SCENE ── */
.robot-scene{
display:none;
position:fixed;
bottom:0; right:0;
width:clamp(240px,28vw,420px);
z-index:20;
pointer-events:none;
animation:robotBob 3.5s ease-in-out infinite;
transform-origin:bottom center;
}
.robot-scene.visible{display:block;}
@keyframes robotBob{
0%,100%{transform:translateY(0);}
50%{transform:translateY(-14px);}
}
.robot-body{position:relative;width:100%;}
.robot-card-hold{
position:absolute;
bottom:28%; left:-8%;
width:54%;
background:linear-gradient(140deg,#3d2510 0%,#1c0e06 100%);
border-radius:9px;
border:1.5px solid rgba(201,169,110,.6);
padding:8px 9px 7px;
box-shadow:0 8px 28px rgba(0,0,0,.6),0 0 0 .5px rgba(201,169,110,.25),inset 0 1px 0 rgba(255,255,255,.07);
transform:rotate(6deg);
transform-origin:60% 100%;
animation:cardTilt 3.5s ease-in-out infinite;
}
@keyframes cardTilt{
0%,100%{transform:rotate(6deg) translateY(0);}
50%{transform:rotate(4.5deg) translateY(-6px);}
}
.rmc-top{display:flex;justify-content:space-between;align-items:center;margin-bottom:5px;}
.rmc-brand{font-family:'Bebas Neue',sans-serif;font-size:.62em;letter-spacing:.12em;background:linear-gradient(90deg,#c9a96e,#f0deb0);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text;}
.rmc-id{font-family:'Lato',sans-serif;font-size:.4em;color:rgba(201,169,110,.4);letter-spacing:.14em;}
.rmc-mid{display:flex;gap:5px;align-items:center;margin-bottom:5px;}
.rmc-photo{width:22px;height:22px;border-radius:3px;background:rgba(201,169,110,.12);border:1px solid rgba(201,169,110,.4);flex-shrink:0;display:flex;align-items:center;justify-content:center;color:rgba(201,169,110,.7);font-size:10px;}
.rmc-lines{flex:1;display:flex;flex-direction:column;gap:2.5px;}
.rmc-line{height:2px;border-radius:1px;background:rgba(245,240,232,.2);}
.rmc-line.g{background:rgba(201,169,110,.55);width:65%;}
.rmc-line.m{width:80%;}
.rmc-bot{display:flex;gap:1.5px;align-items:flex-end;height:10px;border-top:.5px solid rgba(201,169,110,.12);padding-top:3px;}
.rmc-bar{width:1.5px;border-radius:.5px;background:rgba(201,169,110,.38);}
.rmc-glow{position:absolute;inset:-4px;border-radius:12px;background:radial-gradient(ellipse at 50% 50%,rgba(201,169,110,.12),transparent 70%);pointer-events:none;}
/* ── DOWNLOAD ── */
.dl-btn{padding:12px 44px;background:linear-gradient(90deg,#5c3f0a,#c9a96e,#e8d5b0,#c9a96e,#5c3f0a);background-size:200% auto;border:none;border-radius:50px;color:#1a1008;font-family:'Bebas Neue',sans-serif;font-size:1rem;letter-spacing:.14em;cursor:pointer;animation:shimmer 3s linear infinite;box-shadow:0 4px 20px rgba(201,169,110,.28);font-weight:700;transition:opacity .2s,transform .15s;}
.dl-btn:hover{opacity:.88;transform:translateY(-2px);}
@media(max-width:540px){
.form-grid{grid-template-columns:1fr;}.full{grid-column:1;}
.card-photo-box{width:78px;height:78px;}.card-name{font-size:1.08em;}
.card-qr{width:62px;height:62px;}
.robot-scene{width:clamp(180px,50vw,260px);}
.card-logo-big .logo-px{font-size:2em;}
}
</style>
</head>
<body>
<div class="page-bg"></div>
<div class="bp bp1"></div>
<div class="bp bp2"></div>
<div class="bp bp3"></div>
<!-- ═══════════════ ROBOT SCENE ═══════════════ -->
<div class="robot-scene" id="robot-scene">
<div class="robot-body">
<div class="robot-card-hold" id="robot-card-hold">
<div class="rmc-glow"></div>
<div class="rmc-top">
<div class="rmc-brand">PrismaX</div>
<div class="rmc-id" id="rmc-id">ID·000001</div>
</div>
<div class="rmc-mid">
<div class="rmc-photo">✦</div>
<div class="rmc-lines">
<div class="rmc-line g"></div>
<div class="rmc-line m"></div>
<div class="rmc-line"></div>
<div class="rmc-line" style="width:45%"></div>
</div>
</div>
<div class="rmc-bot" id="rmc-bars"></div>
</div>
<img id="robot-actual" src="" alt="Robot"
style="width:100%;display:block;filter:drop-shadow(-12px 8px 32px rgba(0,0,0,.5));">
</div>
</div>
<!-- ═══════════════ PAGE CONTENT ═══════════════ -->
<div class="page-inner">
<div class="site-header">
<div class="px-logo-h">
<svg viewBox="0 0 60 55" xmlns="http://www.w3.org/2000/svg">
<text x="1" y="46" font-family="'Playfair Display',serif" font-size="44" font-weight="900" fill="#c9a96e">P</text>
<text x="30" y="40" font-family="'Playfair Display',serif" font-size="18" fill="#c9a96e">(x)</text>
</svg>
</div>
<h1>PrismaX</h1>
</div>
<p class="subtitle">Official Identity Card Generator</p>
<div class="form-wrap">
<div class="form-grid">
<div class="full">
<label>Display Name</label>
<input type="text" id="inp-name" placeholder="Your Name" maxlength="22">
</div>
<div>
<label>Role / Title</label>
<select id="inp-role">
<option value="">— Select Role —</option>
<option>PrismaX Team</option>
<option>PrismaX Preserver</option>
<option>Groundbreaker</option>
<option>Navigational</option>
<option>Stabilized</option>
<option>Exploratory</option>
<option>Proactive</option>
<option>Assistive</option>
<option>Reactive</option>
</select>
</div>
<div>
<label>Region</label>
<input type="text" id="inp-region" placeholder="e.g. Dhaka, BD" maxlength="20">
</div>
<div class="full">
<label>Joined Date</label>
<input type="date" id="inp-date">
</div>
<div class="full">
<label>Website / Username</label>
<input type="text" id="inp-website" placeholder="prismax.io or @username" maxlength="30">
</div>
<!-- Profile Photo -->
<div class="full">
<label>Profile Photo</label>
<div class="photo-row">
<img id="photo-preview" class="preview-img" src="" alt="">
<span class="upload-btn" id="photo-upload-btn">📷 Upload Photo</span>
<input type="file" id="file-inp" accept="image/*" style="display:none">
</div>
</div>
<!-- Add Photo (optional) — robot scene -->
<div class="full">
<label>Add Photo <span style="color:rgba(26,16,8,.32);font-weight:400;text-transform:none;letter-spacing:0;font-size:.95em">(optional)</span></label>
<div class="photo-row">
<img id="robot-preview" class="preview-img robot-border" src="" alt="">
<span class="upload-btn robot-style" id="robot-upload-btn">🖼️ Add Photo</span>
<input type="file" id="robot-inp" accept="image/*" style="display:none">
</div>
</div>
</div>
<button class="gen-btn" onclick="generateCard()">✦ GENERATE ID CARD ✦</button>
</div>
<!-- CARD OUTPUT -->
<section id="card-section">
<div id="id-card">
<div class="card-bg"></div>
<div class="card-arc"></div><div class="card-arc2"></div><div class="card-arc3"></div>
<div class="card-vignette"></div>
<div class="card-glow-top"></div>
<div class="card-inner">
<div class="card-top">
<div class="brand-block">
<div class="px-logo-c">
<svg viewBox="0 0 60 55" xmlns="http://www.w3.org/2000/svg">
<text x="1" y="46" font-family="'Playfair Display',serif" font-size="44" font-weight="900" fill="#c9a96e">P</text>
<text x="30" y="40" font-family="'Playfair Display',serif" font-size="18" fill="#c9a96e">(x)</text>
</svg>
</div>
<div class="brand-name">PrismaX</div>
</div>
<div class="card-id-num" id="card-id-num">ID · 000001</div>
</div>
<div class="card-mid">
<div class="card-photo-box">
<img id="card-photo"
src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect fill='%233a2210' width='100' height='100'/%3E%3Ctext x='50' y='58' text-anchor='middle' font-size='38' fill='%23c9a96e'%3E%E2%9C%A6%3C/text%3E%3C/svg%3E"
alt="">
</div>
<div class="card-info">
<div class="card-name" id="card-name">Your Name</div>
<div class="info-divider"></div>
<div class="info-line"><div class="info-dot"></div><span class="info-label">Role</span><span class="info-val" id="card-role">—</span></div>
<div class="info-line"><div class="info-dot"></div><span class="info-label">Region</span><span class="info-val" id="card-region">—</span></div>
<div class="info-line"><div class="info-dot"></div><span class="info-label">Joined</span><span class="info-val" id="card-joined">—</span></div>
<div class="info-line"><div class="info-dot"></div><span class="info-val" id="card-website">prismax.io</span></div>
</div>
<div class="card-qr">
<canvas id="qr-canvas" width="80" height="80"></canvas>
</div>
</div>
<div class="card-bot">
<div class="card-barcode">
<div class="barcode-lines" id="barcode-el"></div>
<div class="barcode-txt" id="barcode-txt">PRISMAX · 000001</div>
</div>
<!-- Big PrismaX logo bottom-right replacing empty space -->
<div class="card-logo-big">
<div class="logo-px">P<span style="font-size:.6em;vertical-align:super;opacity:.8">(x)</span></div>
<div class="logo-sub">PrismaX</div>
</div>
</div>
</div>
</div>
<button class="dl-btn" onclick="downloadCard()">⬇ DOWNLOAD CARD</button>
</section>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dom-to-image/2.6.0/dom-to-image.min.js"></script>
<script>
let userPhoto = null, robotPhoto = null, cardCount = 0;
// ── Fix upload buttons: use click on hidden input ──
document.getElementById('photo-upload-btn').addEventListener('click', function(){
document.getElementById('file-inp').click();
});
document.getElementById('robot-upload-btn').addEventListener('click', function(){
document.getElementById('robot-inp').click();
});
document.getElementById('file-inp').addEventListener('change', function(e){
const file = e.target.files[0]; if(!file) return;
const r = new FileReader();
r.onload = ev => {
userPhoto = ev.target.result;
const p = document.getElementById('photo-preview');
p.src = userPhoto; p.style.display = 'block';
};
r.readAsDataURL(file);
});
document.getElementById('robot-inp').addEventListener('change', function(e){
const file = e.target.files[0]; if(!file) return;
const r = new FileReader();
r.onload = ev => {
robotPhoto = ev.target.result;
const p = document.getElementById('robot-preview');
p.src = robotPhoto; p.style.display = 'block';
// Also set the robot scene image
document.getElementById('robot-actual').src = robotPhoto;
};
r.readAsDataURL(file);
});
function drawQR(canvasEl, text) {
const size = canvasEl.width;
const ctx = canvasEl.getContext('2d');
ctx.fillStyle = '#fff'; ctx.fillRect(0, 0, size, size);
const url = `https://api.qrserver.com/v1/create-qr-code/?size=${size}x${size}&data=${encodeURIComponent(text||'https://prismax.io')}&color=1a1008&bgcolor=ffffff&margin=1`;
const img = new Image(); img.crossOrigin = 'anonymous';
img.onload = () => ctx.drawImage(img, 0, 0, size, size);
img.onerror = () => drawFallbackQR(ctx, size);
img.src = url;
}
function drawFallbackQR(ctx, size) {
const cell = size/21;
const pat=[[1,1,1,1,1,1,1,0,0,1,0,1,0,0,1,1,1,1,1,1,1],[1,0,0,0,0,0,1,0,1,0,1,0,1,0,1,0,0,0,0,0,1],[1,0,1,1,1,0,1,0,0,1,0,1,0,0,1,0,1,1,1,0,1],[1,0,1,1,1,0,1,0,1,0,1,0,1,0,1,0,1,1,1,0,1],[1,0,1,1,1,0,1,0,0,1,0,0,0,0,1,0,1,1,1,0,1],[1,0,0,0,0,0,1,0,1,0,1,0,1,0,1,0,0,0,0,0,1],[1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,1,1],[0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0],[1,0,1,1,0,1,1,1,0,1,1,0,1,1,1,0,1,0,0,1,0],[0,1,0,0,1,0,0,0,1,0,1,0,1,0,0,1,0,1,0,1,1],[1,0,1,0,1,1,1,0,0,1,0,1,0,1,1,0,1,0,1,0,1],[0,1,0,1,0,0,0,1,1,0,1,0,1,0,0,1,0,1,1,0,0],[1,0,1,0,1,0,1,0,0,1,0,1,0,1,1,0,1,0,0,1,1],[0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0],[1,1,1,1,1,1,1,0,0,1,0,1,0,1,0,1,0,1,0,0,1],[1,0,0,0,0,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,0],[1,0,1,1,1,0,1,0,0,1,0,1,0,0,0,1,0,0,0,1,0],[1,0,1,1,1,0,1,0,1,0,0,0,1,1,1,0,1,0,1,0,1],[1,0,1,1,1,0,1,1,0,1,0,1,0,0,0,1,0,1,0,1,0],[1,0,0,0,0,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1],[1,1,1,1,1,1,1,0,0,1,0,0,0,1,0,1,0,1,0,1,0]];
ctx.fillStyle='#fff'; ctx.fillRect(0,0,size,size);
pat.forEach((row,r)=>row.forEach((v,c)=>{if(v){ctx.fillStyle='#1a1008';ctx.fillRect(c*cell,r*cell,cell,cell);}}));
}
function buildBarcode() {
const el = document.getElementById('barcode-el'); el.innerHTML='';
[12,18,8,16,22,10,18,14,6,20,12,16,8,14,22,10,18,6,16,12,20,8,14,18,10,22,6,16,12,14].forEach(h=>{
const s=document.createElement('span'); s.style.height=h+'px'; el.appendChild(s);
});
}
function buildMiniBarcode() {
const el = document.getElementById('rmc-bars'); el.innerHTML='';
[6,9,4,8,11,5,9,7,3,10,6,8,4,7,11,5,9,3,8,6,10,4,8,6].forEach(h=>{
const b=document.createElement('div'); b.className='rmc-bar'; b.style.height=h+'px'; el.appendChild(b);
});
}
function formatDate(val) {
if(!val) return '—';
const [y,m,d] = val.split('-');
return `${d} ${['JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC'][parseInt(m)-1]} ${y}`;
}
function generateCard() {
const name = document.getElementById('inp-name').value.trim() || 'Your Name';
const role = document.getElementById('inp-role').value || '—';
const region = document.getElementById('inp-region').value.trim() || '—';
const dateVal = document.getElementById('inp-date').value;
const website = document.getElementById('inp-website').value.trim() || 'prismax.io';
cardCount++;
const idNum = String(cardCount).padStart(6,'0');
document.getElementById('card-name').textContent = name;
document.getElementById('card-role').textContent = role;
document.getElementById('card-region').textContent = region;
document.getElementById('card-joined').textContent = formatDate(dateVal);
document.getElementById('card-website').textContent= website;
document.getElementById('card-id-num').textContent = 'ID · '+idNum;
document.getElementById('barcode-txt').textContent = 'PRISMAX · '+idNum;
if(userPhoto) document.getElementById('card-photo').src = userPhoto;
if(robotPhoto) document.getElementById('robot-actual').src = robotPhoto;
buildBarcode();
const qrCanvas = document.getElementById('qr-canvas');
qrCanvas.width=80; qrCanvas.height=80;
drawQR(qrCanvas, website.startsWith('http') ? website : 'https://'+website);
document.getElementById('rmc-id').textContent = 'ID·'+idNum;
buildMiniBarcode();
document.getElementById('card-section').classList.add('visible');
if(robotPhoto) document.getElementById('robot-scene').classList.add('visible');
setTimeout(()=>document.getElementById('card-section').scrollIntoView({behavior:'smooth',block:'center'}),100);
}
function downloadCard() {
const card = document.getElementById('id-card');
const robot = document.getElementById('robot-scene');
if(robot) robot.style.display='none';
domtoimage.toPng(card, {
width: card.offsetWidth*3,
height: card.offsetHeight*3,
style:{transform:'scale(3)',transformOrigin:'top left',width:card.offsetWidth+'px',height:card.offsetHeight+'px'}
}).then(dataUrl=>{
const a=document.createElement('a');
a.download='prismax-id-card.png'; a.href=dataUrl; a.click();
if(robot) robot.style.display='block';
}).catch(()=>{
html2canvas(card,{scale:3,useCORS:true,allowTaint:true,backgroundColor:'#1a1008'}).then(canvas=>{
const a=document.createElement('a');
a.download='prismax-id-card.png'; a.href=canvas.toDataURL('image/png'); a.click();
if(robot) robot.style.display='block';
});
});
}
</script>
</body>
</html>