:root {
  --bg: #000;
  --fg: #e8e8e8;
  --dim: #6b6b6b;
  --line: #1c1c1c;
  --accent: #00ff9c;
  --accent-dim: rgba(0, 255, 156, 0.15);
  --danger: #ff2e63;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
::selection { background: var(--accent); color: #000; }
a { color: inherit; text-decoration: none; }
.mono { font-family: var(--mono); }
.accent { color: var(--accent); }
.dim { color: var(--dim); }
.label { color: var(--accent); font-size: 0.8rem; letter-spacing: 0.15em; text-transform: uppercase; }

/* ---------- background ---------- */
#rain {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: 0; opacity: 0.18; pointer-events: none;
}
.scanlines {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: repeating-linear-gradient(to bottom, transparent 0 2px, rgba(255,255,255,0.025) 2px 3px);
}
main, footer, nav { position: relative; z-index: 2; }

/* ---------- nav ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.25rem clamp(1rem, 4vw, 3rem);
  font-family: var(--mono); font-size: 0.85rem;
  background: linear-gradient(to bottom, rgba(0,0,0,0.85), transparent);
  border-bottom: 1px solid transparent;
  transition: background-color .3s, border-color .3s;
}
/* once off the hero, give the bar a real backdrop so content doesn't show through the links */
.nav.scrolled {
  background: rgba(0,0,0,0.72);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom-color: var(--line);
}
.logo { font-weight: 600; }
.nav-links { display: flex; gap: 1.5rem; white-space: nowrap; }
@media (max-width: 480px) {
  .nav { font-size: .75rem; }
  .nav-links { gap: .9rem; }
}
.nav-links a { color: var(--dim); transition: color .2s; }
.nav-links a:hover { color: var(--accent); }

/* burger: script.js adds .collapsed when the links don't fit on one line */
.nav-toggle {
  display: none; flex-direction: column; justify-content: center; gap: 5px;
  width: 2.25rem; height: 2.25rem; padding: 0 .45rem; margin-right: -.45rem;
  background: none; border: 0; cursor: pointer;
}
.nav-toggle span { display: block; height: 1.5px; background: var(--fg); transition: transform .25s, opacity .2s, background .2s; }
.nav-toggle:hover span, .nav.open .nav-toggle span { background: var(--accent); }
.nav.open .nav-toggle span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.nav.open .nav-toggle span:nth-child(2) { opacity: 0; }
.nav.open .nav-toggle span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }
.nav.collapsed .nav-toggle { display: flex; }
.nav.collapsed .nav-links {
  position: absolute; top: 100%; left: 0; right: 0;
  flex-direction: column; gap: 0;
  padding: .5rem clamp(1rem, 4vw, 3rem) 1rem;
  background: var(--bg); border-bottom: 1px solid var(--line);
  font-size: .95rem;
  visibility: hidden; opacity: 0; transform: translateY(-.5rem);
  transition: opacity .2s, transform .2s, visibility 0s .2s;
}
.nav.collapsed .nav-links a { padding: .8rem 0; border-top: 1px solid var(--line); }
.nav.collapsed .nav-links a::before { content: "> "; color: var(--accent); }
.nav.collapsed.open { background: var(--bg); }
.nav.collapsed.open .nav-links { visibility: visible; opacity: 1; transform: none; transition: opacity .2s, transform .2s; }

/* ---------- hero ---------- */
.hero {
  overflow-x: clip;
  position: relative;
  min-height: 100svh;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: 0 1rem; text-align: center;
}
.terminal {
  font-size: clamp(0.75rem, 2.5vw, 0.95rem);
  color: var(--dim); text-align: left; min-height: 4.5em;
  margin-bottom: 2rem; width: min(640px, 100%);
}
.prompt { color: var(--accent); }
.cursor { animation: blink 1s steps(1) infinite; color: var(--accent); }
.term-out { color: var(--fg); white-space: pre-wrap; margin-top: .25rem; }
@keyframes blink { 50% { opacity: 0; } }
.terminal.live { cursor: text; }
.term-log { max-height: 11.5em; overflow-y: auto; scrollbar-width: none; }
.term-log::-webkit-scrollbar { display: none; }
.term-log > div { white-space: pre-wrap; word-break: break-word; }
.term-log .t-out { color: var(--fg); }
.term-log .t-ok { color: var(--accent); }
.term-log .t-err { color: var(--danger); }
.term-log .t-dim { color: var(--dim); }
.term-row { display: flex; align-items: baseline; gap: .6em; }
.term-input {
  flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; padding: 0;
  color: var(--fg); font: inherit; caret-color: var(--accent);
}
.term-row .cursor { pointer-events: none; }
.term-row:focus-within .cursor { display: none; }
.term-row[hidden] { display: none; }
.term-log.choosing-game { max-height: min(50svh, 24em); }
.term-games { display: flex; flex-direction: column; align-items: flex-start; margin: .4em 0; }
.term-games button, .term-game-back {
  background: transparent; border: 1px solid transparent; color: var(--fg);
  font: inherit; padding: .25em .6em; min-height: 44px; cursor: pointer;
}
.term-games button::before { content: "> "; color: var(--accent); }
.term-game-back { margin-top: .4em; }
.term-games button:hover, .term-games button:focus-visible,
.term-game-back:hover, .term-game-back:focus-visible {
  outline: none; border-color: var(--accent); color: var(--accent);
}

.hero-name {
  font-size: clamp(2.8rem, 12vw, 10rem);
  font-weight: 900; letter-spacing: -0.04em; line-height: 0.9;
  opacity: 0; transform: scale(1.4); filter: blur(20px);
  transition: opacity 1.4s cubic-bezier(.2,.8,.2,1), transform 1.4s cubic-bezier(.2,.8,.2,1), filter 1.4s;
}
.hero-name.in { opacity: 1; transform: scale(1); filter: blur(0); }
.hero-sub {
  margin-top: 1.5rem; color: var(--dim);
  font-size: clamp(0.7rem, 2.2vw, 0.95rem); letter-spacing: 0.1em;
  opacity: 0; transition: opacity 1s .6s;
}
.hero-name.in + .hero-sub { opacity: 1; }
.scroll-hint {
  position: absolute; bottom: 2rem; left: 50%; transform: translateX(-50%);
  font-size: 0.7rem; color: var(--dim); letter-spacing: 0.3em; text-transform: uppercase;
  display: flex; flex-direction: column; align-items: center; gap: .75rem;
}
.scroll-hint .line {
  width: 1px; height: 48px; background: linear-gradient(var(--accent), transparent);
  animation: drip 2s ease-in-out infinite; transform-origin: top;
}
@keyframes drip { 0% { transform: scaleY(0); } 50% { transform: scaleY(1); } 100% { transform: scaleY(1); opacity: 0; } }

/* glitch */
.glitch { position: relative; }
.glitch::before, .glitch::after {
  content: attr(data-text); position: absolute; inset: 0; pointer-events: none;
  opacity: 0;
}
.glitch.in::before { color: var(--accent); animation: glitch-a 4s infinite steps(1); }
.glitch.in::after { color: var(--danger); animation: glitch-b 4s infinite steps(1); }
@keyframes glitch-a {
  0%, 92%, 100% { opacity: 0; transform: none; clip-path: none; }
  93% { opacity: .8; transform: translate(-4px, 2px); clip-path: inset(10% 0 60% 0); }
  95% { opacity: .8; transform: translate(4px, -2px); clip-path: inset(50% 0 20% 0); }
  97% { opacity: .8; transform: translate(-2px, 0); clip-path: inset(80% 0 5% 0); }
}
@keyframes glitch-b {
  0%, 92%, 100% { opacity: 0; transform: none; clip-path: none; }
  94% { opacity: .8; transform: translate(4px, -1px); clip-path: inset(30% 0 40% 0); }
  96% { opacity: .8; transform: translate(-4px, 2px); clip-path: inset(5% 0 75% 0); }
}

/* ---------- zoom-through section ---------- */
.zoom { height: 400vh; position: relative; }
.zoom-sticky {
  position: sticky; top: 0; height: 100svh; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.zoom-text {
  font-size: clamp(2.5rem, 11vw, 9rem);
  font-weight: 900; letter-spacing: -0.04em; white-space: nowrap;
  position: relative;
  will-change: transform;
  transform: scale(var(--zs, 1));
  transform-origin: var(--zox, 50%) var(--zoy, 50%);
}
.zoom-target { color: var(--accent); }
.zoom-caption {
  margin-top: 2rem; color: var(--dim); font-size: 0.85rem; letter-spacing: .2em;
  opacity: var(--zc, 1);
}
.zoom-flash {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle, var(--accent-dim), #000 70%);
  opacity: var(--zf, 0);
}

/* ---------- about ---------- */
.about { padding: 25vh clamp(1rem, 6vw, 6rem) 5vh; max-width: 1200px; }
.about-text {
  margin-top: 1.5rem;
  font-size: clamp(1.4rem, 3.4vw, 2.6rem); font-weight: 600; letter-spacing: -0.02em; line-height: 1.25;
  color: #8a8a8a;
}
.about-text .hl { color: var(--fg); }
.about-text .fn { color: var(--accent); font-size: .6em; vertical-align: super; line-height: 0; }
.about-note { margin-top: 1rem; font-size: .75rem; color: var(--dim); }
.about-grid {
  display: grid; gap: 2.5rem; margin-top: 4rem;
  grid-template-columns: repeat(2, 1fr);
}
@media (max-width: 720px) { .about-grid { grid-template-columns: 1fr; } }
.about-h { color: var(--accent); font-size: .8rem; letter-spacing: .15em; text-transform: uppercase; margin-bottom: 1rem; }
.about-grid ul { list-style: none; display: flex; flex-direction: column; gap: 1rem; }
.about-grid li { font-size: .9rem; color: #9a9a9a; line-height: 1.5; padding-left: 1rem; border-left: 1px solid var(--line); }
.about-grid li b { color: var(--fg); font-weight: 600; }
.about-grid li span { display: block; color: var(--dim); font-size: .8rem; }
.about-grid li a { border-bottom: 1px solid var(--accent-dim); transition: color .2s, border-color .2s; }
.about-grid li a:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- projects ---------- */
.projects { padding-top: 15vh; }
.section-head { padding: 0 clamp(1rem, 6vw, 6rem); margin-bottom: 10vh; }
.section-head h2, .stack h2 {
  font-size: clamp(2.2rem, 7vw, 5.5rem); font-weight: 800; letter-spacing: -0.03em; margin-top: 1rem;
}

.proj { height: 220vh; position: relative; }
.proj-sticky {
  position: sticky; top: 0; height: 100svh;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.proj-panel {
  --p: 0;
  position: relative;
  width: 100vw; height: 100svh;
  transform: scale(calc(0.55 + 0.45 * var(--p)));
  border-radius: calc(40px * (1 - var(--p)));
  border: 1px solid rgba(0,255,156, calc(0.35 * (1 - var(--p))));
  background:
    radial-gradient(ellipse at 70% 30%, var(--glow, rgba(0,255,156,.12)), transparent 60%),
    linear-gradient(160deg, #0b0b0b, #000 70%);
  overflow: hidden;
  will-change: transform;
}
.proj-bg {
  position: absolute; inset: 0;
  font-family: var(--mono); font-size: 0.75rem; line-height: 1.4;
  color: rgba(255,255,255,0.05); white-space: pre; overflow: hidden;
  transform: scale(calc(1.5 - 0.5 * var(--p)));
}
.proj-index {
  position: absolute; right: clamp(1rem, 5vw, 4rem); bottom: -0.15em;
  font-size: clamp(8rem, 30vw, 26rem); font-weight: 900; line-height: 1;
  color: transparent; -webkit-text-stroke: 1px rgba(255,255,255,0.08);
  transform: translateY(calc(30% * (1 - var(--p))));
}
.proj-content {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: center;
  padding: 0 clamp(1.25rem, 8vw, 8rem);
  max-width: 1100px;
  opacity: var(--c, 0);
  transform: translateY(calc(40px * (1 - var(--c, 0))));
}
.proj-tag { color: var(--accent); font-size: .8rem; letter-spacing: .15em; text-transform: uppercase; }
.proj-title {
  font-size: clamp(2.5rem, 9vw, 7rem); font-weight: 900; letter-spacing: -0.04em; line-height: 0.95;
  margin: 1rem 0 1.5rem;
}
.proj-desc { font-size: clamp(1rem, 2.2vw, 1.35rem); color: #b5b5b5; max-width: 40ch; line-height: 1.5; }
.proj-stack { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 2rem; }
.proj-stack span {
  font-family: var(--mono); font-size: .75rem; padding: .35rem .7rem;
  border: 1px solid var(--line); border-radius: 999px; color: var(--dim);
}
.proj-links { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 2rem; }
.btn {
  font-family: var(--mono); font-size: .85rem;
  padding: .8rem 1.3rem; border: 1px solid var(--accent); color: var(--accent);
  border-radius: 999px; transition: background .2s, color .2s;
}
.btn:hover { background: var(--accent); color: #000; }
.btn.ghost { border-color: #333; color: var(--fg); }
.btn.ghost:hover { border-color: var(--fg); background: var(--fg); }

/* ---------- archive grid ---------- */
.archive { padding-top: 25vh; }
.archive-grid {
  display: grid; gap: 1px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  margin: 0 clamp(1rem, 6vw, 6rem);
}
.repo {
  background: #000; padding: 1.75rem 1.5rem; min-height: 180px;
  box-shadow: 0 0 0 1px var(--line);
  display: flex; flex-direction: column; gap: .75rem;
  position: relative; overflow: hidden;
}
.repo::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), var(--accent-dim), transparent 60%);
  opacity: 0; transition: opacity .3s;
}
.repo:hover::after { opacity: 1; }
.repo-name { font-size: .95rem; color: var(--fg); word-break: break-word; }
.repo-name::before { content: "~/"; color: var(--accent); }
.repo:hover .repo-name { color: var(--accent); }
.repo-desc { font-size: .9rem; color: #9a9a9a; line-height: 1.5; flex: 1; }
.repo-lang { font-size: .7rem; color: var(--dim); text-transform: uppercase; letter-spacing: .1em; }
.archive-more { text-align: center; margin-top: 3rem; }

/* ---------- competitions ---------- */
.comps { padding-top: 25vh; }
.wins {
  display: grid; gap: 1px; margin: 0 clamp(1rem, 6vw, 6rem);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}
.win {
  display: flex; flex-direction: column; gap: .6rem; padding: 2rem 1.5rem; min-height: 260px;
  background: #000; box-shadow: 0 0 0 1px var(--line); position: relative; overflow: hidden;
}
.win::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: radial-gradient(circle at 20% 0%, var(--accent-dim), transparent 60%);
}
a.win:hover::before { opacity: 1; }
.win-rank {
  font-size: clamp(2.6rem, 6vw, 4rem); font-weight: 900; letter-spacing: -0.04em; line-height: 1;
  color: var(--accent);
}
.win-event { font-weight: 600; font-size: 1.1rem; line-height: 1.3; }
.win-meta { font-size: .75rem; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; }
.win-desc { font-size: .9rem; color: #9a9a9a; line-height: 1.5; }
a.win .win-event::after { content: " ↗"; color: var(--dim); }

.ctfs { margin: 5rem clamp(1rem, 6vw, 6rem) 0; }
.ctfs-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 1rem; margin-bottom: 1rem; }
.proof {
  font-size: .8rem; color: var(--accent); border: 1px solid var(--accent); border-radius: 999px;
  padding: .4rem .9rem; transition: background .2s, color .2s;
}
.proof:hover { background: var(--accent); color: #000; }
.ctf-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); column-gap: 3rem; }
.ctf-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  padding: .9rem 0; border-bottom: 1px solid var(--line); transition: padding .2s;
}
.ctf-row:hover { padding-left: .5rem; }
.ctf-event { color: #c8c8c8; }
.ctf-place { color: var(--fg); white-space: nowrap; }
.ctf-row.top .ctf-place { color: var(--accent); }
.ctf-row.top .ctf-place .dim { color: rgba(0,255,156,.5); }
.ctf-note { margin-top: 1.5rem; font-size: .8rem; }

/* ---------- stack marquee ---------- */
.stack { padding: 20vh 0 15vh; }
.stack .label { padding: 0 clamp(1rem, 6vw, 6rem); margin-bottom: 3rem; }
.marquee { overflow: hidden; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 1.5rem 0; }
.marquee-track {
  display: flex; gap: 3rem; width: max-content;
  font-size: clamp(1.25rem, 4vw, 2.5rem); color: var(--dim);
  animation: marquee 40s linear infinite;
}
.marquee-track span::before { content: "▸ "; color: var(--accent); }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------- contact ---------- */
.contact { min-height: 100svh; display: flex; align-items: center; justify-content: center; padding: 10vh 1rem; text-align: center; }
.contact-zoom {
  transform: scale(var(--cs, 0.6)); opacity: var(--co, 0);
  will-change: transform;
}
.contact-title { font-size: clamp(3rem, 13vw, 11rem); font-weight: 900; letter-spacing: -0.05em; line-height: 1; margin: 1rem 0 3rem; }
.contact-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; }

/* ---------- reveal ---------- */
.reveal { opacity: 0; transform: translateY(40px) scale(.96); transition: opacity 1s cubic-bezier(.2,.8,.2,1), transform 1s cubic-bezier(.2,.8,.2,1); }
.reveal.in { opacity: 1; transform: none; }

/* ---------- footer ---------- */
.footer {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 1rem;
  padding: 2rem clamp(1rem, 4vw, 3rem); font-size: .75rem; color: var(--dim);
  border-top: 1px solid var(--line);
}
#hash { word-break: break-all; }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .zoom { height: auto; }
  .zoom-sticky { position: relative; height: 70vh; }
  .proj { height: auto; }
  .proj-sticky { position: relative; height: auto; min-height: 100svh; }
  .proj-panel { --p: 1 !important; height: auto; min-height: 100svh; }
  .proj-content { position: relative; min-height: 100svh; opacity: 1; transform: none; }
  .hero-name, .hero-sub, .reveal { opacity: 1; transform: none; filter: none; }
  .contact-zoom { transform: none; opacity: 1; }
  #rain { display: none; }
}
