/* ===== Design tokens ===== */
:root {
  --bg-void: #05070d;
  --bg-deep: #0a0f1a;
  --bg-panel: #0d1420;
  --bg-panel-alt: #0f1826;
  --line: #1c2b40;
  --line-bright: #2c4a68;
  --blue-dim: #2a4a70;
  --blue: #3a7bd5;
  --blue-bright: #5fa8ff;
  --cyan: #4fd1e5;
  --text-primary: #e6edf5;
  --text-secondary: #92a3b8;
  --text-dim: #56667a;
  --font-display: 'Space Grotesk', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius: 10px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Reset ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
/* No scroll-behavior:smooth — it fights the JS-driven scroll-linked camera in the
   3D journey (two independent easing curves racing each other reads as jank). */
body {
  background: var(--bg-void);
  color: var(--text-primary);
  font-family: var(--font-display);
  line-height: 1.6;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
img { max-width: 100%; display: block; }

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

/* ===== Background layers ===== */
.bg-grid {
  position: fixed;
  inset: 0;
  z-index: -3;
  background-image:
    linear-gradient(rgba(58, 123, 213, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(58, 123, 213, 0.06) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 20%, black 40%, transparent 90%);
}
.bg-glow {
  position: fixed;
  top: 0; left: 0;
  width: 600px; height: 600px;
  z-index: -2;
  background: radial-gradient(circle, rgba(58, 123, 213, 0.15), transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: opacity 0.4s ease;
  will-change: transform;
}
#node-canvas {
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.5;
}
#journey-canvas {
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}
#journey-canvas.is-visible {
  opacity: 1;
}

/* ===== Boot screen ===== */
#boot-screen {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: var(--bg-void);
  color: var(--cyan);
  font-family: var(--font-mono);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}
#boot-screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
#boot-log {
  font-size: 0.85rem;
  white-space: pre-wrap;
  max-width: 560px;
  width: 100%;
  min-height: 200px;
}
.boot-bar {
  width: 100%;
  max-width: 560px;
  height: 3px;
  background: var(--line);
  margin-top: 1.5rem;
  overflow: hidden;
}
.boot-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
  transition: width 0.15s linear;
}

/* ===== Header / Nav ===== */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem clamp(1.5rem, 5vw, 4rem);
  backdrop-filter: blur(10px);
  background: rgba(5, 7, 13, 0.6);
  border-bottom: 1px solid var(--line);
}
.logo {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: 0.05em;
}
.logo span { color: var(--blue-bright); }
.site-nav { display: flex; gap: 2rem; }
.site-nav a {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-secondary);
  position: relative;
  transition: color var(--transition);
}
.site-nav a::after {
  content: '';
  position: absolute;
  left: 0; bottom: -6px;
  width: 0; height: 1px;
  background: var(--blue-bright);
  transition: width var(--transition);
}
.site-nav a:hover { color: var(--text-primary); }
.site-nav a:hover::after { width: 100%; }

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}
.nav-toggle span {
  width: 22px; height: 2px;
  background: var(--text-primary);
  transition: transform var(--transition), opacity var(--transition);
}

@media (max-width: 800px) {
  .site-nav {
    position: fixed;
    top: 64px; right: 0;
    flex-direction: column;
    background: var(--bg-panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.5rem 2rem;
    gap: 1.25rem;
    transform: translateX(120%);
    transition: transform var(--transition);
  }
  .site-nav.open { transform: translateX(-1rem); }
  .nav-toggle { display: flex; }
}

/* ===== Side rail ===== */
.side-rail {
  position: fixed;
  right: clamp(1rem, 3vw, 2rem);
  top: 50%;
  transform: translateY(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1.05rem;
}
.side-rail a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 2px 0;
}
.side-rail-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--line-bright);
  background: transparent;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}
.side-rail-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  white-space: nowrap;
  opacity: 0;
  transform: translateX(6px);
  transition: opacity var(--transition), transform var(--transition);
}
.side-rail a:hover .side-rail-label,
.side-rail a.active .side-rail-label {
  opacity: 1;
  transform: translateX(0);
}
.side-rail a:hover .side-rail-dot,
.side-rail a.active .side-rail-dot {
  border-color: var(--blue-bright);
  background: var(--blue-bright);
  box-shadow: 0 0 8px rgba(95, 168, 255, 0.7);
}
.side-rail a.active .side-rail-dot {
  transform: scale(1.35);
}
@media (max-width: 900px) {
  .side-rail { display: none; }
}

/* ===== Hero ===== */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding: 7rem clamp(1.5rem, 5vw, 4rem) 3rem;
  position: relative;
}
.hero-inner {
  display: grid;
  grid-template-columns: 1fr;
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}
/* Solid panel, no backdrop-filter: blurring a full-viewport canvas that's
   animating every frame is expensive and was a major source of scroll jank. */
.journey-active .hero-text {
  background: rgba(8, 12, 22, 0.78);
  border-radius: var(--radius);
  padding: 2rem clamp(1.25rem, 4vw, 2.5rem);
  border: 1px solid var(--line);
}

.kicker {
  font-family: var(--font-mono);
  color: var(--cyan);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
}
.hero-text h1 {
  font-size: clamp(2.75rem, 6vw, 4.5rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
}
.accent {
  background: linear-gradient(120deg, var(--blue-bright), var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-sub {
  margin-top: 1.5rem;
  color: var(--text-secondary);
  font-size: 1.1rem;
  max-width: 46ch;
}
.hero-actions {
  display: flex;
  gap: 1rem;
  margin-top: 2.25rem;
  flex-wrap: wrap;
}
.btn {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.85rem 1.5rem;
  border-radius: 6px;
  transition: all var(--transition);
  border: 1px solid transparent;
}
.btn-primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 0 0 0 rgba(58, 123, 213, 0.5);
}
.btn-primary:hover {
  background: var(--blue-bright);
  box-shadow: 0 0 24px 2px rgba(95, 168, 255, 0.4);
}
.btn-ghost {
  border-color: var(--line);
  color: var(--text-primary);
}
.btn-ghost:hover { border-color: var(--blue-bright); color: var(--blue-bright); }

.hero-stats {
  display: flex;
  gap: 2.5rem;
  margin-top: 3rem;
}
.stat { display: flex; flex-direction: column; }
.stat-num {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  color: var(--blue-bright);
}
.stat-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.scroll-cue {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  width: 22px; height: 36px;
  border: 1px solid var(--line-bright);
  border-radius: 12px;
}
.scroll-cue span {
  display: block;
  width: 4px; height: 8px;
  background: var(--blue-bright);
  border-radius: 2px;
  margin: 6px auto 0;
  animation: scrollcue 1.8s infinite;
}
@keyframes scrollcue {
  0% { transform: translateY(0); opacity: 1; }
  70% { transform: translateY(14px); opacity: 0; }
  100% { opacity: 0; }
}

/* ===== Sections ===== */
.section { padding: 6rem clamp(1.5rem, 5vw, 4rem); position: relative; }
.section-alt { background: linear-gradient(180deg, transparent, rgba(10, 15, 26, 0.5), transparent); }
.section-inner { max-width: 1180px; margin: 0 auto; }
.section-title {
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  font-weight: 600;
  margin-bottom: 3rem;
  display: flex;
  align-items: baseline;
  gap: 1rem;
}
.section-num {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--blue-dim);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
}

/* ===== Reveal-on-scroll ===== */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.reveal.in-view { opacity: 1; transform: translateY(0); }

/* ===== About ===== */
.about-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 3rem;
  align-items: start;
}
@media (max-width: 800px) { .about-grid { grid-template-columns: 1fr; } }
.photo-placeholder {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg-panel);
}
.photo-scanline {
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  opacity: 0.6;
  animation: scanline 3.2s linear infinite;
}
@keyframes scanline {
  0% { top: 0%; }
  100% { top: 100%; }
}
.about-text p { color: var(--text-secondary); margin-bottom: 1.1rem; }
.highlight { color: var(--blue-bright); }
.about-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.5rem;
}
.about-tags span {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.35rem 0.7rem;
  color: var(--text-secondary);
}

/* ===== Timeline ===== */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before {
  content: '';
  position: absolute;
  left: 5px; top: 6px; bottom: 6px;
  width: 1px;
  background: linear-gradient(180deg, var(--blue-bright), var(--line) 90%);
}
.timeline-entry { position: relative; margin-bottom: 2.75rem; }
.timeline-entry:last-child { margin-bottom: 0; }
/* Each entry is a tall scroll "runway" (see journey.js) — its .timeline-content
   card is pinned dead-center on screen (position:fixed) for most of that runway,
   then scales up and fades as the next card takes over. journey.js drives the
   transform/opacity every frame; this just establishes the fixed/centered base. */
.journey-active .timeline-entry[data-chapter] {
  min-height: 180vh;
  /* .reveal.in-view sets transform:translateY(0) — any non-'none' transform,
     even a no-op one, turns this into a CSS containing block for fixed-position
     descendants, which would make the "pinned" card scroll with the page
     instead of the viewport. Force it off here. */
  transform: none !important;
}
.journey-active .timeline-content {
  position: fixed;
  top: 50%;
  width: min(480px, 42vw);
  z-index: 10;
  background: rgba(8, 12, 22, 0.78);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  border: 1px solid var(--line);
  will-change: transform, opacity;
  opacity: 0;
}
/* Off to one side, alternating per entry, so the 3D object reads as a distinct
   showcased thing on the other side of the screen rather than sitting behind
   the text. journey.js's translateY(-50%) scale(...) still does the vertical
   centering + zoom; `left` here just moves the anchor point off-center. */
.journey-active [data-chapter="exp-1"] .timeline-content,
.journey-active [data-chapter="exp-3"] .timeline-content {
  left: 27%;
}
.journey-active [data-chapter="exp-2"] .timeline-content,
.journey-active [data-chapter="exp-4"] .timeline-content {
  left: 73%;
}
.timeline-marker {
  position: absolute;
  left: -2rem; top: 6px;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--bg-void);
  border: 2px solid var(--blue-bright);
  box-shadow: 0 0 10px rgba(95, 168, 255, 0.6);
}
/* The dot-and-line timeline reads as a chronological list — that doesn't fit
   once each entry becomes a centered card that zooms through, so it's hidden
   in favor of the side rail for wayfinding. */
.journey-active .timeline::before,
.journey-active .timeline-marker {
  display: none;
}
.timeline-date {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--cyan);
  letter-spacing: 0.05em;
}
.timeline-content h3 {
  font-size: 1.25rem;
  margin: 0.4rem 0 0.6rem;
  font-weight: 600;
}
.timeline-org { color: var(--text-dim); font-weight: 400; font-size: 0.95rem; }
.timeline-content p { color: var(--text-secondary); max-width: 65ch; }
.timeline-tags { display: flex; gap: 0.5rem; margin-top: 0.75rem; flex-wrap: wrap; }
.timeline-tags span {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--blue-dim);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
}

/* ===== Projects ===== */
.project-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}
@media (max-width: 800px) { .project-grid { grid-template-columns: 1fr; } }
.project-card {
  position: relative;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2rem;
  overflow: hidden;
  transition: border-color var(--transition), transform var(--transition);
}
.project-card:hover {
  border-color: var(--blue-dim);
  transform: translateY(-4px);
}
.project-card-glow {
  position: absolute;
  top: -60%; right: -30%;
  width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(58, 123, 213, 0.18), transparent 70%);
  pointer-events: none;
}
.project-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.project-card h3 { margin: 0.6rem 0 0.75rem; font-size: 1.3rem; font-weight: 600; }
.project-card p { color: var(--text-secondary); margin-bottom: 1.25rem; }
.project-links { display: flex; gap: 1.25rem; }
.project-links a {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--blue-bright);
  transition: opacity var(--transition);
}
.project-links a:hover { opacity: 0.7; }

/* ===== Skills ===== */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2.5rem;
}
@media (max-width: 700px) { .skills-grid { grid-template-columns: 1fr; } }
.skill-group h3 {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1.25rem;
}
.skill-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.meter {
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
  transition: width 1.1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Publications ===== */
.pub-list { display: flex; flex-direction: column; gap: 1.5rem; }
.pub-item {
  display: grid;
  grid-template-columns: 70px 1fr auto;
  align-items: center;
  gap: 1.5rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--line);
}
@media (max-width: 700px) {
  .pub-item { grid-template-columns: 1fr; gap: 0.5rem; }
}
.pub-year {
  font-family: var(--font-mono);
  color: var(--blue-dim);
  font-size: 1.1rem;
}
.pub-item h3 { font-size: 1.05rem; font-weight: 600; }
.pub-item p { color: var(--text-secondary); font-size: 0.9rem; margin-top: 0.3rem; }
.pub-link {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--blue-bright);
}

/* ===== Contact / footer ===== */
.contact { text-align: left; }
.contact-lead { font-size: 1.3rem; color: var(--text-secondary); max-width: 40ch; }
.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 2rem;
  margin-top: 1.5rem;
  font-family: var(--font-mono);
}
.contact-links a {
  color: var(--text-primary);
  border-bottom: 1px solid var(--line);
  padding-bottom: 2px;
  transition: color var(--transition), border-color var(--transition);
}
.contact-links a:hover { color: var(--blue-bright); border-color: var(--blue-bright); }
.footer-note {
  margin-top: 3rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
}
