/**
 * graphicbit.ro — modul robot
 *
 * Oglinda în text simplu a site-ului: un terminal roz pe negru. Același
 * conținut ca în pagina pentru oameni, scris ca listă, ca să-l poată citi
 * la fel de ușor un agent AI, un crawler sau cineva care îl vrea crud.
 *
 * Fără stiluri inline și fără resurse externe (CSP-ul site-ului). Tot ce se
 * mișcă se oprește la prefers-reduced-motion.
 */

@font-face {
  font-family: 'Departure Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(../assets/departure-mono.woff2) format('woff2');
}

:root {
  --bg: #050307;
  --r: #ff3d8b;          /* roz-ul graphicbit, aprins ca un fosfor */
  --r-hi: #ffb3d4;       /* valori, titluri */
  --r-dim: #9c2a62;      /* chei, puncte de ghidaj, etichete */
  --r-faint: rgba(255, 61, 139, .12);
  --ok: #5dffa8;
  --cy: #36c3ff;         /* doar pentru sclipirea logo-ului */
  --maxw: 780px;
  --font: 'Departure Mono', ui-monospace, 'DejaVu Sans Mono', Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { background: var(--bg); scroll-behavior: smooth; }

body {
  min-height: 100vh;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(255, 61, 139, .08), transparent 60%),
    var(--bg);
  color: var(--r);
  font: 13px/1.65 var(--font);
  letter-spacing: .02em;
  text-transform: uppercase;
  -webkit-font-smoothing: antialiased;
  padding: clamp(28px, 6vw, 56px) 20px calc(120px + env(safe-area-inset-bottom));
}

::selection { background: var(--r); color: #000; }

.top, main { max-width: var(--maxw); margin: 0 auto; }

a { color: inherit; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover, a:focus-visible { background: var(--r); color: #000; text-decoration: none; outline: none; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 12px; z-index: 300; background: var(--r); color: #000; padding: 4px 8px; }

/* ─── logo ASCII ───────────────────────────────────────────
   72 de coloane lățime; Departure Mono are avansul de ~0,62 em, de unde
   împărțirea. Sub 640px trece pe varianta pe două rânduri (52 de coloane). */

.logo { display: block; position: relative; text-decoration: none; width: max-content; max-width: 100%; }
.logo:hover, .logo:focus-visible { background: none; color: inherit; }

.ascii {
  font: inherit;
  font-size: min(16px, calc((100vw - 40px) / 44.6));
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
  white-space: pre;
  color: var(--r);
  text-shadow: 2px 2px 0 var(--r-dim), 0 0 18px rgba(255, 61, 139, .35);
}
.ascii.stack { display: none; }

/* două copii puse de robot.js, decupate și deplasate: sclipirea */
.ascii.g {
  position: absolute; inset: 0; pointer-events: none;
  text-shadow: none; opacity: 0; mix-blend-mode: screen;
}
.ascii.g1 { color: var(--cy); animation: glitch1 7s steps(1) infinite; }
.ascii.g2 { color: #fff; animation: glitch2 7s steps(1) infinite; }

@keyframes glitch1 {
  0%, 86%, 100% { opacity: 0; transform: none; clip-path: none; }
  87% { opacity: .8; transform: translate(-3px, 0); clip-path: inset(10% 0 62% 0); }
  89% { opacity: .8; transform: translate(4px, 0);  clip-path: inset(55% 0 20% 0); }
  91% { opacity: .7; transform: translate(-2px, 0); clip-path: inset(30% 0 45% 0); }
  93% { opacity: 0; }
}
@keyframes glitch2 {
  0%, 87%, 100% { opacity: 0; transform: none; clip-path: none; }
  88% { opacity: .5; transform: translate(3px, 0);  clip-path: inset(70% 0 8% 0); }
  90% { opacity: .5; transform: translate(-4px, 0); clip-path: inset(5% 0 80% 0); }
  92% { opacity: 0; }
}

/* ─── meniu ───────────────────────────────────────────── */

.menu { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 26px 0 0; }
.menu a { padding: 1px 3px; }
.menu a.on { background: var(--r); color: #000; text-decoration: none; }

/* ─── conținut ─────────────────────────────────────────── */

.title { margin-top: 30px; color: var(--r-hi); }
.lede { margin-top: 18px; max-width: 60ch; min-height: 3.3em; }

section { scroll-margin-top: 24px; }

.rule {
  display: flex; white-space: nowrap; overflow: hidden;
  font: inherit; color: var(--r);
  margin: 46px 0 18px;
}
.rule::before { content: '── '; flex: none; white-space: pre; }
.rule::after {
  content: ' ────────────────────────────────────────────────────────────────────────────────────────────────────────────';
  flex: 1; overflow: hidden; white-space: pre;
}

p { max-width: 68ch; }
section > p { margin-top: 18px; }

/* cheie ............ valoare */
.kv { display: grid; grid-template-columns: 16ch 1fr; gap: 3px 0; }
.kv dt { color: var(--r-dim); white-space: nowrap; overflow: hidden; }
.kv dt::after { content: ' ................................................'; }
.kv dd { color: var(--r-hi); padding-left: 1ch; }

.items { list-style: none; display: grid; gap: 16px; }
.items b { font-weight: 400; color: var(--r-hi); }
.items p { margin: 2px 0 2px 2ch; }
.tags { margin-left: 2ch; color: var(--r-dim); }

.projects { list-style: none; counter-reset: p; display: grid; gap: 12px; }
.projects li { counter-increment: p; display: grid; grid-template-columns: 5ch 1fr; }
.projects li::before { content: '[' counter(p, decimal-leading-zero) ']'; color: var(--r-dim); }
.projects a { justify-self: start; }
.projects .p-name { color: var(--r-hi); }
.projects a:hover .p-name, .projects a:focus-visible .p-name { color: #000; }
.projects .p-path { color: var(--r-dim); }
.projects a:hover .p-path, .projects a:focus-visible .p-path { color: #000; }
.projects p { grid-column: 2; }
.more { margin-top: 20px; color: var(--r-dim); }

.steps { list-style: none; counter-reset: s; display: grid; gap: 14px; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 5ch 1fr; }
.steps li::before { content: '0' counter(s) ' >'; color: var(--r-dim); }
.steps b { font-weight: 400; color: var(--r-hi); }
.steps p { grid-column: 2; }

.ok { color: var(--ok); }

/* terminalul: un input invizibil peste rând; textul și cursorul-bloc sunt
   desenate de .typed și .caret, ca să arate ca un terminal, nu ca un câmp */
.term { margin-top: 56px; color: var(--r-hi); }
.term-log { white-space: pre-wrap; word-break: break-word; }
.term-log .echo { color: var(--r-dim); }
.term-log .err { color: var(--r); }
.prompt { position: relative; display: block; cursor: text; white-space: pre-wrap; word-break: break-all; }
.typed { color: #fff; text-transform: none; }
.cmd {
  position: absolute; inset: 0; width: 100%;
  opacity: 0; border: 0; background: none; color: transparent;
  font: inherit; font-size: 16px; /* sub 16px, iOS mărește pagina la focus */
  caret-color: transparent; cursor: text;
}
.term:not(.focus) .caret { opacity: .55; }
.caret {
  display: inline-block; width: .62em; height: 1.1em; vertical-align: -.2em;
  background: var(--r); animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.keys { margin-top: 8px; color: var(--r-dim); }
@media (pointer: coarse) { .keys { display: none; } }

/* ─── CRT: linii de baleiaj, vignetă, pâlpâire fină ─────── */

.crt {
  position: fixed; inset: 0; z-index: 50; pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .28) 0 1px, transparent 1px 3px),
    radial-gradient(130% 100% at 50% 50%, transparent 55%, rgba(0, 0, 0, .65) 100%);
  animation: flicker 4s infinite;
}
@keyframes flicker {
  0%, 100% { opacity: 1; }
  47% { opacity: .92; }
  48% { opacity: 1; }
  72% { opacity: .96; }
}

/* ─── pornirea (pusă de robot.js) ───────────────────────── */

.boot {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg);
  padding: clamp(24px, 6vw, 56px) 20px;
  font-size: 12px; line-height: 1.7;
  white-space: pre-wrap;
  transition: opacity .35s ease, transform .35s ease;
}
.boot .ok { color: var(--ok); }
.boot.out { opacity: 0; transform: scale(1.02); pointer-events: none; }

/* ─── ieșirea spre modul om ─────────────────────────────── */

.wipe {
  position: fixed; inset: 0; z-index: 400;
  display: grid; place-items: center;
  background: #060716; color: #f4f1fb;
  font: 13px var(--font); letter-spacing: .08em; text-transform: uppercase;
  clip-path: inset(0 0 100% 0);
  animation: wipe .42s steps(10) forwards;
}
@keyframes wipe { to { clip-path: inset(0 0 0 0); } }

/* ─── comenzile ascunse: matrix și trenul (sl) ─── */
.matrix { position: fixed; inset: 0; z-index: 450; width: 100%; height: 100%; background: var(--bg); cursor: default; }
.sl {
  position: fixed; left: 0; top: 40%; z-index: 450; margin: 0; pointer-events: none;
  font: 13px/1.1 var(--font); white-space: pre; text-transform: none; letter-spacing: 0;
  color: var(--r-hi); text-shadow: 0 0 10px var(--r);
  transform: translateX(100vw);
  animation: slRun 5s linear forwards; will-change: transform;
}
@keyframes slRun { to { transform: translateX(-100%); } }

/* ─── vim ─── */
html.vim-open { overflow: hidden; }
.vim {
  position: fixed; inset: 0; z-index: 480;
  display: flex; flex-direction: column;
  background: var(--bg); color: var(--r-hi);
  font: 14px/20px var(--font); text-transform: none; letter-spacing: 0;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  cursor: text;
}
.vim-screen { flex: 1; overflow: hidden; padding: 6px 10px 0; white-space: pre; }
.vim-tilde { color: #3d4cff; }
.vim-nu { color: var(--r-dim); }
.vim-cur { background: var(--r); color: #000; }
.vim-cur.ins { background: none; color: inherit; box-shadow: inset 2px 0 0 var(--r); }
.vim:not(:focus-within) .vim-cur { background: none; color: inherit; box-shadow: inset 0 0 0 1px var(--r); }
.vim-status { padding: 0 10px; background: var(--r-dim); color: #fff; white-space: pre; overflow: hidden; }
.vim-cmd { min-height: 20px; padding: 0 10px 4px; white-space: pre; overflow: hidden; color: var(--r-hi); }
.vim-cmd.err { color: #fff; }
.vim-cmd.err::before { content: ''; }
.vim-in {
  position: absolute; left: 0; bottom: 0; width: 1px; height: 1px;
  opacity: 0; border: 0; padding: 0; resize: none;
  font-size: 16px; /* sub 16px, iOS mărește pagina la focus */
}
.vim-esc {
  position: absolute; right: 12px; bottom: calc(52px + env(safe-area-inset-bottom));
  padding: 8px 14px; border: 1px solid var(--r); background: var(--bg); color: var(--r);
  font: 13px var(--font); letter-spacing: .1em;
}

/* ─── easter egg: pagina 404 a serverului (după „sudo rm -rf”) ───
   Copia paginii LiteSpeed pe care o dă graphicbit.ro la o adresă inexistentă,
   EXACT cum apare în browser: CSP-ul site-ului (style-src 'self') se aplică și
   ei și îi blochează toate stilurile inline, deci se vede cu stilurile implicite
   ale browserului — Times, negru pe alb, marginea de 8px a lui body. Aici sunt
   reproduse acele valori implicite (robot.css resetează margin/padding la 0
   și pune majuscule, de aceea sunt scrise toate). Doar decor. */
html.nuked { overflow: hidden; }
.e404 {
  position: fixed; inset: 0; z-index: 500; overflow: auto;
  padding: 8px; background: #fff; color: #000; color-scheme: light;
  font: 16px/normal 'Times New Roman', Times, serif;
  text-transform: none; letter-spacing: normal; -webkit-font-smoothing: auto;
  cursor: default;
}
.e404 ::selection { background: #b3d4fc; color: #000; }
.e404 h1 { display: block; font-size: 2em; font-weight: bold; margin: .67em 0; }
.e404 h2 { display: block; font-size: 1.5em; font-weight: bold; margin: .83em 0; }
.e404 p { margin: 1em 0; max-width: none; }

/* ─── ecrane înguste ───────────────────────────────────── */

@media (max-width: 640px) {
  body { font-size: 12px; }
  .ascii.wide { display: none; }
  .ascii.stack { display: block; font-size: min(14px, calc((100vw - 40px) / 32.2)); }
  .kv { grid-template-columns: 12ch 1fr; }
  .projects li, .steps li { grid-template-columns: 5ch 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .ascii.g, .crt, .caret { animation: none; }
  .ascii.g { display: none; }
  .boot { transition: none; }
  .wipe { animation: none; clip-path: none; }
}

@media print {
  .crt, .boot, .keys, .term { display: none !important; }
  body { background: #fff; color: #000; }
}
