:root {
  --bg: #0a0a0a;
  --panel: #0f0f10;
  --panel-strong: #141416;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --quiet: #6b7280;
  --line: rgba(255, 255, 255, 0.15);
  --line-faint: rgba(255, 255, 255, 0.08);
  --blue: #7dd3fc;
  --amber: #f59e0b;
  --font-display: "Inter", "Helvetica Neue", Arial, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  --nav-height: 72px;
  --max: 1320px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(var(--line-faint) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-faint) 1px, transparent 1px),
    var(--bg);
  background-size: 48px 48px;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: 0;
  overflow-x: hidden;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.025) 0,
      rgba(255, 255, 255, 0.025) 1px,
      transparent 1px,
      transparent 6px
    );
  opacity: 0.52;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
}

img,
svg {
  display: block;
}

::selection {
  background: var(--blue);
  color: #030608;
}

:focus-visible {
  outline: 1px solid var(--blue);
  outline-offset: 4px;
}

.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1400;
  width: 0;
  height: 1px;
  background: var(--amber);
}

.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1200;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: stretch;
  min-height: var(--nav-height);
  background: rgba(10, 10, 10, 0.94);
  border-bottom: 1px solid var(--line);
}

.nav-mark,
.nav-links a,
.nav-toggle {
  display: inline-flex;
  align-items: center;
  min-height: var(--nav-height);
  border-right: 1px solid var(--line);
}

.nav-mark {
  padding: 0 24px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
}

.nav-links {
  display: flex;
  justify-content: flex-end;
}

.nav-links a {
  padding: 0 18px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--blue);
  background: rgba(125, 211, 252, 0.06);
}

.nav-toggle {
  display: none;
  width: var(--nav-height);
  justify-content: center;
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  width: 18px;
  height: 1px;
  margin: 4px 0;
  background: var(--text);
  transition: transform 180ms var(--ease);
}

.nav-toggle.open span:first-child {
  transform: translateY(5px) rotate(45deg);
}

.nav-toggle.open span:last-child {
  transform: translateY(-5px) rotate(-45deg);
}

.mobile-menu {
  position: fixed;
  top: var(--nav-height);
  left: 0;
  right: 0;
  z-index: 1100;
  display: none;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.mobile-menu.open {
  display: grid;
}

.mobile-menu a {
  padding: 18px 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.mobile-menu a:hover {
  color: var(--blue);
}

.section {
  position: relative;
  min-height: 100vh;
  padding: calc(var(--nav-height) + 40px) 0 72px;
  border-top: 1px solid var(--line);
}

.section-grid {
  width: min(100%, var(--max));
  margin: 0 auto;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.hero {
  display: grid;
  align-items: stretch;
  padding-top: var(--nav-height);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
  min-height: calc(100vh - var(--nav-height));
}

.hero-copy,
.hero-panel,
.metric-strip,
.section-header,
.copy-stack,
.system-card,
.compute-cell-wrapper,
.artifact-card,
.timeline,
.contact-panel,
.resume-modal form {
  border: 1px solid var(--line);
  background: rgba(10, 10, 10, 0.82);
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 56px;
  border-top: 0;
  border-left: 0;
}

.metadata-line,
.section-index,
.metadata-tag,
.timeline-meta,
.metric-strip span,
.register-grid dt,
.register-grid dd,
.artifact-link,
.compute-cell-wrapper,
.compute-tabs,
.compute-tab,
.compute-header,
.telemetry-grid,
.compute-status,
.contact-panel,
.site-footer,
.modal-close {
  font-family: var(--font-mono);
  letter-spacing: 0;
}

.metadata-line,
.section-index,
.metadata-tag {
  margin: 0;
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.45;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 920px;
  margin: 28px 0 0;
  font-size: 4.8rem;
  font-weight: 900;
  line-height: 0.98;
  letter-spacing: 0;
}

.hero-lead {
  max-width: 780px;
  margin: 30px 0 0;
  color: var(--muted);
  font-size: 1.18rem;
  font-weight: 600;
  line-height: 1.55;
}

.hero-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  border-top: 0;
  border-right: 0;
}

.portrait-block {
  min-height: 460px;
  border-bottom: 1px solid var(--line);
  background: #050505;
  overflow: hidden;
}

.portrait-block img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(1) contrast(1.45) brightness(0.72);
  mix-blend-mode: luminosity;
}

.register-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 0;
}

.register-grid div {
  min-height: 112px;
  padding: 18px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.register-grid div:nth-child(2n) {
  border-right: 0;
}

.register-grid div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.register-grid dt {
  margin: 0 0 10px;
  color: var(--quiet);
  font-size: 0.68rem;
  font-weight: 700;
}

.register-grid dd {
  margin: 0;
  color: var(--text);
  font-size: 0.78rem;
}

.metric-strip {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
}

.metric-strip a {
  display: grid;
  min-height: 144px;
  align-content: space-between;
  padding: 20px;
  border-right: 1px solid var(--line);
}

.metric-strip a:last-child {
  border-right: 0;
}

.metric-strip span {
  color: var(--quiet);
  font-size: 0.68rem;
  font-weight: 700;
}

.metric-strip strong {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.44fr) minmax(0, 1fr);
}

.section-header {
  align-content: start;
  min-height: 280px;
  padding: 32px;
  border-left: 0;
  border-top: 0;
}

.section-header h2 {
  max-width: 620px;
  margin: 28px 0 0;
  font-size: 3rem;
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: 0;
}

.copy-stack {
  padding: 32px;
  border-top: 0;
  border-right: 0;
}

.copy-stack p,
.system-card p,
.artifact-card p,
.timeline-row p,
.resume-modal p {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.64;
}

.copy-stack p {
  max-width: 860px;
  margin: 0 0 22px;
}

.copy-stack .lead {
  color: var(--text);
  font-size: 1.18rem;
  font-weight: 700;
}

.system-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.system-card {
  min-height: 350px;
  padding: 28px;
  border-left: 0;
  border-bottom: 0;
}

.system-card:last-child {
  border-right: 0;
}

.system-card h3,
.artifact-card h3,
.timeline-row h3,
.resume-modal h2 {
  margin: 22px 0 0;
  color: var(--text);
  font-size: 1.45rem;
  font-weight: 900;
  line-height: 1.08;
  letter-spacing: 0;
}

.system-card p:not(.metadata-line) {
  margin: 22px 0 0;
}

.compute-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.38fr) minmax(0, 1fr);
}

.compute-cell-wrapper {
  min-height: 520px;
  border-top: 0;
  border-right: 0;
}

.compute-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.compute-tab {
  min-height: 52px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--quiet);
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
}

.compute-tab:last-child {
  border-right: 0;
}

.compute-tab:hover,
.compute-tab.active {
  color: var(--blue);
  background: rgba(125, 211, 252, 0.06);
}

.compute-panel[hidden] {
  display: none;
}

.compute-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}

.compute-body {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(300px, 0.75fr);
  min-height: 360px;
}

#compute-canvas,
#life-canvas {
  width: 100%;
  height: 100%;
  min-height: 360px;
  border: 0;
  border-right: 1px solid var(--line);
  background: #020202;
  image-rendering: pixelated;
}

#life-canvas {
  cursor: crosshair;
}

.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.telemetry-grid div {
  min-height: 120px;
  padding: 18px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--quiet);
  font-size: 0.72rem;
  font-weight: 700;
}

.telemetry-grid div:nth-child(2n) {
  border-right: 0;
}

.telemetry-grid span,
.compute-status strong {
  display: block;
  margin-top: 10px;
  color: var(--amber);
  font-size: 0.86rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.compute-status {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.compute-status button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}

.compute-status button:disabled {
  color: var(--quiet);
  cursor: wait;
}

.life-controls {
  align-items: center;
}

.life-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.life-buttons button {
  min-width: 106px;
}

.artifact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.artifact-card {
  min-height: 430px;
  padding: 28px;
  border-left: 0;
  border-bottom: 0;
}

.artifact-card:nth-child(2n) {
  border-right: 0;
}

.artifact-card h3 {
  max-width: 720px;
  margin-top: 28px;
}

.artifact-card p:not(.metadata-tag) {
  margin: 22px 0 0;
}

.artifact-tags {
  display: grid;
  gap: 8px;
}

.artifact-link {
  display: inline-flex;
  margin-top: 24px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.artifact-link:hover,
.compute-tab:hover,
.compute-status button:hover:not(:disabled),
.contact-panel a:hover,
.contact-panel button:hover {
  color: #030608;
  background: var(--blue);
}

.math-block {
  margin: 24px 0 0;
  padding: 18px;
  overflow-x: auto;
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.92rem;
}

.math-block svg {
  width: min(100%, 860px);
  min-width: 680px;
  height: auto;
  color: var(--text);
}

.math-block path {
  fill: none;
  stroke: currentColor;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.math-block text {
  fill: currentColor;
  font-family: var(--font-mono);
  font-weight: 700;
}

.math-compiler-meta {
  margin-top: 14px;
  color: var(--quiet);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
}

.math-error {
  color: var(--amber);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.archive-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 24px;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.archive-grid figure {
  aspect-ratio: 1;
  margin: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #020202;
  overflow: hidden;
}

.archive-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(1) contrast(1.85) brightness(0.54);
}

.archive-grid figure:nth-child(2) img {
  object-position: center;
}

.archive-grid figure:nth-child(3) img {
  object-position: 68% center;
  transform: scale(1.18);
}

.timeline {
  border-top: 0;
  border-right: 0;
}

.timeline-row {
  display: grid;
  grid-template-columns: minmax(190px, 0.28fr) minmax(0, 1fr);
  gap: 28px;
  padding: 28px;
  border-bottom: 1px solid var(--line);
}

.timeline-row:last-child {
  border-bottom: 0;
}

.timeline-meta p,
.timeline-meta span {
  display: block;
  margin: 0 0 10px;
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 700;
}

.timeline-meta span {
  color: var(--quiet);
}

.timeline-row h3 {
  margin-top: 0;
}

.timeline-row p {
  max-width: 820px;
  margin: 14px 0 0;
}

.contact {
  min-height: auto;
}

.contact-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(360px, 0.56fr);
}

.contact-panel {
  display: grid;
  align-content: center;
  border-top: 0;
  border-right: 0;
}

.contact-panel a,
.contact-panel button {
  display: block;
  width: 100%;
  padding: 22px 24px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.contact-panel *:last-child {
  border-bottom: 0;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--bg);
  color: var(--quiet);
  font-size: 0.72rem;
  font-weight: 700;
}

.footer-grid {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 24px;
}

.footer-grid p {
  margin: 0;
}

.resume-modal {
  width: min(560px, calc(100% - 32px));
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
}

.resume-modal::backdrop {
  background: rgba(0, 0, 0, 0.82);
}

.resume-modal form {
  position: relative;
  padding: 30px;
  background: var(--bg);
}

.resume-modal a {
  color: var(--blue);
}

.modal-close {
  position: absolute;
  top: 0;
  right: 0;
  width: 48px;
  height: 48px;
  border: 0;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
}

.reveal-up {
  opacity: 1;
  transform: none;
}

.motion-ready .reveal-up {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 420ms ease, transform 420ms var(--ease);
}

.motion-ready .reveal-up.visible,
.reveal-up.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1100px) {
  .hero-grid,
  .split-grid,
  .compute-grid,
  .contact-grid {
    grid-template-columns: 1fr;
  }

  .hero-copy,
  .hero-panel,
  .copy-stack,
  .compute-cell-wrapper,
  .timeline,
  .contact-panel {
    border-right: 0;
  }

  .hero h1 {
    font-size: 3.7rem;
  }

  .system-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .system-card:nth-child(2n),
  .artifact-card:nth-child(2n) {
    border-right: 0;
  }
}

@media (max-width: 780px) {
  :root {
    --nav-height: 64px;
  }

  body {
    font-size: 15px;
  }

  .nav-links {
    display: none;
  }

  .nav-toggle {
    display: inline-grid;
    align-content: center;
  }

  .section-grid {
    width: 100%;
  }

  .hero-copy,
  .section-header,
  .copy-stack,
  .system-card,
  .artifact-card,
  .timeline-row {
    padding: 22px;
  }

  .hero h1 {
    font-size: 2.75rem;
  }

  .hero-lead,
  .copy-stack .lead {
    font-size: 1rem;
  }

  .metric-strip,
  .system-grid,
  .compute-body,
  .artifact-grid,
  .archive-grid,
  .register-grid {
    grid-template-columns: 1fr;
  }

  .metric-strip a,
  .register-grid div,
  .system-card,
  #compute-canvas,
  #life-canvas,
  .artifact-card {
    border-right: 0;
  }

  #compute-canvas,
  #life-canvas {
    border-bottom: 1px solid var(--line);
  }

  .section-header h2 {
    font-size: 2.2rem;
  }

  .telemetry-grid {
    grid-template-columns: 1fr;
  }

  .telemetry-grid div {
    min-height: 92px;
    border-right: 0;
  }

  .timeline-row {
    grid-template-columns: 1fr;
  }

  .footer-grid {
    display: grid;
  }
}

@media (max-width: 480px) {
  .nav-mark {
    padding: 0 16px;
  }

  .hero h1 {
    font-size: 2.2rem;
  }

  .section-header h2 {
    font-size: 1.9rem;
  }

  .compute-status {
    display: grid;
  }

  .compute-status button {
    width: 100%;
  }

  .compute-tabs {
    grid-template-columns: 1fr;
  }

  .compute-tab {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .compute-tab:last-child {
    border-bottom: 0;
  }

  .life-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    justify-content: stretch;
  }

  .contact-panel a,
  .contact-panel button {
    overflow-wrap: anywhere;
  }
}

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

  .reveal-up,
  .motion-ready .reveal-up {
    opacity: 1;
    transform: none;
  }
}
