:root {
  --bg:        #faf8f4;
  --bg-soft:   #f2eee6;
  --surface:   #ffffff;
  --ink:       #23201b;
  --ink-soft:  #5c554b;
  --ink-faint: #8a8377;
  --accent:    #2f6f4e;
  --accent-2:  #c98a4b;
  --line:      #e6e0d6;
  --shadow:    0 10px 30px rgba(60, 50, 30, 0.08);
  --shadow-lg: 0 20px 50px rgba(60, 50, 30, 0.16);
  --radius:    16px;
  --maxw:      980px;
  --font-serif: "Fraunces", Georgia, serif;
  --font-sans:  "Inter", system-ui, -apple-system, sans-serif;
}

:root[data-theme="dark"] {
  --bg:        #16130f;
  --bg-soft:   #1e1a15;
  --surface:   #211d17;
  --ink:       #f0ebe1;
  --ink-soft:  #c3bcae;
  --ink-faint: #8c8474;
  --accent:    #7dc79e;
  --accent-2:  #e0a668;
  --line:      #322c23;
  --shadow:    0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background .4s ease, color .4s ease;
}

h1, h2, h3, h4 { font-family: var(--font-serif); font-weight: 600; line-height: 1.2; color: var(--ink); }
h1 { font-size: clamp(2rem, 5vw, 3rem); letter-spacing: -0.5px; }
h2 { font-size: clamp(1.5rem, 3.5vw, 2rem); }
h3 { font-size: 1.15rem; }

a { color: var(--accent); text-decoration: none; transition: color .2s; }
a:hover { color: var(--accent-2); }

img { max-width: 100%; display: block; }

.site-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px clamp(20px, 5vw, 48px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-family: var(--font-serif); font-weight: 600; font-size: 1.3rem;
  color: var(--ink); letter-spacing: -0.3px;
}
.brand:hover { color: var(--accent); }
.site-nav { display: flex; align-items: center; gap: clamp(8px, 2vw, 22px); }
.site-nav a {
  color: var(--ink-soft); font-size: 0.95rem; font-weight: 500;
  padding: 6px 2px; position: relative;
}
.site-nav a::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 2px; width: 0;
  background: var(--accent); transition: width .25s ease;
}
.site-nav a:hover, .site-nav a.active { color: var(--ink); }
.site-nav a:hover::after, .site-nav a.active::after { width: 100%; }

.theme-toggle {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
  font-size: 1rem; display: grid; place-items: center;
  transition: transform .3s ease, background .3s;
}
.theme-toggle:hover { transform: rotate(20deg); }
.theme-icon-dark { display: none; }
:root[data-theme="dark"] .theme-icon-light { display: none; }
:root[data-theme="dark"] .theme-icon-dark { display: inline; }

.site-main { max-width: var(--maxw); margin: 0 auto; padding: clamp(28px, 6vw, 64px) clamp(20px, 5vw, 40px); }
.section { margin-bottom: clamp(48px, 8vw, 80px); }
.section-title { display: flex; align-items: baseline; gap: 14px; margin-bottom: 28px; }
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.hero {
  display: grid; grid-template-columns: 260px 1fr; gap: clamp(24px, 5vw, 48px);
  align-items: center; margin-bottom: clamp(40px, 8vw, 72px);
}
.hero-portrait {
  width: 240px; height: 240px; object-fit: cover; border-radius: 50%;
  border: 6px solid var(--surface); box-shadow: var(--shadow-lg);
  justify-self: center;
}
.hero-text h1 { margin: 0 0 4px; }
.hero-eyebrow { color: var(--accent); font-weight: 600; letter-spacing: .5px; text-transform: uppercase; font-size: .8rem; margin: 0 0 10px; }
.hero-text p { color: var(--ink-soft); margin: 0 0 14px; }
@media (max-width: 720px) {
  .hero { grid-template-columns: 1fr; text-align: center; }
  .hero-portrait { width: 180px; height: 180px; }
}

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li {
  position: relative; padding: 0 0 22px 26px; border-left: 2px solid var(--line);
}
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: -7px; top: 6px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--bg);
}
.timeline strong { color: var(--ink); }
.timeline span.when { color: var(--ink-faint); font-size: .85rem; }

.pub-card {
  display: grid; grid-template-columns: 130px 1fr; gap: 24px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; margin-bottom: 22px; box-shadow: var(--shadow);
  transition: transform .35s ease, box-shadow .35s ease, border-color .35s;
}
.pub-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.pub-thumb { border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); }
.pub-thumb img { width: 100%; height: auto; transition: transform .5s ease; }
.pub-card:hover .pub-thumb img { transform: scale(1.06); }
.pub-title { margin: 0 0 6px; font-size: 1.08rem; }
.pub-authors { margin: 0 0 8px; font-size: .88rem; color: var(--ink-soft); }
.pub-authors b, .pub-authors strong { color: var(--ink); }
.pub-venue { margin: 8px 0 12px; font-size: .82rem; color: var(--ink-faint); font-style: italic; }
.pub-links { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 620px) {
  .pub-card { grid-template-columns: 1fr; }
  .pub-thumb { max-width: 160px; }
}

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.tag {
  display: inline-block; background: var(--bg-soft); color: var(--ink-soft);
  border-radius: 999px; padding: 3px 12px; font-size: .72rem; font-weight: 500;
}

.btn {
  display: inline-block; padding: 6px 18px; border-radius: 999px;
  border: 1px solid var(--ink); color: var(--ink); font-size: .78rem; font-weight: 600;
  background: transparent; transition: all .25s ease;
}
.btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; transform: translateY(-1px); }

.projects-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 22px;
}
.project-card {
  display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); transition: transform .35s ease, box-shadow .35s ease;
  color: var(--ink);
}
.project-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); color: var(--ink); }
.project-thumb { overflow: hidden; aspect-ratio: 16 / 10; background: var(--bg-soft); }
.project-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .55s ease; }
.project-card:hover .project-thumb img { transform: scale(1.08); }
.project-body { padding: 18px 20px 22px; }
.project-body h4 { margin: 0 0 8px; font-size: 1.05rem; }
.project-tags { margin: 0 0 6px; font-size: .8rem; color: var(--accent); font-weight: 500; }
.project-date { font-size: .78rem; color: var(--ink-faint); }
.subhead { margin: 40px 0 20px; color: var(--ink-soft); font-size: .82rem; letter-spacing: 1.5px; text-transform: uppercase; font-family: var(--font-sans); font-weight: 600; }

.contact-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(28px, 5vw, 48px); box-shadow: var(--shadow); max-width: 620px;
}
.contact-card ul { list-style: none; padding: 0; margin: 18px 0 0; }
.contact-card li { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--line); font-size: .95rem; }
.contact-card li:last-child { border-bottom: 0; }
.contact-card .label { color: var(--ink-faint); min-width: 92px; font-weight: 600; }

.detail { max-width: 760px; margin: 0 auto; }
.back-link { font-size: .88rem; color: var(--ink-soft); }
.detail-header { margin: 18px 0 24px; }
.detail-meta { color: var(--ink-faint); font-size: .9rem; }
.detail-hero { margin: 0 0 32px; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-lg); }
.detail-body { font-size: 1.02rem; color: var(--ink); }
.detail-body h2 { margin: 32px 0 12px; }
.detail-body h3 { margin: 24px 0 8px; }
.detail-body img { border-radius: 12px; margin: 20px auto; box-shadow: var(--shadow); }
.detail-body blockquote { border-left: 3px solid var(--accent); margin: 20px 0; padding: 4px 20px; color: var(--ink-soft); background: var(--bg-soft); border-radius: 6px; }
.detail-body code { background: var(--bg-soft); padding: 2px 6px; border-radius: 5px; font-size: .9em; }
.detail-links { margin-top: 36px; display: flex; gap: 10px; }

/* Blog list */
.blog-list { display: flex; flex-direction: column; gap: 22px; }
.blog-card {
  display: grid; grid-template-columns: 220px 1fr; gap: 24px;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; text-decoration: none; color: inherit;
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.blog-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.blog-thumb { border-radius: 12px; overflow: hidden; align-self: start; }
.blog-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.blog-card-body { min-width: 0; }
.blog-title { margin: 0 0 6px; font-size: 1.25rem; line-height: 1.3; }
.blog-meta { color: var(--ink-faint); font-size: .82rem; margin: 0 0 12px; }
.blog-excerpt { color: var(--ink-soft); font-size: .96rem; line-height: 1.6; margin: 0 0 14px; }
.blog-readmore { color: var(--accent); font-size: .88rem; font-weight: 600; }
.blog-card:not(:has(.blog-thumb)) { grid-template-columns: 1fr; }
@media (max-width: 640px) {
  .blog-card { grid-template-columns: 1fr; }
}

.site-footer {
  border-top: 1px solid var(--line); text-align: center;
  padding: 32px 20px; color: var(--ink-faint); font-size: .85rem;
}
.site-footer a { color: var(--ink-soft); }

.reveal { opacity: 0; transform: translateY(24px); transition: opacity .7s ease, transform .7s ease; }
.reveal.visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}
