:root {
  --a: 61, 255, 143;             /* accent as r, g, b — swapped by the pills */
  --accent: rgb(var(--a));
  --bg: #000;
  --fg: #cfe9d9;
  --dim: #6b8577;
  --line: rgba(var(--a), .22);
  --red: #ff4d4d;
  --blue: #3db4ff;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --gutter: clamp(14px, 4.5vw, 56px);
}
:root[data-pill="red"] { --a: 255, 77, 77; }
:root[data-pill="blue"] { --a: 61, 180, 255; }

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

html { height: 100%; -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.6;
  height: 100%;
  overflow: hidden; /* one screen, no scrolling */
  -webkit-font-smoothing: antialiased;
}

/* CRT scanlines over everything */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  background: repeating-linear-gradient(rgba(0, 0, 0, 0) 0 2px, rgba(0, 0, 0, .22) 2px 3px);
}

a { color: inherit; text-decoration: none; }
svg { display: block; }
button, input { font: inherit; color: inherit; }
::selection { background: var(--accent); color: #000; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.caret {
  display: inline-block;
  width: .6em;
  height: 1.1em;
  margin-left: 3px;
  vertical-align: -.2em;
  background: var(--accent);
  animation: blink 1.1s steps(1) infinite;
}
.dim { color: var(--dim); }

/* ---------- boot screen ---------- */

body.booting { overflow: hidden; }
body.booting .hero-intro, body.booting .hint { animation-play-state: paused; }

#boot {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  cursor: pointer;
  transition: opacity .6s ease, transform .6s ease, visibility 0s .6s;
  animation: boot-failsafe .01s 12s forwards;
}
#boot.done { opacity: 0; transform: scale(1.06); visibility: hidden; pointer-events: none; }

.boot-log {
  position: absolute;
  inset: 0;
  padding: max(18px, env(safe-area-inset-top)) var(--gutter) 18px;
  overflow: hidden;
  font-size: clamp(10.5px, 2.6vw, 13px);
  line-height: 1.6;
  color: #7c9a8a;
  white-space: nowrap;
}
.boot-log .cmd { color: var(--fg); margin: 0; }
.boot-log .cmd::before { content: "$ "; color: var(--accent); }
.boot-log .cmd.typing::after {
  content: "";
  display: inline-block;
  width: .6em;
  height: 1.1em;
  margin-left: 2px;
  vertical-align: -.2em;
  background: var(--accent);
}
.boot-log .ok { color: var(--accent); }
.boot-log .hex { color: #24402f; }

.boot-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(.96);
  padding: clamp(10px, 2vw, 22px);
  border: 1px solid rgba(var(--a), .35);
  background: rgba(0, 0, 0, .92);
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35), 0 0 90px rgba(var(--a), .18);
  opacity: 0;
  transition: opacity .35s ease, transform .35s ease;
}
.boot-center.show { opacity: 1; transform: translate(-50%, -50%); }

.boot-name {
  font-family: var(--mono);
  font-size: min(2.2vw, 19px);
  line-height: 1.12;
  color: #14261b;
  user-select: none;
}
.boot-name b { font-weight: 500; color: var(--accent); text-shadow: 0 0 12px rgba(var(--a), .7); }

.boot-status {
  margin-top: clamp(8px, 1.4vw, 14px);
  text-align: center;
  font-size: clamp(10px, 2.4vw, 13px);
  letter-spacing: .14em;
  color: var(--dim);
  min-height: 1.5em;
}
.boot-status.granted { color: var(--accent); }

.boot-skip {
  position: absolute;
  right: var(--gutter);
  bottom: max(16px, env(safe-area-inset-bottom));
  font-size: 11px;
  color: #3f5a4a;
}

/* ---------- nav ---------- */

.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px var(--gutter);
  padding-top: max(12px, env(safe-area-inset-top));
  background: linear-gradient(rgba(0, 0, 0, .85), rgba(0, 0, 0, 0));
  font-size: 13.5px;
}
.logo { color: var(--accent); white-space: nowrap; }
.nav nav { display: flex; gap: 2px; }
.nav nav a { color: var(--dim); padding: 6px 10px; transition: color .15s, background .15s; }
.nav nav a:hover { color: #000; background: var(--accent); }
.snd { padding: 6px 10px; background: transparent; border: 0; color: var(--dim); cursor: pointer; white-space: nowrap; }
.snd:hover { color: #000; background: var(--accent); }
.snd[aria-pressed="true"] { color: var(--accent); }
.snd[aria-pressed="true"]:hover { color: #000; }

/* ---------- terminal window ---------- */

.win {
  border: 1px solid rgba(var(--a), .38);
  border-radius: 10px;
  background: rgba(0, 0, 0, .84);
  box-shadow: 0 0 46px rgba(var(--a), .12), 0 30px 80px rgba(0, 0, 0, .9);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  overflow: hidden;
}
.win-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(var(--a), .05);
  font-size: 12px;
  color: var(--dim);
}
.win-bar i { width: 11px; height: 11px; border-radius: 50%; background: #ff5f57; }
.win-bar i:nth-child(2) { background: #febc2e; }
.win-bar i:nth-child(3) { background: #28c840; }
.win-bar span { position: absolute; left: 0; right: 0; text-align: center; pointer-events: none; }
.win-body { padding: clamp(16px, 3.2vw, 28px); }

.cmd { color: var(--fg); margin-bottom: 10px; min-height: 1.6em; }
.cmd::before { content: "jabik@matrix:~$ "; color: var(--accent); }
.cmd.typing::after {
  content: "";
  display: inline-block;
  width: .6em;
  height: 1.1em;
  margin-left: 2px;
  vertical-align: -.2em;
  background: var(--accent);
}
.out { margin-bottom: 26px; }
.out:last-child { margin-bottom: 0; }

/* command output stays hidden until its command has been typed (only when JS is running) */
.js .win[data-auto] .out { visibility: hidden; }
.js .win[data-auto] .out.on { visibility: visible; animation: out-in .4s ease both; }

/* ---------- hero ---------- */

.hero {
  position: relative;
  height: 100vh;
  height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 84px var(--gutter); /* js adds bottom room for the hands on narrow screens */
  overflow: hidden;
}

#matrix, #scene3d {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  -webkit-mask-image: linear-gradient(#000 86%, transparent);
  mask-image: linear-gradient(#000 86%, transparent);
}

/* command line inside the hero window */
.shell-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}
.ps1 { color: var(--accent); white-space: nowrap; }
.shell-line input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
  caret-color: var(--accent);
  font-size: 16px; /* 16px keeps iOS from zooming on focus */
}
.shell-line input::placeholder { color: #3c5446; }
.shell-msg { min-height: 1.6em; margin-top: 4px; font-size: 13px; color: var(--dim); }
.shell-msg.err { color: var(--red); }

/* binary digits that drip from the cursor */
.trail {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  font-size: 12px;
  color: var(--accent);
  text-shadow: 0 0 8px rgba(var(--a), .8);
  animation: trail .7s linear forwards;
}

/* `sudo`: full-screen alarm */
.denied {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(70, 0, 0, .6);
  color: var(--red);
  font-size: clamp(34px, 9vw, 110px);
  font-weight: 800;
  letter-spacing: .06em;
  text-align: center;
  text-shadow: 0 0 30px rgba(255, 77, 77, .9), 4px 0 rgba(61, 180, 255, .6), -4px 0 rgba(255, 0, 70, .6);
  pointer-events: none;
  animation: denied .22s steps(2) 6;
}
body.shake .hero { animation: shake .16s linear 8; }

#scene3d[hidden] { display: none; }

/* threatening messages that flicker up at random spots around the screen */
.whispers { position: absolute; inset: 0; z-index: 1; overflow: hidden; pointer-events: none; }
.whisper {
  position: absolute;
  white-space: nowrap;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--red);
  text-shadow: 0 0 12px rgba(255, 77, 77, .9), 2px 0 rgba(61, 180, 255, .55), -2px 0 rgba(255, 0, 70, .55);
  animation: whisper 3s linear both;
}

/* hit areas over the two hands drawn on the canvas; the label shows on hover */
.hand {
  position: absolute;
  z-index: 2;
  border: 0;
  background: transparent;
  cursor: pointer;
  transform: translate(-50%, -50%);
  -webkit-tap-highlight-color: transparent;
}
.hand span {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translate(-50%, 4px);
  padding: 4px 10px;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 700;
  background: rgba(0, 0, 0, .8);
  border: 1px solid currentColor;
  opacity: 0;
  transition: opacity .18s, transform .18s;
  pointer-events: none;
}
.hand-red span { color: var(--red); text-shadow: 0 0 12px rgba(255, 77, 77, .8); }
.hand-blue span { color: var(--blue); text-shadow: 0 0 12px rgba(61, 180, 255, .8); }
.hand:hover span, .hand:focus-visible span { opacity: 1; transform: translate(-50%, -4px); }
.hand:focus-visible { outline: 0; }
/* the head's label sits to its right, clear of the window below it */
.hand.hand-side span { top: 26%; left: 100%; color: var(--accent); text-shadow: 0 0 12px rgba(var(--a), .8); transform: translate(-6px, 0); }
.hand.hand-side:hover span, .hand.hand-side:focus-visible span { transform: translate(4px, 0); }
/* no hover on touch screens, so the labels are always there */
@media (hover: none) {
  .hand span { opacity: 1; transform: translate(-50%, -4px); }
  .hand.hand-side span { transform: translate(4px, 0); font-size: 12.5px; }
}

.hero-stage { position: relative; z-index: 3; perspective: 1200px; width: min(600px, 100%); }
.hero-intro { animation: win-in 1.1s cubic-bezier(.16, 1, .3, 1) both .1s; transform-style: preserve-3d; }
.hero-win { will-change: transform; }

.name {
  font-size: clamp(60px, 17vw, 112px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: .04em;
  color: var(--accent);
  text-shadow: 0 0 18px rgba(var(--a), .65), 0 0 60px rgba(var(--a), .35);
  margin: 4px 0 10px;
}
.roles { font-size: clamp(13.5px, 3.6vw, 17px); color: var(--fg); }
.roles i { color: var(--accent); font-style: normal; }
.typed { margin: 6px 0 24px; color: var(--dim); font-size: clamp(12.5px, 3.3vw, 14.5px); white-space: nowrap; }
.typed span { color: var(--fg); }
.typed span.warn { color: var(--red); font-weight: 700; text-shadow: 0 0 12px rgba(255, 77, 77, .9); }

.contacts { display: flex; flex-wrap: wrap; gap: 10px; }
.contacts a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid rgba(var(--a), .45);
  color: var(--accent);
  font-size: 14px;
  transition: background .15s, color .15s, transform .15s;
}
.contacts a:hover { background: var(--accent); color: #000; transform: translateY(-2px); }
.contacts svg { width: 17px; height: 17px; }

.hint {
  position: absolute;
  z-index: 3;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--dim);
  white-space: nowrap;
  padding: 4px 8px;
  background: rgba(0, 0, 0, .6);
  animation: fade-up .9s ease both .9s;
}
.hero.compact .hint { display: none; } /* no room between the hands on narrow screens */
.hint b { font-weight: 500; }
.hint .r { color: var(--red); }
.hint .b { color: var(--blue); }
.hint .g { color: var(--accent); }

/* ---------- panels (about me / contact) ---------- */

.panel {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px var(--gutter);
  background: rgba(0, 0, 0, .7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fade-up .25s ease both;
}
.panel[hidden] { display: none; }
.panel .win {
  width: min(860px, 100%);
  max-height: calc(100vh - 40px);
  max-height: calc(100svh - 40px);
  overflow-y: auto;
  background: rgba(0, 0, 0, .93);
  animation: win-in .5s cubic-bezier(.16, 1, .3, 1) both;
}
.panel .win-bar { position: sticky; top: 0; z-index: 1; background: #050a07; }
.win-x {
  position: relative;
  margin-left: auto;
  padding: 2px 6px;
  background: transparent;
  border: 0;
  color: var(--dim);
  cursor: pointer;
}
.win-x:hover { color: #000; background: var(--accent); }

h2 {
  font-size: clamp(21px, 4.4vw, 36px);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -.01em;
  color: #fff;
}

.skills { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.skill {
  padding: 16px 18px;
  border: 1px dashed rgba(var(--a), .3);
  transition: border-color .15s, background .15s;
}
.skill:hover { border-style: solid; border-color: var(--accent); background: rgba(var(--a), .06); }
.skill h3 { font-size: 15.5px; font-weight: 700; color: var(--accent); margin-bottom: 6px; overflow-wrap: anywhere; }
.skill h3 span { color: var(--dim); font-weight: 400; }
.skill p { font-size: 14px; color: var(--fg); opacity: .85; }

.projects { display: grid; gap: 12px; }
.proj em {
  float: right;
  font-style: normal;
  font-weight: 400;
  font-size: 11.5px;
  color: var(--dim);
  border: 1px solid var(--line);
  padding: 1px 7px;
}
.proj em.live { color: var(--accent); border-color: var(--accent); }
.proj-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.proj-links a { padding: 6px 10px; border: 1px solid rgba(var(--a), .45); color: var(--accent); font-size: 13px; transition: background .15s, color .15s; }
.proj-links a:hover { background: var(--accent); color: #000; }
.proj dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; margin-top: 10px; font-size: 13px; }
.proj dt { color: var(--dim); }
.proj dt::after { content: ":"; }
.proj dd { color: var(--fg); }
.readme { font-size: 14px; color: var(--fg); opacity: .9; }
.readme a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

.files { display: flex; flex-direction: column; }
.file {
  display: grid;
  grid-template-columns: auto auto minmax(0, auto) auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 13px 12px;
  border-bottom: 1px dashed var(--line);
  transition: background .15s, color .15s;
}
.file:last-child { border-bottom: 0; }
.file svg { width: 19px; height: 19px; color: var(--accent); }
.perm, .arrow { color: var(--dim); }
.fname { font-weight: 700; font-size: clamp(16px, 3vw, 20px); color: var(--accent); }
.target { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file:hover { background: var(--accent); color: #000; }
.file:hover * { color: #000; }

/* ---------- keyframes ---------- */

@keyframes blink { 50% { opacity: 0; } }
@keyframes trail { to { transform: translateY(28px); opacity: 0; } }
@keyframes denied { 50% { opacity: .35; } }
@keyframes shake { 25% { transform: translate(-7px, 3px); } 75% { transform: translate(7px, -3px); } }
@keyframes whisper {
  0% { opacity: 0; transform: translateX(-8px) skewX(-14deg); }
  4% { opacity: 1; }
  6% { opacity: .15; transform: translateX(6px); }
  9% { opacity: 1; transform: none; }
  46% { opacity: .95; }
  48% { opacity: .2; transform: translateX(-4px) skewX(8deg); }
  51% { opacity: .95; transform: none; }
  82% { opacity: .85; }
  100% { opacity: 0; transform: translateY(5px); }
}
@keyframes boot-failsafe { to { visibility: hidden; pointer-events: none; } }
@keyframes win-in {
  from { opacity: 0; transform: translateY(50px) rotateX(24deg) scale(.9); }
  to { opacity: 1; transform: none; }
}
@keyframes out-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade-up { from { opacity: 0; } to { opacity: 1; } }

/* ---------- small screens ---------- */

@media (max-width: 720px) {
  body { font-size: 14px; }
  .skills { grid-template-columns: 1fr; }
  .cmd::before { content: "~$ "; }
  .perm, .arrow { display: none; }
  .file { grid-template-columns: auto auto minmax(0, 1fr); gap: 12px; padding: 13px 6px; }
  .target { text-align: right; font-size: 12.5px; }
}

@media (max-width: 520px) {
  .hint { font-size: 10.5px; }
  .lf { display: none; }
  .nav { font-size: 12px; }
  .nav nav a, .snd { padding: 6px 6px; }
  .contacts a { padding: 8px 10px; font-size: 13px; gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-intro, .hint, .caret, .panel, .panel .win, body.shake .hero { animation: none; }
}

/* short phones: tighten the hero so the window and the hands both fit */
@media (max-width: 520px) and (max-height: 780px) {
  .hero { padding-top: 60px; }
  .name { font-size: 52px; }
  .typed { margin-bottom: 14px; }
  .win-body { padding: 14px; }
  .shell-line { margin-top: 14px; padding-top: 10px; }
}

@media (max-height: 520px) {
  body { overflow: auto; }
  .hero { height: auto; min-height: 100svh; }
}
