:root {
  --bg: #fbfcfb;
  --bg-alt: #f1f4f2;
  --text: #101c18;
  --text-muted: #4c5d58;
  --border: #dce4e0;
  --accent: #0b6e5f;
  --accent-text: #ffffff;
  --card-bg: #ffffff;
  --shadow: 0 1px 3px rgba(9, 26, 21, 0.06), 0 10px 28px rgba(9, 26, 21, 0.07);
  --radius: 12px;
  --max-width: 960px;

  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-body: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", "SF Mono", "Cascadia Code", Consolas, monospace;

  --ease-snap: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a100d;
    --bg-alt: #101815;
    --text: #e7f1ec;
    --text-muted: #9bb0a9;
    --border: #22302a;
    --accent: #3fe0c4;
    --accent-text: #04211b;
    --card-bg: #0f1613;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.35), 0 10px 28px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.15;
  margin: 0 0 0.5em;
  text-wrap: balance;
}

img { max-width: 100%; }

/* ---------- Header / nav ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.nav {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text);
}
.brand:hover { text-decoration: none; color: var(--accent); }

.nav-links {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 22px;
  margin: 0;
  padding: 0;
}

.nav-links a {
  color: var(--text-muted);
  font-size: 0.95rem;
}
.nav-links a:hover { color: var(--text); text-decoration: none; }

.nav-cta {
  color: var(--accent-text) !important;
  background: var(--accent);
  padding: 7px 14px;
  border-radius: 999px;
  font-weight: 600;
  transition: transform 0.2s var(--ease-snap), opacity 0.2s var(--ease-snap);
}
.nav-cta:hover { opacity: 0.92; text-decoration: none; transform: translateY(-1px); }

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
}
.nav-toggle span {
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}

/* ---------- Hero ---------- */

.hero {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 96px 24px 64px;
}

.hero-inner { max-width: 680px; }

.eyebrow {
  font-family: var(--font-mono);
  color: var(--accent);
  font-weight: 500;
  letter-spacing: 0.03em;
  margin: 0 0 14px;
  font-size: 0.88rem;
}

.hero h1 {
  font-size: clamp(2.4rem, 5.5vw, 3.6rem);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.hero-lede {
  font-size: 1.15rem;
  color: var(--text-muted);
  margin: 18px 0 32px;
  max-width: 56ch;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 28px;
}

.hero-links {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 0;
  margin: 0;
  font-family: var(--font-mono);
}
.hero-links a { color: var(--text-muted); font-size: 0.86rem; }
.hero-links a:hover { color: var(--accent); }

/* Hero load-in: a short, orchestrated stagger — not scattered effects. */
.hero .eyebrow,
.hero h1,
.hero-lede,
.hero-actions,
.hero-links {
  opacity: 0;
  transform: translateY(10px);
  animation: hero-in 0.6s var(--ease-snap) forwards;
}
.hero .eyebrow    { animation-delay: 0.02s; }
.hero h1          { animation-delay: 0.10s; }
.hero-lede        { animation-delay: 0.20s; }
.hero-actions     { animation-delay: 0.30s; }
.hero-links       { animation-delay: 0.38s; }

@keyframes hero-in {
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .hero .eyebrow, .hero h1, .hero-lede, .hero-actions, .hero-links {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-block;
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.98rem;
  border: 1px solid transparent;
  transition: transform 0.2s var(--ease-snap), opacity 0.2s var(--ease-snap), border-color 0.2s var(--ease-snap), color 0.2s var(--ease-snap);
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}
.btn-primary:hover { opacity: 0.92; }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.btn-large { padding: 15px 30px; font-size: 1.05rem; }

/* ---------- Sections ---------- */

.section {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 64px 24px;
  border-top: 1px solid var(--border);
}

.section-title {
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  margin-bottom: 28px;
}

.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s var(--ease-snap), transform 0.6s var(--ease-snap);
}
.reveal.in-view {
  opacity: 1;
  transform: none;
}

/* Stagger project cards and pipeline nodes slightly once their section reveals. */
.reveal.in-view .card-grid > .card,
.reveal.in-view .era-pipeline > .era-node {
  animation: child-in 0.5s var(--ease-snap) backwards;
}
.card-grid > .card:nth-child(1) { animation-delay: 0.03s; }
.card-grid > .card:nth-child(2) { animation-delay: 0.08s; }
.card-grid > .card:nth-child(3) { animation-delay: 0.13s; }
.card-grid > .card:nth-child(4) { animation-delay: 0.18s; }
.card-grid > .card:nth-child(5) { animation-delay: 0.23s; }
.card-grid > .card:nth-child(6) { animation-delay: 0.28s; }
.card-grid > .card:nth-child(7) { animation-delay: 0.33s; }
.era-pipeline > .era-node:nth-child(1) { animation-delay: 0.02s; }
.era-pipeline > .era-node:nth-child(2) { animation-delay: 0.07s; }
.era-pipeline > .era-node:nth-child(3) { animation-delay: 0.12s; }
.era-pipeline > .era-node:nth-child(4) { animation-delay: 0.17s; }
.era-pipeline > .era-node:nth-child(5) { animation-delay: 0.22s; }
.era-pipeline > .era-node:nth-child(6) { animation-delay: 0.27s; }

@keyframes child-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .reveal { transition: opacity 0.2s linear; transform: none; }
  .reveal.in-view .card-grid > .card,
  .reveal.in-view .era-pipeline > .era-node {
    animation: none;
  }
}

/* ---------- About ---------- */

.about-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 40px;
}

.about-text { font-size: 1.05rem; color: var(--text-muted); margin: 0; }

.facts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.fact-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 3px;
}

/* ---------- Journey / era pipeline ---------- */

.journey-section { padding-top: 8px; }

.journey-lede {
  color: var(--text-muted);
  font-size: 1.02rem;
  max-width: 640px;
  margin: 0 0 40px;
}

.era-pipeline {
  list-style: none;
  display: flex;
  align-items: stretch;
  gap: 0;
  margin: 0 0 28px;
  padding: 26px 0 6px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.era-node {
  position: relative;
  flex: 1 1 0;
  min-width: 128px;
  display: flex;
}

.era-node::before {
  content: "";
  position: absolute;
  top: -18px;
  left: calc(-50% + 10px);
  width: calc(100% - 20px);
  height: 2px;
  background: var(--border);
}
.era-node:first-child::before { display: none; }

.era-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 14px 16px;
  margin: 0 6px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s var(--ease-snap), transform 0.2s var(--ease-snap), box-shadow 0.2s var(--ease-snap);
  position: relative;
}
.era-btn:hover { border-color: var(--accent); transform: translateY(-2px); }
.era-btn.is-active,
.era-btn[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 28%, transparent);
}

.era-btn::before {
  content: "";
  position: absolute;
  top: -23px;
  left: 14px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  border: 2px solid var(--bg);
}
.era-btn.is-active::before,
.era-btn[aria-pressed="true"]::before {
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

/* The "now" node's dot gets a slow, quiet pulse — it's the one live state on the page. */
.era-btn.is-active .era-now,
.era-btn[aria-pressed="true"] .era-now {
  position: relative;
}
.era-now-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 5px;
  animation: pulse-dot 2.2s var(--ease-snap) infinite;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); }
  50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 0%, transparent); }
}

@media (prefers-reduced-motion: reduce) {
  .era-now-dot { animation: none; }
}

.era-range {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.era-label {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 600;
}
.era-now {
  display: inline-flex;
  align-items: center;
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.era-detail {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 26px;
}
.era-detail .era-summary { margin: 0 0 12px; font-size: 1.04rem; }
.era-evidence {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin: 0;
  padding: 0;
  font-family: var(--font-mono);
}
.era-evidence a { font-weight: 500; font-size: 0.86rem; }

/* ---------- Timeline ---------- */

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 2px solid var(--border);
}

.timeline-item {
  position: relative;
  padding: 0 0 32px 28px;
}
.timeline-item:last-child { padding-bottom: 0; }

.timeline-item::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
}

.timeline-when {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}

.timeline-body h3 { font-size: 1.12rem; font-weight: 600; }
.timeline-where { color: var(--text-muted); font-size: 0.92rem; margin: 2px 0 8px; }
.timeline-body p:last-child { margin-bottom: 0; }

/* ---------- Project cards ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  transition: transform 0.25s var(--ease-snap), box-shadow 0.25s var(--ease-snap), border-color 0.25s var(--ease-snap);
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }

.card h3 { font-size: 1.08rem; font-weight: 600; margin-bottom: 8px; }
.card p { margin: 0 0 8px; color: var(--text-muted); font-size: 0.94rem; }
.card-stack { font-family: var(--font-mono) !important; font-size: 0.78rem !important; color: var(--accent) !important; margin: 0 !important; }

.more-work { margin-top: 24px; font-size: 0.95rem; }
.link-arrow { font-weight: 600; }

/* ---------- Publications ---------- */

.pub {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}
.pub-venue {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  font-weight: 500;
  margin: 0 0 8px;
}
.pub h3 { font-size: 1.2rem; font-weight: 600; }
.pub p:not(.pub-venue) { color: var(--text-muted); }

/* ---------- Stack pills ---------- */

.stack-group { margin-bottom: 26px; }
.stack-group:last-child { margin-bottom: 0; }
.stack-group h3 {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--text);
  transition: border-color 0.2s var(--ease-snap), color 0.2s var(--ease-snap);
}
.pill:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Book section ---------- */

.book-section { border-top: 1px solid var(--border); }

.book-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px;
  text-align: center;
}
.book-card p {
  max-width: 520px;
  margin: 0 auto 28px;
  color: var(--text-muted);
}
.book-fallback { margin: 22px 0 0 !important; font-size: 0.9rem; }

/* ---------- Footer ---------- */

.site-footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 40px 24px 64px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: center;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.footer-links { list-style: none; display: flex; gap: 18px; padding: 0; margin: 0; font-family: var(--font-mono); }

/* ---------- Responsive ---------- */

@media (max-width: 760px) {
  .about-grid { grid-template-columns: 1fr; gap: 24px; }

  .nav-toggle { display: flex; }

  .nav-links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px 20px;
    display: none;
  }
  .nav-links.open { display: flex; }
  .nav-links li { width: 100%; }
  .nav-links a { display: block; padding: 10px 0; }
  .nav-cta { display: inline-block; margin-top: 6px; }

  .era-node { min-width: 108px; }

  .book-card { padding: 32px 22px; }
}
