/* ==========================================================================
   Tokens
   ========================================================================== */
:root {
  --bg: #0a0e13;
  --bg-2: #0d1218;
  --panel: #111821;
  --panel-2: #151e29;
  --border: #1f2b38;
  --fg: #d7e0ea;
  --fg-strong: #f2f6fa;
  --muted: #7f8e9e;
  --grid: #1a2430;
  --accent: #3ddc97;   /* terminal green  */
  --accent2: #5ab0ff;  /* blue            */
  --accent3: #f5b041;  /* amber           */
  --accent4: #ff6b8b;  /* pink / laser    */
  --accent5: #b48cff;  /* violet          */
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --radius: 10px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f6f8fa;
  --bg-2: #eef1f5;
  --panel: #ffffff;
  --panel-2: #f3f5f8;
  --border: #d5dbe3;
  --fg: #24292f;
  --fg-strong: #0d1117;
  --muted: #5d6875;
  --grid: #e3e8ee;
  --accent: #0f9d63;
  --accent2: #1f6fd1;
  --accent3: #b7740a;
  --accent4: #d6335a;
  --accent5: #7a4fd6;
  --shadow: 0 10px 30px rgba(20, 30, 50, .08);
  color-scheme: light;
}

/* ==========================================================================
   Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body::before { /* faint engineering grid */
  content: "";
  position: fixed; inset: 0;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 70%);
  opacity: .55;
  pointer-events: none;
  z-index: -1;
}
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); }
h1, h2, h3 { color: var(--fg-strong); line-height: 1.2; margin: 0; }
p { margin: 0 0 .8em; }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }

.wrap { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 28px; } }

/* ==========================================================================
   Nav
   ========================================================================== */
.nav {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--border);
}
.nav .wrap { display: flex; align-items: center; gap: 16px; height: 58px; }
.logo { font-family: var(--mono); font-weight: 600; color: var(--fg-strong); white-space: nowrap; }
.logo span { color: var(--accent); }
.logo:hover { text-decoration: none; }
.nav-links { display: none; gap: 4px; margin-left: auto; font-family: var(--mono); font-size: 13px; }
.nav-links a { color: var(--muted); padding: 6px 10px; border-radius: 6px; }
.nav-links a:hover { color: var(--fg-strong); background: var(--panel); text-decoration: none; }
.nav-links a::before { content: "./"; color: var(--accent); opacity: .7; }
@media (min-width: 900px) { .nav-links { display: flex; } }
.icon-btn {
  margin-left: auto;
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--panel); color: var(--fg);
  border: 1px solid var(--border); cursor: pointer;
}
@media (min-width: 900px) { .icon-btn { margin-left: 8px; } }
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn svg { width: 18px; height: 18px; }

/* ==========================================================================
   Hero
   ========================================================================== */
.hero { padding: 48px 0 32px; }
.hero .wrap { display: grid; gap: 28px; align-items: center; }
@media (min-width: 960px) {
  .hero { padding: 72px 0 48px; }
  .hero .wrap { grid-template-columns: 1.05fr .95fr; gap: 40px; }
}
.eyebrow {
  font-family: var(--mono); font-size: 13px; color: var(--accent);
  display: inline-flex; align-items: center; gap: 8px; margin-bottom: 14px;
}
.eyebrow .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px transparent; } }
.hero h1 { font-size: clamp(34px, 6vw, 58px); letter-spacing: -.02em; }
.hero h1 .grad {
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero .role { font-family: var(--mono); color: var(--muted); font-size: clamp(14px, 2vw, 17px); margin: 12px 0 20px; }
.hero .lede { font-size: 17px; max-width: 58ch; }

.terminal {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; margin: 22px 0;
  font-family: var(--mono); font-size: 13px;
}
.term-bar {
  display: flex; align-items: center; gap: 6px; padding: 9px 12px;
  background: var(--panel-2); border-bottom: 1px solid var(--border);
  color: var(--muted); font-size: 12px;
}
.term-bar i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.term-bar i:nth-child(1) { background: #ff5f57; }
.term-bar i:nth-child(2) { background: #febc2e; }
.term-bar i:nth-child(3) { background: #28c840; }
.term-bar span { margin-left: 8px; }
.term-body { padding: 14px 16px; min-height: 250px; white-space: pre-wrap; word-break: break-word; line-height: 1.7; }
.term-body .p { color: var(--accent); }
.term-body .c { color: var(--fg-strong); }
.term-body .o { color: var(--muted); }
.term-body .k { color: var(--accent2); }
.caret { display: inline-block; width: 8px; height: 1.05em; background: var(--accent); vertical-align: -2px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.btns { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 13px; font-weight: 500;
  padding: 10px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel); color: var(--fg-strong); cursor: pointer;
}
.btn:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); color: #04140c; border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); color: #04140c; }
.btn svg { width: 16px; height: 16px; }

.hero-viz {
  position: relative; aspect-ratio: 1 / 1; max-height: 520px; width: 100%;
  border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
  background: radial-gradient(circle at 50% 45%, var(--panel-2), var(--bg-2));
}
.hero-viz canvas { width: 100%; height: 100%; display: block; cursor: grab; }
.hero-viz canvas:active { cursor: grabbing; }
.hud {
  position: absolute; font-family: var(--mono); font-size: 11px; color: var(--muted);
  pointer-events: none; line-height: 1.5;
}
.hud.tl { top: 12px; left: 14px; }
.hud.br { bottom: 12px; right: 14px; text-align: right; }
.hud b { color: var(--accent); font-weight: 500; }

/* ==========================================================================
   Stats
   ========================================================================== */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-top: 8px; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(5, 1fr); } }
.stat { background: var(--panel); padding: 18px 16px; }
.stat .n { font-family: var(--mono); font-size: 26px; font-weight: 600; color: var(--fg-strong); }
.stat .n small { font-size: 15px; color: var(--accent); }
.stat .l { font-size: 13px; color: var(--muted); }
.stats .stat:last-child { grid-column: 1 / -1; }
@media (min-width: 720px) { .stats .stat:last-child { grid-column: auto; } }

/* ==========================================================================
   Sections
   ========================================================================== */
section { padding: 56px 0; }
@media (min-width: 960px) { section { padding: 80px 0; } }
.sec-head { margin-bottom: 28px; }
.sec-head .tag { font-family: var(--mono); color: var(--accent); font-size: 13px; }
.sec-head h2 { font-size: clamp(26px, 4vw, 36px); margin-top: 6px; letter-spacing: -.01em; }
.sec-head p { color: var(--muted); max-width: 70ch; margin-top: 10px; }

/* Pipeline */
.pipeline { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; position: relative; }
@media (min-width: 640px) { .pipeline { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1000px) { .pipeline { grid-template-columns: repeat(6, 1fr); } }
.stage {
  position: relative; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 14px 14px; overflow: hidden;
}
.stage::after { /* flowing packet */
  content: ""; position: absolute; left: 0; top: 0; height: 2px; width: 40%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: flow 3.6s linear infinite; animation-delay: calc(var(--i) * .6s);
}
@keyframes flow { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
.stage .idx { font-family: var(--mono); font-size: 12px; color: var(--accent); }
.stage h3 { font-size: 16px; margin: 4px 0 6px; font-family: var(--mono); }
.stage p { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  font-family: var(--mono); font-size: 11px; padding: 2px 7px; border-radius: 5px;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--fg);
}

/* ==========================================================================
   Projects
   ========================================================================== */
.projects { display: grid; gap: 28px; grid-template-columns: minmax(0, 1fr); }
.proj-info { min-width: 0; }
.project {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  overflow: hidden; box-shadow: var(--shadow);
  display: grid; grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 960px) {
  .project { grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); }
  .project.flip { grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); }
  .project.flip .proj-info { order: 2; }
}
.tabbar {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 0; background: var(--panel-2);
  border-bottom: 1px solid var(--border); font-family: var(--mono); font-size: 12px; overflow-x: auto;
}
.tabbar .tab { padding: 9px 14px; color: var(--muted); border-right: 1px solid var(--border); white-space: nowrap; }
.tabbar .tab.on { color: var(--fg-strong); background: var(--panel); box-shadow: inset 0 2px 0 var(--accent); }
.tabbar .where { margin-left: auto; padding: 0 14px; color: var(--muted); white-space: nowrap; }
.proj-info { padding: 22px 20px; }
@media (min-width: 720px) { .proj-info { padding: 28px; } }
.proj-info .kicker { font-family: var(--mono); font-size: 12px; color: var(--accent2); }
.proj-info h3 { font-size: 23px; margin: 6px 0 10px; }
.proj-info ul { padding: 0; margin: 12px 0 16px; list-style: none; }
.proj-info li { position: relative; padding-left: 20px; margin-bottom: 8px; font-size: 14.5px; }
.proj-info li::before { content: "▹"; position: absolute; left: 0; color: var(--accent); }
.proj-info b { color: var(--fg-strong); font-weight: 600; }
.metric {
  display: inline-flex; align-items: baseline; gap: 8px; font-family: var(--mono);
  border: 1px dashed var(--border); border-radius: 8px; padding: 6px 10px; margin: 2px 0 14px;
}
.metric .v { font-size: 20px; color: var(--accent); font-weight: 600; }
.metric .t { font-size: 12px; color: var(--muted); }

.viz {
  position: relative; background: var(--bg-2); border-top: 1px solid var(--border);
  display: flex; flex-direction: column; min-width: 0;
}
@media (min-width: 960px) { .viz { border-top: 0; border-left: 1px solid var(--border); } .project.flip .viz { border-left: 0; border-right: 1px solid var(--border); } }
.viz canvas { width: 100%; height: 340px; display: block; touch-action: none; }
@media (min-width: 960px) { .viz canvas { height: 100%; min-height: 380px; flex: 1; } }
.viz-ctrl {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  padding: 10px 14px; border-top: 1px solid var(--border); background: var(--panel-2);
  font-family: var(--mono); font-size: 12px; color: var(--muted);
}
.viz-ctrl button {
  font: inherit; color: var(--fg); background: var(--panel); border: 1px solid var(--border);
  padding: 5px 10px; border-radius: 6px; cursor: pointer;
}
.viz-ctrl button:hover { border-color: var(--accent); color: var(--accent); }
.viz-ctrl button.on { background: color-mix(in srgb, var(--accent) 16%, var(--panel)); border-color: var(--accent); color: var(--accent); }
.viz-ctrl label { display: inline-flex; align-items: center; gap: 8px; }
.viz-ctrl input[type=range] { width: 110px; accent-color: var(--accent); }
.viz-ctrl .out { color: var(--fg-strong); min-width: 3.5ch; display: inline-block; }
.viz-ctrl .note { margin-left: auto; opacity: .75; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; }
.seg button + button { border-left: 1px solid var(--border); }

/* ==========================================================================
   Experience (git log)
   ========================================================================== */
.log { position: relative; display: grid; gap: 18px; }
.log::before { content: ""; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 2px; background: linear-gradient(var(--accent), var(--accent2), var(--accent5)); opacity: .5; border-radius: 2px; }
.commit { position: relative; padding-left: 34px; }
.commit::before {
  content: ""; position: absolute; left: 0; top: 20px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--accent);
}
.commit:nth-child(2)::before { border-color: var(--accent2); }
.commit:nth-child(3)::before { border-color: var(--accent5); }
.commit-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.commit-meta { font-family: var(--mono); font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 14px; }
.commit-meta .hash { color: var(--accent3); }
.commit-meta .ref { color: var(--accent); }
.commit h3 { font-size: 19px; margin: 8px 0 2px; }
.commit .co { color: var(--accent2); }
.commit p { color: var(--fg); font-size: 14.5px; margin-top: 8px; }
.commit details { margin-top: 6px; }
.commit summary { cursor: pointer; font-family: var(--mono); font-size: 12px; color: var(--muted); list-style: none; }
.commit summary::-webkit-details-marker { display: none; }
.commit summary::before { content: "+ "; color: var(--accent); }
.commit details[open] summary::before { content: "− "; }
.commit details ul { margin: 10px 0 4px; padding-left: 18px; font-size: 14px; }
.commit details li { margin-bottom: 6px; }
.commit .chips { margin-top: 12px; }

/* ==========================================================================
   Skills (yaml)
   ========================================================================== */
.two-col { display: grid; gap: 24px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 960px) { .two-col { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.code {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; font-family: var(--mono); font-size: 13px;
}
.code pre { margin: 0; padding: 16px 0; overflow-x: auto; line-height: 1.75; counter-reset: ln; white-space: normal; }
.code pre span.l { display: block; padding: 0 16px 0 0; white-space: pre; }
.code pre span.l::before {
  counter-increment: ln; content: counter(ln); display: inline-block; width: 3ch; margin-right: 14px;
  text-align: right; color: var(--muted); opacity: .5;
}
.y-k { color: var(--accent2); }
.y-s { color: var(--accent); }
.y-c { color: var(--muted); font-style: italic; }
.y-p { color: var(--muted); }
.y-n { color: var(--accent3); }

/* Bars */
.bars { display: grid; gap: 14px; padding: 18px 20px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr; gap: 12px; align-items: center; font-family: var(--mono); font-size: 12.5px; }
.bar-row .track { height: 8px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 5px; overflow: hidden; }
.bar-row .fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 5px; transition: width 1.2s cubic-bezier(.2,.7,.2,1); }
.in .bar-row .fill { width: var(--w); }

/* ==========================================================================
   Research
   ========================================================================== */
.papers { display: grid; gap: 12px; }
.paper {
  display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: start;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
}
.paper .yr { font-family: var(--mono); font-size: 12px; color: var(--accent3); padding-top: 2px; min-width: 4ch; }
.paper .ttl { color: var(--fg-strong); font-weight: 600; }
.paper .au { font-size: 13.5px; color: var(--muted); }
.paper .au b { color: var(--fg); font-weight: 600; }
.paper .ven { font-family: var(--mono); font-size: 12px; color: var(--accent2); }
.paper.patent { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }

.edu { display: grid; gap: 12px; margin-top: 28px; }
@media (min-width: 720px) { .edu { grid-template-columns: 1fr 1fr; } }
.edu-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.edu-card .deg { font-family: var(--mono); font-size: 12px; color: var(--accent); }
.edu-card h3 { font-size: 17px; margin: 4px 0; }
.edu-card .m { font-size: 13px; color: var(--muted); }

/* ==========================================================================
   Contact / footer
   ========================================================================== */
.contact-term .term-body { min-height: 0; }
.contact-term a { color: var(--accent2); }
footer { border-top: 1px solid var(--border); padding: 28px 0 40px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
footer .wrap { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; }

/* Reveal */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .7s ease, transform .7s ease; }
.reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .stage::after, .caret, .eyebrow .dot { animation: none; }
  .bar-row .fill { transition: none; }
}
