/* ── Reset ── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --text: #1a1a1a;
  --text-2: #555;
  --text-3: #888;
  --accent: #4a6fa5;
  --border: #e5e5e5;
  --bg: #fff;
  --bg-hover: #f8f8f8;
  --sans: "Inter", -apple-system, "Segoe UI", "Helvetica Neue", sans-serif;
  --serif: "Lora", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --max-w: 620px;
}

/* ── Dark theme ── */
[data-theme="dark"] {
  --text: #e0e0e0;
  --text-2: #a0a0a0;
  --text-3: #707070;
  --accent: #7ba3d4;
  --border: #2a2a2a;
  --bg: #141414;
  --bg-hover: #1e1e1e;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --text: #e0e0e0;
    --text-2: #a0a0a0;
    --text-3: #707070;
    --accent: #7ba3d4;
    --border: #2a2a2a;
    --bg: #141414;
    --bg-hover: #1e1e1e;
  }
}

html {
  font-size: 16px;
  hanging-punctuation: first last;
}

body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1, "liga" 1;
  border-top: 2.5px solid var(--accent);
}

/* ── Nav ── */
nav {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: calc(3.5rem - 2.5px) 1.5rem 0.5rem;
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.nav-links {
  display: flex;
  gap: 1.25rem;
  list-style: none;
}

.nav-links a {
  font-size: 0.9rem;
  color: var(--text-3);
  text-decoration: none;
}

.nav-links a:hover {
  color: var(--text);
}

.nav-links a.active {
  color: var(--accent);
  border-bottom: 1.5px solid var(--accent);
  padding-bottom: 1px;
}

/* ── Main ── */
main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 5rem;
}

/* ── Sidebar card ── */
.sidebar-card {
  position: fixed;
  top: 7.5rem;
  left: calc(50% - var(--max-w) / 2 - 140px);
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 110px;
  padding-right: 20px;
  border-right: 1px solid var(--border);
}

.sidebar-card img {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  object-fit: cover;
}

.card-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  margin-top: 0.6rem;
  text-align: center;
  line-height: 1.3;
}

.card-links {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.card-links a {
  color: var(--text-3);
  transition: color 0.15s ease;
}

.card-links a:hover {
  color: var(--accent);
}

.card-links a svg {
  width: 20px;
  height: 20px;
  display: block;
}

/* ── Intro ── */
.intro h1 {
  font-family: var(--sans);
  font-size: 1.75rem;
  font-weight: 300;
  line-height: 1.35;
  letter-spacing: -0.02em;
  margin-bottom: 2rem;
}

.intro p {
  font-family: var(--sans);
  font-size: 0.92rem;
  color: var(--text-2);
  line-height: 1.75;
  margin-bottom: 0.75rem;
}

.intro em {
  font-style: italic;
  color: var(--text);
}

/* ── Page title ── */
.page-title {
  font-family: var(--sans);
  font-size: 1.75rem;
  font-weight: 300;
  letter-spacing: -0.02em;
  margin-bottom: 2rem;
}

/* ── Section headings ── */
h2 {
  font-family: var(--sans);
  font-size: 1.6rem;
  font-weight: 400;
  color: var(--text);
  margin-top: 3rem;
  margin-bottom: 2rem;
}

h2:first-of-type {
  margin-top: 0;
}

/* ── Projects ── */
.project {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.project:last-of-type {
  border-bottom: none;
  margin-bottom: 0.5rem;
}

.project h3 {
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 600;
  margin-top: 0;
  margin-bottom: 0.3rem;
}

.project p {
  font-size: 0.88rem;
  color: var(--text-2);
  line-height: 1.6;
  margin-bottom: 0.25rem;
}

.project .pub-links {
  margin-top: 0.4rem;
}

/* ── Publication list ── */
.pub-list {
  list-style: none;
}

.pub-list li {
  padding: 0.6rem 0.5rem;
  margin: 0 -0.5rem;
  border-bottom: 1px solid var(--border);
  border-radius: 4px;
  display: grid;
  grid-template-columns: 2.8rem 1fr;
  gap: 0 0.75rem;
  align-items: baseline;
  font-size: 0.88rem;
  line-height: 1.5;
  transition: background 0.15s ease;
}

.pub-list li:hover {
  background: var(--bg-hover);
}

.pub-list li:last-child {
  border-bottom: none;
}

.pub-category {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-3);
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

.pub-category:first-of-type {
  margin-top: 0;
}

.pub-year {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.pub-no-year > div {
  grid-column: 1 / -1;
}

.pub-title {
  color: var(--text);
}

.pub-meta {
  color: var(--text-2);
  font-size: 0.82rem;
}

.pub-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.3rem;
}

.pub-links a {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--accent);
  border: 1px solid var(--border);
  padding: 0.25em 0.6em;
  border-radius: 4px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.pub-links a:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.pub-links > a > svg {
  width: 10px;
  height: 10px;
  margin-right: 3px;
  flex-shrink: 0;
}


.pub-badge {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--accent);
  color: #fff;
  padding: 0.15em 0.45em;
  border-radius: 2px;
  vertical-align: middle;
  margin-left: 0.25em;
}

/* ── Contact ── */
.contact-block dt {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-top: 1.5rem;
}

.contact-block dt:first-of-type {
  margin-top: 0;
}

.contact-block dd {
  font-size: 0.92rem;
  margin-top: 0.2rem;
  line-height: 1.5;
}

.contact-block dd a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}

.contact-block dd a:hover {
  border-color: var(--accent);
}

/* ── Theme toggle ── */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-3);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.theme-toggle svg {
  width: 14px;
  height: 14px;
  display: block;
}

.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
  html:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
}

/* ── Theme transitions ── */
body,
.sidebar-card,
.card-name,
.card-links a,
.nav-links a,
.pub-links a,
.contact-block dd a,
.project,
.pub-list li,
footer {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Dark mode portrait */
[data-theme="dark"] .sidebar-card img {
  filter: brightness(0.9);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .sidebar-card img {
    filter: brightness(0.9);
  }
}

/* ── Footer ── */
footer {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 3rem 1.5rem 2rem;
  font-size: 0.72rem;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Fade in ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}

main {
  animation: fadeIn 0.4s ease both;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .sidebar-card {
    position: static;
    flex-direction: row;
    width: auto;
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 1.5rem 1.5rem 0;
    align-items: center;
    gap: 0.75rem;
    border-right: none;
  }
  .sidebar-card img {
    width: 44px;
    height: 44px;
  }
  .card-name {
    margin-top: 0;
    font-size: 0.85rem;
  }
  .card-links {
    margin-top: 0;
    margin-left: auto;
  }
}

@media (max-width: 600px) {
  .sidebar-card { padding: 1.25rem 1.25rem 0; }
  nav { padding: 1.5rem 1.25rem 0.75rem; }
  .nav-links { flex-wrap: wrap; }
  main { padding: 2rem 1.25rem 4rem; }
  .intro h1 { font-size: 1.4rem; }
  .pub-list li { grid-template-columns: 1fr; gap: 0; }
  .pub-year { margin-bottom: 0.1rem; }
  footer { padding: 2rem 1.25rem; }
}
