/* Tokens. light-dark() follows the OS; the toggle pins color-scheme via [data-theme]. */
:root {
  color-scheme: light dark;
  --bg: light-dark(#f5f4ef, #0a0a09);
  --bg-raised: light-dark(#ffffff, #121211);
  --fg: light-dark(#151513, #ecebe5);
  --muted: light-dark(#5d5c56, #8e8d86);
  --line: light-dark(rgb(21 21 19 / .12), rgb(236 235 229 / .1));
  --line-strong: light-dark(rgb(21 21 19 / .26), rgb(236 235 229 / .22));
  --accent: light-dark(#0062e0, #00aaff);
  --accent-ink: light-dark(#ffffff, #0a0a09);
  --nebula: light-dark(#7a5cff, #8b5cf6);
  --star: light-dark(rgb(21 21 19 / .3), rgb(236 235 229 / .75));
  --star-bright: light-dark(rgb(0 98 224 / .45), #9fdcff);
  --twinkle: light-dark(transparent, #9fdcff); /* glow halos smear on cream, so night only */
  --serif: 'Instrument Serif', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --sans: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --radius: 18px;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 1rem/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s, color .3s;
}
/* Film grain over everything; pointer-events off so it never blocks clicks. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
/* Starfield: one tile masked at two scales; the bigger, sparser layer drifts faster on scroll. */
.sky::before, .sky::after {
  content: "";
  position: fixed;
  inset: 0 0 -600px;
  z-index: -1;
  pointer-events: none;
  background: var(--star);
  -webkit-mask: url(assets/stars.svg) 0 0 / 800px;
  mask: url(assets/stars.svg) 0 0 / 800px;
}
.sky::after { --d: -600px; background: var(--star-bright); -webkit-mask-size: 1700px; mask-size: 1700px; }
/* Three sparse glow layers that fade out of phase read as single stars twinkling. */
.twinkle {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: var(--twinkle);
  -webkit-mask: url(assets/twinkle.svg) var(--p) / var(--s);
  mask: url(assets/twinkle.svg) var(--p) / var(--s);
}
.meteor {
  position: fixed;
  z-index: -1;
  top: var(--y);
  left: var(--x);
  width: 160px;
  height: 1px;
  rotate: -32deg;
  opacity: 0;
  pointer-events: none;
  background: linear-gradient(90deg, var(--star-bright), transparent);
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.container { width: min(100% - clamp(2rem, 8vw, 6rem), 1180px); margin-inline: auto; }
.mono { font-family: var(--mono); font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; }
em { font-family: var(--serif); font-style: italic; font-weight: 400; }

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 200;
  padding: .5rem 1rem;
  border-radius: 999px;
  background: var(--fg);
  color: var(--bg);
}
.skip:focus { top: 1rem; }

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in oklab, var(--bg) 75%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--line);
}
.nav { display: flex; align-items: center; gap: 1rem; height: 64px; }
.brand { display: flex; align-items: center; gap: .6rem; margin-right: auto; font-weight: 500; font-size: .9375rem; text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--fg);
  color: var(--bg);
  font: italic 400 1.2rem/1 var(--serif);
}
.nav-links { display: flex; gap: 1.75rem; margin: 0; padding: 0; list-style: none; }
.nav-links a { color: var(--muted); font-size: .875rem; text-decoration: none; transition: color .2s; }
.nav-links a:hover { color: var(--fg); }
.theme-toggle {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  transition: transform .4s;
}
.theme-toggle:hover { transform: rotate(180deg); }

/* Hero */
.hero { position: relative; isolation: isolate; overflow: hidden; padding: clamp(4rem, 11vw, 8.5rem) 0 clamp(3rem, 6vw, 5rem); }
.hero::after {
  content: "";
  position: absolute;
  z-index: -1;
  top: -35vmax;
  right: -25vmax;
  width: 70vmax;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(closest-side at 36% 64%, color-mix(in oklab, var(--nebula) 16%, transparent), transparent),
    radial-gradient(closest-side, color-mix(in oklab, var(--accent) 20%, transparent), transparent);
  filter: blur(40px); /* hides the crease where the linear falloff meets the edge */
}
/* Orrery: a planet with moons on slow orbits in the hero's top-right. */
.orrery { position: absolute; z-index: -1; top: clamp(5rem, 12vw, 9rem); right: clamp(2rem, 16vw, 15rem); width: clamp(84px, 13vw, 180px); aspect-ratio: 1; }
.planet {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 70% 28%, color-mix(in oklab, var(--accent) 30%, var(--bg-raised)), var(--bg) 70%);
  box-shadow: inset -8px 8px 16px -6px color-mix(in oklab, var(--accent) 80%, transparent), 0 0 70px -10px color-mix(in oklab, var(--accent) 45%, transparent);
}
.orbit { position: absolute; inset: calc(50% - var(--r) * 50%); border: 1px solid var(--line); border-radius: 50%; rotate: var(--a); }
.orbit.dashed { border-style: dashed; }
.orbit::after { content: ""; position: absolute; top: calc(50% - 3px); left: -3.5px; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.orbit.glow::after { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.hero-grid { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: clamp(2.5rem, 6vw, 5rem); }
.eyebrow { margin: 0; color: var(--muted); }
.display {
  margin: .35em 0 .4em;
  font: 400 clamp(3.5rem, 11vw, 9rem)/.9 var(--serif);
  letter-spacing: -.035em;
}
.display em { display: block; }
.lede { max-width: 38ch; margin: 0; color: var(--muted); font-size: clamp(1.0625rem, 1.8vw, 1.3rem); line-height: 1.55; }
.lede em { color: var(--fg); font-size: 1.12em; line-height: 1; }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 2.25rem; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  height: 46px;
  padding: 0 1.35rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: .9375rem;
  font-weight: 500;
  text-decoration: none;
  transition: background-color .2s, border-color .2s, color .2s;
}
.btn:hover { border-color: var(--fg); }
.btn-primary { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.id-card {
  width: 290px;
  padding: 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in oklab, var(--bg-raised) 70%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.id-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; }
.id-card img {
  width: 112px;
  height: 112px;
  border-radius: 12px;
  object-fit: cover;
  filter: grayscale(1) contrast(1.06);
  transition: filter .5s;
}
.id-card:hover img { filter: none; }
.id-status { display: flex; align-items: center; gap: .5rem; margin: 0; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.id-card dl { display: grid; gap: .6rem; margin: 1.1rem 0 0; font-size: .8125rem; }
.id-card dl div { display: flex; justify-content: space-between; gap: 1rem; padding-top: .6rem; border-top: 1px dashed var(--line-strong); }
.id-card dt { color: var(--muted); white-space: nowrap; }
.id-card dd { margin: 0; text-align: right; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); margin: clamp(3.5rem, 8vw, 6rem) 0 0; border-block: 1px solid var(--line); }
.stats > div { display: flex; flex-direction: column-reverse; justify-content: flex-end; gap: .6rem; padding: 1.5rem; }
.stats > div:first-child { padding-left: 0; }
.stats > div + div { border-left: 1px solid var(--line); }
.stats dd { margin: 0; font: 400 clamp(2.5rem, 5vw, 3.75rem)/1 var(--serif); letter-spacing: -.02em; }
.stats dt { max-width: 22ch; color: var(--muted); font-size: .875rem; line-height: 1.45; }

/* Sections */
.section { padding-block: clamp(5rem, 11vw, 8.5rem); border-top: 1px solid var(--line); }
.section-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1.5rem 3rem; margin-bottom: clamp(2.5rem, 5vw, 4rem); }
.label { display: flex; gap: .75rem; margin: 0; color: var(--muted); }
.label span { color: var(--accent); }
.display-2 { margin: .9rem 0 0; font: 400 clamp(2.5rem, 6vw, 4.75rem)/1 var(--serif); letter-spacing: -.03em; }
.section-note { max-width: 34ch; margin: 0; color: var(--muted); }

/* Selected work */
.work { display: grid; grid-template-columns: repeat(6, 1fr); gap: 1rem; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: .9rem;
  padding: clamp(1.25rem, 2.4vw, 1.75rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-raised);
  transition: border-color .3s;
}
/* Spotlight that follows the pointer; --x/--y come from script.js. */
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(420px circle at var(--x, 50%) var(--y, 0%), color-mix(in oklab, var(--accent) 12%, transparent), transparent 65%);
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
}
.card:hover { border-color: var(--line-strong); }
.card:hover::before { opacity: 1; }
.card > * { position: relative; }
.card-meta { display: flex; justify-content: space-between; gap: 1rem; margin: 0; color: var(--muted); }
.card h3 { margin: .25rem 0 0; font: 400 clamp(1.6rem, 2.4vw, 2rem)/1.08 var(--serif); letter-spacing: -.015em; }
.card p:not(.card-meta) { margin: 0; color: var(--muted); font-size: .9375rem; }
.tags { display: flex; flex-wrap: wrap; gap: .4rem; margin: auto 0 0; padding: .5rem 0 0; list-style: none; }
.tags li { padding: .2rem .55rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font: 400 .6875rem/1.5 var(--mono); }
/* A link in a card's title stretches over the whole card, so a click anywhere on it opens the site. */
.card h3:has(a) { position: static; }
.card h3 a { color: inherit; text-decoration: none; }
.card h3 a::after { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: var(--radius); }
.card h3 a:focus-visible { outline: none; }
.card h3 a:focus-visible::after { outline: 2px solid var(--accent); outline-offset: 3px; }
.card:hover h3 a { color: var(--accent); }

/* Grows to absorb the extra height when a card stretches to match its row. */
.viz { position: relative; flex: 1 0 128px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.shot { width: 100%; height: auto; border: 1px solid var(--line); border-radius: 12px; }
/* Above the stretched title link (z-index 1), so its controls get the clicks. */
video.shot { z-index: 2; background: var(--bg); }
.candles { position: absolute; inset: 0; width: 100%; height: 100%; padding: 10px 6px; }
.candles .wick { stroke: var(--muted); stroke-width: 1; }
.candles .up { fill: var(--accent); }
.candles .down { fill: var(--muted); }
.candles .bos { stroke: var(--line-strong); stroke-dasharray: 3 3; }
.candles text { fill: var(--muted); font: 7px var(--mono); letter-spacing: .08em; }

/* Experience */
.timeline { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.role { display: grid; grid-template-columns: 220px 1fr; gap: 2rem; padding: 2.25rem 0; border-bottom: 1px solid var(--line); }
.role-dates { margin: 0; padding-top: .55rem; color: var(--muted); }
.role h3 { margin: 0; font: 400 clamp(1.8rem, 3vw, 2.25rem)/1.1 var(--serif); letter-spacing: -.015em; }
.role-title { display: block; margin-top: .4rem; color: var(--muted); font: 400 .9375rem/1.4 var(--sans); letter-spacing: 0; }
.role-blurb { max-width: 62ch; margin: 1rem 0 .75rem; }
.role-points { display: grid; gap: .45rem; max-width: 72ch; margin: 0; padding-left: 1.1rem; color: var(--muted); }
.role-points li::marker { color: var(--accent); }

/* Stack */
.stack { display: grid; grid-template-columns: repeat(2, 1fr); column-gap: 3rem; margin: 0; }
.stack > div { display: grid; grid-template-columns: 10rem 1fr; gap: 1rem; padding: 1.1rem 0; border-top: 1px solid var(--line); }
.stack dt { padding-top: .2rem; color: var(--muted); }
.stack dd { margin: 0; }

/* Contact, with a planet horizon rising from the bottom edge. */
.contact { position: relative; isolation: isolate; overflow: hidden; padding-bottom: clamp(10rem, 22vw, 17rem); }
.contact::after {
  content: "";
  position: absolute;
  z-index: -1;
  top: calc(100% - clamp(4rem, 9vw, 8rem));
  left: 50%;
  width: max(1400px, 160vw);
  aspect-ratio: 1;
  translate: -50% 0;
  border-radius: 50%;
  background: var(--bg);
  box-shadow:
    0 0 0 1px color-mix(in oklab, var(--accent) 70%, transparent),
    0 0 90px 4px color-mix(in oklab, var(--accent) 30%, transparent),
    inset 0 24px 60px -30px color-mix(in oklab, var(--accent) 55%, transparent);
}
.contact .display-2 { max-width: 15ch; }
.contact .display-2 em { white-space: nowrap; }
.big-link {
  display: inline-flex;
  align-items: baseline;
  gap: .6rem;
  margin-top: 2.5rem;
  padding-bottom: .3rem;
  border-bottom: 1px solid var(--line-strong);
  font: 400 clamp(1.5rem, 5.5vw, 4rem)/1.15 var(--serif);
  text-decoration: none;
  overflow-wrap: anywhere;
  transition: color .2s, border-color .2s;
}
.big-link span { transition: transform .3s; }
.big-link:hover { color: var(--accent); border-color: var(--accent); }
.big-link:hover span { transform: translate(4px, -4px); }
.links { display: flex; flex-wrap: wrap; gap: .5rem 2rem; margin: 2rem 0 0; padding: 0; list-style: none; color: var(--muted); font: 400 .8125rem/1.5 var(--mono); text-transform: uppercase; letter-spacing: .06em; }
.links a { text-decoration: none; }
.links a:hover { color: var(--fg); }

/* Opaque so the stars stop at the horizon above it. */
.site-footer { background: var(--bg); padding: 2rem 0; border-top: 1px solid var(--line); color: var(--muted); font-size: .8125rem; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 2rem; }
.footer-inner p { margin: 0; }
.footer-inner a { text-decoration: none; }
.footer-inner a:hover { color: var(--fg); }

/* Motion: everything animated lives here, so reduced-motion users get a static page. */
@media (prefers-reduced-motion: no-preference) {
  .rise { animation: rise .9s cubic-bezier(.2, .7, .2, 1) both; animation-delay: calc(var(--i, 0) * 90ms); }
  .dot { animation: pulse 2.4s ease-out infinite; }
  .orbit { animation: spin var(--t) linear infinite; }
  /* Negative delays start each layer mid-cycle so they never pulse together. */
  .twinkle { animation: twinkle var(--t) ease-in-out calc(var(--t) * -.37) infinite alternate; }
  .meteor { animation: meteor var(--t) linear var(--d) infinite; }
  /* Scroll-linked reveal; browsers without view timelines just show the content. */
  @supports (animation-timeline: view()) {
    .reveal { animation: rise linear both; animation-timeline: view(); animation-range: entry 0% entry 100%; }
    .sky::before, .sky::after { animation: drift linear both; animation-timeline: scroll(root); }
  }
}
@keyframes rise { from { opacity: 0; transform: translateY(24px); } }
@keyframes spin { to { transform: rotate(1turn); } }
@keyframes twinkle { from { opacity: .1; } }
@keyframes meteor { 1% { opacity: 1; } 7%, 100% { opacity: 0; transform: translateX(-480px); } }
@keyframes drift { to { transform: translateY(var(--d, -250px)); } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--accent) 60%, transparent); } 100% { box-shadow: 0 0 0 10px transparent; } }

@media (max-width: 960px) {
  .hero-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats > div:nth-child(odd) { padding-left: 0; border-left: 0; }
  .stats > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .work { grid-template-columns: repeat(2, 1fr); }
  .work > * { grid-column: auto; }
  .stack { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .nav-links li:not(:last-child) { display: none; }
  .work { grid-template-columns: 1fr; }
  .role { grid-template-columns: 1fr; gap: .5rem; padding: 1.75rem 0; }
  .role-dates { padding-top: 0; }
  .stack > div { grid-template-columns: 1fr; gap: .35rem; }
  .stats > div { padding: 1.25rem 1rem; }
  .id-card { width: 100%; }
  .orbit.dashed { display: none; }
}

/* Job-hunting additions: a result line and project links inside cards, and the contact note. */
.card p.card-result { color: var(--fg); padding-top: .75rem; border-top: 1px dashed var(--line-strong); }
.card p.card-links { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; font-size: .875rem; }
.card-links a { color: var(--fg); text-underline-offset: 3px; }
.card-links a:hover { color: var(--accent); }
.contact-note { max-width: 46ch; margin: 1.5rem 0 0; color: var(--muted); font-size: clamp(1.0625rem, 1.6vw, 1.2rem); }
.nowrap { white-space: nowrap; }
