:root {
  --bg: #0a0a0b;
  --surface: #111113;
  --border: #1e1e22;
  --text: #e8e6e3;
  --text-muted: #8a8a96;
  --accent: #22d3ee;
  --accent-dim: #0e7490;
  --accent-glow: rgba(34, 211, 238, 0.15);
  --green: #4ade80;
  --orange: #fb923c;
  --purple: #a78bfa;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-x: hidden;
  position: relative;
}

/* Faint grid under the network canvas */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 60px 60px;
  opacity: 0.3;
  pointer-events: none;
}

/* Glow orb */
body::after {
  content: '';
  position: fixed;
  top: -200px;
  right: -200px;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
  animation: orbFloat 8s ease-in-out infinite;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-80px, 60px); }
}

/* Scrolling code background */
#net {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Scroll progress bar */
.progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  z-index: 10;
  background: linear-gradient(90deg, var(--green), var(--accent), var(--purple));
  transform-origin: 0 50%;
  transform: scaleX(0);
  box-shadow: 0 0 12px var(--accent);
}

.container {
  position: relative;
  z-index: 1;
  max-width: 800px;
  width: 100%;
  padding: 4rem 2rem 2rem;
  animation: fadeUp 1s ease-out;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Terminal prompt */
.terminal-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
  animation: fadeUp 1s ease-out 0.2s both;
}

.terminal-badge .cursor {
  display: inline-block;
  width: 8px;
  height: 16px;
  background: var(--accent);
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.terminal-badge .prompt { color: var(--green); }

h1 {
  font-size: clamp(3rem, 8vw, 5.5rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin-bottom: 1.5rem;
  animation: fadeUp 1s ease-out 0.3s both;
}

h1 .highlight {
  background: linear-gradient(120deg, var(--accent), var(--purple), var(--green), var(--accent));
  background-size: 300% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 10s linear infinite;
}

@keyframes shimmer {
  to { background-position: 300% 0; }
}

.subtitle {
  font-size: 1.2rem;
  font-weight: 300;
  color: var(--text-muted);
  line-height: 1.7;
  max-width: 520px;
  margin-bottom: 2.5rem;
  animation: fadeUp 1s ease-out 0.5s both;
}

.subtitle strong {
  color: var(--text);
  font-weight: 600;
}

/* Hero terminal window */
.term {
  background: rgba(17, 17, 19, 0.85);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 2.5rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(34, 211, 238, 0.04);
  animation: fadeUp 1s ease-out 0.55s both;
}

.term-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.term-bar i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
}

.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 {
  min-height: 11.5rem;
  padding: 14px 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}

.term-body .ps { color: var(--green); }
.term-body .ok { color: var(--green); }
.term-body .dim { color: var(--text-muted); }
.term-body .hl { color: var(--accent); }

.term-body .caret {
  display: inline-block;
  width: 8px;
  height: 1em;
  vertical-align: text-bottom;
  background: var(--accent);
  animation: blink 1s step-end infinite;
}

/* Topic pills */
.topics {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 2.5rem;
  animation: fadeUp 1s ease-out 0.6s both;
}

.pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  padding: 6px 14px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  transition: all 0.3s ease;
}

.pill:hover {
  border-color: var(--accent-dim);
  color: var(--accent);
  background: var(--accent-glow);
  transform: translateY(-2px);
}

/* Links */
.links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  animation: fadeUp 1s ease-out 0.7s both;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 8px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.3s ease;
}

.link-btn.primary {
  background: var(--accent);
  color: var(--bg);
}

.link-btn.primary:hover {
  background: #06b6d4;
  box-shadow: 0 0 30px var(--accent-glow);
  transform: translateY(-2px);
}

.link-btn.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.link-btn.secondary:hover {
  border-color: var(--text-muted);
  transform: translateY(-2px);
}

.link-btn svg {
  width: 18px;
  height: 18px;
}

/* Section headings */
.section-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 4.5rem 0 1.25rem;
}

.section-title::before {
  content: '$ ';
  color: var(--green);
}

/* Projects */
.project {
  --mx: 50%;
  --my: 0%;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  overflow: hidden;
  transition: border-color 0.3s ease, transform 0.3s ease;
}

/* Cursor-following spotlight */
.project::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(360px circle at var(--mx) var(--my), var(--accent-glow), transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.project:hover {
  border-color: var(--accent-dim);
  transform: translateY(-2px);
}

.project:hover::before { opacity: 1; }

.project > * { position: relative; }

.project h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.project p {
  color: var(--text-muted);
  font-weight: 300;
  line-height: 1.7;
  margin-bottom: 1rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 1rem;
}

.tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  padding: 3px 10px;
  border-radius: 100px;
  background: var(--accent-glow);
  color: var(--accent);
}

.project-link {
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}

.project-link:hover { text-decoration: underline; }

/* Scroll reveal, only armed when JS is running */
.js .reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.js .reveal.in {
  opacity: 1;
  transform: none;
}

/* Status bar */
.status {
  position: relative;
  width: 100%;
  margin-top: 3rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  padding: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-muted);
  background: linear-gradient(transparent, var(--bg));
  gap: 8px 24px;
  z-index: 2;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s ease-in-out infinite;
}

.status-dot.building { background: var(--orange); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@media (max-width: 600px) {
  .container { padding: 1.5rem; }
  .links { flex-direction: column; }
  .link-btn { justify-content: center; }
  .term-body { font-size: 0.74rem; }
  .status { flex-direction: column; align-items: center; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}

/* ---------- Project pages ---------- */
.crumb {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 16px;
  margin-bottom: 2.5rem;
  transition: border-color 0.3s ease, color 0.3s ease;
  animation: fadeUp 1s ease-out 0.2s both;
}

.crumb:hover { border-color: var(--accent-dim); color: var(--accent); }
.crumb .prompt { color: var(--green); }

h1.page-title {
  font-size: clamp(2.2rem, 6vw, 3.6rem);
  line-height: 1.1;
  margin-bottom: 1.25rem;
}

.lead {
  font-size: 1.15rem;
  font-weight: 300;
  color: var(--text-muted);
  line-height: 1.75;
  margin-bottom: 1.5rem;
  animation: fadeUp 1s ease-out 0.5s both;
}

.page .tags { animation: fadeUp 1s ease-out 0.55s both; margin-bottom: 1.75rem; }
.page .links { margin-bottom: 1rem; }

.page h2.section-title { margin-top: 3.5rem; }

.page p.body {
  color: var(--text-muted);
  font-weight: 300;
  line-height: 1.8;
  margin-bottom: 1rem;
  max-width: 640px;
}

.page p.body strong { color: var(--text); font-weight: 600; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-bottom: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem 1.2rem;
  transition: border-color 0.3s ease, transform 0.3s ease;
}

.card:hover { border-color: var(--accent-dim); transform: translateY(-2px); }

.card h3 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.card p {
  color: var(--text-muted);
  font-weight: 300;
  font-size: 0.92rem;
  line-height: 1.65;
}

.card code, .page code.inline {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82em;
  color: var(--text);
}

.steps {
  list-style: none;
  counter-reset: step;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 1rem;
}

.steps li {
  counter-increment: step;
  display: flex;
  gap: 14px;
  align-items: baseline;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  font-weight: 300;
  line-height: 1.6;
}

.steps li::before {
  content: counter(step);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--green);
  flex: none;
}

.steps li strong { color: var(--text); font-weight: 600; }

.code {
  background: rgba(17, 17, 19, 0.9);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 1rem;
  overflow-x: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  line-height: 1.7;
  color: var(--text);
}

.code .c { color: var(--text-muted); }
.code .k { color: var(--purple); }
.code .s { color: var(--green); }

.table-wrap { overflow-x: auto; margin-bottom: 1rem; }

table.spec {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.spec th, table.spec td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 300;
  color: var(--text-muted);
  vertical-align: top;
}

table.spec th {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

table.spec td:first-child {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--text);
  white-space: nowrap;
}

.back-row { margin-top: 4rem; }

/* Home project cards are links */
a.project {
  display: block;
  color: inherit;
  text-decoration: none;
}

a.project .project-link { display: inline-block; transition: transform 0.3s ease; }
a.project:hover .project-link { transform: translateX(4px); }
a.project:focus-visible, .crumb:focus-visible, .link-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ---------- Home sections ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.section-lead {
  color: var(--text-muted);
  font-weight: 300;
  line-height: 1.7;
  margin: -0.5rem 0 1.25rem;
  max-width: 520px;
}

.soon {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.soon-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
  animation: pulse 1.4s ease-in-out infinite;
}

/* ---------- 3D rover stage ---------- */
.stage-wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  display: flex;
  justify-content: center;
}

.stage {
  position: relative;
  width: 100%;
  max-width: 1100px;
  height: clamp(380px, 64vh, 580px);
  overflow: hidden;
}

.stage #rover-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 0.8s ease;
}

.stage.ready #rover-canvas { opacity: 1; }

.node-label {
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 8px;
  align-items: center;
  padding: 7px 12px;
  background: rgba(17, 17, 19, 0.88);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  will-change: transform;
  transition: border-color 0.3s ease, opacity 0.3s ease;
  --c: var(--accent);
}

.node-label.green { --c: var(--green); }
.node-label.purple { --c: var(--purple); }

.node-label .dot {
  grid-row: 1 / 3;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 10px var(--c);
}

.node-label .name { font-size: 0.8rem; font-weight: 500; }
.node-label .sub { font-size: 0.66rem; color: var(--text-muted); }
.node-label:hover, .node-label.active { border-color: var(--c); }
.node-label:focus-visible { outline: 2px solid var(--c); outline-offset: 3px; }

/* Labels stay hidden until the scene is ready, and when 3D is missing */
.stage:not(.ready) .node-label { opacity: 0; pointer-events: none; }

.stage-msg {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
}

.stage.nogl .stage-msg { display: flex; }
.stage.nogl .node-label { display: none; }

.lab-main {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Soft dark backdrop so the scene reads over the code background */
.stage::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(10, 10, 11, 0.88) 0%, rgba(10, 10, 11, 0.7) 50%, transparent 78%);
  pointer-events: none;
}

.stage-hint {
  text-align: center;
  margin-top: 0.25rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
}

@media (max-width: 600px) {
  .stage { height: clamp(380px, 56vh, 480px); }
  .node-label { padding: 5px 9px; column-gap: 6px; }
  .node-label .name { font-size: 0.7rem; }
  .node-label .sub { font-size: 0.58rem; }
}
