@font-face {
  font-family: "Archivo";
  src: url("../fonts/archivo-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif 4";
  src: url("../fonts/source-serif-4-latin.woff2") format("woff2");
  font-weight: 200 900;
  font-display: swap;
}

/* Light theme is a graph-paper printout; dark theme is the same trace on a scope screen. */
:root {
  color-scheme: light;
  --bg: #edf1f0;
  --ink: #101c24;
  --muted: #465a63;
  --rule: #c2cfcc;
  --grid-minor: rgba(16, 28, 36, 0.055);
  --grid-major: rgba(16, 28, 36, 0.1);
  --ch1: #e59a00;
  --ch2: #0088a0;
  --link: #00657a;

  --rail-x: clamp(10px, 2.2vw, 26px);
  --gutter: clamp(36px, 7vw, 104px);
  --pad: clamp(16px, 4vw, 48px);
  --display: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --text: "Source Serif 4", Georgia, "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b1418;
    --ink: #dfeaed;
    --muted: #9db2b9;
    --rule: #24373f;
    --grid-minor: rgba(223, 234, 237, 0.045);
    --grid-major: rgba(223, 234, 237, 0.09);
    --ch1: #ffc53d;
    --ch2: #5cd6e6;
    --link: #5cd6e6;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1418;
  --ink: #dfeaed;
  --muted: #9db2b9;
  --rule: #24373f;
  --grid-minor: rgba(223, 234, 237, 0.045);
  --grid-major: rgba(223, 234, 237, 0.09);
  --ch1: #ffc53d;
  --ch2: #5cd6e6;
  --link: #5cd6e6;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  scroll-behavior: smooth;
  scroll-padding-top: 1rem;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--text);
  font-size: 1.125rem;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid-minor) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-minor) 1px, transparent 1px);
  background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
}

a {
  color: var(--link);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
}
a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 3px solid var(--link);
  outline-offset: 3px;
}

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  padding: 0.6rem 1rem;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--display);
  z-index: 10;
}
.skip:focus {
  top: 1rem;
}

/* Header */
.top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem 2rem;
  max-width: 76rem;
  margin: 0 auto;
  padding: 1.1rem var(--pad) 1.1rem var(--gutter);
  font-family: var(--display);
}
.brand {
  font-weight: 700;
  font-stretch: 115%;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  margin-right: auto;
}
.top nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
}
.top nav a {
  color: var(--ink);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  padding-block: 0.25rem;
  border-bottom: 2px solid transparent;
}
.top nav a:hover {
  border-bottom-color: var(--ch2);
}
.theme {
  font: 500 0.9rem var(--display);
  color: var(--ink);
  background: transparent;
  border: 1.5px solid var(--rule);
  border-radius: 3px;
  padding: 0.35rem 0.8rem;
  cursor: pointer;
}
.theme:hover {
  border-color: var(--ink);
}
.theme[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

/* The rail is the page-long trace: amber at the hardware end, cyan at the cloud end. */
main {
  position: relative;
  max-width: 76rem;
  margin: 0 auto;
  padding: 0 var(--pad) 0 var(--gutter);
}
main::before {
  content: "";
  position: absolute;
  left: var(--rail-x);
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, var(--ch1), var(--ch2));
}
main > section {
  position: relative;
  padding-block: clamp(3rem, 7vw, 5.5rem);
}
main > section > h2 {
  position: relative;
}
main > section > h2::before {
  content: "";
  position: absolute;
  left: calc(var(--rail-x) - var(--gutter) - 5px + 1px);
  top: calc(0.6em - 6px);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--ink);
}
h2,
h3 {
  font-family: var(--display);
  line-height: 1.15;
  margin: 0;
}
h2 {
  font-size: clamp(1.7rem, 3.6vw, 2.5rem);
  font-weight: 700;
  font-stretch: 112%;
  letter-spacing: -0.01em;
}
h3 {
  font-size: 1.25rem;
  font-weight: 700;
  font-stretch: 105%;
}
p {
  margin: 0 0 1em;
}
.section-note {
  color: var(--muted);
  max-width: 44rem;
  margin-top: 0.9rem;
}
.meta {
  font-family: var(--display);
  font-size: 0.92rem;
  color: var(--muted);
  margin: 0.35rem 0 1rem;
}

/* Hero */
.hero {
  padding-top: clamp(1.5rem, 4vw, 3rem);
}
.hero h1 {
  font-family: var(--display);
  font-weight: 800;
  font-stretch: 125%;
  font-size: clamp(2rem, 8.4vw, 5.9rem);
  line-height: 0.98;
  letter-spacing: -0.025em;
  margin: 0;
}
.signal {
  --sig-h: clamp(120px, 19vw, 210px);
  position: relative;
  height: calc(var(--sig-h) + 3rem);
  margin: clamp(1rem, 3vw, 2rem) 0 0 calc(var(--rail-x) - var(--gutter) + 1px);
}
.signal-svg {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: var(--sig-h);
  overflow: visible;
}
.tag {
  position: absolute;
  top: calc(var(--sig-h) + 0.4rem);
  font-family: var(--display);
  font-size: 0.85rem;
  line-height: 1.25;
  color: var(--muted);
  padding-right: 0.6rem;
}
.tag-analog { left: 0; width: 44%; padding-left: 0.6rem; }
.tag-sampled { left: 44%; width: 28%; }
.tag-cloud { left: 72%; width: 28%; }

.lead {
  font-family: var(--display);
  font-weight: 600;
  font-stretch: 108%;
  font-size: clamp(1.4rem, 3.2vw, 2.15rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
  max-width: 34rem;
  margin: 0.4rem 0 1.2rem;
}
.intro {
  max-width: 40rem;
  font-size: 1.2rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.6rem 0 0;
}
.button {
  display: inline-block;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  color: var(--bg);
  background: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 3px;
  padding: 0.7rem 1.2rem;
}
.button:hover {
  border-color: var(--link);
  background: var(--bg);
  color: var(--link);
}
.button.ghost {
  background: transparent;
  color: var(--ink);
}
.button.ghost:hover {
  border-color: var(--link);
  color: var(--link);
}

/* Layers: the border colour walks from amber to cyan, hardware to cloud. */
.layers {
  list-style: none;
  padding: 0;
  margin: 2.4rem 0 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2rem 1.5rem;
}
.layers li {
  --mix: 0%;
  border-top: 4px solid var(--ch1);
  border-top-color: color-mix(in srgb, var(--ch2) var(--mix), var(--ch1));
  padding-top: 1rem;
}
.layers li:nth-child(2) { --mix: 33%; }
.layers li:nth-child(3) { --mix: 66%; }
.layers li:nth-child(4) { --mix: 100%; }
.layers p {
  font-size: 1rem;
  line-height: 1.55;
  margin: 0.6rem 0 0;
}

/* Projects */
.project {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 1.5rem 3rem;
  padding-block: 2.4rem;
  border-top: 1px solid var(--rule);
}
#work > h2 + .project {
  margin-top: 2rem;
}
.project-text p:not(.meta) {
  max-width: 36rem;
}
.flagship h3 {
  font-size: clamp(1.7rem, 3.8vw, 2.7rem);
  font-stretch: 118%;
  font-weight: 800;
  letter-spacing: -0.015em;
}
.side-note {
  max-width: 50rem;
  margin-top: 1rem;
  margin-bottom: 0;
}
.side-note + .project {
  border-top: 0;
  padding-top: 1.4rem;
}

.specs > div,
.tools > div {
  display: grid;
  grid-template-columns: 9rem minmax(0, 1fr);
  gap: 1rem;
  padding: 0.7rem 0;
  border-top: 1px solid var(--rule);
}
.specs > div:last-child,
.tools > div:last-child {
  border-bottom: 1px solid var(--rule);
}
.specs,
.tools {
  margin: 0;
  font-family: var(--display);
  font-variant-numeric: tabular-nums;
}
dt {
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 500;
}
dd {
  margin: 0;
  font-size: 0.97rem;
  line-height: 1.45;
}

/* Experience */
.timeline {
  list-style: none;
  padding: 0;
  margin: 2rem 0 0;
}
.timeline li {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr);
  gap: 0.5rem 2rem;
  padding-block: 1.8rem;
  border-top: 1px solid var(--rule);
}
.when {
  font-family: var(--display);
  font-size: 0.95rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin: 0.2rem 0 0;
}
.timeline .meta {
  margin-bottom: 0.7rem;
}
.timeline p:not(.when):not(.meta):not(.stack) {
  max-width: 38rem;
}
.stack {
  font-family: var(--display);
  font-size: 0.92rem;
  color: var(--muted);
  margin: 0;
}
.edu-h {
  margin-top: 1.5rem;
  padding-top: 1.8rem;
  border-top: 1px solid var(--rule);
}
.edu {
  list-style: none;
  padding: 0;
  margin: 0.8rem 0 0;
}
.edu li {
  padding: 0.15rem 0;
}

/* Tools */
.tools {
  margin-top: 2rem;
  max-width: 46rem;
}
.tools > div {
  grid-template-columns: 11rem minmax(0, 1fr);
}

/* Contact */
.contact-lead {
  font-size: clamp(1.25rem, 2.6vw, 1.7rem);
  line-height: 1.4;
  max-width: 36rem;
  margin-top: 1.2rem;
}
.availability {
  font-family: var(--display);
  color: var(--muted);
  margin: 1.4rem 0 0;
}

footer {
  max-width: 76rem;
  margin: 0 auto;
  padding: 2rem var(--pad) 3rem var(--gutter);
  font-family: var(--display);
  font-size: 0.9rem;
  color: var(--muted);
}
footer p {
  margin: 0;
}

/* Trace animation: one orchestrated moment on load. */
.signal-svg path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sig-analog { stroke: var(--ch1); stroke-width: 3; }
.sig-ghost { stroke: var(--ch1); stroke-width: 2; stroke-dasharray: 2 7; opacity: 0.5; }
.sig-stair { stroke: var(--ch2); stroke-width: 3; }
.sig-link { stroke: var(--ch2); stroke-width: 3; }
.sig-cell { stroke: var(--ch2); stroke-width: 2.5; fill: color-mix(in srgb, var(--ch2) 14%, transparent); stroke-linejoin: round; }

.draw {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: draw 1.4s cubic-bezier(0.3, 0.6, 0.3, 1) forwards;
}
.draw.stair { animation-duration: 1s; animation-delay: 1.35s; }
.draw.link { animation-duration: 0.6s; animation-delay: 2.25s; }
.fade-in {
  opacity: 0;
  animation: fade 0.5s ease-out 2.7s forwards;
}
.signal-svg.static .draw { animation: none; stroke-dashoffset: 0; }
.signal-svg.static .fade-in { animation: none; opacity: 1; }

@keyframes draw {
  to { stroke-dashoffset: 0; }
}
@keyframes fade {
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .draw { animation: none; stroke-dashoffset: 0; }
  .fade-in { animation: none; opacity: 1; }
}

/* Smaller screens */
@media (max-width: 960px) {
  .layers {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .project {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 640px) {
  body { font-size: 1.05rem; }
  .layers { grid-template-columns: minmax(0, 1fr); }
  .timeline li { grid-template-columns: minmax(0, 1fr); }
  .specs > div,
  .tools > div { grid-template-columns: minmax(0, 1fr); gap: 0.15rem; }
  .tag { font-size: 0.78rem; }
  .top nav { order: 3; width: 100%; }
}
