/* ---------- Theme tokens ---------- */
:root {
  --bg: #f6f3ee;
  --surface: #fffdf9;
  --ink: #1b1d22;
  --muted: #5d6270;
  --line: #e2ddd4;
  --accent: #2456d6;
  --accent-ink: #ffffff;
  --accent-soft: #e4ebfb;
  --shadow: 0 1px 2px rgb(20 20 30 / 0.05), 0 8px 24px rgb(20 20 30 / 0.06);

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --max: 68rem;
  --gutter: clamp(1rem, 4vw, 2rem);
  color-scheme: light;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 5rem; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.0625rem/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.2; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 0.2em; }
img { max-width: 100%; display: block; }
ul, ol { margin: 0; padding: 0; list-style: none; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.skip {
  position: absolute; left: 1rem; top: -3rem;
  background: var(--accent); color: var(--accent-ink);
  padding: 0.5rem 1rem; border-radius: 6px; z-index: 20;
}
.skip:focus { top: 1rem; }

main, .topbar-inner, .footer {
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
.topbar.scrolled { border-bottom-color: var(--line); }

.topbar-inner {
  display: flex;
  align-items: baseline; /* name and tabs sit on the same text line */
  gap: 1rem;
  padding-block: 0.75rem;
}

.mark {
  font: 600 1.15rem/1.2 var(--serif);
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0.02em;
}

.nav { display: flex; gap: 0.25rem; margin-left: auto; }
.nav a {
  display: block;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.925rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s, background-color 0.15s;
}
.nav a:hover { color: var(--ink); }
.nav a.active { color: var(--accent); background: var(--accent-soft); }

/* ---------- Hero ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(2rem, 6vw, 5rem);
  padding-block: clamp(3rem, 9vw, 7rem) clamp(2.5rem, 6vw, 4.5rem);
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}

.hero h1 {
  font: 600 clamp(2.75rem, 7vw, 4.75rem)/1.02 var(--serif);
  letter-spacing: -0.02em;
}

.role {
  font: 400 clamp(1.2rem, 2.4vw, 1.5rem)/1.3 var(--serif);
  font-style: italic;
  color: var(--muted);
  margin-top: 0.75rem;
}

.bio {
  max-width: 36rem;
  margin-top: 1.5rem;
  color: var(--muted);
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 2rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.925rem;
  font-weight: 500;
  text-decoration: none;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.btn:hover { transform: translateY(-1px); border-color: var(--accent); box-shadow: var(--shadow); }
.btn svg {
  width: 1.05rem; height: 1.05rem; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.btn svg.filled { fill: currentColor; stroke: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.portrait { margin: 0; justify-self: center; width: min(100%, 24rem); }
.portrait img { width: 100%; height: auto; }

/* ---------- Sections ---------- */
.section {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr);
  gap: 2rem;
  padding-block: clamp(3rem, 7vw, 5rem);
  border-bottom: 1px solid var(--line);
}
.section:last-child { border-bottom: 0; }

.section-head h2 { font: 600 1.9rem var(--serif); letter-spacing: -0.01em; }
.section-head p { color: var(--muted); font-size: 0.925rem; margin-top: 0.35rem; }
@media (min-width: 761px) {
  .section-head { position: sticky; top: 6rem; align-self: start; }
}

h3 { font-size: 1.05rem; font-weight: 600; }
.meta { color: var(--muted); font-size: 0.925rem; margin-top: 0.2rem; }

/* Publications */
.pubs { display: grid; gap: 0.25rem; }
.pub {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px dashed var(--line);
}
.pub:last-child { border-bottom: 0; }
.pub h3 { font: 600 1.15rem/1.35 var(--serif); }
.pub-status {
  align-self: start;
  justify-self: start;
  padding: 0.15rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
  margin-top: 0.15rem;
}
.pub-status.published { background: var(--accent-soft); border-color: transparent; color: var(--accent); }

/* Experience timeline */
.timeline { position: relative; }
.job {
  display: grid;
  grid-template-columns: 9.5rem minmax(0, 1fr);
  gap: 1.5rem;
  padding-bottom: 2.25rem;
}
.job:last-child { padding-bottom: 0; }
.job-when { color: var(--muted); font-size: 0.875rem; font-variant-numeric: tabular-nums; padding-top: 0.15rem; }
.job-body {
  position: relative;
  padding-left: 1.5rem;
  border-left: 1px solid var(--line);
}
.job-body::before {
  content: "";
  position: absolute;
  left: -0.35rem; top: 0.45rem;
  width: 0.7rem; height: 0.7rem;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
}
.job-body ul { margin-top: 0.75rem; display: grid; gap: 0.4rem; }
.job-body li {
  position: relative;
  padding-left: 1rem;
  color: var(--muted);
  font-size: 0.975rem;
}
.job-body li::before {
  content: "";
  position: absolute;
  left: 0; top: 0.7em;
  width: 0.35rem; height: 1px;
  background: var(--muted);
}

/* Education */
.degrees { display: grid; gap: 1rem; }
.degree {
  padding: 1.25rem 1.4rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.degree-when { color: var(--accent); font-size: 0.8rem; font-weight: 600; letter-spacing: 0.06em; margin-bottom: 0.3rem; }
.degree h3 { font: 600 1.15rem var(--serif); }
.degree .meta + p { margin-top: 0.5rem; font-size: 0.95rem; }

/* Projects */
.projects { display: grid; gap: 1rem; }
.project {
  padding: 1.25rem 1.4rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.project-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
}
.project h3 { font: 600 1.15rem var(--serif); }
.project-link { font-size: 0.875rem; font-weight: 500; text-decoration: none; white-space: nowrap; }
.project-link:hover { text-decoration: underline; }
.project-links { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; }
.tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.6rem; }
.tags li {
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 500;
}
.project-points { margin-top: 0.85rem; display: grid; gap: 0.4rem; }
.project-points li {
  position: relative;
  padding-left: 1rem;
  color: var(--muted);
  font-size: 0.975rem;
}
.project-points li::before {
  content: "";
  position: absolute;
  left: 0; top: 0.7em;
  width: 0.35rem; height: 1px;
  background: var(--muted);
}

/* Awards (reuse the publication list layout) */
.award-note { color: var(--muted); font-size: 0.95rem; margin-top: 0.4rem; }

/* ---------- Footer ---------- */
.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 2rem 2.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.875rem;
}
.footer-links { display: flex; gap: 1.25rem; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--accent); }

/* ---------- Scroll reveal (only when JS is running) ---------- */
.js .reveal { opacity: 0; transform: translateY(16px); transition: opacity 0.6s ease, transform 0.6s ease; }
.js .reveal.visible { opacity: 1; transform: none; }

/* Page fade-in: hidden while fonts load, then fades in as the intro rises. */
body { transition: opacity 0.7s ease; }
html.loading body { opacity: 0; }

html:not(.loading) .hero-text > *,
html:not(.loading) .portrait { animation: rise 0.8s ease both; }
.hero-text > :nth-child(2) { animation-delay: 0.05s; }
.hero-text > :nth-child(3) { animation-delay: 0.1s; }
.hero-text > :nth-child(4) { animation-delay: 0.15s; }
.hero-text > :nth-child(5) { animation-delay: 0.2s; }
.portrait { animation-delay: 0.15s; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .reveal { opacity: 1; transform: none; }
}

/* ---------- Narrow screens ---------- */
@media (max-width: 760px) {
  .nav { display: none; }

  .hero { grid-template-columns: 1fr; text-align: left; }
  .portrait { grid-row: 1; justify-self: start; width: 10rem; }

  .section { grid-template-columns: 1fr; gap: 1.5rem; }
  .pub { grid-template-columns: 1fr; gap: 0.4rem; }
  .job { grid-template-columns: 1fr; gap: 0.4rem; }
  .job-when { padding-left: 1.5rem; }
}

/* ---------- Taxi agent link in the top bar ---------- */
.demo-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-left: auto;
  align-self: center;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.15s, box-shadow 0.15s;
}
.demo-link:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.nav + .demo-link, nav + .demo-link { margin-left: 0.5rem; }
/* A soft pulse marks it as live. */
.demo-dot {
  width: 0.45rem; height: 0.45rem; border-radius: 50%;
  background: #7ee2a8;
  box-shadow: 0 0 0 0 rgb(126 226 168 / 0.7);
  animation: pulse 2s ease-out infinite;
}
@keyframes pulse { to { box-shadow: 0 0 0 0.45rem rgb(126 226 168 / 0); } }
@media (max-width: 760px) { nav + .demo-link { margin-left: auto; } }
/* Mid widths: keep the name on one line and tighten the tabs to make room. */
.mark { white-space: nowrap; }
@media (min-width: 761px) and (max-width: 980px) {
  .nav a { padding-inline: 0.45rem; font-size: 0.875rem; }
  .demo-link { padding-inline: 0.7rem; }
}

/* Second top-bar pill: the Spotify dashboard, in Spotify green with dark text
   (white on #1DB954 is too low-contrast; Spotify's own buttons use black). */
/* The top bar already spaces items 1rem apart; pull the second pill in to 0.4rem. */
.demo-link + .demo-link { margin-left: -0.6rem; }
.demo-link--spotify { background: #1db954; color: #0b0b0b; }
.demo-link--spotify .demo-dot {
  background: #0b0b0b;
  box-shadow: 0 0 0 0 rgb(11 11 11 / 0.45);
  animation-name: pulse-dark;
}
@keyframes pulse-dark { to { box-shadow: 0 0 0 0.45rem rgb(11 11 11 / 0); } }
/* Phones: let the two pills drop below the name instead of overflowing. */
@media (max-width: 520px) {
  .topbar-inner { flex-wrap: wrap; row-gap: 0.5rem; }
  .mark { flex-basis: 100%; }
  nav + .demo-link { margin-left: 0; }
}
/* Narrow screens hide the section links; hide their <nav> too, or the empty
   element still takes a flex slot and its gap pushes the pills off the edge. */
@media (max-width: 760px) { .topbar-inner > nav { display: none; } }
