/* ---------- Tokens ---------- */
:root {
  --bg: #f6f5f1;
  --bg-soft: #efeee8;
  --fg: #1a1a18;
  --muted: #6b6a63;
  --line: #d9d7cf;
  --accent: #b8442d;
  --card: #fbfaf7;
  --max: 1080px;
  --ease: cubic-bezier(.22, 1, .36, 1);
}
:root[data-theme="dark"] {
  --bg: #0e0e0d;
  --bg-soft: #151513;
  --fg: #ece9e2;
  --muted: #8f8d84;
  --line: #26251f;
  --accent: #e0674c;
  --card: #161613;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 90px; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background .5s var(--ease), color .5s var(--ease);
  overflow-x: hidden;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

main, .nav, footer { position: relative; z-index: 1; }

em { font-style: normal; color: var(--accent); }

/* ---------- Nav ---------- */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px clamp(20px, 6vw, 64px);
  z-index: 100;
  backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  border-bottom: 1px solid transparent;
  transition: border-color .4s var(--ease);
}
.nav.scrolled { border-bottom-color: var(--line); }
.brand {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: 20px;
  letter-spacing: .04em;
  text-decoration: none;
  color: var(--fg);
}
.nav-links {
  display: flex;
  gap: 30px;
}
.nav-links a {
  text-decoration: none;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: .02em;
  transition: color .25s var(--ease);
}
.nav-links a:hover { color: var(--fg); }
.theme-toggle {
  background: none;
  border: 1px solid var(--line);
  color: var(--fg);
  width: 34px; height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  transition: transform .4s var(--ease), border-color .25s;
}
.theme-toggle:hover { transform: rotate(-25deg); border-color: var(--accent); }

/* ---------- Layout ---------- */
main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 clamp(20px, 6vw, 64px);
}
.block {
  padding: clamp(70px, 12vh, 130px) 0;
  border-top: 1px solid var(--line);
}
.section-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 54px;
}
.section-head .index {
  font-family: 'Fraunces', serif;
  color: var(--accent);
  font-size: 14px;
  letter-spacing: .05em;
}
.section-head h2 {
  font-family: 'Fraunces', serif;
  font-weight: 400;
  font-size: clamp(28px, 4vw, 40px);
  letter-spacing: -.01em;
}

/* ---------- Hero ---------- */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 120px 0 60px;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: .28em;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 28px;
}
.hero h1 {
  font-family: 'Fraunces', serif;
  font-weight: 400;
  font-size: clamp(52px, 11vw, 128px);
  line-height: .92;
  letter-spacing: -.03em;
  margin-bottom: 34px;
}
.lede {
  max-width: 52ch;
  font-size: clamp(17px, 2vw, 20px);
  color: var(--muted);
  margin-bottom: 40px;
}
.lede em { font-weight: 500; }
.hero-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 46px;
}
.btn {
  display: inline-block;
  padding: 13px 26px;
  background: var(--fg);
  color: var(--bg);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: 100px;
  border: 1px solid var(--fg);
  transition: transform .3s var(--ease), background .3s, color .3s;
}
.btn:hover { transform: translateY(-2px); }
.btn.ghost {
  background: transparent;
  color: var(--fg);
  border-color: var(--line);
}
.btn.ghost:hover { border-color: var(--fg); }
.hero-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
}
.hero-meta .dot { color: var(--accent); }

/* ---------- About ---------- */
.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  margin-bottom: 64px;
}
.about-grid p { font-size: 18px; }
.skills {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 40px;
}
.skill-col h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--accent);
  margin-bottom: 16px;
  font-weight: 600;
}
.skill-col ul { list-style: none; }
.skill-col li {
  padding: 9px 0;
  border-top: 1px solid var(--line);
  font-size: 15px;
  color: var(--muted);
}

/* ---------- Timeline ---------- */
.timeline { list-style: none; }
.timeline li {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 28px;
  padding: 30px 0;
  border-top: 1px solid var(--line);
}
.timeline li:last-child { border-bottom: 1px solid var(--line); }
.tl-when {
  font-family: 'Fraunces', serif;
  color: var(--muted);
  font-size: 15px;
  padding-top: 3px;
}
.tl-what h3 { font-size: 20px; font-weight: 600; margin-bottom: 3px; }
.tl-org { color: var(--accent); font-size: 14px; margin-bottom: 10px; }
.tl-desc { color: var(--muted); font-size: 16px; max-width: 60ch; }

/* ---------- Projects ---------- */
.projects {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}
.project {
  display: block;
  padding: 30px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  text-decoration: none;
  color: var(--fg);
  transition: transform .4s var(--ease), border-color .3s, box-shadow .4s;
}
.project:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 18px 40px -24px rgba(0,0,0,.4);
}
.p-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.p-top h3 { font-size: 20px; font-weight: 600; }
.stars { color: var(--accent); font-size: 14px; }
.project p { color: var(--muted); font-size: 15px; margin-bottom: 16px; }
.tag {
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 4px 12px;
  border-radius: 100px;
}
.publication {
  margin-bottom: 26px;
  padding: 26px 30px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  display: flex;
  align-items: baseline;
  gap: 18px;
  flex-wrap: wrap;
  text-decoration: none;
  color: var(--fg);
  transition: border-color .3s var(--ease), transform .4s var(--ease);
}
.publication:hover {
  border-color: var(--accent);
  border-style: solid;
  transform: translateY(-3px);
}
.pub-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--accent);
}
.publication p { font-family: 'Fraunces', serif; font-size: 18px; }
.pub-venue {
  font-size: 13px;
  color: var(--muted);
  margin-left: auto;
  transition: color .3s var(--ease);
}
.publication:hover .pub-venue { color: var(--accent); }

/* ---------- Contact ---------- */
.contact { text-align: left; }
.contact-lede {
  font-size: clamp(20px, 3vw, 28px);
  font-family: 'Fraunces', serif;
  max-width: 30ch;
  margin-bottom: 34px;
}
.mail {
  display: inline-block;
  font-size: clamp(22px, 4.5vw, 44px);
  font-family: 'Fraunces', serif;
  color: var(--fg);
  text-decoration: none;
  border-bottom: 2px solid var(--line);
  padding-bottom: 6px;
  transition: border-color .3s, color .3s;
}
.mail:hover { color: var(--accent); border-color: var(--accent); }
.socials {
  display: flex;
  gap: 26px;
  margin-top: 40px;
}
.socials a {
  color: var(--muted);
  text-decoration: none;
  font-size: 15px;
  position: relative;
  transition: color .25s;
}
.socials a::after {
  content: "↗";
  font-size: 12px;
  margin-left: 3px;
}
.socials a:hover { color: var(--fg); }

/* ---------- Footer ---------- */
footer {
  max-width: var(--max);
  margin: 0 auto;
  padding: 34px clamp(20px, 6vw, 64px);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- Reveal (only hidden when JS is present) ---------- */
.js .reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity .8s var(--ease), transform .8s var(--ease);
}
.js .reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .nav-links { display: none; }
  .about-grid { grid-template-columns: 1fr; gap: 20px; }
  .skills { grid-template-columns: 1fr; gap: 30px; }
  .projects { grid-template-columns: 1fr; }
  .timeline li { grid-template-columns: 1fr; gap: 6px; }
  .tl-when { padding-top: 0; }
  footer { flex-direction: column; gap: 8px; }
}
