:root {
  --bg: #0a0c0f;
  --bg-2: #11151a;
  --line: #1f262e;
  --line-2: #2c3540;
  --text: #e6e9ec;
  --body: #c4cad0;
  --muted: #8a949e;
  --accent: #ff8a3d;      /* the one interactive hue */
  --accent-2: #4fd1c5;    /* non-interactive highlight: code, status */
  --ok: #7ee787;
  --bad: #f2555a;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* type: body / secondary / meta */
  --fs-body: 1rem;
  --fs-2: .875rem;
  --fs-meta: .75rem;

  /* motion tokens */
  --m-150: 150ms;
  --m-200: 200ms;
  --m-300: 300ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --vp-wide: 1280px;
  --hit: 44px;
  --nav-h: calc(var(--hit) + .5rem + 1px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-body)/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, b, strong { font-weight: 600; }
a { color: inherit; }
code { font-family: var(--mono); font-size: .875em; color: var(--accent-2); }
.mono { font-family: var(--mono); }
.dim { color: var(--muted); }
.small { font-size: var(--fs-meta); }
.accent { color: var(--accent); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.skip {
  position: absolute; left: 1rem; top: -4rem; z-index: 20;
  display: inline-flex; align-items: center; min-height: var(--hit);
  padding: 0 1rem; background: var(--accent); color: #111; border-radius: 8px;
  font: 600 var(--fs-2) var(--mono); text-decoration: none;
}
.skip:focus { top: 1rem; }

#net {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  z-index: -1;
  opacity: .5;
}

/* nav: full-width chrome */
.nav {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .25rem clamp(1rem, 4vw, 3rem);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  font-family: var(--mono); font-size: var(--fs-2);
}
@supports (backdrop-filter: blur(8px)) {
  .nav { background: rgb(10 12 15 / .85); backdrop-filter: blur(8px); }
}
.logo, .nav nav a, .menu-btn {
  display: inline-flex; align-items: center; min-height: var(--hit);
  text-decoration: none;
}
.logo .prompt { color: var(--ok); }
.logo .path { color: var(--accent-2); }
.nav nav { display: flex; gap: .25rem 1rem; }
.nav nav a { color: var(--muted); padding-inline: .5rem; justify-content: center; }
.nav nav a:hover { color: var(--accent); }
.menu-btn {
  display: none; gap: .5rem; padding: 0 1rem;
  font: inherit; color: var(--text); background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
}

main { max-width: var(--vp-wide); margin: 0 auto; padding-inline: clamp(1rem, 4vw, 3rem); }

/* hero */
.hero {
  min-height: calc(100vh - var(--nav-h));
  min-height: calc(100svh - var(--nav-h));
  display: flex; flex-direction: column;
  padding-block: 2rem 1.5rem;
}
.hero-body { margin-block: auto; padding-block: 1rem; }
section[id], .block { scroll-margin-top: var(--nav-h); }
.kicker { color: var(--muted); font-size: var(--fs-2); margin: 0 0 1rem; }
h1 {
  font-size: clamp(3.5rem, min(13vw, 14vh), 9rem);
  line-height: 1.1; letter-spacing: -.04em; margin: 0;
}
.tagline { font-size: clamp(1rem, 2.4vw, 1.25rem); margin: 1.5rem 0 .5rem; min-height: 2em; }
.typed { color: var(--accent-2); }
.caret { color: var(--accent); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.lede { max-width: 65ch; color: var(--muted); font-size: 1.125rem; margin: 0 0 2rem; }
.cta { display: flex; gap: .75rem; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; min-height: var(--hit);
  font-family: var(--mono); font-size: var(--fs-2);
  padding: 0 1.25rem; border: 1px solid var(--line-2); border-radius: 8px;
  text-decoration: none; background: var(--bg-2);
  transition: border-color var(--m-150) ease;
}
.btn.primary { background: var(--accent); color: #111; border-color: var(--accent); font-weight: 600; }
.edge {
  margin: 2rem 0 0; min-height: 2.5rem; font-size: var(--fs-meta); color: var(--muted);
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
}
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }

/* stats */
.stats {
  margin-top: 1.5rem;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
  background: var(--line); gap: 1px;
}
.stats div { background: var(--bg-2); padding: 1.5rem; display: flex; gap: 1rem; align-items: center; }
.stats b { font-size: 2rem; line-height: 1.2; color: var(--accent); font-family: var(--mono); min-width: 3.25rem; }
.stats span { color: var(--muted); font-size: var(--fs-2); line-height: 1.5; }

/* sections */
.block { padding-block: 6rem 1rem; }
h2 { font-size: clamp(2rem, 5vw, 3rem); line-height: 1.15; letter-spacing: -.02em; margin: 0 0 2.5rem; display: flex; align-items: baseline; gap: 1rem; }
.num { font-size: var(--fs-2); color: var(--accent); font-weight: 500; }
h3 { margin: 0 0 .5rem; font-size: 1.25rem; line-height: 1.25; letter-spacing: -.01em; }
.label { color: var(--accent); font-size: var(--fs-meta); text-transform: uppercase; letter-spacing: .1em; margin: 0 0 .5rem; }
.prose, .timeline p, .card p { max-width: 70ch; }

/* research */
.research { display: grid; grid-template-columns: 1.05fr 1fr; gap: 3rem; align-items: start; }
.research h3 { font-size: clamp(1.25rem, 2.6vw, 1.75rem); line-height: 1.2; margin-bottom: 1rem; }
.research p { color: var(--body); }
.ticks { list-style: none; padding: 0; margin: 1.5rem 0 0; }
.ticks li { padding-left: 1.5rem; position: relative; margin: .5rem 0; color: var(--body); }
.ticks li::before { content: "→"; position: absolute; left: 0; color: var(--accent); font-family: var(--mono); }

.viz {
  margin: 0; background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px;
  padding: 1.25rem; position: sticky; top: 6rem;
}
.viz-head { display: flex; justify-content: space-between; font-size: var(--fs-meta); color: var(--muted); margin-bottom: 1.5rem; gap: 1rem; min-height: 3rem; }
.cpus { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin-bottom: 1.5rem; }
.cpu {
  font-family: var(--mono); font-size: var(--fs-meta); text-align: center;
  border: 1px solid var(--line); border-radius: 8px; padding: .5rem .25rem;
}
.cpu b { display: block; color: var(--muted); font-weight: 500; }
.cpu.active { border-color: var(--accent-2); color: var(--accent-2); }
.cpu.restart { border-color: var(--bad); color: var(--bad); }
.list { display: flex; flex-wrap: wrap; gap: 1.25rem .25rem; align-items: center; min-height: 3.5rem; padding-top: 1rem; }
.node {
  font-family: var(--mono); font-size: var(--fs-2);
  min-width: 2.75rem; padding: .5rem; text-align: center;
  border: 1px solid var(--line-2); border-radius: 8px; background: var(--bg);
  position: relative;
  transition: opacity var(--m-300) ease-in, transform var(--m-300) ease-in;
}
.arrow { color: var(--muted); font-family: var(--mono); font-size: var(--fs-2); }
.node.hp { border-color: var(--accent-2); box-shadow: inset 0 1px 0 rgb(79 209 197 / .35); background: rgb(79 209 197 / .08); }
.node.retired { border-color: var(--accent); color: var(--accent); border-style: dashed; }
.node.freed { opacity: 0; transform: scale(.5); }
.node .who { position: absolute; top: -1.25rem; left: 0; right: 0; font-size: var(--fs-meta); line-height: 1; color: var(--accent-2); }
.viz-legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: var(--fs-meta); color: var(--muted); margin-top: 1.5rem; }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .25rem; vertical-align: -1px; border: 1px solid; }
.lg.hp { border-color: var(--accent-2); background: rgb(79 209 197 / .3); }
.lg.retired { border-color: var(--accent); border-style: dashed; }
.lg.freed { border-color: var(--line-2); }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.timeline li { display: grid; grid-template-columns: 11rem 1fr; gap: 1.5rem; padding: 0 0 2.5rem 2rem; position: relative; }
.timeline li::before {
  content: ""; position: absolute; left: -6px; top: .5rem;
  width: 11px; height: 11px; border-radius: 50%; background: var(--bg); border: 2px solid var(--accent);
}
.when { color: var(--accent); font-size: var(--fs-2); padding-top: .25rem; }
.where { color: var(--accent-2); margin: 0 0 .5rem; font-size: var(--fs-2); }
.timeline p:last-child { color: var(--muted); margin: 0; }

/* projects */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.25rem; }
.card {
  position: relative; overflow: hidden;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px;
  padding: 1.5rem; display: flex; flex-direction: column;
  transition: transform var(--m-200) var(--ease-out);
}
.tag { font-size: var(--fs-meta); color: var(--accent); text-transform: uppercase; letter-spacing: .1em; margin: 0 0 .75rem; }
.card p { color: var(--body); font-size: var(--fs-2); margin: 0 0 1rem; }
.card .stack { font-size: var(--fs-meta); color: var(--accent-2); margin-top: auto; }
.links { display: flex; flex-wrap: wrap; gap: 0 1.5rem; }
.repo {
  display: inline-flex; align-items: center; min-height: var(--hit);
  font-size: var(--fs-2); color: var(--accent); text-decoration: underline;
  text-decoration-color: rgb(255 138 61 / .4); text-underline-offset: 4px;
}

/* tiny Pac-Man: transform-only animation */
.pacman { position: absolute; top: 1.25rem; right: 1.25rem; width: 88px; height: 16px; overflow: hidden; }
.pellets {
  position: absolute; inset: 6px 0 auto; height: 4px;
  background: radial-gradient(circle, #ffd23f 2px, transparent 2.5px) 0 0 / 16px 4px repeat-x;
}
.pm { position: absolute; left: 0; top: 0; width: 16px; height: 16px; z-index: 2; animation: run 4s linear infinite; }
/* the strip behind him, edge at his centre, hides every pellet he has passed */
.eaten { position: absolute; top: 0; left: -120px; width: 128px; height: 16px; z-index: 1; background: var(--bg-2); animation: run 4s linear infinite; }
.pm::before, .pm::after {
  content: ""; position: absolute; left: 0; width: 16px; height: 8px; background: #ffd23f;
}
.pm::before { top: 0; border-radius: 8px 8px 0 0; transform-origin: 50% 100%; animation: jaw-top .3s ease-in-out infinite alternate; }
.pm::after { bottom: 0; border-radius: 0 0 8px 8px; transform-origin: 50% 0; animation: jaw-bot .3s ease-in-out infinite alternate; }
@keyframes jaw-top { from { transform: rotate(-30deg); } to { transform: rotate(0); } }
@keyframes jaw-bot { from { transform: rotate(30deg); } to { transform: rotate(0); } }
@keyframes run { from { transform: translateX(-16px); } to { transform: translateX(96px); } }

/* live repos: L1 surface + hairline rows */
.live { margin-top: 2.5rem; border: 1px solid var(--line); border-radius: 16px; padding: 1.5rem; background: var(--bg-2); }
.live-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.live-head h3 { font-size: var(--fs-2); display: flex; align-items: center; gap: .5rem; margin: 0; font-weight: 500; }
.repos { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0 2rem; }
.repos a {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; min-height: var(--hit);
  border-bottom: 1px solid var(--line); text-decoration: none; font-family: var(--mono); font-size: var(--fs-2);
}
.repos .rn::after { content: " ↗"; color: var(--muted); }
.repos .lang { color: var(--muted); font-size: var(--fs-meta); white-space: nowrap; }
.repos .lang::before { content: "●"; margin-right: .25rem; color: var(--c, var(--muted)); }
.repos .skel { min-height: var(--hit); border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.repos .skel::before { content: ""; width: 60%; height: .75rem; border-radius: 4px; background: var(--line); }
.repos .msg { font-family: var(--mono); font-size: var(--fs-2); color: var(--muted); min-height: var(--hit); display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.repos .msg a { color: var(--accent); }

/* skills */
.skills { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.skills div { background: var(--bg-2); padding: 1.5rem; }
.skills h3 { font-size: var(--fs-meta); color: var(--accent); text-transform: uppercase; letter-spacing: .1em; font-weight: 500; }
.skills p { margin: 0; color: var(--body); }
.langs { color: var(--muted); font-size: var(--fs-2); margin-top: 1.5rem; }

/* contact */
.big { font-size: clamp(1.25rem, 3vw, 2rem); max-width: 34rem; line-height: 1.25; margin: 0 0 2rem; }
.contact .cta { margin-bottom: 2rem; }
.terminal { background: #07090b; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; max-width: 640px; }
.term-bar { display: flex; align-items: center; gap: .5rem; padding: .75rem 1rem; border-bottom: 1px solid var(--line); font-size: var(--fs-meta); color: var(--muted); }
.term-bar i { width: 12px; height: 12px; border-radius: 50%; }
.term-bar i:nth-child(1) { background: #f2555a; }
.term-bar i:nth-child(2) { background: #ffd23f; }
.term-bar i:nth-child(3) { background: #7ee787; }
.term-bar span { margin-left: .5rem; }
.terminal pre { margin: 0; padding: 1.25rem; font-size: var(--fs-2); line-height: 2; overflow-x: auto; }
.terminal a { color: var(--accent); text-underline-offset: 4px; }

footer {
  max-width: var(--vp-wide); margin: 6rem auto 0; padding: 2rem clamp(1rem, 4vw, 3rem);
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 1rem; font-size: var(--fs-meta);
}

/* reveal: only hidden once JS has opted in, so content never depends on it */
.js .reveal { opacity: 0; transform: translateY(8px); transition: opacity var(--m-300) var(--ease-out), transform var(--m-300) var(--ease-out); }
.js .reveal.in { opacity: 1; transform: none; }

/* hover extras only where hover exists */
@media (hover: hover) {
  .btn:hover { border-color: var(--accent); }
  .card:hover { transform: translateY(-4px); border-color: var(--line-2); }
  .repo:hover, .repos a:hover .rn { color: var(--accent); text-decoration-color: currentColor; }
}

/* narrow: compact 2×2 banner so it still fits the first screen */
@media (max-width: 767.98px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stats .extra { display: none; }
  .stats div { padding: .75rem; gap: .5rem; flex-direction: column; align-items: flex-start; }
  .stats b { font-size: 1.25rem; min-width: 0; }
  .stats span { font-size: var(--fs-meta); line-height: 1.4; }
}

/* short screens: keep the whole first screen in view */
@media (min-width: 768px) and (max-height: 820px) {
  .hero { padding-top: 1rem; }
  .tagline { margin-top: 1rem; }
  .lede { margin-bottom: 1.5rem; }
  .edge { margin-top: 1rem; }
  .stats div { padding-block: 1rem; }
}

/* short phones: keep the whole first screen in view */
@media (max-width: 767.98px) and (max-height: 720px) {
  .hero { padding-top: 1rem; }
  .hero-body { padding-block: 0; }
  .kicker { display: none; }  /* the degree tiles below say the same */
  .tagline { margin: 1rem 0 .5rem; }
  .lede { font-size: 1rem; margin-bottom: 1.5rem; }
  .edge { margin-top: 1.5rem; }
}

/* narrow */
@media (max-width: 767.98px) {
  .research { grid-template-columns: 1fr; }
  .viz { position: static; }
  .timeline li { grid-template-columns: 1fr; gap: .25rem; }
  .grid, .skills { grid-template-columns: 1fr; }
  .menu-btn { display: inline-flex; }
  .nav nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; padding: .5rem clamp(1rem, 4vw, 3rem) 1rem;
    background: var(--bg); border-bottom: 1px solid var(--line);
  }
  .nav.open nav { display: flex; }
  .nav nav a { border-bottom: 1px solid var(--line); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .reveal { opacity: 1; transform: none; }
}
