@font-face {
  font-family: "Space Grotesk";
  src: url(fonts/space-grotesk.woff2) format("woff2");
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url(fonts/jetbrains-mono.woff2) format("woff2");
  font-weight: 100 800;
  font-display: swap;
}

:root {
  --bg: #fbfbfa;
  --fg: #1d1d1f;
  --muted: #62626a;
  --rule: #e3e3e0;
  --panel: #f1f1ee;
  --raised: #ffffff;
  --accent: #c2410c;
  --glow: rgba(194, 65, 12, 0.28);
  /* The inferno colour map from the thermal camera firmware. */
  --inferno: linear-gradient(90deg, #000004, #160b39, #420a68, #6a176e, #932667,
                             #bc3754, #dd513a, #f37819, #fca50a, #f6d746, #fcffa4);
  --heat-text: linear-gradient(90deg, #6a176e, #bc3754, #e35d0b);
  --display: "Space Grotesk", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111113;
    --fg: #e8e8ea;
    --muted: #9a9aa3;
    --rule: #2a2a30;
    --panel: #1b1b20;
    --raised: #18181c;
    --accent: #fb923c;
    --glow: rgba(243, 120, 25, 0.25);
    --heat-text: linear-gradient(90deg, #d94a4a, #f37819, #f6d746);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
/* A strip of the colour map across the top of every page. */
body::before {
  content: "";
  display: block;
  height: 3px;
  background: var(--inferno);
}

main, .site-header .wrap, .site-footer {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px;
}

a { color: var(--accent); text-underline-offset: 3px; }
::selection { background: #f37819; color: #000; }

/* ------------------------------------------------------------ header -- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--rule);
}
.site-header .wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 56px;
}
.site-header a { text-decoration: none; }
.brand { font-family: var(--mono); font-weight: 700; color: var(--fg); letter-spacing: -0.02em; }
.brand span { color: var(--accent); }
.site-header nav { display: flex; gap: 20px; }
.site-header nav a { color: var(--muted); font-size: 15px; }
.site-header nav a:hover { color: var(--fg); }

/* ------------------------------------------------------------ footer -- */
.site-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 80px;
  padding-top: 20px;
  padding-bottom: 32px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font: 13px var(--mono);
}
.heat-bar { flex: 1; max-width: 160px; height: 6px; border-radius: 3px; background: var(--inferno); margin-left: auto; }

/* ------------------------------------------------------------ type ---- */
h1, h2, h3, h4 { line-height: 1.2; font-family: var(--display); font-weight: 700; letter-spacing: -0.015em; }
h1 { font-size: 2.3rem; margin: 40px 0 10px; }
.prose h2 { font-size: 1.6rem; margin-top: 56px; }
.prose h2::before {
  content: "";
  display: block;
  width: 48px;
  height: 4px;
  margin-bottom: 14px;
  border-radius: 2px;
  background: var(--inferno);
  background-size: 400% 100%;
  background-position: 70% 0;
}
.prose h3 { font-size: 1.25rem; margin-top: 36px; }
.prose h4 { font-size: 1.05rem; margin-top: 28px; }
.headerlink {
  margin-left: 8px;
  color: var(--muted);
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s;
}
h2:hover .headerlink, h3:hover .headerlink, h4:hover .headerlink, .headerlink:focus { opacity: 1; }

.lead { font-size: 1.15rem; color: var(--muted); margin: 0 0 16px; }
.crumb { margin: 32px 0 0; font: 13px var(--mono); }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a::before { content: "\2190  "; }
.crumb a:hover { color: var(--accent); }

.tags { list-style: none; padding: 0; margin: 0 0 24px; display: flex; flex-wrap: wrap; gap: 6px; }
.tags li {
  font: 12px/1 var(--mono);
  padding: 5px 8px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
}

.prose ul li::marker { color: var(--accent); }
.prose strong { color: var(--fg); }
.prose a:not(.headerlink):hover { text-decoration-thickness: 2px; }

/* ------------------------------------------------------------ hero ---- */
.hero {
  display: grid;
  gap: 32px;
  padding: 40px 0 24px;
}
@media (min-width: 720px) {
  .hero { grid-template-columns: 1.15fr 1fr; align-items: center; padding-top: 64px; }
}
.hero h1 { font-size: clamp(2.1rem, 5.5vw, 2.8rem); margin: 0 0 16px; }
.hot {
  background: var(--heat-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.eyebrow { font: 13px var(--mono); color: var(--muted); margin: 0 0 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.btn {
  display: inline-block;
  padding: 10px 18px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  color: var(--fg);
  background: var(--raised);
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.btn:hover { transform: translateY(-1px); border-color: var(--accent); }
.btn.primary {
  border-color: transparent;
  color: #1a0b1f;
  background: linear-gradient(90deg, #f37819, #fca50a);
  box-shadow: 0 6px 20px -8px var(--glow);
}
.btn.primary:hover { box-shadow: 0 10px 28px -8px var(--glow); }

/* A Cheap Yellow Display, more or less. */
.cyd {
  position: relative;
  padding: 14px 14px 30px;
  border-radius: 12px;
  background: linear-gradient(160deg, #f7d154, #e9b92a);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset, 0 24px 48px -20px rgba(221, 81, 58, 0.55),
              0 2px 6px rgba(0, 0, 0, 0.18);
  transform: rotate(1.5deg);
  transition: transform 0.3s;
}
.cyd:hover { transform: rotate(0deg) scale(1.01); }
.cyd .screen { padding: 6px; background: #0b0b0c; border-radius: 4px; }
.cyd canvas { display: block; width: 100%; aspect-ratio: 4 / 3; cursor: crosshair; touch-action: pan-y; }
.cyd .silk {
  position: absolute;
  left: 16px;
  bottom: 9px;
  font: 700 10px var(--mono);
  color: rgba(40, 30, 0, 0.6);
  letter-spacing: 0.04em;
}
.cyd .led {
  position: absolute;
  right: 18px;
  bottom: 12px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3cff6b;
  box-shadow: 0 0 8px 2px rgba(60, 255, 107, 0.7);
  animation: blink 2.4s ease-in-out infinite;
}
.cyd .led.touch { background: #4d8bff; box-shadow: 0 0 10px 3px rgba(77, 139, 255, 0.8); animation: none; }
@keyframes blink { 50% { opacity: 0.45; } }
.device { margin: 0; }
.device figcaption { margin-top: 14px; font-size: 13px; color: var(--muted); text-align: center; }
@media (prefers-reduced-motion: reduce) {
  .cyd, .cyd:hover { transform: none; }
  .cyd .led { animation: none; }
}

/* ------------------------------------------------------------ cards --- */
.cards { display: grid; gap: 20px; }
.card {
  position: relative;
  display: grid;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--raised);
  color: var(--fg);
  text-decoration: none;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
@media (min-width: 600px) { .card { grid-template-columns: 220px 1fr; } }
.card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 16px 40px -18px var(--glow); }
.card-visual { background: #000004; min-height: 160px; }
.card-visual canvas, .card-visual img { display: block; width: 100%; height: 100%; object-fit: cover; }
.card-visual canvas { aspect-ratio: 4 / 3; transition: filter 0.3s; filter: saturate(0.85); }
.card:hover .card-visual canvas { filter: saturate(1.15) brightness(1.08); }
.card-body { padding: 20px 22px; }
.card h3 { margin: 0 0 6px; font-size: 1.3rem; }
.card p { margin: 0 0 14px; color: var(--muted); font-size: 16px; }
.card .tags { margin: 0 0 14px; }
.more { font: 600 13px var(--mono); color: var(--accent); }
.more span { display: inline-block; transition: transform 0.2s; }
.card:hover .more span { transform: translateX(4px); }
@media (prefers-reduced-motion: reduce) { .card, .card:hover, .btn, .btn:hover { transform: none; } }

/* ------------------------------------------------------------ code ---- */
code {
  font-family: var(--mono);
  font-size: 0.84em;
  background: var(--panel);
  padding: 1px 5px;
  border-radius: 4px;
}
pre {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--rule);
  padding: 14px 16px;
  border-radius: 8px;
  overflow-x: auto;
  line-height: 1.55;
}
pre code { background: none; padding: 0; font-size: 13.5px; }
.copy {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 8px;
  border: 1px solid var(--rule);
  border-radius: 5px;
  background: var(--raised);
  color: var(--muted);
  font: 11px var(--mono);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
pre:hover .copy, .copy:focus-visible { opacity: 1; }
@media (hover: none) { .copy { opacity: 1; } }
.copy:hover { color: var(--fg); border-color: var(--accent); }

.prose table {
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 15px;
  margin: 16px 0;
}
.prose th, .prose td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.prose th { border-bottom-width: 2px; font-family: var(--display); }
.prose tbody tr:hover { background: var(--panel); }

.gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 8px 0 24px;
}
@media (max-width: 480px) { .gallery { grid-template-columns: 1fr; } }
.gallery figure { margin: 0; }
/* The first image leads, full width; the rest sit in the grid below it. */
.gallery figure:first-child { grid-column: 1 / -1; }
.gallery img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  border: 1px solid var(--rule);
  transition: transform 0.2s, box-shadow 0.2s;
}
.gallery a:hover img { transform: scale(1.02); box-shadow: 0 12px 30px -14px var(--glow); }
.gallery figcaption { font-size: 13px; color: var(--muted); margin-top: 6px; }

img { max-width: 100%; }

.home h2:first-child { margin-top: 32px; }
#projects { margin-top: 64px; }
#projects > h2 { font-size: 1.6rem; }
#projects > h2::before {
  content: "";
  display: block;
  width: 48px;
  height: 4px;
  margin-bottom: 14px;
  border-radius: 2px;
  background: var(--inferno);
  background-size: 400% 100%;
  background-position: 70% 0;
}

details {
  margin: 16px 0;
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--raised);
}
details summary { cursor: pointer; font-family: var(--mono); font-size: 14px; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "\25B8"; display: inline-block; margin-right: 8px; color: var(--accent); transition: transform 0.15s; }
details[open] summary::before { transform: rotate(90deg); }
details[open] summary { margin-bottom: 10px; }
details pre { margin: 0; }
