:root {
  --bg: #fbfaf7;
  --fg: #16140f;
  --muted: #16140f;
  --line: #d9d4c7;
  --card: #fbfaf7;
  --accent: #c2410c;
}
:root[data-theme="dark"] {
  --bg: #141311;
  --fg: #f3f0e9;
  --muted: #f3f0e9;
  --line: #3a3731;
  --card: #141311;
  --accent: #fb923c;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Fraunces", Georgia, serif;
  font-weight: 400;
  line-height: 1.6;
  font-size: 18px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Header sits on the page instead of on a bar */
.nav {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px max(20px, calc((100vw - 880px) / 2)) 34px;
  background: linear-gradient(var(--bg) 35%, transparent);
  pointer-events: none;
}
.nav > *, .nav nav a, #theme { pointer-events: auto; }
.brand { font-weight: 600; color: var(--fg); font-size: 1.3rem; }
.nav nav { display: flex; gap: 22px; align-items: center; font-size: 0.98rem; font-style: italic; }
.nav nav a { color: var(--fg); }
.nav nav a:hover { color: var(--accent); text-decoration: none; }
#theme {
  background: none; border: 0; color: var(--fg); padding: 0 2px;
  cursor: pointer; font-size: 1.1rem; font-family: inherit; font-style: normal;
}
#theme:hover { color: var(--accent); }

main { max-width: 880px; margin: 0 auto; padding: 0 20px; }
section { padding: 56px 0 8px; }
h1, h2, h3 { font-weight: 600; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(2.8rem, 7.5vw, 4.4rem); letter-spacing: -0.025em; }
h2 { font-size: 1.9rem; margin-bottom: 18px; letter-spacing: -0.01em; }
h3 { font-size: 1.2rem; }
h3 small { display: block; font-weight: 400; font-style: italic; font-size: 0.95rem; color: var(--fg); margin-top: 4px; }

.hero {
  display: grid; grid-template-columns: 1fr 260px; gap: 48px; align-items: center;
  padding: 40px 0 24px;
}
.eyebrow { color: var(--accent); font-style: italic; font-size: 1.05rem; margin: 0 0 10px; }
.lede { font-size: 1.2rem; margin: 20px 0 26px; max-width: 54ch; }
.links { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.btn {
  display: inline-block; padding: 8px 16px; border-radius: 2px;
  background: var(--fg); color: var(--bg); border: 1px solid var(--fg);
  font-size: 0.98rem;
}
.btn:hover { text-decoration: none; background: var(--accent); border-color: var(--accent); color: var(--bg); }
.btn.ghost { background: transparent; color: var(--fg); border-color: var(--fg); }
.btn.ghost:hover { background: transparent; color: var(--accent); border-color: var(--accent); }
.portrait { margin: 0; }
.portrait img, .fallback {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 28px;
  border: 1px solid var(--line); box-shadow: 0 18px 40px -22px rgba(0,0,0,.45);
  transform: rotate(2deg); transition: transform .3s ease;
}
.portrait img:hover { transform: rotate(0deg) scale(1.02); }
.fallback { display: grid; place-items: center; font-size: 4rem; color: var(--accent); }

.timeline { display: grid; gap: 26px; }
.timeline article { border-left: 1px solid var(--fg); padding: 2px 0 6px 22px; position: relative; }
.timeline article::before {
  content: ""; position: absolute; left: -5px; top: 9px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--accent);
}
.meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.92rem; font-style: italic; margin-bottom: 4px; }
.timeline p { margin: 10px 0 0; }
.timeline ul { margin: 8px 0 0; padding-left: 18px; }
.timeline li { margin-bottom: 5px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card {
  background: color-mix(in srgb, var(--card) 82%, transparent);
  border: 1px solid var(--fg); border-radius: 3px; padding: 20px;
  transition: border-color .2s ease, background .2s ease;
}
.card:hover { border-color: var(--accent); background: var(--card); }
.card p { margin: 8px 0 0; font-size: 0.98rem; }
.card .tag { color: var(--accent); font-size: 0.9rem; font-style: italic; margin-top: 4px; }

.skills { display: grid; grid-template-columns: 160px 1fr; gap: 10px 20px; margin: 0; }
.skills dt { font-weight: 600; }
.skills dd { margin: 0; }

footer { text-align: center; font-size: 0.92rem; font-style: italic; padding: 64px 0 40px; }

.reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }

/* Scroll progress bar */
.progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 20;
  background: var(--accent); transform: scaleX(var(--p, 0)); transform-origin: left;
}

/* Active nav link */
.nav nav a.active:not(#theme) { color: var(--accent); }

/* Hero entrance */
.hero-text > :not(h1) { animation: rise .7s cubic-bezier(.2,.7,.2,1) backwards; }
.hero-text .eyebrow { animation-delay: .05s; }
.hero-text .lede { animation-delay: .55s; }
.hero-text .links { animation-delay: .7s; }
.portrait { animation: rise .8s cubic-bezier(.2,.7,.2,1) .3s backwards; }
h1 .w { display: inline-block; animation: rise .7s cubic-bezier(.2,.7,.2,1) backwards; animation-delay: calc(.15s + var(--i) * .12s); }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }

/* Staggered children once a section reveals */
.reveal.in .stagger > * { animation: rise .6s ease backwards; animation-delay: calc(var(--i, 0) * 70ms); }

/* Three.js node network */
main, footer { position: relative; z-index: 2; }
#net { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 1; pointer-events: none; }

@media (max-width: 720px) {
  .hero { grid-template-columns: 1fr; padding-top: 24px; }
  .portrait { order: -1; max-width: 200px; }
  .nav nav a:not(#theme) { display: none; }
  .skills { grid-template-columns: 1fr; gap: 2px; }
  .skills dd { margin-bottom: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
  .hero-text > :not(h1), .portrait, h1 .w, .reveal.in .stagger > * { animation: none; }
}

/* Three.js aurora shader (faint) */
#aurora { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 0; pointer-events: none; }
