:root {
  --bg: #fafaf7;
  --fg: #1a1a1a;
  --muted: #5a5a5a;
  --rule: #e6e3dc;
  --card: #f3f1ea;
  --accent: #1f6f5c;
  --max-width: 42rem;
  --wide-width: 60rem;
  --pad: 1.5rem;
  --serif: "Iowan Old Style", "Charter", "Georgia", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14140f;
    --fg: #ececec;
    --muted: #9a9a92;
    --rule: #2a2a23;
    --card: #1c1c16;
    --accent: #6fb89f;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 4rem var(--pad) 6rem;
}

/* ---- top nav ---- */
.topnav {
  width: min(100vw - 2 * var(--pad), var(--wide-width));
  margin: 0 auto 2rem;
  padding: 0.6rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--rule);
}
.topnav a {
  color: var(--muted);
  border-bottom: none;
  text-transform: uppercase;
  font-family: var(--mono);
  font-size: 0.78rem;
}
.topnav a:hover { color: var(--accent); }
.topnav a.current { color: var(--fg); }
.topnav .nav-name {
  margin-right: auto;
  color: var(--fg);
  text-transform: none;
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* break out of the narrow prose column, capped at --wide-width */
.repo-grid,
.mermaid,
.gallery,
.skill-grid,
.spec-grid {
  width: min(100vw - 2 * var(--pad), var(--wide-width));
  margin-left: calc(50% - min(100vw - 2 * var(--pad), var(--wide-width)) / 2);
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
a:hover { border-bottom-color: var(--accent); }

h1, h2, h3 {
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

h1 {
  font-size: 1.9rem;
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 3rem 0 1rem;
  font-weight: 500;
}

h3 {
  font-size: 1.05rem;
  margin: 0 0 0.4rem;
}

p { margin: 0 0 1rem; color: var(--fg); }

/* ---- intro ---- */
.intro { border-top: none; margin-top: 0; padding-top: 0; }

.intro-row {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--rule);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.intro-text { flex: 1; min-width: 0; }

.intro .tagline {
  color: var(--muted);
  font-size: 1.02rem;
  margin-top: 0.5rem;
  margin-bottom: 0;
}

.sparkline {
  display: block;
  width: 100%;
  height: 48px;
  margin-top: 1.5rem;
  color: color-mix(in srgb, var(--accent) 55%, transparent);
}

/* ---- sections ---- */
section {
  padding-top: 0.5rem;
  border-top: 1px solid var(--rule);
  margin-top: 2.5rem;
}

/* per-section accents for the 8 knowledge domains */
.domain                { --section-accent: var(--accent); }
.domain.markets        { --section-accent: #2d8771; }  /* teal — grid & markets */
.domain.fleet          { --section-accent: #c47633; }  /* amber — fuels & fleet */
.domain.renewables-mod { --section-accent: #c99a2c; }  /* gold — solar & wind */
.domain.forecast       { --section-accent: #6f63b3; }  /* indigo — ML & forecasting */
.domain.optim          { --section-accent: #3a72a8; }  /* blue — optimisation */
.domain.data           { --section-accent: #5a7a85; }  /* slate — data eng */
.domain.geo            { --section-accent: #5a8c47; }  /* green — geo & topology */
.domain.matlab         { --section-accent: #c4592c; }  /* MATLAB orange */

@media (prefers-color-scheme: dark) {
  .domain.markets        { --section-accent: #4ea591; }
  .domain.fleet          { --section-accent: #d6904f; }
  .domain.renewables-mod { --section-accent: #e0b449; }
  .domain.forecast       { --section-accent: #8a7fcf; }
  .domain.optim          { --section-accent: #5e95cc; }
  .domain.data           { --section-accent: #7e9aa6; }
  .domain.geo            { --section-accent: #7eaf68; }
  .domain.matlab         { --section-accent: #de7848; }
}

.domain h2 {
  color: var(--section-accent);
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.domain h2::before {
  content: "";
  flex: 0 0 auto;
  width: 1.75rem;
  height: 2px;
  background: var(--section-accent);
  border-radius: 1px;
}
.domain .skill-card {
  border-top: 2px solid var(--section-accent);
}
.domain .skill-card:hover {
  border-color: var(--section-accent);
  transform: translateY(-1px);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.domain p a {
  color: var(--section-accent);
  border-bottom-color: color-mix(in srgb, var(--section-accent) 35%, transparent);
}
.domain p a:hover { border-bottom-color: var(--section-accent); }

/* ---- career timeline ---- */
.timeline {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  border-left: 2px solid var(--rule);
}
.timeline li {
  position: relative;
  padding: 0.4rem 0 1rem 1.25rem;
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 1rem;
  align-items: baseline;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 0.85rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
}
.t-when {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.t-what { color: var(--fg); }
.t-what strong { font-weight: 600; }

/* ---- project blocks ---- */
.project { margin: 1.5rem 0 2rem; }
.project p { color: var(--muted); }

/* ---- mermaid ---- */
.mermaid {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1.5rem 1rem;
  margin: 1.25rem 0;
  text-align: center;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
}
.mermaid svg { max-width: 100%; height: auto; }

/* ---- repo grid ---- */
.repo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}
.repo {
  display: block;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.85rem 1rem;
  color: var(--fg);
  border-bottom: 1px solid var(--rule);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.repo:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.repo h3 {
  font-size: 0.95rem;
  margin: 0 0 0.3rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: baseline;
}
.repo .stars {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 400;
}
.repo p {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0 0 0.5rem;
  line-height: 1.45;
}
.repo .lang {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.more {
  text-align: right;
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

/* ---- elsewhere ---- */
.links {
  list-style: none;
  padding: 0;
  margin: 0;
}
.links li {
  padding: 0.35rem 0;
  color: var(--muted);
}
.links li a {
  color: var(--fg);
  border-bottom-color: var(--rule);
}
.links li a:hover {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

/* ---- footer ---- */
footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-size: 0.85rem;
  color: var(--muted);
}
footer a {
  color: var(--muted);
  border-bottom-color: var(--rule);
}

/* ---- skills / toolbox ---- */
.skill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}
.skill-card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.85rem 1rem;
}
.skill-card h3 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 0.5rem;
  font-weight: 500;
}
.skill-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.7;
  color: var(--fg);
}
.skill-card ul li { color: var(--muted); }
.skill-card ul li b { color: var(--fg); font-weight: 500; }

/* ---- spec table for hardware pages ---- */
.spec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.5rem 2rem;
  margin: 1rem 0 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.82rem;
}
.spec-grid dt {
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.25rem;
}
.spec-grid dd {
  margin: 0 0 0.5rem;
  color: var(--fg);
}

/* ---- gallery ---- */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 1rem 0.75rem;
  margin: 1rem 0;
}
.gallery a {
  display: flex;
  flex-direction: column;
  border-bottom: none;
  color: var(--fg);
}
.gallery a img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  border-radius: 4px;
  background: var(--card);
  transition: transform 0.3s ease, filter 0.3s ease;
}
.gallery a:hover img {
  transform: scale(1.02);
  filter: brightness(1.05);
}
.gallery .caption {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.45rem;
  text-align: center;
}
.gallery a:hover .caption { color: var(--accent); }

/* category tiles — used when we don't have hostable images */
.cat-tiles a.cat {
  position: relative;
  aspect-ratio: 4 / 3;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 1rem 1.1rem;
  border-radius: 4px;
  border-bottom: none;
  color: #fff;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.cat-tiles a.cat::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 40%, rgba(0,0,0,0.45) 100%);
  pointer-events: none;
}
.cat-tiles a.cat:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
}
.cat-tiles .cat-label,
.cat-tiles .cat-sub {
  position: relative;
  z-index: 1;
}
.cat-tiles .cat-label {
  font-family: var(--sans);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.cat-tiles .cat-sub {
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.85;
  margin-top: 0.25rem;
}
/* per-category palettes — moody, varied, tied loosely to subject */
.cat-portrait  { background: linear-gradient(135deg, #6b4a3a 0%, #b8896a 50%, #d4ad8c 100%); }
.cat-aerial    { background: linear-gradient(135deg, #1d3a5f 0%, #3e6f9c 50%, #7fb0d6 100%); }
.cat-corporate { background: linear-gradient(135deg, #2a3340 0%, #4a5566 50%, #7a8595 100%); }
.cat-sport     { background: linear-gradient(135deg, #7a2c1e 0%, #c2543a 50%, #e89368 100%); }
.cat-analogue  { background: linear-gradient(135deg, #3a3528 0%, #6e6249 50%, #b3a47e 100%); }
.cat-product   { background: linear-gradient(135deg, #2c4a3a 0%, #4f7a64 50%, #88b39c 100%); }
.gallery .placeholder {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  padding: 1rem;
  background: var(--card);
  border-radius: 4px;
}

/* ---- influences (research) ---- */
.influences {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}
.influence {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.85rem 1rem;
}
.influence h3 {
  font-size: 0.95rem;
  margin: 0 0 0.3rem;
}
.influence p {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 0.5rem;
  line-height: 1.45;
}
.influence a { font-size: 0.78rem; }

/* ---- mobile ---- */
@media (max-width: 560px) {
  main { padding: 2.5rem 1.25rem 4rem; }
  h1 { font-size: 1.55rem; }
  .intro-row { flex-direction: column; align-items: flex-start; gap: 1rem; }
  .avatar { width: 96px; height: 96px; }
  .timeline li {
    grid-template-columns: 1fr;
    gap: 0.1rem;
  }
}
