-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDESINGHUB.HTML
More file actions
585 lines (530 loc) · 34.9 KB
/
Copy pathDESINGHUB.HTML
File metadata and controls
585 lines (530 loc) · 34.9 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
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Miyuki Design Hub - Producción</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;900&display=swap" rel="stylesheet">
<style>
body { font-family: 'Inter', sans-serif; background-color: #f3f4f6; }
.bead {
width: 38px; height: 38px; border-radius: 50%; position: relative;
box-shadow: inset -4px -4px 8px rgba(0,0,0,0.3), inset 4px 4px 8px rgba(255,255,255,0.4), 0 6px 12px rgba(0,0,0,0.15);
transition: transform 0.2s;
}
.bead:hover { transform: scale(1.15); }
.bead::after {
content: ''; position: absolute; top: 15%; left: 15%; width: 30%; height: 30%;
background: rgba(255,255,255,0.35); border-radius: 50%;
}
/* Colores Dinámicos Mariposa */
.c1 { background-color: var(--c1); }
.c2 { background-color: var(--c2); }
.c3 { background-color: var(--c3); }
.neg { background-color: var(--neg); }
.blan { background-color: var(--blan); border: 1px solid rgba(0,0,0,0.1); }
.extra { background-color: var(--extra); }
/* Colores Estandarizados */
.color-D { background-color: #daa520; } /* Dorado */
.color-N { background-color: #222; } /* Negro */
.color-P { background-color: #ffdbac; } /* Piel */
.color-V { background-color: #2d5a27; } /* Verde */
.color-C { background-color: #5d4037; } /* Café */
.color-R { background-color: #b71c1c; } /* Rojo */
.color-A { background-color: #FFEB3B; } /* Amarillo */
.color-O { background-color: #FF5722; } /* Naranja */
.color-M { background-color: #A569BD; } /* Morado */
.modal-overlay {
position: fixed; top: 0; left: 0; width: 100%; height: 100%;
background: rgba(0,0,0,0.7); display: flex; justify-content: center;
align-items: center; z-index: 1000;
}
.custom-scroll::-webkit-scrollbar { width: 6px; }
.custom-scroll::-webkit-scrollbar-track { background: transparent; }
.custom-scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
</style>
</head>
<body class="min-h-screen">
<!-- HUB PRINCIPAL -->
<div id="hubView" class="container mx-auto px-4 py-12">
<div class="text-center mb-12">
<h1 class="text-5xl font-black text-indigo-950 mb-4 tracking-tighter uppercase">Miyuki Design Hub</h1>
<p class="text-xl text-gray-500 font-medium">Panel de Producción Técnica</p>
</div>
<div class="grid grid-cols-1 md:grid-cols-3 gap-8 max-w-6xl mx-auto">
<!-- Card Mariposa -->
<div onclick="openPattern('mariposa')" class="group bg-white rounded-[2.5rem] overflow-hidden shadow-xl hover:shadow-2xl transition-all cursor-pointer transform hover:-translate-y-2 border-4 border-transparent hover:border-indigo-200">
<div class="h-56 bg-gradient-to-br from-orange-400 to-yellow-300 flex items-center justify-center text-8xl transition-transform duration-500 group-hover:scale-110">🦋</div>
<div class="p-8 text-center">
<h3 class="text-2xl font-black text-gray-800 uppercase">Mariposa</h3>
<div class="mt-2 flex items-center justify-center gap-1 text-indigo-600 font-black text-lg">
<span class="text-xl">🏷️</span> $1.000 COP
</div>
</div>
</div>
<!-- Card Virgen -->
<div onclick="openPattern('virgen')" class="group bg-white rounded-[2.5rem] overflow-hidden shadow-xl hover:shadow-2xl transition-all cursor-pointer transform hover:-translate-y-2 border-4 border-transparent hover:border-purple-200">
<div class="h-56 bg-gradient-to-br from-indigo-600 to-purple-500 flex items-center justify-center text-8xl transition-transform duration-500 group-hover:scale-110">🙏</div>
<div class="p-8 text-center">
<h3 class="text-2xl font-black text-gray-800 uppercase">Virgen María</h3>
<div class="mt-2 flex items-center justify-center gap-1 text-indigo-600 font-black text-lg">
<span class="text-xl">🏷️</span> $4.000 COP
</div>
</div>
</div>
<!-- Card Frida -->
<div onclick="openPattern('frida')" class="group bg-white rounded-[2.5rem] overflow-hidden shadow-xl hover:shadow-2xl transition-all cursor-pointer transform hover:-translate-y-2 border-4 border-transparent hover:border-rose-200">
<div class="h-56 bg-gradient-to-br from-rose-500 to-amber-400 flex items-center justify-center text-8xl transition-transform duration-500 group-hover:scale-110">👩🎨</div>
<div class="p-8 text-center">
<h3 class="text-2xl font-black text-gray-800 uppercase">Frida Kahlo</h3>
<div class="mt-2 flex items-center justify-center gap-1 text-indigo-600 font-black text-lg">
<span class="text-xl">🏷️</span> $1.000 COP
</div>
</div>
</div>
</div>
</div>
<!-- VISOR DE PASOS -->
<div id="patternView" class="hidden container mx-auto px-4 py-6">
<div class="max-w-4xl mx-auto bg-white rounded-[3rem] shadow-2xl overflow-hidden border-4 border-white">
<div class="bg-indigo-950 p-6 flex justify-between items-center text-white">
<button onclick="showHub()" class="flex items-center gap-2 bg-indigo-900 hover:bg-white hover:text-indigo-950 px-6 py-3 rounded-2xl transition-all font-black text-xs tracking-widest uppercase">← HUB</button>
<button onclick="showMaterials()" class="bg-emerald-600 hover:bg-emerald-500 text-white px-5 py-3 rounded-2xl transition-all font-black text-xs tracking-widest uppercase shadow-lg flex items-center gap-2">📦 VER MATERIALES</button>
<div id="step-label" class="font-black tracking-widest text-indigo-200 text-sm uppercase">ETAPA 1</div>
</div>
<div class="p-8">
<!-- Selectores Mariposa -->
<div id="mariposaSelectors" class="hidden mb-10 text-center">
<div class="flex justify-center gap-4 flex-wrap">
<div onclick="setTheme('orange')" class="w-10 h-10 rounded-full border-4 border-white shadow-lg cursor-pointer bg-orange-500 hover:scale-110 transition"></div>
<div onclick="setTheme('blue')" class="w-10 h-10 rounded-full border-4 border-white shadow-lg cursor-pointer bg-blue-500 hover:scale-110 transition"></div>
<div onclick="setTheme('pink')" class="w-10 h-10 rounded-full border-4 border-white shadow-lg cursor-pointer bg-[#FFB6C1] hover:scale-110 transition"></div>
<div class="w-px h-10 bg-gray-200 mx-1"></div>
<div onclick="setTheme('red_white')" class="w-10 h-10 rounded-full border-4 border-white shadow-lg cursor-pointer bg-red-600 hover:scale-110 transition"></div>
<div onclick="setTheme('black_gold')" class="w-10 h-10 rounded-full border-4 border-white shadow-lg cursor-pointer bg-black hover:scale-110 transition"></div>
<div onclick="setTheme('orange_green')" class="w-10 h-10 rounded-full border-4 border-white shadow-lg cursor-pointer bg-[#2E7D32] hover:scale-110 transition"></div>
<div onclick="setTheme('red_green_v2')" class="w-10 h-10 rounded-full border-4 border-white shadow-lg cursor-pointer bg-[#f1948a] hover:scale-110 transition"></div>
<div onclick="setTheme('purple_yellow')" class="w-10 h-10 rounded-full border-4 border-white shadow-lg cursor-pointer bg-[#4A235A] hover:scale-110 transition"></div>
</div>
</div>
<!-- Info Técnica Glosario -->
<div id="glossaryInfo" class="mb-8">
<div class="p-6 bg-indigo-50 rounded-3xl border-2 border-indigo-100">
<h4 class="font-black text-indigo-900 text-xs mb-4 uppercase tracking-widest flex items-center gap-2">🎨 Glosario de Colores:</h4>
<div id="glossary-grid" class="grid grid-cols-3 md:grid-cols-6 gap-3 text-[10px] font-black uppercase text-indigo-700">
</div>
</div>
</div>
<div class="text-center mb-8">
<h2 id="pattern-title" class="text-3xl font-black text-gray-900 uppercase tracking-tight">Cargando...</h2>
</div>
<div id="image-container" class="flex justify-center mb-8">
<img id="step-image" src="" alt="Guía" class="w-80 h-auto rounded-[2rem] shadow-2xl border-8 border-white object-cover">
</div>
<div class="w-full bg-gray-100 h-3 rounded-full mb-8 overflow-hidden">
<div id="progress-bar" class="bg-indigo-600 h-full transition-all duration-500"></div>
</div>
<div id="instruction-box" class="min-h-[140px] bg-amber-50 border-l-[12px] border-amber-400 p-8 rounded-3xl font-bold text-amber-950 mb-10 flex flex-col items-center justify-center text-center text-2xl leading-tight shadow-sm">
</div>
<div id="bead-display" class="flex justify-center flex-wrap gap-4 mb-10 p-10 bg-white rounded-[2.5rem] border-4 border-gray-100 min-h-[120px] shadow-inner">
</div>
<div class="mb-12 px-4">
<input type="range" id="stepSlider" class="w-full h-4 bg-gray-200 rounded-2xl appearance-none cursor-pointer accent-indigo-600" oninput="jumpToStep(this.value)">
</div>
<div class="grid grid-cols-2 gap-6">
<button onclick="changeStep(-1)" id="prevBtn" class="py-6 bg-gray-200 hover:bg-gray-300 text-gray-700 font-black rounded-[2rem] transition-all text-xl uppercase tracking-widest shadow-lg">Anterior</button>
<button onclick="changeStep(1)" id="nextBtn" class="py-6 bg-indigo-600 hover:bg-indigo-700 text-white font-black rounded-[2rem] transition-all text-xl uppercase tracking-widest shadow-xl">Siguiente</button>
</div>
<button id="branchBtn" class="hidden w-full py-6 font-black rounded-[2rem] transition-all shadow-lg uppercase tracking-widest text-xl mt-6"></button>
</div>
</div>
</div>
<!-- MODAL MATERIALES -->
<div id="materialsModal" class="modal-overlay hidden">
<div class="bg-white p-10 rounded-[3rem] shadow-2xl max-lg w-[90%] max-w-lg relative border-4 border-emerald-50 flex flex-col max-h-[85vh]">
<button onclick="closeMaterials()" class="absolute top-8 right-10 text-4xl font-black text-gray-300 hover:text-gray-500 transition">×</button>
<h3 class="text-3xl font-black text-emerald-950 mb-6 uppercase tracking-tight flex items-center gap-3">
<span class="bg-emerald-100 p-2 rounded-xl text-xl">📦</span> Material Necesario
</h3>
<div id="materials-list" class="flex-1 overflow-y-auto custom-scroll pr-4 space-y-3"></div>
<div class="mt-8 pt-6 border-t border-gray-100">
<button onclick="closeMaterials()" class="w-full py-5 bg-emerald-600 text-white font-black rounded-2xl uppercase tracking-widest shadow-xl hover:bg-emerald-700 transition">Cerrar Reporte</button>
</div>
</div>
</div>
<!-- MODAL REDUCCIÓN -->
<div id="reductionModal" class="modal-overlay hidden">
<div class="bg-white p-12 rounded-[3rem] shadow-2xl max-w-xl w-[90%] relative border-4 border-indigo-50">
<button onclick="closeModal()" class="absolute top-8 right-10 text-4xl font-black text-gray-300 hover:text-gray-500 transition">×</button>
<h3 class="text-3xl font-black text-indigo-950 mb-6 uppercase tracking-tight">Técnica de Reducción</h3>
<p id="modal-text" class="text-gray-600 text-lg leading-relaxed font-medium"></p>
<button onclick="closeModal()" class="mt-10 w-full py-5 bg-indigo-600 text-white font-black rounded-2xl uppercase tracking-widest shadow-xl">Entendido</button>
</div>
</div>
<script>
const patterns = {
mariposa: {
title: "Mariposa Monarca",
themes: {
orange: {
c1: "#ffd700", c2: "#ffb347", c3: "#e65c00", extra: "#daa520", neg: "#222", blan: "#fff",
names: { c1: "Amarillo", c2: "Naranja Claro", c3: "Naranja Oscuro", extra: "Dorado", neg: "Negro", blan: "Blanco" }
},
blue: {
c1: "#AED6F1", c2: "#1ABC9C", c3: "#2E86C1", extra: "#daa520", neg: "#154360", blan: "#A569BD",
names: { c1: "Azul Claro", c2: "Verde Azulado", c3: "Azul", extra: "Dorado", neg: "Azul Marino", blan: "Morado" }
},
pink: {
c1: "#FFB6C1", c2: "#F5F5DC", c3: "#F5F5DC", extra: "#daa520", neg: "#9370DB", blan: "#4B0082",
names: { c1: "Rosado Claro", c2: "Beige", c3: "Beige", extra: "Dorado", neg: "Morado Trans.", blan: "Morado Oscuro Trans." }
},
red_white: {
c1: "#e74c3c", c2: "#ffffff", c3: "#ffffff", extra: "#daa520", neg: "#16A085", blan: "#ffd700",
names: { c1: "Rojo", c2: "Blanco", c3: "Blanco", extra: "Dorado", neg: "Verde Azulado", blan: "Amarillo" }
},
black_gold: {
c1: "#222", c2: "#222", c3: "#222", extra: "#daa520", neg: "#daa520", blan: "#222",
names: { c1: "Negro", c2: "Negro", c3: "Negro", extra: "Dorado", neg: "Dorado", blan: "Negro" }
},
orange_green: {
c1: "#FF5722", c2: "#2E7D32", c3: "#76FF03", extra: "#daa520", neg: "#1B5E20", blan: "#FFEB3B",
names: { c1: "Naranja", c2: "Verde Pasto", c3: "Verde Fosforescente", extra: "Dorado", neg: "Verde Mate", blan: "Amarillo" }
},
red_green_v2: {
c1: "#76FF03", c2: "#f1948a", c3: "#f1948a", extra: "#daa520", neg: "#8b0000", blan: "#daa520",
names: { c1: "Verde Fosfo", c2: "Rojo Claro", c3: "Rojo Claro", extra: "Dorado", neg: "Rojo Oscuro", blan: "Dorado" }
},
purple_yellow: {
c1: "#D2B4DE", c2: "#4A235A", c3: "#A569BD", extra: "#daa520", neg: "#D2B4DE", blan: "#FFEB3B",
names: { c1: "Morado Trans.", c2: "Morado Oscuro", c3: "Morado Claro", extra: "Dorado", neg: "Morado Trans.", blan: "Amarillo" }
}
},
steps: [
{ beads: ["c1", "c1", "c2", "neg", "neg", "neg", "c1", "c1", "blan"], note: "Fila inicial. Regresa por la 3ra pepa." },
{ beads: ["c3", "c2", "c2"], note: "Fila de 3 cuentas." },
{ beads: ["c2", "c2", "neg", "c1"] },
{ beads: ["c1", "c3", "c2", "c2"] },
{ beads: ["neg", "c2", "neg", "c3"] },
{ beads: ["neg", "c3", "c2", "neg"] },
{ beads: ["extra", "extra", "extra", "extra"], note: "Cuerpo central." },
{ beads: ["extra", "extra", "extra", "extra"] },
{ beads: ["extra", "extra", "extra", "extra"] },
{ beads: ["neg", "c3", "c2", "neg"] },
{ beads: ["neg", "c2", "neg", "c3"] },
{ beads: ["c1", "c3", "c2", "c2"] },
{ beads: ["c2", "c2", "neg", "c1"] },
{ beads: ["blan", "c3", "c2", "c2"] },
{ beads: ["c1", "c2", "neg", "c1"] },
{ beads: ["c1", "neg", "neg", "c1"], note: "Fin de sección." }
]
},
virgen: {
title: "Virgen María",
mainSteps: [
{ pattern: "Prepara tu espacio de trabajo." },
{ pattern: "1D 2N 10P 1N 1D 4V" },
{ pattern: "1D 1N 5P 1N" },
{ pattern: "1D 3P 2C 1P 1N 1V" },
{ pattern: "1V 1D 1N 3C 1P 1C 1N" },
{ pattern: "1D 2C 4P 1N 1V" },
{ pattern: "1V 1D 6P 1N" },
{ pattern: "1D 3P 2N 1P 1N 1V" },
{ pattern: "1V 1D 2P 1N 3P 1N" },
{ pattern: "1D 2N 4P 1N 1V" },
{ pattern: "1V 1D 4P 1C 2N" },
{ pattern: "1D 1C 5P 1N 1V" },
{ pattern: "2D 4P 1C 1P 1N" },
{ pattern: "1D 1C 1P 1C 3P 1N 1V" },
{ pattern: "1V 1D 5P 1C 1N" },
{ pattern: "1D 1N 5P 1N 1V" },
{ pattern: "1V 1D 2P 2C 1P 1C 1D" },
{ pattern: "REDUCCION (Reducción Tipo 2)" },
{ pattern: "1N 1M 1P 1M 1P 1M 1N 1V" },
{ pattern: "1V 1D 1P 1M 2P 1M 1N" },
{ pattern: "Notaras que quedas justo en una pepa negra, debes subir a la dorada y agregaras una dorada" },
{ pattern: "Los siguientes pasos son una explicacion grafica de la reduccion tipo 1" },
{ pattern: "ahora que el hilo sale por la pepa dorada, y tienes una dorada en la aguja, debereas pasar la agua por la negra justo debajo" },
{ pattern: "Ahora justo detras de la pepa donde quedo el hielo metras la aguja hacia el lado contrario que salio el hilo" },
{ pattern: "Subes por la dorada siguiendo la direccion del hilo" },
{ pattern: "ahora solo pon la aguaja en la dorada que pusiste antes." },
{ pattern: "1D 1N 1M 1P 1M 1P 1D 1V" },
{ pattern: "1D 1V 2P 2M 2N" },
{ pattern: "1D 2N 1M 2P 1D 1V" },
{ pattern: "2V 3P 3N" },
{ pattern: "1D 2N 3P 1D 1V" },
{ pattern: "1V 1D 1R 2P 1R 1N 1D" },
{ pattern: "1V 1N 5R 1D" },
{ pattern: "1V 1D 5R 1D" },
{ pattern: "1V 6R 1V" },
{ pattern: "1V 1D 5R 1D" },
{ pattern: "1V 2R 1P 3R 1V" },
{ pattern: "1V 1D 2R 2P 1R 1D" },
{ pattern: "1V 1R 1C 2P 2R 1V" },
{ pattern: "REDUCCION (Reducción Tipo 2)" },
{ pattern: "1D 2R 2P 1R 1D" },
{ pattern: "1V 1R 3P 2R" },
{ pattern: "REDUCCION (Reducción Tipo 2)" },
{ pattern: "1R 2P 1C 1R 1D" },
{ pattern: "REDUCCION (Reducción Tipo 2)" },
{ pattern: "1R 3P 1R" },
{ pattern: "REDUCCION (Reducción Tipo 2)" },
{ pattern: "2P 1C 1R" },
{ pattern: "REDUCCION (Reducción Tipo 2)" },
{ pattern: "3P" }
],
leftSteps: [
{ pattern: "1D 1N 4P 1N 1D 1V" },
{ pattern: "2V 1D 1N 3P 1N 1D" },
{ pattern: "REDUCCION (Reducción Tipo 2)" },
{ pattern: "2N 2P 1N 1D 1V 1D" },
{ pattern: "REDUCCION (Reducción Tipo 2)" },
{ pattern: "2V 1D 4N" },
{ pattern: "Aqui haremos lo explicado en el paso anterior, son los mismos pasos, debes agregar una pepa D" },
{ pattern: "1D 3N 1D 2V" },
{ pattern: "PONER UNA V Y PONER EL HILO EN ESA" },
{ pattern: "1V 1D 1V 1D 2N 1D" },
{ pattern: "REDUCCION (Reducción Tipo 2)" },
{ pattern: "1D 1N 1D 3V" },
{ pattern: "REDUCCION (Reducción Tipo 2)" },
{ pattern: "3V 2D" },
{ pattern: "REDUCCION (Reducción Tipo 2)" },
{ pattern: "1D 3V" }
]
},
frida: {
title: "Frida Kahlo",
mainSteps: [
{ pattern: "1D 10P", note: "Fila 1" },
{ pattern: "1N 1P 1N 1P", note: "Fila 2" },
{ pattern: "1N 4P", note: "Fila 3" },
{ pattern: "5P", note: "Fila 4" },
{ pattern: "2N 2P 1N", note: "Fila 5" },
{ pattern: "1P 3N 1P", note: "Fila 6" },
{ pattern: "1N 1P 2N 1P", note: "Fila 7" },
{ pattern: "1N 3P 1N", note: "Fila 8" },
{ pattern: "1V 1N 2P 1N", note: "Fila 9" },
{ pattern: "1M 3N 1A", note: "Fila 10" },
{ pattern: "2A 2N 1M", note: "Fila 11" },
{ pattern: "1D 3N 1D", note: "Fila 12" },
{ pattern: "2A 1O 1R 1M", note: "Fila 13" },
{ pattern: "1M 2R 1O 1A", note: "Fila 14" }
]
}
};
let curKey = 'mariposa';
let curStep = 0;
let isLeft = false;
let curThemeKey = 'orange';
const colorGlossary = {
D: 'Dorado', N: 'Negro', P: 'Piel', V: 'Verde', C: 'Café', R: 'Rojo',
A: 'Amarillo', O: 'Naranja', M: 'Morado'
};
function showHub() {
document.getElementById('hubView').classList.remove('hidden');
document.getElementById('patternView').classList.add('hidden');
curStep = 0;
}
function openPattern(key) {
curKey = key; curStep = 0; isLeft = false;
document.getElementById('hubView').classList.add('hidden');
document.getElementById('patternView').classList.remove('hidden');
const mS = document.getElementById('mariposaSelectors');
const bB = document.getElementById('branchBtn');
const imgCont = document.getElementById('image-container');
updateGlossary();
if(key === 'mariposa') {
mS.classList.remove('hidden'); bB.classList.add('hidden'); imgCont.classList.add('hidden'); setTheme(curThemeKey);
} else if (key === 'frida') {
mS.classList.add('hidden'); bB.classList.add('hidden'); imgCont.classList.add('hidden'); render();
} else {
mS.classList.add('hidden'); bB.classList.remove('hidden'); imgCont.classList.remove('hidden');
bB.onclick = toggleBranch; updateBranchUI(); render();
}
}
function updateGlossary() {
const grid = document.getElementById('glossary-grid');
grid.innerHTML = '';
let map = {};
if (curKey === 'virgen') {
map = { D: 'Dorado', N: 'Negro', P: 'Piel', V: 'Verde', C: 'Café', R: 'Rojo', M: 'Mostaza' };
} else if (curKey === 'frida') {
map = { D: 'Dorado', N: 'Negro', P: 'Piel', V: 'Verde', A: 'Amarillo', O: 'Naranja', M: 'Morado', R: 'Rojo' };
} else {
const names = patterns.mariposa.themes[curThemeKey].names;
map = { c1: names.c1, c2: names.c2, c3: names.c3, extra: names.extra, neg: names.neg, blan: names.blan };
}
for (let code in map) {
const hex = getColorHex(code);
grid.innerHTML += `<div class="flex items-center gap-2"><span class="w-4 h-4 rounded-full shadow-inner" style="background-color: ${hex}"></span> ${code}: ${map[code]}</div>`;
}
}
function getColorHex(code) {
const standard = { D: '#daa520', N: '#222', P: '#ffdbac', V: '#2d5a27', C: '#5d4037', R: '#b71c1c', A: '#FFEB3B', O: '#FF5722', M: '#ffa000' };
if (standard[code]) return standard[code];
if (curKey === 'mariposa') {
const theme = patterns.mariposa.themes[curThemeKey];
return theme[code] || '#ccc';
}
return '#ccc';
}
function setTheme(t) {
curThemeKey = t;
const theme = patterns.mariposa.themes[t];
const root = document.documentElement;
root.style.setProperty('--c1', theme.c1);
root.style.setProperty('--c2', theme.c2);
root.style.setProperty('--c3', theme.c3);
root.style.setProperty('--extra', theme.extra);
root.style.setProperty('--neg', theme.neg);
root.style.setProperty('--blan', theme.blan);
updateGlossary();
render();
}
function toggleBranch() { isLeft = !isLeft; curStep = 0; updateBranchUI(); render(); }
function updateBranchUI() {
const bB = document.getElementById('branchBtn');
if (isLeft) {
bB.innerText = "← VOLVER A CUERPO"; bB.className = "w-full py-6 bg-gray-700 text-white font-black rounded-[2rem] mt-6 hover:bg-gray-800 transition shadow-xl";
} else {
bB.innerText = "IR A SECCIÓN CABEZA →"; bB.className = "w-full py-6 bg-rose-600 text-white font-black rounded-[2rem] mt-6 hover:bg-rose-700 transition shadow-xl animate-pulse";
}
}
function showMaterials() {
const listCont = document.getElementById('materials-list');
listCont.innerHTML = '';
const summary = {};
if (curKey === 'mariposa') {
const themeData = patterns.mariposa.themes[curThemeKey];
patterns.mariposa.steps.forEach(s => {
s.beads.forEach(b => {
const name = themeData.names[b];
const hex = themeData[b];
if (!summary[name]) summary[name] = { count: 0, hex: hex };
summary[name].count++;
});
});
} else {
const colorMap = {
D: { name: 'Dorado', hex: '#daa520' }, N: { name: 'Negro', hex: '#222' },
P: { name: 'Piel', hex: '#ffdbac' }, V: { name: 'Verde', hex: '#2d5a27' },
C: { name: 'Café', hex: '#5d4037' }, R: { name: 'Rojo', hex: '#b71c1c' },
A: { name: 'Amarillo', hex: '#FFEB3B' }, O: { name: 'Naranja', hex: '#FF5722' },
M: { name: 'Morado', hex: '#A569BD' }
};
const patternList = curKey === 'virgen' ? [...patterns.virgen.mainSteps, ...patterns.virgen.leftSteps] : patterns.frida.mainSteps;
patternList.forEach(s => {
const text = s.pattern || "";
const parts = text.split(' ');
parts.forEach(p => {
const count = p.match(/\d+/) ? parseInt(p.match(/\d+/)[0]) : 1;
const code = p.match(/[A-Z]/);
if (code && colorMap[code[0]]) {
const data = colorMap[code[0]];
if (!summary[data.name]) summary[data.name] = { count: 0, hex: data.hex };
summary[data.name].count += count;
}
});
});
}
Object.keys(summary).sort().forEach(name => {
const data = summary[name];
listCont.innerHTML += `
<div class="flex items-center justify-between p-5 bg-gray-50 rounded-2xl border border-gray-100 hover:border-emerald-300 transition-colors">
<div class="flex items-center gap-4">
<div class="w-6 h-6 rounded-full shadow-sm border border-gray-200" style="background-color: ${data.hex}"></div>
<span class="font-bold text-gray-700 text-lg uppercase tracking-tight">${name}</span>
</div>
<span class="bg-emerald-100 text-emerald-800 font-black px-4 py-1.5 rounded-xl text-xl">${data.count} <small class="text-[10px] opacity-60">pepas</small></span>
</div>`;
});
document.getElementById('materialsModal').classList.remove('hidden');
}
function closeMaterials() { document.getElementById('materialsModal').classList.add('hidden'); }
function getBeads(text) {
if (!text) return [];
const forbiddenWords = ["agrega", "sube", "notaras", "explicacion", "ahora", "paso", "poner", "hilo", "prepara", "reduccion", "haremos", "explicado"];
if (forbiddenWords.some(word => text.toLowerCase().includes(word))) return [];
const parts = text.split(' '); let beads = [];
parts.forEach(p => {
const count = p.match(/\d+/) ? parseInt(p.match(/\d+/)[0]) : 1;
const col = p.match(/[A-Z]/);
if (col) for(let i=0; i<count; i++) beads.push(`color-${col[0]}`);
});
return beads;
}
function standardizeInstruction(rawString, key) {
if (!rawString || rawString.includes("REDUCCION") || rawString.includes("Prepara") || rawString.includes("Notaras") || rawString.includes("haremos") || rawString.includes("PONER")) return rawString;
if (Array.isArray(rawString)) {
const themeNames = patterns.mariposa.themes[curThemeKey].names;
let groups = [];
let i = 0;
while (i < rawString.length) {
let code = rawString[i];
let count = 0;
while (i < rawString.length && rawString[i] === code) {
count++;
i++;
}
groups.push(`${count} ${themeNames[code] || code}`);
}
return groups.join(", ");
}
const parts = rawString.trim().split(' ');
const result = parts.map(p => {
const count = p.match(/\d+/) ? p.match(/\d+/)[0] : "1";
const code = p.match(/[A-Z]/);
if (code) {
const name = colorGlossary[code[0]] || code[0];
return `${count} ${name}`;
}
return p;
});
return result.join(", ");
}
function render() {
const p = patterns[curKey];
const list = (curKey === 'virgen' && isLeft) ? p.leftSteps : (p.mainSteps || p.steps);
const s = list[curStep];
document.getElementById('pattern-title').innerText = isLeft ? "Sección Cabeza" : p.title;
document.getElementById('step-label').innerText = `ETAPA ${curStep + 1} / ${list.length}`;
let formattedText = "";
if (curKey === 'mariposa' && s.beads) {
const groupedColors = standardizeInstruction(s.beads, 'mariposa');
formattedText = (s.note ? `<span class="block mb-4 text-indigo-900 font-black italic">📝 ${s.note}</span>` : "") +
`<div class="flex flex-col items-center gap-3"><span class="text-[10px] uppercase tracking-[0.4em] text-gray-400 font-black">Insertar en orden:</span><span class="text-3xl text-gray-800 tracking-tight font-black">${groupedColors}</span></div>`;
} else {
const standardized = standardizeInstruction(s.pattern, curKey);
formattedText = (s.note ? `<span class="block mb-4 text-rose-900 font-black italic">🎨 ${s.note}</span>` : "") +
`<div class="text-3xl text-gray-800 font-black">${standardized || ""}</div>`;
}
const instrBox = document.getElementById('instruction-box');
if (curKey === 'virgen' && formattedText.includes("Reducción Tipo 2")) {
instrBox.innerHTML = formattedText.replace("Reducción Tipo 2", `<span onclick="openModal('r2')" class="text-indigo-700 underline cursor-pointer hover:text-indigo-950 transition font-black">Reducción Tipo 2</span>`);
} else { instrBox.innerHTML = formattedText; }
const imgEl = document.getElementById('step-image'); imgEl.src = s.imageUrl || s.img || ""; imgEl.style.display = (curKey === 'virgen' && imgEl.src) ? 'block' : 'none';
const prog = ((curStep + 1) / list.length) * 100; document.getElementById('progress-bar').style.width = `${prog}%`;
const slider = document.getElementById('stepSlider'); slider.max = list.length - 1; slider.value = curStep;
const beadBox = document.getElementById('bead-display'); beadBox.innerHTML = '';
let beadClasses = (curKey === 'mariposa') ? (s.beads || []) : getBeads(s.pattern);
beadClasses.forEach(cls => { const b = document.createElement('div'); b.className = `bead ${cls}`; beadBox.appendChild(b); });
const pB = document.getElementById('prevBtn'); const nB = document.getElementById('nextBtn');
pB.disabled = curStep === 0; nB.disabled = curStep === list.length - 1; pB.style.opacity = curStep === 0 ? "0.2" : "1"; nB.style.opacity = curStep === list.length - 1 ? "0.2" : "1";
}
function openModal(type) {
const modal = document.getElementById('reductionModal'); const text = document.getElementById('modal-text');
if (type === 'r2') text.innerText = "Tras insertar la última pepa de la reducción, se forma un escalón. El hilo queda en la pepa de la fila previa. Inserta el hilo en la pepa anterior inmediata. Luego, en la penúltima columna, cuenta 3 pepas desde donde estás hacia el centro. Inserta la aguja en la 3ra, regresa por la 2da en sentido contrario y finalmente sal por la pepa que acabas de poner.";
modal.classList.remove('hidden');
}
function closeModal() { document.getElementById('reductionModal').classList.add('hidden'); }
function changeStep(d) { jumpToStep(curStep + d); }
function jumpToStep(v) { const p = patterns[curKey]; const list = (curKey === 'virgen' && isLeft) ? p.leftSteps : (p.mainSteps || p.steps); const val = parseInt(v); if (val >= 0 && val < list.length) { curStep = val; render(); } }
document.addEventListener('keydown', (e) => {
if(document.getElementById('patternView').classList.contains('hidden')) return;
if(e.key === "ArrowRight") changeStep(1); if(e.key === "ArrowLeft") changeStep(-1);
if(e.key === "Escape") { if(!document.getElementById('reductionModal').classList.contains('hidden')) closeModal(); else if(!document.getElementById('materialsModal').classList.contains('hidden')) closeMaterials(); else showHub(); }
});
window.onload = showHub;
</script>
</body>
</html>