:root {
  --navy: #02255F;
  --electric: #0179C1;
  --near-black: #070B16;
  --off-white: #F6F8FF;
  --grid-dark: rgba(1,121,193,.18);
  --grid-light: rgba(2,37,95,.12);

  --bg: var(--off-white);
  --text: var(--navy);
  --muted: rgba(2,37,95,.65);
  --line: var(--grid-light);
  --panel: rgba(2,37,95,.03);

  --font-title: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

[data-theme="dark"] {
  --bg: var(--near-black);
  --text: var(--off-white);
  --muted: rgba(246,248,255,.7);
  --line: var(--grid-dark);
  --panel: rgba(1,121,193,.08);
}

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

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.45;
  overflow-x: hidden;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--electric) var(--bg);
}

*::-webkit-scrollbar {
  width: 10px;
}

*::-webkit-scrollbar-track {
  background: var(--bg);
}

*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--electric), var(--navy));
  border-radius: 10px;
  border: 2px solid var(--bg);
}

.container {
  width: min(1200px, 92vw);
  margin: 0 auto;
}

.section {
  padding: 96px 0;
}

.section-title {
  font-family: var(--font-title);
  font-size: clamp(28px, 3vw, 40px);
  letter-spacing: .5px;
  margin-bottom: 12px;
}

.section-sub {
  color: var(--muted);
  margin-bottom: 32px;
}

.blueprint-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: .8;
  pointer-events: none;
  z-index: 0;
}

.noise {
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.6' numOctaves='2' stitchTiles='stitch'/></filter><rect width='160' height='160' filter='url(%23n)' opacity='.05'/></svg>");
  mix-blend-mode: soft-light;
  opacity: .15;
  pointer-events: none;
  z-index: 1;
}

.cursor {
  position: fixed;
  width: 18px;
  height: 18px;
  border: 2px solid var(--electric);
  background: rgba(1,121,193,.08);
  box-shadow:
    0 0 8px rgba(1,121,193,.6),
    0 0 18px rgba(1,121,193,.35);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 999;
  transition: width .18s ease, height .18s ease, border-color .18s ease;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(180deg, var(--bg) 0%, transparent 100%);
  backdrop-filter: blur(4px);
}

.header-inner {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  padding: 20px 0;
  gap: 16px;
  border-bottom: 1px solid transparent;
  transition: padding .2s ease, border-color .2s ease;
}

.site-header.shrink .header-inner {
  padding: 10px 0;
  border-color: var(--line);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-title);
  font-weight: 700;
  letter-spacing: .5px;
  color: inherit;
  text-decoration: none;
}

.logo img {
  width: auto;
  height: 32px;
  object-fit: contain;
}

.logo-fallback {
  font-size: 0;
}

.caret {
  color: var(--electric);
  animation: blink 1.1s steps(2) infinite;
}

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

.nav {
  position: relative;
}

.nav-toggle {
  display: none;
}

.nav-panel {
  display: flex;
  gap: 18px;
  align-items: center;
  text-align: left;
  font-family: var(--font-mono);
}

.nav-panel a {
  color: var(--text);
  text-decoration: none;
  position: relative;
  padding-bottom: 2px;
  font-family: var(--font-mono);
}

.nav-panel a::before {
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 0;
  width: 0ch;
  overflow: hidden;
  white-space: nowrap;
  color: var(--electric);
  opacity: 0;
  animation: none;
  z-index: 2;
}

.nav-panel a::after {
  content: "|";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--electric);
  opacity: 0;
  z-index: 3;
  animation: none;
  font-weight: 700;
  text-shadow: 0 0 6px rgba(1,121,193,.6);
}

.nav-panel a:hover::before,
.nav-panel a:focus-visible::before {
  opacity: 1;
  animation: eraseType 2.6s steps(calc(var(--chars) + 1)) infinite;
}

.nav-panel a:hover::after,
.nav-panel a:focus-visible::after {
  opacity: 1;
  animation:
    caretMove 2.6s steps(calc(var(--chars) + 1)) infinite,
    caretBlink .8s steps(2) infinite;
}

.nav-panel a:hover,
.nav-panel a:focus-visible {
  color: transparent;
}

@keyframes eraseType {
  0% { width: calc(var(--chars) * 1ch); }
  40% { width: 0ch; }
  55% { width: 0ch; }
  100% { width: calc(var(--chars) * 1ch); }
}

@keyframes caretMove {
  0% { transform: translateX(0); }
  40% { transform: translateX(0); }
  55% { transform: translateX(0); }
  100% { transform: translateX(calc(var(--chars) * 1ch)); }
}

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

.mode-toggle {
  font-family: var(--font-mono);
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 6px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 32px;
}

.bulb {
  width: 18px;
  height: 18px;
  fill: transparent;
  stroke: var(--text);
  stroke-width: 1.6;
  transition: filter .2s ease, stroke .2s ease, fill .2s ease;
}

.mode-toggle[data-mode="dark"] .bulb {
  fill: var(--electric);
  stroke: var(--electric);
}

.mode-toggle:hover .bulb,
.mode-toggle:focus-visible .bulb {
  animation: bulbFlicker 1.8s infinite;
  filter:
    drop-shadow(0 0 10px rgba(1,121,193,.9))
    drop-shadow(0 0 22px rgba(1,121,193,.7))
    drop-shadow(0 0 36px rgba(1,121,193,.45));
}

@keyframes bulbFlicker {
  0% { opacity: .15; }
  6% { opacity: 1; }
  12% { opacity: .2; }
  18% { opacity: .9; }
  26% { opacity: .4; }
  34% { opacity: 1; }
  46% { opacity: .25; }
  56% { opacity: 1; }
  62% { opacity: .35; }
  72% { opacity: 1; }
  86% { opacity: .2; }
  100% { opacity: 1; }
}

.hero {
  padding-top: 120px;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 48px;
  align-items: center;
}

.hero-copy h1 {
  font-family: var(--font-title);
  font-size: clamp(38px, 5vw, 64px);
  margin-bottom: 12px;
}

.eyebrow {
  font-family: var(--font-mono);
  color: var(--electric);
  margin-bottom: 10px;
}

.lead {
  font-size: clamp(18px, 2.2vw, 24px);
  margin-bottom: 16px;
}

.sublead {
  color: var(--muted);
  margin-bottom: 24px;
}

.cta-row {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
}

.btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  padding: 10px 16px;
  cursor: pointer;
  font-family: var(--font-mono);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: filter .2s ease, box-shadow .2s ease, color .2s ease, border-color .2s ease;
}

.btn.primary {
  background: var(--electric);
  color: #fff;
  border-color: var(--electric);
}

.btn.ghost:hover {
  border-color: var(--electric);
  color: var(--electric);
}

.btn:hover,
.btn:focus-visible {
  animation: bulbFlicker 1.8s infinite;
  filter:
    drop-shadow(0 0 10px rgba(1,121,193,.9))
    drop-shadow(0 0 22px rgba(1,121,193,.7))
    drop-shadow(0 0 36px rgba(1,121,193,.45));
}

.btn.primary:hover,
.btn.primary:focus-visible {
  box-shadow:
    0 0 10px rgba(1,121,193,.5),
    0 0 22px rgba(1,121,193,.35);
}

.micro {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

.hero-panel {
  border: 1px solid var(--line);
  padding: 20px;
  background: var(--panel);
  display: grid;
  gap: 20px;
  transform-style: preserve-3d;
  transition: transform .2s ease;
  position: relative;
  overflow: hidden;
  --rx: 0deg;
  --ry: 0deg;
  transform: perspective(900px) rotateX(var(--rx)) rotateY(var(--ry));
  will-change: transform;
}

.border-snake {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}

.border-snake rect {
  fill: none;
  stroke: rgba(1,121,193,.95);
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-dasharray: 30 260;
  stroke-dashoffset: 0;
  filter:
    drop-shadow(0 0 12px rgba(1,121,193,.9))
    drop-shadow(0 0 26px rgba(1,121,193,.75))
    drop-shadow(0 0 42px rgba(1,121,193,.45));
}

.hero-panel:hover .border-snake {
  opacity: 1;
}

.hero-panel:hover .border-snake rect {
  animation: snakeRun 2.4s linear infinite;
}

@keyframes snakeRun {
  to { stroke-dashoffset: -290; }
}

.panel-header {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

.tag {
  color: var(--electric);
}

.panel-metrics {
  display: grid;
  gap: 16px;
}

.metric-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

.metric-value {
  font-family: var(--font-title);
  font-size: 20px;
}

.panel-foot {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.card {
  border: 1px solid var(--line);
  padding: 18px;
  background: var(--panel);
}

.card h3 {
  font-family: var(--font-title);
  margin-bottom: 8px;
}

.accordion-toggle {
  margin-top: 12px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 6px 10px;
  cursor: pointer;
  font-family: var(--font-mono);
}

.accordion {
  max-height: 0;
  overflow: hidden;
  transition: max-height .25s ease;
}

.card.open .accordion {
  max-height: 140px;
  margin-top: 12px;
}

.accordion ul {
  display: grid;
  gap: 6px;
  color: var(--muted);
  padding-left: 14px;
}

.labs-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

.lab-card {
  border: 1px dashed var(--line);
  padding: 18px;
  background: transparent;
}

.lab-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.process-line {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  border-top: 1px solid var(--line);
  padding-top: 24px;
}

.node {
  position: relative;
  padding-left: 16px;
  font-family: var(--font-mono);
}

.node::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--electric);
}

.node small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-family: var(--font-body);
}

.contact-form {
  display: grid;
  gap: 14px;
  max-width: 520px;
}

label {
  display: grid;
  gap: 6px;
  font-family: var(--font-mono);
}

input, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-family: var(--font-body);
}

input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--electric);
  outline-offset: 2px;
}

.form-hint {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--font-mono);
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 18px 0 30px;
  font-family: var(--font-mono);
}

.site-footer .container {
  display: flex;
  justify-content: space-between;
}

.reveal {
  opacity: 0;
  translate: 0 16px;
  transition: opacity .35s ease, transform .35s ease;
}

.reveal.visible {
  opacity: 1;
  translate: 0 0;
}

@media (max-width: 960px) {
  .hero-grid {
    grid-template-columns: 1fr;
  }

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

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

  .process-line {
    grid-template-columns: 1fr;
  }

  .nav-toggle {
    display: inline-flex;
    background: transparent;
    border: 1px solid var(--line);
    color: var(--text);
    padding: 6px 10px;
    font-family: var(--font-mono);
  }

  .nav-panel {
    position: absolute;
    right: 0;
    top: 40px;
    background: var(--bg);
    border: 1px solid var(--line);
    padding: 12px;
    display: none;
  }

  .nav-panel.open {
    display: grid;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
