/* ============================
   Tokens
============================ */
:root {
  --bg: #faf8f4;
  --bg-alt: #f2efe8;
  --ink: #1c1a17;
  --ink-soft: #4a4640;
  --ink-faint: #8a8478;
  --accent: #2f5d4f;
  --accent-soft: #e4ece8;
  --line: #e2ddd2;
  --card-bg: #ffffff;

  --font-serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --max: 880px;
  --gutter: 24px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161512;
    --bg-alt: #1c1b18;
    --ink: #f2efe8;
    --ink-soft: #c9c3b6;
    --ink-faint: #837d70;
    --accent: #7fb8a2;
    --accent-soft: #223530;
    --line: #2c2a25;
    --card-bg: #1c1b18;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: 500;
  color: var(--ink);
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

ul { margin: 0; padding: 0; list-style: none; }
p { margin: 0; }

::selection {
  background: var(--accent);
  color: var(--bg);
}

/* ============================
   Grain overlay & scroll progress
============================ */
.noise-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  pointer-events: none;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  .noise-overlay { opacity: 0.05; }
}

.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  z-index: 1000;
  pointer-events: none;
}

.scroll-progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.1s linear;
}

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

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

.nav-links {
  display: flex;
  gap: 28px;
}

.nav-links a {
  font-size: 0.88rem;
  color: var(--ink-soft);
  transition: color 0.15s ease;
  position: relative;
  padding-bottom: 3px;
}

.nav-links a::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.2s ease;
}

.nav-links a:hover { color: var(--accent); }
.nav-links a:hover::after,
.nav-links a.active::after { transform: scaleX(1); }
.nav-links a.active { color: var(--accent); }

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}

.nav-toggle span {
  width: 20px;
  height: 1.5px;
  background: var(--ink);
  display: block;
}

/* ============================
   Hero
============================ */
.hero {
  padding: 96px 0 72px;
}

.hero-inner {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 56px;
  align-items: center;
}

.hero-photo-wrap {
  position: relative;
  justify-self: end;
  width: 100%;
  max-width: 340px;
}

.hero-photo-frame {
  position: absolute;
  top: 18px;
  left: 18px;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  background: var(--accent-soft);
  border: 1px solid var(--line);
  z-index: 0;
}

.hero-photo {
  position: relative;
  z-index: 1;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  box-shadow: 0 18px 40px -18px rgba(28, 26, 23, 0.35);
}

.hero-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: grayscale(0.15);
  transition: transform 0.5s ease;
}

.hero-photo:hover img {
  transform: scale(1.03);
}

.hero-eyebrow {
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 18px;
  font-weight: 500;
}

.hero h1 {
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  line-height: 1.08;
  letter-spacing: -0.01em;
}

.hero h1 .cred {
  color: var(--ink-faint);
  font-weight: 400;
}

.hero-lede {
  margin-top: 22px;
  max-width: 560px;
  font-size: 1.15rem;
  color: var(--ink-soft);
  line-height: 1.65;
}

.hero-actions {
  margin-top: 34px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 3px;
  font-size: 0.92rem;
  font-weight: 500;
  transition: all 0.18s ease;
  border: 1px solid transparent;
}

.btn::after {
  content: '\2192';
  display: inline-block;
  transition: transform 0.18s ease;
}

.btn:hover::after {
  transform: translateX(3px);
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  box-shadow: 0 10px 24px -12px rgba(47, 93, 79, 0.55);
}

.btn-primary:hover {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 14px 28px -12px rgba(47, 93, 79, 0.6);
}

.btn-ghost {
  border-color: var(--line);
  color: var(--ink);
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.hero-location {
  margin-top: 40px;
  font-size: 0.85rem;
  color: var(--ink-faint);
}

/* ============================
   Sections (shared)
============================ */
.section {
  padding: 64px 0;
  border-top: 1px solid var(--line);
}

.section-label {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 32px;
  font-weight: 500;
}

.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ============================
   About
============================ */
.about-grid {
  display: grid;
  gap: 22px;
  max-width: 720px;
}

.about-text {
  font-size: 1.05rem;
  color: var(--ink-soft);
  line-height: 1.75;
}

/* ============================
   Page header (CV / Research)
============================ */
.page-header {
  padding: 72px 0 48px;
}

.page-header h1 {
  font-size: clamp(2rem, 5vw, 2.8rem);
  letter-spacing: -0.01em;
}

.page-lede {
  margin-top: 16px;
  max-width: 620px;
  font-size: 1.08rem;
  color: var(--ink-soft);
  line-height: 1.7;
}

.cv-actions {
  margin-top: 30px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

/* ============================
   CV embed
============================ */
.cv-preview {
  padding-top: 0;
  border-top: none;
}

.cv-embed {
  width: 100%;
  height: 70vh;
  min-height: 420px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 18px 40px -22px rgba(28, 26, 23, 0.35);
}

.cv-embed iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.cv-fallback {
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--ink-faint);
}

/* ============================
   Publications
============================ */
.pub-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pub-list li {
  font-size: 0.94rem;
  color: var(--ink-soft);
  line-height: 1.65;
  padding-left: 18px;
  position: relative;
}

.pub-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.6em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.55;
}

.pub-list strong {
  color: var(--ink);
  font-weight: 600;
}

.pub-link {
  margin-top: 30px;
}

.pub-link a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.92rem;
  color: var(--accent);
  font-weight: 500;
  border-bottom: 1px solid var(--accent);
  padding-bottom: 2px;
}

.pub-link a::after {
  content: '\2192';
  transition: transform 0.18s ease;
}

.pub-link a:hover::after {
  transform: translateX(3px);
}

/* ============================
   Working Papers / Works in Progress
============================ */
.paper-list {
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.paper-item {
  padding-left: 18px;
  border-left: 2px solid var(--accent);
}

.paper-item.is-progress {
  border-left-color: var(--line);
}

.paper-title {
  font-family: var(--font-serif);
  font-size: 1.08rem;
  line-height: 1.4;
  margin-bottom: 6px;
}

.paper-meta {
  font-size: 0.88rem;
  color: var(--ink-faint);
}

.paper-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent);
  border-bottom: 1px solid var(--accent);
  padding-bottom: 1px;
}

.paper-link::after {
  content: '\2192';
  transition: transform 0.18s ease;
}

.paper-link:hover::after {
  transform: translateX(3px);
}

/* ============================
   Contact
============================ */
.contact-links {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.contact-link {
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  padding-bottom: 3px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.contact-link:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.contact-location {
  font-size: 0.85rem;
  color: var(--ink-faint);
}

/* ============================
   Footer
============================ */
.site-footer {
  border-top: 1px solid var(--line);
}

.footer-inner {
  padding: 28px var(--gutter);
  font-size: 0.82rem;
  color: var(--ink-faint);
}

/* ============================
   Responsive
============================ */
@media (max-width: 720px) {
  .nav-toggle { display: flex; }

  .nav-links {
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    gap: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
  }

  .nav-links.open {
    max-height: 320px;
  }

  .nav-links li {
    border-top: 1px solid var(--line);
  }

  .nav-links a {
    display: block;
    padding: 16px var(--gutter);
  }

  .page-header {
    padding: 48px 0 36px;
  }

  .cv-embed {
    height: 60vh;
    min-height: 320px;
  }

  .hero {
    padding: 48px 0 40px;
  }

  .hero-inner {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .hero-inner .hero-text {
    order: 2;
  }

  .hero-photo-wrap {
    order: 1;
    justify-self: start;
    max-width: 220px;
  }

  .hero-photo-frame {
    top: 12px;
    left: 12px;
  }

  .section {
    padding: 48px 0;
  }
}

/* ============================
   Scroll reveal
============================ */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.reveal-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .hero-photo img,
  .btn::after,
  .pub-link a::after {
    transition: none;
  }

  html { scroll-behavior: auto; }
}
