:root {
  --bg: #f5f2ea;
  --surface: #fffdf8;
  --ink: #16161a;
  --muted: #5e5e66;
  --line: #e0dbcf;
  --accent: #3a46e0;
  --accent-soft: rgba(58, 70, 224, 0.07);
  --trail: #c4622d;
  --topo: 22, 22, 26;
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --max: 1080px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0e11;
    --surface: #16161b;
    --ink: #ededf0;
    --muted: #9c9ca6;
    --line: #29292f;
    --accent: #8b93ff;
    --accent-soft: rgba(139, 147, 255, 0.09);
    --trail: #f08a4b;
    --topo: 237, 237, 240;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0e11;
  --surface: #16161b;
  --ink: #ededf0;
  --muted: #9c9ca6;
  --line: #29292f;
  --accent: #8b93ff;
  --accent-soft: rgba(139, 147, 255, 0.09);
  --trail: #f08a4b;
  --topo: 237, 237, 240;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s, color 0.3s;
  overflow-x: hidden;
}
a { color: inherit; }
::selection { background: var(--accent); color: var(--bg); }
.mono { font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.03em; }

.progress {
  position: fixed; top: 0; left: 0; height: 2px; width: 0; z-index: 20;
  background: linear-gradient(90deg, var(--accent), var(--trail));
}

/* Nav */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px max(24px, calc((100vw - var(--max)) / 2 + 24px));
  transition: background 0.3s, border-color 0.3s;
  border-bottom: 1px solid transparent;
}
.nav.scrolled {
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom-color: var(--line);
}
.brand { font-family: var(--serif); font-size: 1.6rem; text-decoration: none; }
.nav nav { display: flex; align-items: center; gap: 24px; }
.nav nav a { text-decoration: none; font-size: 0.88rem; color: var(--muted); transition: color 0.2s; }
.nav nav a:hover, .nav nav a.active { color: var(--ink); }
.theme-toggle {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; transition: transform 0.3s;
}
.theme-toggle:hover { transform: rotate(-20deg); }

/* Hero */
.hero {
  position: relative; min-height: 100vh; min-height: 100svh;
  display: flex; align-items: center; overflow: hidden;
}
#topo { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 70% 60% at 30% 50%, var(--bg) 20%, transparent 75%);
  opacity: 0.85;
}
.hero-inner {
  position: relative; z-index: 1; width: 100%;
  max-width: var(--max); margin: 0 auto; padding: 120px 24px 80px;
}
.eyebrow { color: var(--muted); margin: 0 0 24px; display: flex; align-items: center; gap: 10px; }
.dot {
  width: 8px; height: 8px; border-radius: 50%; background: #2fbf71;
  box-shadow: 0 0 0 0 rgba(47, 191, 113, 0.6); animation: pulse 2.4s infinite;
}
@keyframes pulse { 70% { box-shadow: 0 0 0 10px rgba(47, 191, 113, 0); } 100% { box-shadow: 0 0 0 0 rgba(47, 191, 113, 0); } }
.hero h1 {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(4rem, 13vw, 9.5rem); line-height: 0.88;
  letter-spacing: -0.025em; margin: 0 0 28px;
}
.hero h1 em { color: var(--accent); }
.rotator { font-family: var(--serif); font-size: clamp(1.6rem, 3.6vw, 2.4rem); margin: 0 0 18px; line-height: 1.2; }
.rot-word {
  font-style: italic; display: inline-block; border-bottom: 2px solid var(--trail);
  transition: opacity 0.35s, transform 0.35s;
}
.rot-word.out { opacity: 0; transform: translateY(8px); }
.lede { font-size: clamp(1rem, 1.8vw, 1.15rem); max-width: 600px; color: var(--muted); margin: 0 0 36px; }
.cta { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-block; padding: 11px 20px; border-radius: 999px;
  border: 1px solid var(--line); text-decoration: none; font-size: 0.92rem; font-weight: 500;
  background: var(--surface); transition: transform 0.15s, border-color 0.2s, box-shadow 0.2s;
}
.btn:hover { transform: translateY(-2px); border-color: var(--ink); box-shadow: 0 6px 20px -8px rgba(0,0,0,0.25); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.ghost { background: transparent; }

.coords {
  position: absolute; z-index: 1; right: max(24px, calc((100vw - var(--max)) / 2 + 24px)); bottom: 28px;
  display: flex; gap: 20px; color: var(--muted);
}
.coords b { color: var(--trail); font-weight: 500; }
.scroll-hint {
  position: absolute; z-index: 1; left: max(24px, calc((100vw - var(--max)) / 2 + 24px)); bottom: 28px;
  color: var(--muted); text-decoration: none; animation: bob 2s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateY(4px); } }

main { max-width: var(--max); margin: 0 auto; padding: 0 24px; }

/* Stats */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.stats div { padding: 32px 20px 32px 0; display: flex; flex-direction: column; gap: 6px; }
.stats div + div { padding-left: 24px; border-left: 1px solid var(--line); }
.num { font-family: var(--serif); font-size: clamp(2.2rem, 4.5vw, 3.2rem); line-height: 1; }
.label { font-size: 0.85rem; color: var(--muted); }

/* Sections */
.section { padding: 112px 0 0; }
.section-title {
  font-family: var(--serif); font-weight: 400; font-size: clamp(2rem, 4.5vw, 2.8rem);
  margin: 0 0 16px; display: flex; align-items: baseline; gap: 16px; line-height: 1.1;
}
.section-title .mono { color: var(--accent); }
.section-sub { color: var(--muted); max-width: 620px; margin: 0 0 40px; }
.section > .section-title:only-of-type { margin-bottom: 40px; }
#work .section-title, #experience .section-title, #research .section-title, #recognition .section-title, #education .section-title, .section:last-of-type .section-title { margin-bottom: 40px; }

/* Cards with cursor spotlight */
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.card {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 28px; transition: transform 0.25s, border-color 0.25s;
}
.card::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.3s;
  background: radial-gradient(320px circle at var(--mx, 50%) var(--my, 50%), var(--accent-soft), transparent 70%);
}
.card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.card:hover::before { opacity: 1; }
.card-icon {
  width: 40px; height: 40px; border-radius: 12px; margin-bottom: 18px;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent);
}
.card-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.card h3 { margin: 0 0 8px; font-size: 1.1rem; font-weight: 600; position: relative; }
.card p { margin: 0; color: var(--muted); font-size: 0.95rem; position: relative; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags span {
  font-family: var(--mono); font-size: 0.72rem; padding: 4px 10px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
}

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.job {
  display: grid; grid-template-columns: 180px 1fr; gap: 24px;
  padding: 28px 0; border-top: 1px solid var(--line);
  transition: background 0.2s;
}
.job .when { color: var(--muted); padding-top: 4px; }
.job h3 { margin: 0; font-size: 1.15rem; font-weight: 600; }
.job .at { color: var(--muted); font-weight: 400; }
.job .where { margin: 2px 0 10px; color: var(--muted); font-size: 0.88rem; }
.job ul { margin: 0; padding-left: 18px; }
.job li { margin: 4px 0; font-size: 0.95rem; }
.job li::marker { color: var(--accent); }
.job.featured .what { background: var(--accent-soft); border-radius: 18px; padding: 24px; margin: -8px 0; }
.job.featured .tags { margin-top: 16px; }

/* Shared photo button */
.photo {
  display: block; position: relative; padding: 0; border: 0; margin: 0; width: 100%;
  border-radius: 16px; overflow: hidden; cursor: zoom-in; background: var(--line);
}
.photo img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 0.6s ease; }
.photo:hover img { transform: scale(1.04); }
.photo:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Recognition */
.awards { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.award { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 12px; }
.award .photo { aspect-ratio: 4 / 3; }
.award figcaption { padding: 18px 12px 10px; }
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  background: var(--trail); color: #fff; font-size: 0.7rem;
}
.award h3 { margin: 12px 0 6px; font-size: 1.15rem; font-weight: 600; }
.award p { margin: 0; color: var(--muted); font-size: 0.95rem; }

/* Off the clock */
.life-card {
  display: grid; gap: 40px; align-items: center;
  padding: 20px; border-radius: 28px; background: var(--surface); border: 1px solid var(--line);
}
.life-card + .life-card { margin-top: 20px; }
.life-card.trail { grid-template-columns: 0.85fr 1fr; }
.life-card.music { grid-template-columns: 1fr 1.15fr; }
.life-card .life-text { padding: 16px 20px 16px 4px; }
.life-card.music .life-text { padding: 16px 4px 16px 20px; }
.life-kicker { color: var(--trail); margin: 0 0 6px; text-transform: uppercase; }
.life-lede { font-family: var(--serif); font-style: italic; font-size: clamp(2.2rem, 5vw, 3.4rem); line-height: 1; margin: 0 0 16px; }
.life-text > p:not(.life-kicker):not(.life-lede) { color: var(--muted); }
.trail .life-lede { color: var(--trail); }
.music .life-lede { color: var(--accent); }
.stage-note { color: var(--ink) !important; margin-top: 18px; }

.hike-hero { aspect-ratio: 3 / 4; border-radius: 20px; }
.pin {
  position: absolute; left: 14px; bottom: 14px; padding: 6px 12px; border-radius: 999px;
  background: rgba(14, 14, 17, 0.6); color: #fff; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}

.profile { margin: 24px 0 0; color: var(--trail); }
.profile svg { width: 100%; height: 130px; display: block; overflow: visible; }
.profile .grid line { stroke: var(--line); stroke-dasharray: 3 5; }
.profile .area { fill: url(#fill); opacity: 0; transition: opacity 1.2s 0.8s; }
.profile .line {
  fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round;
  stroke-dasharray: 1000; stroke-dashoffset: 1000; transition: stroke-dashoffset 2.2s ease-out;
}
.profile .summit { opacity: 0; transition: opacity 0.5s 1.6s; }
.profile .summit line { stroke: var(--ink); stroke-width: 1.5; }
.profile .summit path { fill: currentColor; }
.in .profile .line { stroke-dashoffset: 0; }
.in .profile .area, .in .profile .summit { opacity: 1; }
.profile figcaption { position: relative; height: 1.4em; color: var(--muted); margin-top: 8px; }
.profile figcaption span { position: absolute; top: 0; }
.profile figcaption span:nth-child(1) { left: 0; }
.profile figcaption span:nth-child(2) { left: 66.67%; transform: translateX(-50%); color: var(--trail); }
.profile figcaption span:nth-child(3) { right: 0; }

.trail-log { margin-top: 24px; }
.trail-log > p { margin: 0 0 6px; color: var(--muted); }
.trail-log ul { list-style: none; margin: 0; padding: 0; }
.trail-log li { display: flex; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line); font-size: 0.95rem; }
.trail-log li .mono { color: var(--muted); }
.trail-log li.soon { color: var(--muted); font-style: italic; }

.stage-grid { display: grid; grid-template-columns: 0.8fr 1fr; grid-template-rows: 1fr 1fr; gap: 12px; height: 460px; }
.stage-grid .tall { grid-row: span 2; }
.stage-grid .photo { height: 100%; }

.inline-link { color: var(--accent); text-decoration: none; white-space: nowrap; }
.inline-link:hover { text-decoration: underline; }

/* Lightbox */
.lightbox {
  border: 0; padding: 0; background: transparent; max-width: 92vw; max-height: 92vh; overflow: visible;
}
.lightbox::backdrop { background: rgba(8, 8, 10, 0.85); backdrop-filter: blur(4px); }
.lightbox img { display: block; max-width: 92vw; max-height: 88vh; border-radius: 12px; }
.lb-close {
  position: absolute; top: -14px; right: -14px; width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: #fff; color: #111; font-size: 1.3rem; line-height: 1; cursor: pointer;
}

/* Education */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 48px; }
.edu { padding: 20px 0; border-top: 1px solid var(--line); }
.edu .when { margin: 0 0 4px; color: var(--muted); }
.edu h3 { margin: 0 0 4px; font-size: 1.1rem; font-weight: 600; }
.edu p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.edu ul { margin: 8px 0 0; padding-left: 18px; font-size: 0.92rem; }
.edu li::marker { color: var(--accent); }

/* Skills */
.skills { display: grid; grid-template-columns: 180px 1fr; margin: 0; }
.skills dt, .skills dd { padding: 16px 0; border-top: 1px solid var(--line); margin: 0; }
.skills dt { font-weight: 600; font-size: 0.95rem; }
.skills dd { color: var(--muted); font-size: 0.95rem; }

/* Marquee */
.marquee { margin-top: 112px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); overflow: hidden; padding: 22px 0; }
.marquee-track { display: flex; gap: 32px; width: max-content; animation: marquee 40s linear infinite; }
.marquee-track span { font-family: var(--serif); font-size: clamp(1.6rem, 3.5vw, 2.6rem); white-space: nowrap; }
.marquee-track span:nth-child(even) { color: var(--trail); font-size: 1.4rem; align-self: center; }
@keyframes marquee { to { transform: translateX(-50%); } }

/* Contact */
.contact { padding: 120px 24px 96px; text-align: center; max-width: var(--max); margin: 0 auto; }
.contact h2 { font-family: var(--serif); font-weight: 400; font-size: clamp(2.6rem, 8vw, 5.5rem); margin: 0 0 14px; line-height: 0.95; }
.contact h2 em { color: var(--accent); }
.contact p { color: var(--muted); margin: 0 0 28px; }
.big-link {
  display: inline-block; font-family: var(--serif); font-style: italic;
  font-size: clamp(1.4rem, 4vw, 2.2rem); color: var(--accent);
  text-decoration: none; border-bottom: 1px solid currentColor; margin-bottom: 32px;
  overflow-wrap: anywhere; transition: color 0.2s;
}
.big-link:hover { color: var(--trail); }
.contact .cta { justify-content: center; }

.footer { text-align: center; color: var(--muted); padding: 24px; border-top: 1px solid var(--line); }

/* Reveal on scroll */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.8s ease, transform 0.8s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
  .marquee-track, .dot, .scroll-hint { animation: none; }
  .profile .line { stroke-dashoffset: 0; transition: none; }
  .profile .area, .profile .summit { opacity: 1; transition: none; }
}

/* Tablet */
@media (max-width: 900px) {
  .life-card.trail, .life-card.music, .awards { grid-template-columns: 1fr; }
  .life-card .life-text, .life-card.music .life-text { padding: 8px 8px 12px; }
  .life-card.music .life-text { order: -1; }
  .hike-hero { aspect-ratio: 4 / 5; }
}

/* Mobile */
@media (max-width: 720px) {
  .nav { padding: 14px 16px; }
  .nav nav { gap: 14px; }
  .nav nav a:not(:last-of-type) { display: none; }
  .hero-inner { padding: 100px 16px 96px; }
  .coords { right: 16px; bottom: 22px; gap: 12px; font-size: 0.68rem; }
  .coords span:first-child { display: none; }
  .scroll-hint { left: 16px; bottom: 22px; }
  main { padding: 0 16px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats div:nth-child(3) { padding-left: 0; border-left: 0; }
  .stats div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .cards, .two-col { grid-template-columns: 1fr; }
  .job, .skills { grid-template-columns: 1fr; gap: 6px; }
  .skills dd { border-top: 0; padding-top: 0; }
  .section { padding-top: 80px; }
  .job.featured .what { padding: 18px; }
  .life-card { padding: 12px; border-radius: 22px; gap: 20px; }
  .stage-grid { height: 380px; gap: 8px; }
  .marquee { margin-top: 80px; }
  .contact { padding: 88px 16px 72px; }
}

section[id] { scroll-margin-top: 72px; }

/* Research */
.paper {
  position: relative; padding: 36px; border-radius: 22px;
  background: var(--surface); border: 1px solid var(--line);
  transition: border-color 0.25s;
}
.paper:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.paper-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--muted); margin-bottom: 14px; }
.paper-meta .venue { color: var(--accent); }
.paper h3 { font-family: var(--serif); font-weight: 400; font-size: clamp(1.6rem, 3.4vw, 2.2rem); line-height: 1.15; margin: 0 0 14px; }
.paper h3 a { text-decoration: none; background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat; transition: background-size 0.3s; }
.paper h3 a:hover { background-size: 100% 1px; }
.paper .authors { margin: 0 0 16px; font-size: 0.88rem; color: var(--muted); }
.paper .authors b { color: var(--ink); font-weight: 600; border-bottom: 2px solid var(--trail); }
.paper .abstract { margin: 0 0 24px; max-width: 760px; }
.paper-links { display: flex; flex-wrap: wrap; gap: 10px; }
@media (max-width: 720px) { .paper { padding: 24px 20px; } }
