-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
538 lines (505 loc) · 23.5 KB
/
index.html
File metadata and controls
538 lines (505 loc) · 23.5 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<title>ОТМАЗКАТОР 3000</title>
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
min-height: 100vh; min-height: 100dvh;
display: flex; justify-content: center; align-items: flex-start;
padding: 32px 12px 60px;
font-family: -apple-system, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
background: #04040c;
color: #f0f0f0;
overflow-x: hidden;
-webkit-font-smoothing: antialiased;
}
#stars-canvas { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
/* CARD — полупрозрачный */
.card {
position: relative; z-index: 1;
width: 100%; max-width: 560px;
background: rgba(255,255,255,0.022);
border: 1px solid rgba(255,255,255,0.1);
border-radius: 28px;
padding: 26px 22px;
backdrop-filter: blur(100px) saturate(200%);
-webkit-backdrop-filter: blur(100px) saturate(200%);
box-shadow:
0 0 0 1px rgba(255,255,255,0.055) inset,
0 1px 0 rgba(255,255,255,0.1) inset,
0 40px 80px rgba(0,0,0,0.5);
animation: fadeUp .8s cubic-bezier(.22,1,.36,1) both;
}
@keyframes fadeUp { from{opacity:0;transform:translateY(20px)} to{opacity:1;transform:translateY(0)} }
.header-row {
display: flex; align-items: flex-start; justify-content: space-between;
margin-bottom: 20px; gap: 12px;
}
h1 {
font-size: clamp(1.5rem,5vw,2.1rem); font-weight: 900;
letter-spacing: -0.03em; color: #fff; line-height: 1.1; margin-bottom: 3px;
}
.subtitle { color: rgba(255,255,255,0.3); font-size: clamp(0.75rem,2.5vw,0.85rem); }
.lang-toggle {
display: flex; background: rgba(255,255,255,0.05);
border: 1px solid rgba(255,255,255,0.1); border-radius: 10px;
padding: 3px; gap: 2px; flex-shrink: 0; margin-top: 3px;
}
.lang-btn {
padding: 5px 11px; border-radius: 7px; font-size: 0.7rem; font-weight: 700;
letter-spacing: 0.06em; cursor: pointer; border: none;
background: transparent; color: rgba(255,255,255,0.3);
font-family: inherit; transition: background .2s, color .2s;
-webkit-tap-highlight-color: transparent; min-height: 30px;
}
.lang-btn.active {
background: rgba(255,255,255,0.12); color: #fff;
box-shadow: 0 1px 0 rgba(255,255,255,0.08) inset;
}
.field { margin-bottom: 10px; }
.field-label {
font-size: 0.6rem; font-weight: 600; color: rgba(255,255,255,0.3);
text-transform: uppercase; letter-spacing: 0.13em; margin-bottom: 6px;
}
/* GLASS */
.glass {
background: rgba(255,255,255,0.035);
border: 1px solid rgba(255,255,255,0.09);
border-radius: 14px;
backdrop-filter: blur(60px) saturate(180%);
-webkit-backdrop-filter: blur(60px) saturate(180%);
box-shadow: 0 0 0 1px rgba(255,255,255,0.03) inset, 0 1px 0 rgba(255,255,255,0.06) inset;
transition: border-color .2s, background .2s;
}
.glass:hover { background: rgba(255,255,255,0.055); border-color: rgba(255,255,255,0.14); }
/* MODE PILLS */
.mode-scroll-wrap {
overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
margin-bottom: 10px;
mask-image: linear-gradient(90deg,transparent 0,black 10px,black calc(100% - 10px),transparent 100%);
-webkit-mask-image: linear-gradient(90deg,transparent 0,black 10px,black calc(100% - 10px),transparent 100%);
}
.mode-scroll-wrap::-webkit-scrollbar { display: none; }
.mode-track {
display: inline-flex; gap: 4px; padding: 4px;
background: rgba(255,255,255,0.035); border: 1px solid rgba(255,255,255,0.09);
border-radius: 14px; white-space: nowrap; min-width: 100%;
}
.mode-pill {
display: flex; align-items: center; gap: 5px; padding: 8px 12px;
border-radius: 10px; cursor: pointer; border: 1px solid transparent;
background: transparent; color: rgba(255,255,255,0.35);
font-size: clamp(0.7rem,2.2vw,0.78rem); font-weight: 600; font-family: inherit;
transition: all .2s cubic-bezier(.22,1,.36,1); white-space: nowrap; flex-shrink: 0;
-webkit-tap-highlight-color: transparent; min-height: 38px;
}
.mode-pill:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.7); }
.mode-pill.active {
background: rgba(255,255,255,0.11); border-color: rgba(255,255,255,0.15); color: #fff;
box-shadow: 0 1px 0 rgba(255,255,255,0.08) inset, 0 2px 10px rgba(0,0,0,0.3);
}
.mode-pill .icon { font-size: 0.85rem; line-height: 1; }
/* SELECT */
.custom-select { user-select: none; }
.cs-trigger {
display: flex; align-items: center; justify-content: space-between;
padding: 11px 14px; cursor: pointer;
font-size: clamp(0.83rem,2.8vw,0.9rem); color: rgba(255,255,255,0.82);
font-weight: 500; border-radius: 14px; min-height: 44px;
-webkit-tap-highlight-color: transparent;
}
.cs-arrow {
display: flex; align-items: center; justify-content: center;
color: rgba(255,255,255,0.25); flex-shrink: 0; margin-left: 8px;
transition: transform .3s cubic-bezier(.34,1.56,.64,1), color .2s;
}
.cs-arrow svg { width: 10px; height: 10px; }
.cs-open .cs-arrow { transform: rotate(180deg); color: rgba(255,255,255,0.55); }
/* PORTAL DROPDOWN */
#swear-portal {
position: fixed; z-index: 99999;
background: rgba(4,4,14,0.97);
border: 1px solid rgba(255,255,255,0.13); border-radius: 13px;
backdrop-filter: blur(80px) saturate(200%); -webkit-backdrop-filter: blur(80px) saturate(200%);
box-shadow: 0 8px 48px rgba(0,0,0,0.9), 0 0 0 1px rgba(255,255,255,0.05) inset;
overflow: hidden; min-width: 140px;
opacity: 0; pointer-events: none;
transform: translateY(-6px) scale(0.97); transform-origin: top left;
transition: opacity .18s, transform .18s cubic-bezier(.22,1,.36,1);
}
#swear-portal.open { opacity: 1; pointer-events: all; transform: translateY(0) scale(1); }
.cs-option {
padding: 12px 16px; font-size: 0.88rem; color: rgba(255,255,255,0.5);
cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 16px;
transition: background .15s, color .15s; font-weight: 400; min-height: 44px; white-space: nowrap;
-webkit-tap-highlight-color: transparent;
}
.cs-option + .cs-option { border-top: 1px solid rgba(255,255,255,0.07); }
.cs-option:hover { background: rgba(255,255,255,0.07); color: #fff; }
.cs-option.selected { color: #fff; font-weight: 600; }
.cs-check { opacity: 0; transition: opacity .15s; flex-shrink: 0; }
.cs-check svg { width: 12px; height: 12px; display: block; }
.cs-option.selected .cs-check { opacity: 1; }
.row { display: flex; gap: 10px; }
.row > .field { flex: 1; min-width: 0; }
/* СЛАЙДЕРЫ — компактные и красивые */
.slider-wrap {
padding: 10px 14px 12px;
display: flex; flex-direction: column; gap: 10px;
}
.slider-row {
display: flex; align-items: center; gap: 10px;
}
.slider-name {
font-size: 0.6rem; font-weight: 600; color: rgba(255,255,255,0.28);
text-transform: uppercase; letter-spacing: 0.1em; min-width: 60px;
}
.slider-track {
flex: 1; position: relative; height: 20px; display: flex; align-items: center;
}
.slider-bg {
position: absolute; left: 0; right: 0; height: 3px;
background: rgba(255,255,255,0.08); border-radius: 10px; overflow: hidden;
}
.slider-fill {
height: 100%; background: rgba(255,255,255,0.55); border-radius: 10px;
transition: width .1s;
}
input[type=range] {
position: absolute; left: 0; right: 0; width: 100%;
height: 20px; appearance: none; -webkit-appearance: none;
background: transparent; outline: none; cursor: pointer; margin: 0;
}
input[type=range]::-webkit-slider-thumb {
appearance: none; -webkit-appearance: none;
width: 18px; height: 18px; border-radius: 50%;
background: #fff;
box-shadow: 0 1px 8px rgba(0,0,0,0.5), 0 0 10px rgba(255,255,255,0.15);
cursor: pointer;
transition: transform .15s cubic-bezier(.34,1.56,.64,1);
}
input[type=range]::-webkit-slider-thumb:active { transform: scale(1.35); }
input[type=range]::-moz-range-thumb {
width: 18px; height: 18px; border-radius: 50%; border: none;
background: #fff; cursor: pointer;
box-shadow: 0 1px 8px rgba(0,0,0,0.5);
}
.slider-val {
font-size: 0.68rem; font-weight: 700; color: rgba(255,255,255,0.45);
min-width: 18px; text-align: right;
}
textarea {
width: 100%; background: transparent; border: none; outline: none;
color: rgba(255,255,255,0.85); font-size: clamp(0.88rem,3vw,0.92rem);
padding: 12px 15px; font-family: inherit; resize: none;
min-height: 96px; line-height: 1.65; font-weight: 400; -webkit-appearance: none;
}
textarea::placeholder { color: rgba(255,255,255,0.18); }
.divider {
height: 1px;
background: linear-gradient(90deg,transparent,rgba(255,255,255,0.08),transparent);
margin: 16px 0;
}
#btn-generate {
width: 100%; padding: 15px; border: none; border-radius: 14px;
font-size: clamp(0.8rem,2.8vw,0.86rem); font-weight: 700; letter-spacing: 0.07em;
text-transform: uppercase; cursor: pointer; color: #04040c; background: #fff;
box-shadow: 0 1px 0 rgba(255,255,255,0.9) inset, 0 4px 24px rgba(255,255,255,0.1);
transition: transform .2s cubic-bezier(.34,1.56,.64,1), opacity .2s;
position: relative; overflow: hidden; font-family: inherit;
-webkit-tap-highlight-color: transparent; min-height: 50px; touch-action: manipulation;
}
#btn-generate::before {
content:''; position:absolute; top:0; left:0; right:0; height:50%;
background: linear-gradient(180deg,rgba(255,255,255,0.1) 0%,transparent 100%);
}
#btn-generate:active:not(:disabled) { transform: scale(0.97); }
#btn-generate:disabled { opacity: 0.15; cursor: not-allowed; }
.spinner {
display: none; margin: 16px auto 0; width: 22px; height: 22px;
border: 2px solid rgba(255,255,255,0.06); border-top-color: rgba(255,255,255,0.55);
border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to{transform:rotate(360deg)} }
.result-wrap { margin-top: 14px; }
.result-label {
font-size: 0.6rem; font-weight: 600; color: rgba(255,255,255,0.25);
text-transform: uppercase; letter-spacing: 0.13em; margin-bottom: 6px;
}
.result {
padding: 14px 16px; min-height: 76px;
font-size: clamp(0.91rem,3vw,0.98rem); line-height: 1.75;
color: rgba(255,255,255,0.82); white-space: pre-wrap; font-weight: 400; transition: opacity .3s;
}
.result.loading { opacity: 0.08; }
.result.has-content { animation: resultIn .5s cubic-bezier(.22,1,.36,1) both; }
@keyframes resultIn { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:translateY(0)} }
@media(max-width:480px){
body{padding:14px 8px 36px;} .card{padding:20px 16px;border-radius:22px;}
.row{flex-direction:column;gap:8px;} .row>.field{flex:none;width:100%;} h1{font-size:1.65rem;}
}
</style>
</head>
<body>
<canvas id="stars-canvas"></canvas>
<div id="swear-portal">
<div class="cs-option selected" data-value="No">
<span data-i18n="swear-off">Off</span>
<span class="cs-check"><svg viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><polyline points="2,7 5.5,11 12,3"/></svg></span>
</div>
<div class="cs-option" data-value="Yes">
<span data-i18n="swear-on">On</span>
<span class="cs-check"><svg viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><polyline points="2,7 5.5,11 12,3"/></svg></span>
</div>
</div>
<div class="card">
<div class="header-row">
<div>
<h1 id="main-title">EXCUSINATOR 3000</h1>
<p class="subtitle" data-i18n="subtitle"></p>
</div>
<div class="lang-toggle">
<button class="lang-btn active" data-lang="en">EN</button>
<button class="lang-btn" data-lang="ru">RU</button>
</div>
</div>
<div class="field">
<div class="field-label" data-i18n="lbl-mode"></div>
<div class="mode-scroll-wrap">
<div class="mode-track">
<button class="mode-pill active" data-mode="normal"><span class="icon">😐</span><span data-i18n="mode-normal"></span></button>
<button class="mode-pill" data-mode="absurd"><span class="icon">🤪</span><span data-i18n="mode-absurd"></span></button>
<button class="mode-pill" data-mode="serious"><span class="icon">🎩</span><span data-i18n="mode-serious"></span></button>
<button class="mode-pill" data-mode="poetic"><span class="icon">🌸</span><span data-i18n="mode-poetic"></span></button>
<button class="mode-pill" data-mode="tech"><span class="icon">🤖</span><span data-i18n="mode-tech"></span></button>
<button class="mode-pill" data-mode="baby"><span class="icon">🍼</span><span data-i18n="mode-baby"></span></button>
<button class="mode-pill" data-mode="conspiracy"><span class="icon">👁️</span><span data-i18n="mode-conspiracy"></span></button>
<button class="mode-pill" data-mode="random"><span class="icon">🎲</span><span data-i18n="mode-random"></span></button>
</div>
</div>
</div>
<!-- Мат + слайдеры в одной строке -->
<div class="row" style="align-items:stretch">
<div class="field" style="flex:0 0 auto; min-width:110px; max-width:130px">
<div class="field-label" data-i18n="lbl-profanity"></div>
<div class="custom-select glass" id="cs-swear" style="height:calc(100% - 22px)">
<div class="cs-trigger" id="cs-trigger">
<span class="cs-label">Off</span>
<span class="cs-arrow"><svg viewBox="0 0 12 8" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><polyline points="1,1 6,7 11,1"/></svg></span>
</div>
</div>
</div>
<div class="field" style="flex:1; min-width:0">
<div class="field-label" data-i18n="lbl-sliders"></div>
<div class="glass">
<div class="slider-wrap">
<div class="slider-row">
<span class="slider-name" data-i18n="lbl-creativity-short"></span>
<div class="slider-track">
<div class="slider-bg"><div class="slider-fill" id="roughness-fill" style="width:40%"></div></div>
<input type="range" id="roughness" min="1" max="10" value="5">
</div>
<span class="slider-val" id="roughness-val">5</span>
</div>
<div class="slider-row">
<span class="slider-name" data-i18n="lbl-rudeness-short"></span>
<div class="slider-track">
<div class="slider-bg"><div class="slider-fill" id="rudeness-fill" style="width:22%"></div></div>
<input type="range" id="rudeness" min="1" max="10" value="3">
</div>
<span class="slider-val" id="rudeness-val">3</span>
</div>
</div>
</div>
</div>
</div>
<div class="field" style="margin-top:2px">
<div class="field-label" data-i18n="lbl-situation"></div>
<div class="glass"><textarea id="text"></textarea></div>
</div>
<div class="divider"></div>
<button id="btn-generate"></button>
<div class="spinner" id="spinner"></div>
<div class="result-wrap">
<div class="result-label" data-i18n="lbl-result"></div>
<div class="glass result" id="result"></div>
</div>
</div>
<script>
/* STARS */
(function(){
const c=document.getElementById('stars-canvas'),ctx=c.getContext('2d');
let W,H,S=[];
function resize(){W=c.width=window.innerWidth;H=c.height=window.innerHeight;}
function mk(){return{x:Math.random()*W,y:Math.random()*H,r:Math.random()*1.1+0.15,a:Math.random()*.5+.07,spd:Math.random()*.22+.03,ts:Math.random()*.009+.003,td:Math.random()>.5?1:-1};}
function init(){resize();S=Array.from({length:180},mk);}
function draw(){
ctx.clearRect(0,0,W,H);
for(const s of S){
s.a+=s.ts*s.td;if(s.a>.75){s.a=.75;s.td=-1;}if(s.a<.04){s.a=.04;s.td=1;}
s.y-=s.spd;if(s.y<-2){s.y=H+2;s.x=Math.random()*W;}
ctx.beginPath();ctx.arc(s.x,s.y,s.r,0,Math.PI*2);
ctx.fillStyle=`rgba(255,255,255,${s.a})`;ctx.fill();
}
requestAnimationFrame(draw);
}
window.addEventListener('resize',resize);init();draw();
})();
/* I18N */
const T={
en:{
title:'EXCUSINATOR 3000', subtitle:'Excuse generator',
'lbl-mode':'Mode','lbl-profanity':'Profanity',
'lbl-sliders':'Creativity & Rudeness',
'lbl-creativity-short':'Creative','lbl-rudeness-short':'Rude',
'lbl-situation':'Describe your situation','lbl-result':'Your excuse',
btn:'Generate Excuse', ph:'e.g. I was 2 hours late to work...', wait:'Waiting for your situation...',
'mode-normal':'Normal','mode-absurd':'Absurd','mode-serious':'Serious','mode-poetic':'Poetic',
'mode-tech':'Tech','mode-baby':'Baby','mode-conspiracy':'Conspiracy','mode-random':'Random',
'swear-off':'Off','swear-on':'On'
},
ru:{
title:'ОТМАЗКАТОР 3000', subtitle:'Генератор отмазок',
'lbl-mode':'Режим','lbl-profanity':'Мат',
'lbl-sliders':'Стиль',
'lbl-creativity-short':'Крейт','lbl-rudeness-short':'Груб',
'lbl-situation':'Опиши ситуацию','lbl-result':'Твоя отмазка',
btn:'Сгенерировать', ph:'Например: опоздал на работу на 2 часа...', wait:'Жду твоей ситуации...',
'mode-normal':'Обычный','mode-absurd':'Абсурд','mode-serious':'Серьёзно','mode-poetic':'Поэтично',
'mode-tech':'Техно','mode-baby':'Детский','mode-conspiracy':'Конспиролог','mode-random':'Случайно',
'swear-off':'Нет','swear-on':'Да'
}
};
let lang='en';
function applyLang(l){
lang=l; const t=T[l];
document.getElementById('main-title').textContent=t.title;
document.title=t.title;
document.querySelectorAll('[data-i18n]').forEach(el=>{
const k=el.dataset.i18n; if(t[k]!==undefined)el.textContent=t[k];
});
document.getElementById('text').placeholder=t.ph;
document.getElementById('btn-generate').textContent=t.btn;
const selSpan=document.querySelector('#swear-portal .cs-option.selected [data-i18n]');
document.querySelector('#cs-trigger .cs-label').textContent=selSpan?selSpan.textContent:'';
const res=document.getElementById('result');
if(!res.classList.contains('has-content')&&!res.classList.contains('loading'))res.textContent=t.wait;
}
document.querySelectorAll('.lang-btn').forEach(b=>b.addEventListener('click',()=>{
document.querySelectorAll('.lang-btn').forEach(x=>x.classList.remove('active'));
b.classList.add('active'); applyLang(b.dataset.lang);
}));
applyLang('en');
/* MODE */
let currentMode='normal';
document.querySelectorAll('.mode-pill').forEach(p=>p.addEventListener('click',()=>{
document.querySelectorAll('.mode-pill').forEach(x=>x.classList.remove('active'));
p.classList.add('active'); currentMode=p.dataset.mode;
}));
/* SELECT PORTAL */
const vals={swear:'No'};
const portal=document.getElementById('swear-portal');
const trigger=document.getElementById('cs-trigger');
let dropOpen=false;
function positionPortal(){
const r=trigger.getBoundingClientRect();
portal.style.top=(r.bottom+6)+'px';
portal.style.left=r.left+'px';
portal.style.minWidth=r.width+'px';
}
function openPortal(e){
e.stopPropagation();
if(dropOpen){closePortal();return;}
positionPortal(); portal.classList.add('open'); trigger.classList.add('cs-open'); dropOpen=true;
}
function closePortal(){
portal.classList.remove('open'); trigger.classList.remove('cs-open'); dropOpen=false;
}
trigger.addEventListener('click',openPortal);
window.addEventListener('scroll',()=>{if(dropOpen)positionPortal();},true);
window.addEventListener('resize',()=>{if(dropOpen)positionPortal();});
document.addEventListener('click',()=>{if(dropOpen)closePortal();});
document.querySelectorAll('#swear-portal .cs-option').forEach(opt=>{
opt.addEventListener('click',e=>{
e.stopPropagation();
document.querySelectorAll('#swear-portal .cs-option').forEach(o=>o.classList.remove('selected'));
opt.classList.add('selected'); vals.swear=opt.dataset.value;
const sp=opt.querySelector('[data-i18n]');
document.querySelector('#cs-trigger .cs-label').textContent=sp?sp.textContent:opt.dataset.value;
closePortal();
});
});
/* SLIDERS */
const $=id=>document.getElementById(id);
function updateSlider(inputId, fillId, valId){
const inp=$( inputId), fill=$(fillId), val=$(valId);
const pct=((inp.value-1)/9)*100;
fill.style.width=pct+'%';
val.textContent=inp.value;
}
$('roughness').addEventListener('input',()=>updateSlider('roughness','roughness-fill','roughness-val'));
$('rudeness').addEventListener('input',()=>updateSlider('rudeness','rudeness-fill','rudeness-val'));
/* GENERATE */
const API_KEY="mQ0CdL1z29dH7lKn0HRbBftPZiVo4jF8";
const MODES={
normal:'realistic and believable',absurd:'completely wild, surreal and ridiculous',
serious:'formal, professional and very convincing',poetic:'poetic and dramatic, like Shakespeare wrote it',
tech:'overloaded with tech jargon, code terms and IT slang',
baby:'like a small child explaining with innocent simple logic',
conspiracy:'blaming secret organizations, the deep state, lizard people or the government',
random:'totally unexpected and surprising, any style'
};
const RUDENESS_DESC=[
'extremely polite and gentle','polite with a slightly firm tone','neutral, matter-of-fact',
'slightly blunt','noticeably blunt and direct','rude and dismissive',
'quite rude, bordering on hostile','very rude and aggressive',
'extremely rude and confrontational','maximally hostile, savage and brutal'
];
$('btn-generate').addEventListener('click',async()=>{
const creativity=$('roughness').value;
const rudeness=parseInt($('rudeness').value);
const text=$('text').value.trim();
const outLang=lang==='ru'?'Russian':'English';
const swearOn=vals.swear==='Yes';
if(currentMode!=='random'&&!text)return;
$('btn-generate').disabled=true;
const result=$('result');
result.className='glass result loading'; result.textContent='';
$('spinner').style.display='block';
const swearInstruction=swearOn
?'Use strong, uncensored profanity freely. Do NOT censor words with asterisks or dashes. Write real swear words fully spelled out.'
:'Keep it clean, no profanity.';
const sys=`You are ОТМАЗКАТОР 3000 — an excuse generation machine.
Your ONLY job: invent a funny and creative EXCUSE for the user's situation.
NEVER insult the user directly. ALWAYS produce an actual excuse.
Mode: ${currentMode} — make it ${MODES[currentMode]||'creative'}.
Write entirely in ${outLang}.
Profanity rule: ${swearInstruction}
Creativity level: ${creativity}/10.
Rudeness/tone level: ${rudeness}/10 — be ${RUDENESS_DESC[rudeness-1]}.
Length: 2-4 sentences only. No intro, just the excuse.`;
const usr=currentMode==='random'?'Generate a random excuse for any situation.':`Generate a ${currentMode} excuse for this situation: ${text}`;
try{
const res=await fetch('https://api.mistral.ai/v1/chat/completions',{
method:'POST',
headers:{'Content-Type':'application/json','Authorization':'Bearer '+API_KEY},
body:JSON.stringify({model:'mistral-large-latest',messages:[{role:'system',content:sys},{role:'user',content:usr}],temperature:1.05,max_tokens:250})
});
const data=await res.json();
if(!res.ok)throw new Error(data.message||'API Error');
result.textContent=data.choices[0].message.content.trim();
result.className='glass result has-content';
}catch(e){
result.textContent='Error: '+e.message;
result.className='glass result';
}finally{
$('btn-generate').disabled=false;
$('spinner').style.display='none';
}
});
</script>
</body>
</html>