:root {
  --ink: #0e1116;
  --ink-2: #161b22;
  --paper: #f3eee4;
  --muted: #9aa3ad;
  --line: rgba(243, 238, 228, 0.12);
  --accent: #ff7a45;
  --accent-2: #7fd1e6;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--ink);
  color: var(--paper);
  font: 400 17px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
.mono { font-family: var(--mono); }
.small { font-size: 0.8rem; }

#network {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  z-index: -1;
  opacity: 0.55;
}

/* CJK pages: Latin display fonts first, then native fallbacks */
:lang(ja) { --serif: "Fraunces", "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif; --sans: "Inter", "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif; }
:lang(zh-Hans) { --serif: "Fraunces", "Songti SC", "Noto Serif SC", serif; --sans: "Inter", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif; }
:lang(zh-Hant) { --serif: "Fraunces", "Songti TC", "Noto Serif TC", serif; --sans: "Inter", "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif; }
:lang(ko) { --serif: "Fraunces", "AppleMyungjo", "Noto Serif KR", serif; --sans: "Inter", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif; word-break: keep-all; }
html:not([lang="en"]) .lede { max-width: 24em; }
html:not([lang="en"]) .eyebrow { letter-spacing: 0.08em; }

/* NAV */
.nav {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.1rem clamp(1.25rem, 5vw, 4rem);
  background: rgba(14, 17, 22, 0.7);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { font: 700 1.4rem var(--serif); letter-spacing: -0.02em; }
.brand span { color: var(--accent); font-style: italic; }
.nav nav { display: flex; gap: clamp(0.9rem, 2.5vw, 2rem); }
.nav nav a {
  font: 500 0.78rem var(--mono); text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); transition: color 0.2s;
}
.nav nav a:hover { color: var(--accent); }
.nav nav { align-items: center; }
.lang {
  display: flex; gap: 0.7rem; padding-left: clamp(0.9rem, 2.5vw, 2rem);
  border-left: 1px solid var(--line);
}
.nav nav .lang a { text-transform: none; letter-spacing: 0.02em; font-size: 0.75rem; }
.nav nav .lang a[aria-current="page"] { color: var(--accent); }
.menu-toggle {
  display: none; width: 40px; height: 40px; padding: 0 9px;
  flex-direction: column; justify-content: center; gap: 5px;
  background: none; border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
}
.menu-toggle span { display: block; height: 2px; background: var(--paper); border-radius: 2px; transition: transform 0.25s, opacity 0.25s; }
.nav.open .menu-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav.open .menu-toggle span:nth-child(2) { opacity: 0; }
.nav.open .menu-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

main { max-width: 1180px; margin: 0 auto; padding: 0 clamp(1.25rem, 5vw, 4rem); }

/* HERO */
.hero {
  min-height: calc(100vh - 70px);
  display: grid; grid-template-columns: 1.15fr 1fr; gap: clamp(2rem, 5vw, 5rem);
  align-items: center; padding: 4rem 0;
}
.eyebrow {
  font: 500 0.75rem var(--mono); text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--accent-2); margin-bottom: 1.2rem;
}
h1 {
  font: 300 clamp(3.8rem, 10vw, 8.5rem)/0.88 var(--serif);
  letter-spacing: -0.04em; font-variation-settings: "opsz" 144;
}
h1 em { font-weight: 700; color: var(--accent); }
.lede { margin: 2rem 0 2.4rem; max-width: 33ch; font-size: 1.15rem; color: #cfd5db; }
.cta { display: flex; flex-wrap: wrap; gap: 0.8rem; }
.btn {
  font: 500 0.85rem var(--mono); padding: 0.85rem 1.4rem;
  border: 1px solid var(--line); border-radius: 999px;
  transition: transform 0.2s, background 0.2s, border-color 0.2s;
}
.btn:hover { transform: translateY(-2px); border-color: var(--paper); }
.btn.primary { background: var(--accent); color: var(--ink); border-color: var(--accent); }
.btn.primary:hover { background: var(--paper); border-color: var(--paper); }

.portrait { position: relative; }
.portrait img {
  width: 100%; aspect-ratio: 4 / 5; object-fit: cover;
  object-position: center 20%;
  border-radius: 4px 120px 4px 4px;
  filter: saturate(0.9) contrast(1.05);
}
.portrait::before {
  content: ""; position: absolute; inset: 1.2rem -1.2rem -1.2rem 1.2rem;
  border: 1px solid var(--accent); border-radius: 4px 120px 4px 4px; z-index: -1;
}

/* SECTIONS */
.section { padding: clamp(4rem, 9vw, 7rem) 0; border-top: 1px solid var(--line); }
.section-head { display: flex; align-items: baseline; gap: 1.2rem; margin-bottom: 3rem; }
.num { color: var(--accent); font-size: 0.85rem; }
h2 { font: 400 clamp(2.4rem, 5vw, 3.8rem)/1 var(--serif); letter-spacing: -0.03em; }
h3 { font: 600 1.25rem/1.3 var(--serif); }

.bio { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem 3rem; }
.bio .big { grid-column: 1 / -1; font: 300 clamp(1.4rem, 2.6vw, 2rem)/1.4 var(--serif); }
.bio p { color: #cfd5db; }

/* WRITING */
.medium-card {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 2rem;
  padding: clamp(2rem, 4vw, 3.2rem); border-radius: 20px;
  background: linear-gradient(135deg, #1b2230, #11151c);
  border: 1px solid var(--line);
  transition: transform 0.3s, border-color 0.3s;
}
.medium-card:hover { transform: translateY(-4px); border-color: var(--accent); }
.medium-card h3 { font: 400 clamp(1.5rem, 3vw, 2.2rem)/1.25 var(--serif); max-width: 24ch; margin-bottom: 1rem; }
.medium-card p:not(.eyebrow) { color: var(--muted); max-width: 50ch; }
.arrow { font: 500 0.85rem var(--mono); color: var(--accent); white-space: nowrap; }
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.6rem; }
.tags li {
  font-size: 0.78rem; padding: 0.45rem 0.9rem; border-radius: 999px;
  border: 1px solid rgba(127, 209, 230, 0.35); color: var(--accent-2);
  background: rgba(127, 209, 230, 0.06);
}

/* TEACHING */
.teach { display: grid; grid-template-columns: 1fr 1.1fr; gap: clamp(2rem, 5vw, 4rem); align-items: start; }
.teach-intro .big { font: 300 italic clamp(2rem, 4vw, 3rem)/1.1 var(--serif); color: var(--accent); margin-bottom: 1.2rem; }
.teach-intro p:not(.big) { color: #cfd5db; }
.gap { display: flex; align-items: center; gap: 0.9rem; margin-top: 2.2rem; font-size: 0.75rem; color: var(--muted); }
.bridge {
  flex: 1; height: 2px; position: relative;
  background: repeating-linear-gradient(90deg, var(--accent-2) 0 8px, transparent 8px 14px);
}
.bridge::before, .bridge::after {
  content: ""; position: absolute; top: -4px; width: 10px; height: 10px; border-radius: 50%;
}
.bridge::before { left: 0; background: var(--paper); }
.bridge::after { right: 0; background: var(--accent); }
.teach-links { display: grid; gap: 1.2rem; }
.teach-card {
  display: block; padding: 1.8rem; border-radius: 18px;
  background: rgba(22, 27, 34, 0.7); border: 1px solid var(--line);
  transition: transform 0.3s, border-color 0.3s;
}
.teach-card:hover { transform: translateX(6px); border-color: var(--accent-2); }
.teach-card h3 { font-size: 1.6rem; margin-bottom: 0.5rem; }
.teach-card p:not(.eyebrow) { color: var(--muted); margin-bottom: 1rem; }
.teach-card .eyebrow { margin-bottom: 0.6rem; }

/* BOOKS */
.books { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
.book {
  border: 1px solid var(--line); border-radius: 20px; overflow: hidden;
  background: rgba(22, 27, 34, 0.7); transition: transform 0.3s;
}
.book:hover { transform: translateY(-4px) rotate(-0.4deg); }
.cover {
  aspect-ratio: 16 / 9; padding: 1.8rem; display: flex; flex-direction: column; justify-content: flex-end; gap: 0.4rem;
  position: relative; overflow: hidden;
}
.cover .mono { position: absolute; top: 1.4rem; right: 1.6rem; font-size: 0.85rem; opacity: 0.8; }
.cover strong { font: 600 1.55rem/1.15 var(--serif); max-width: 18ch; }
.cover small { font: 0.75rem var(--mono); opacity: 0.75; }
.c1 { background: radial-gradient(circle at 85% 20%, #ffb08a 0, transparent 45%), linear-gradient(135deg, #ff7a45, #c2410c); color: #1a0d06; }
.c2 { background: radial-gradient(circle at 85% 20%, #c4f1fb 0, transparent 45%), linear-gradient(135deg, #3fa7c4, #1e4f7a); color: #06141c; }
.book-body { padding: 1.8rem; }
.book-body .meta { font-size: 0.75rem; color: var(--accent-2); margin-bottom: 0.8rem; }
.book-body p { color: #cfd5db; }
.links { display: flex; gap: 1.4rem; margin-top: 1.4rem; font: 500 0.85rem var(--mono); }
.links a { color: var(--accent); border-bottom: 1px solid transparent; }
.links a:hover { border-color: var(--accent); }

/* RESEARCH */
.intro { color: #cfd5db; max-width: 60ch; margin-bottom: 2.5rem; }
.papers { list-style: none; border-top: 1px solid var(--line); }
.papers li {
  display: grid; grid-template-columns: 80px 1fr auto; gap: 1.5rem; align-items: center;
  padding: 1.6rem 0; border-bottom: 1px solid var(--line); transition: padding 0.25s, background 0.25s;
}
.papers li:hover { padding-left: 1rem; background: linear-gradient(90deg, rgba(255, 122, 69, 0.08), transparent); }
.papers .year { color: var(--muted); font-size: 0.85rem; }
.papers p { color: var(--muted); font-size: 0.9rem; }
.papers a { color: var(--accent); font-size: 0.8rem; }
.socials a {
  font: 500 0.8rem var(--mono); padding: 0.6rem 1.1rem; border: 1px solid var(--line);
  border-radius: 999px; transition: border-color 0.2s, color 0.2s;
}
.socials a:hover { border-color: var(--accent); color: var(--accent); }

/* BANNER */
.banner {
  position: relative; border-radius: 24px; overflow: hidden; margin: 2rem 0 0;
  min-height: 460px; display: flex; align-items: flex-end;
}
.banner img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 60% 45%; }
.banner::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(0deg, rgba(14, 17, 22, 0.95) 10%, rgba(14, 17, 22, 0.2) 65%);
}
.banner-text { position: relative; z-index: 1; padding: clamp(1.8rem, 4vw, 3rem); }
.quote { font: 300 italic clamp(1.5rem, 3.4vw, 2.6rem)/1.2 var(--serif); max-width: 26ch; margin-bottom: 1rem; }
.banner .small { color: var(--muted); }

/* CONTACT */
.contact { text-align: center; border-top: none; }
.contact h2 { font-size: clamp(3rem, 8vw, 6rem); font-style: italic; margin-bottom: 1rem; }
.contact p { color: var(--muted); margin-bottom: 2rem; }
.socials { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.8rem; }
.contact .email {
  display: inline-block; margin: 0.5rem 0 2.2rem;
  font: 400 clamp(1.4rem, 4vw, 2.6rem)/1.2 var(--serif); color: var(--accent);
  border-bottom: 2px solid rgba(255, 122, 69, 0.35); padding-bottom: 0.2rem;
  transition: border-color 0.2s, color 0.2s;
}
.contact .email:hover { color: var(--paper); border-color: var(--paper); }
.contact .or { margin-bottom: 1rem; }
.contact .eyebrow { color: var(--accent-2); margin-bottom: 1rem; }

footer {
  display: flex; justify-content: space-between;
  padding: 2rem clamp(1.25rem, 5vw, 4rem); border-top: 1px solid var(--line);
  color: var(--muted); font-size: 0.8rem;
}

/* REVEAL */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.8s ease, transform 0.8s ease; }
.reveal.in { opacity: 1; transform: none; }

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; padding-top: 2.5rem; min-height: auto; }
  .bio, .books, .teach { grid-template-columns: 1fr; }
  .medium-card { flex-direction: column; align-items: flex-start; }
  .papers li { grid-template-columns: 1fr auto; }
  .papers .year { grid-column: 1 / -1; }

  /* Photos: show the whole image on narrow screens */
  .portrait { max-width: 420px; margin-right: 1.2rem; }
  .portrait img { aspect-ratio: auto; height: auto; border-radius: 4px 72px 4px 4px; }
  .portrait::before { border-radius: 4px 72px 4px 4px; }
  .banner { min-height: 0; display: block; background: var(--ink-2); }
  .banner img { position: static; height: auto; aspect-ratio: 3 / 2; object-fit: contain; }
  .banner::after { display: none; }
}

/* Collapse the nav into a menu before the links and language switcher run out of room */
@media (max-width: 1000px) {
  .nav { flex-wrap: wrap; }
  .menu-toggle { display: flex; }
  .nav nav { display: none; flex-basis: 100%; flex-direction: column; gap: 0; padding-top: 0.6rem; }
  .nav.open nav { display: flex; }
  .nav nav a { padding: 0.85rem 0; font-size: 0.85rem; border-top: 1px solid var(--line); color: var(--paper); }
  .nav nav { align-items: stretch; }
  .lang { flex-wrap: wrap; gap: 0.5rem 1.2rem; padding: 0.9rem 0 0.3rem; border-left: none; border-top: 1px solid var(--line); }
  .nav nav .lang a { padding: 0; border-top: none; color: var(--muted); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  #network { display: none; }
}
