/* ============ Fonts (self-hosted) ============ */
@font-face { font-family: "Fraunces"; font-weight: 800; font-display: swap; src: url("fonts/fraunces-latin-800-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url("fonts/inter-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url("fonts/inter-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-display: swap; src: url("fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); }

/* ============ Tokens ============ */
:root {
  --paper: #f5f3ec;
  --paper-2: #ece9df;
  --ink: #101722;
  --ink-2: #3b4452;
  --muted: #6b7280;
  --rule: #d6d2c4;
  --navy: #101722;
  --navy-2: #1a2333;
  --blue: #1455e8;
  --lime: #c6f500;
  --ok: #3fbf3f;

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;

  --sidebar: 260px;
  --gutter: clamp(20px, 4vw, 56px);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background-color: var(--paper);
  /* faint engineering grid */
  background-image:
    linear-gradient(rgba(16, 23, 34, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 23, 34, .035) 1px, transparent 1px);
  background-size: 32px 32px;
  color: var(--ink);
  font: 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

.mono { font-family: var(--mono); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 50; background: var(--lime); color: var(--ink); padding: 8px 12px; }
.skip:focus { left: 8px; }

/* ============ Sidebar ============ */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar);
  background: var(--navy); color: #e8ecf2;
  display: flex; flex-direction: column;
  padding: 36px 22px 28px; z-index: 20;
  overflow-y: auto; overscroll-behavior: contain;
  background-image: repeating-linear-gradient(135deg, transparent 0 22px, rgba(255,255,255,.018) 22px 23px);
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; }
.logo {
  font: 800 52px/1 var(--serif); color: #fff; letter-spacing: -2px;
}
.logo span { color: var(--lime); font-style: italic; margin-left: 2px; }
.logo:hover { text-decoration: none; }
.menu-toggle { display: none; }

.sidebar-body { display: flex; flex-direction: column; flex: 1; }
.identity { margin: 26px 0 24px; padding-bottom: 24px; border-bottom: 1px solid rgba(255,255,255,.14); }
.identity .name { font: 600 19px/1.3 var(--sans); color: #fff; margin-bottom: 8px; }
.identity .mono { font-size: 12.5px; color: #a9b3c2; line-height: 1.6; }

.sidebar nav li + li { margin-top: 4px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 12px; border-radius: 6px;
  color: #c9d1dd; font-size: 15px; border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: var(--navy-2); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--navy-2); color: #fff; border-left-color: var(--lime); }
.sidebar nav svg, .btn svg, .facts svg {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}

.sidebar-foot { margin-top: auto; padding-top: 22px; border-top: 1px dashed rgba(255,255,255,.22); }
.status { font: 13px/1.5 var(--mono); color: #c9d1dd; position: relative; padding-left: 20px; }
.status .dot {
  position: absolute; left: 0; top: 5px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--lime); box-shadow: 0 0 0 0 rgba(198,245,0,.6); animation: ping 2.4s infinite;
}
.social { margin-top: 16px; font: 13px var(--mono); }
.social a { color: #fff; border-bottom: 1px solid var(--lime); }
.social a:hover { text-decoration: none; color: var(--lime); }

/* ============ Main ============ */
main {
  margin-left: var(--sidebar);
  padding: 0 max(var(--gutter), calc((100vw - var(--sidebar) - 1320px) / 2));
}

.strip {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 22px 0 14px; border-bottom: 1px solid var(--ink);
  font: 500 12.5px var(--mono); letter-spacing: .14em; text-transform: uppercase;
}
.strip b { color: var(--blue); font-weight: 500; }

/* ============ Hero ============ */
.hero {
  display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr);
  gap: clamp(24px, 4vw, 56px); align-items: center;
  padding: 44px 0 40px;
}
.label {
  display: inline-block; background: var(--lime); color: var(--ink);
  font: 500 13px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase;
  padding: 7px 10px;
}
.hero h1 {
  font: 800 clamp(40px, 4.4vw, 68px)/1.02 var(--serif);
  letter-spacing: -.025em; margin: 18px 0 20px;
}
.squiggle {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 12' preserveAspectRatio='none'%3E%3Cpath d='M2 8C40 3 80 2 120 4s60 3 78 1' fill='none' stroke='%23c6f500' stroke-width='5' stroke-linecap='round'/%3E%3C/svg%3E") left bottom / 100% .28em no-repeat;
  padding-bottom: .06em;
}
.hero-sub { font: 400 17px/1.65 var(--mono); color: var(--ink-2); max-width: 34em; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }
.btn {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 12px 18px; border: 1.5px solid var(--ink); border-radius: 4px;
  background: transparent; color: var(--ink); font: 600 15px var(--sans);
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn:hover { text-decoration: none; transform: translate(-2px, -2px); box-shadow: 3px 3px 0 var(--ink); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { box-shadow: 3px 3px 0 var(--ink); }
.btn-lime { background: var(--lime); border-color: var(--lime); color: var(--ink); }
.btn-ghost { border-color: rgba(255,255,255,.5); color: #fff; }
.btn-lime:hover, .btn-ghost:hover { box-shadow: 3px 3px 0 var(--blue); }

/* Diagram */
.hero-diagram { margin: 0; min-width: 0; }
.hero-diagram svg { width: 100%; height: auto; overflow: visible; }
.swipe { display: none; }
.hero-diagram figcaption { font-size: 12px; color: var(--muted); margin-top: 10px; text-align: right; }

.node rect { fill: #fbfaf6; stroke: var(--ink); stroke-width: 1.2; filter: drop-shadow(3px 3px 0 rgba(16,23,34,.12)); }
.node-hot rect { stroke: var(--blue); stroke-width: 2; fill: #f3f6ff; }
.node .ico { fill: none; stroke: var(--blue); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.node .ico.tf { stroke: #5c4ee5; }
.node text { text-anchor: middle; fill: var(--ink); }
.node text.l { text-anchor: start; }
.node .t { font: 600 13px var(--sans); }
.node .s { font: 10.5px var(--mono); fill: var(--ink-2); }
.badge circle { fill: var(--ok); }
.badge path { fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.ok { fill: var(--ok); animation: blink 3s ease-in-out infinite; }
.target:nth-of-type(2) .ok { animation-delay: .6s; }

.wire path { fill: none; stroke: var(--ink); stroke-width: 1.6; }
.wire .flow { stroke-dasharray: 6 6; animation: flow 1.2s linear infinite; }
.wire-iac path { stroke: var(--blue); }
.wire-iac .flow { stroke-dasharray: 3 5; animation-duration: 1.8s; animation-direction: reverse; }

@keyframes flow { to { stroke-dashoffset: -24; } }
@keyframes blink { 50% { opacity: .35; } }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(198,245,0,.55); } 70%, 100% { box-shadow: 0 0 0 9px rgba(198,245,0,0); } }

/* ============ Capabilities ============ */
.capabilities {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
}
.capabilities article { padding: 24px 22px; }
.capabilities article + article { border-left: 1px solid var(--rule); }
.capabilities .num { font: 500 12px var(--mono); color: var(--blue); }
.capabilities h3 { font: 600 18px/1.3 var(--sans); margin: 6px 0 6px; }
.capabilities p { font-size: 14px; color: var(--ink-2); }

/* ============ Sections ============ */
.section { padding: 72px 0 8px; scroll-margin-top: 12px; }
.section-head { margin-bottom: 30px; }
.kicker { font: 500 13px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--blue); }
.title { font: 800 clamp(30px, 3.4vw, 46px)/1.1 var(--serif); letter-spacing: -.02em; margin: 8px 0 0; }
.section-sub { color: var(--ink-2); margin-top: 10px; max-width: 46em; }

/* Case studies */
.cases { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.case {
  background: #fbfaf6; border: 1px solid var(--rule); border-radius: 6px;
  padding: 24px; display: flex; flex-direction: column;
  border-bottom: 5px solid var(--blue);
  transition: transform .2s ease, box-shadow .2s ease;
}
.case.accent-lime { border-bottom-color: var(--lime); }
.case:hover { transform: translateY(-3px); box-shadow: 0 14px 30px -18px rgba(16,23,34,.35); }
.case-head { display: flex; justify-content: space-between; gap: 10px; font: 500 12px var(--mono); color: var(--muted); }
.case-head .num { color: var(--ink); }
.case-head .cat { text-transform: uppercase; letter-spacing: .08em; text-align: right; }
.case h3 { font: 800 25px/1.15 var(--serif); letter-spacing: -.01em; margin: 10px 0 14px; }

.case-art { height: 120px; margin: 0 auto 18px; }
.case-art .win { fill: #fff; stroke: var(--blue); stroke-width: 1.5; }
.case-art .bar, .case-art .line { fill: none; stroke: var(--blue); stroke-width: 1.5; }
.case-art .wp { fill: none; stroke: var(--blue); stroke-width: 2; }
.case-art .req { stroke: var(--ink); stroke-dasharray: 3 5; animation: flow 1.4s linear infinite; }
.case-art .dot-in { fill: var(--ink); }
.case-art .shield { fill: rgba(198,245,0,.35); stroke: var(--blue); stroke-width: 2; stroke-linejoin: round; }
.case-art .shield-q { font: 800 30px var(--serif); fill: var(--blue); text-anchor: middle; }
.case-art .blob { fill: rgba(198,245,0,.28); }
.case-art .cycle { fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 4 4; }
.case-art .tag-node rect { fill: #fff; stroke: var(--ink); stroke-width: 1.2; }
.case-art .tag-node text { font: 500 11px var(--mono); text-anchor: middle; fill: var(--blue); }
.case-art .tag-node.tf text { fill: #5c4ee5; }

.case-body { margin: 0 0 16px; font-size: 14.5px; }
.case-body dt { font: 500 11px var(--mono); text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin-top: 12px; }
.case-body dt:first-child { margin-top: 0; }
.case-body dd { margin: 3px 0 0; color: var(--ink-2); }
.case-body .result { color: var(--ink); background: linear-gradient(transparent 62%, rgba(198,245,0,.55) 62%); display: inline; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.chips li { font: 12px var(--mono); border: 1px solid var(--ink); border-radius: 3px; padding: 3px 8px; background: #fff; }
.case-links { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; font: 13px var(--mono); }
.case-links a { display: inline-block; padding: 4px 0; min-height: 24px; }

.case-intro { color: var(--ink-2); font-size: 14.5px; margin-bottom: 16px; }
.products li { border: 1px solid var(--blue); border-radius: 4px; padding: 12px 14px; background: #fff; box-shadow: 4px 4px 0 rgba(20,85,232,.12); }
.products li + li { margin-top: 12px; }
.products li:nth-child(even) { margin-left: 14px; }
.products p { font-size: 14px; color: var(--ink-2); }
.products .p-name { font: 600 15px var(--sans); color: var(--ink); margin-bottom: 2px; }
.products .p-stack { font: 12px var(--mono); color: var(--blue); margin-top: 6px; }

/* Lab */
.lab { border-top: 1px solid var(--ink); }
.lab li {
  display: grid; grid-template-columns: 56px minmax(0, 1fr) 240px; gap: 18px;
  padding: 20px 0; border-bottom: 1px solid var(--rule); align-items: baseline;
}
.lab .num { font: 500 13px var(--mono); color: var(--blue); }
.lab h3 { font: 500 16px var(--mono); margin: 0 0 4px; }
.lab p { color: var(--ink-2); font-size: 15px; }
.lab .stack { font: 12.5px var(--mono); color: var(--ink); text-align: right; }
.now { margin-top: 24px; font-size: 15px; color: var(--ink-2); display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.now .label { font-size: 11px; padding: 5px 8px; }

/* Experience */
.exp { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 40px; }
.timeline { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; position: relative; padding-top: 30px; }
.timeline::before { content: ""; position: absolute; top: 6px; left: 0; right: 0; height: 2px; background: var(--rule); }
.timeline > li { position: relative; }
.timeline > li::before {
  content: ""; position: absolute; top: -30px; left: 0; width: 14px; height: 14px; border-radius: 50%;
  background: var(--paper); border: 2px solid var(--muted);
}
.timeline > li.current::before { background: var(--blue); border-color: var(--blue); box-shadow: 0 0 0 4px rgba(20,85,232,.18); }
.timeline .when { font: 12.5px var(--mono); color: var(--muted); }
.timeline h3 { font: 800 22px/1.2 var(--serif); margin: 4px 0 2px; }
.timeline .role { font-weight: 600; font-size: 14.5px; margin-bottom: 10px; }
.timeline ul li { font-size: 14.5px; color: var(--ink-2); padding-left: 16px; position: relative; }
.timeline ul li + li { margin-top: 6px; }
.timeline ul li::before { content: "—"; position: absolute; left: 0; color: var(--blue); }

.facts { border-left: 1px solid var(--rule); padding-left: 28px; align-self: start; }
.facts li { display: flex; gap: 12px; align-items: center; font-size: 14.5px; }
.facts li + li { margin-top: 14px; }
.facts svg { color: var(--blue); }
.facts .edu-item { align-items: flex-start; }
.facts .edu { display: flex; flex-direction: column; gap: 10px; line-height: 1.35; }
.facts .edu > span + span { padding-top: 10px; border-top: 1px dashed var(--rule); }

/* Contact */
.contact {
  margin: 80px 0 0; padding: clamp(36px, 6vw, 64px);
  background: var(--navy); color: #fff; border-radius: 6px; position: relative; overflow: hidden;
}
.contact::after {
  content: ""; position: absolute; right: -40px; bottom: -40px; width: 220px; height: 220px;
  background: var(--lime); transform: skewX(-28deg); opacity: .9;
}
.contact .kicker { color: var(--lime); }
.contact h2 { font: 800 clamp(30px, 4vw, 52px)/1.1 var(--serif); margin: 10px 0 0; max-width: 16em; position: relative; z-index: 1; }
.contact .actions { position: relative; z-index: 1; }

.footer {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 26px 0 34px; font-size: 12.5px; color: var(--muted);
}

/* Back to top */
.to-top {
  position: fixed; right: 24px; bottom: 24px; z-index: 30;
  width: 48px; height: 48px; display: grid; place-items: center;
  background: var(--navy); color: var(--lime); border-radius: 4px;
  box-shadow: 3px 3px 0 var(--blue);
  opacity: 0; visibility: hidden; transform: translateY(12px);
  transition: opacity .2s ease, transform .2s ease, visibility .2s, box-shadow .15s ease;
}
.to-top.show { opacity: 1; visibility: visible; transform: none; }
.to-top:hover { box-shadow: 5px 5px 0 var(--lime); color: #fff; text-decoration: none; }
.to-top svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* 404 page */
.page-404 main { margin-left: 0; }
.page-404 .hero { display: block; }

/* ============ Responsive ============ */
@media (max-width: 1280px) {
  .cases { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cases .case:last-child { grid-column: 1 / -1; }
  .exp { grid-template-columns: 1fr; }
  .facts { border-left: 0; padding-left: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .facts li + li { margin-top: 0; }
}

@media (max-width: 1100px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .capabilities { grid-template-columns: repeat(2, 1fr); }
  .capabilities article:nth-child(3) { border-left: 0; }
  .capabilities article:nth-child(n+3) { border-top: 1px solid var(--rule); }
  .lab li { grid-template-columns: 44px minmax(0, 1fr); }
  .lab .stack { grid-column: 2; text-align: left; }
}

@media (max-width: 900px), (max-height: 520px) {
  :root { --sidebar: 0px; }
  .sidebar {
    position: sticky; top: 0; inset: auto; width: auto; height: auto;
    padding: 12px 20px;
  }
  .logo { font-size: 32px; }
  .menu-toggle {
    display: inline-flex; background: none; border: 1px solid rgba(255,255,255,.3); border-radius: 4px;
    color: #fff; padding: 6px; cursor: pointer;
  }
  .menu-toggle svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
  .sidebar-body { display: none; padding-bottom: 12px; max-height: calc(100dvh - 64px); overflow-y: auto; }
  .sidebar.open .sidebar-body { display: flex; }
  .identity { margin-top: 16px; }
  .section { scroll-margin-top: 70px; }
  .cases { grid-template-columns: 1fr; }
  .timeline { grid-template-columns: 1fr; padding-top: 0; padding-left: 30px; }
  .timeline::before { top: 0; bottom: 0; left: 6px; right: auto; width: 2px; height: auto; }
  .timeline > li::before { top: 4px; left: -30px; }
}

@media (max-width: 560px) {
  .strip-tags { display: none; }
  .capabilities { grid-template-columns: 1fr; }
  .capabilities article + article { border-left: 0; border-top: 1px solid var(--rule); }
  .facts { grid-template-columns: 1fr; }
  .products li:nth-child(n) { margin-left: 0; }
  .btn { padding: 11px 15px; }
  .to-top { right: 16px; bottom: 16px; width: 44px; height: 44px; }
}

@media (min-width: 901px) and (max-height: 760px) {
  .sidebar { padding-top: 22px; }
  .logo { font-size: 40px; }
  .identity { margin: 16px 0 14px; padding-bottom: 14px; }
  .sidebar nav a { padding: 8px 12px; }
}

@media (max-width: 600px) {
  .diagram-scroll { overflow-x: auto; margin: 0 calc(-1 * var(--gutter)); padding: 14px var(--gutter) 6px; scrollbar-width: thin; }
  .diagram-scroll svg { width: 600px; max-width: none; }
  .swipe { display: inline; }
  .label { letter-spacing: .04em; }
}

@media (max-width: 380px) {
  .hero h1 { font-size: 36px; }
  .case { padding: 18px; }
  .case-head { flex-direction: column; gap: 2px; }
  .case-head .cat { text-align: left; }
  .contact::after { width: 120px; height: 120px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
