/* ============================================================
   WebpageV2 — Latin Modern / LaTeX-inspired, modernized
   Automatic light/dark via prefers-color-scheme + light-dark()
   ============================================================ */

/* ---- Fonts ---- */
@font-face {
  font-family: 'Latin Modern';
  font-style: normal; font-weight: normal; font-display: swap;
  src: url('./fonts/LM-regular.woff2') format('woff2'),
       url('./fonts/LM-regular.woff')  format('woff'),
       url('./fonts/LM-regular.ttf')   format('truetype');
}
@font-face {
  font-family: 'Latin Modern';
  font-style: italic; font-weight: normal; font-display: swap;
  src: url('./fonts/LM-italic.woff2') format('woff2'),
       url('./fonts/LM-italic.woff')  format('woff'),
       url('./fonts/LM-italic.ttf')   format('truetype');
}
@font-face {
  font-family: 'Latin Modern';
  font-style: normal; font-weight: bold; font-display: swap;
  src: url('./fonts/LM-bold.woff2') format('woff2'),
       url('./fonts/LM-bold.woff')  format('woff'),
       url('./fonts/LM-bold.ttf')   format('truetype');
}
@font-face {
  font-family: 'Latin Modern';
  font-style: italic; font-weight: bold; font-display: swap;
  src: url('./fonts/LM-bold-italic.woff2') format('woff2'),
       url('./fonts/LM-bold-italic.woff')  format('woff'),
       url('./fonts/LM-bold-italic.ttf')   format('truetype');
}

/* ---- CSS Variables (auto light/dark) ---- */
:root {
  color-scheme: light dark;

  --bg:           light-dark(#f5f3f0, #1c1c1e);
  --bg-nav:       light-dark(rgba(245,243,240,0.92), rgba(28,28,30,0.92));
  --surface:      light-dark(#ffffff, #242426);
  --text:         light-dark(#1a1a1a, #e8e8e6);
  --text-muted:   light-dark(#555550, #9a9a96);
  --accent:       light-dark(#8b1a1a, #c9a96e);
  --accent-hover: light-dark(#6b1010, #e0c48a);
  --border:       light-dark(#d4d0ca, #3a3a3c);
  --rule:         light-dark(#c8c4bc, #3a3a3c);

  --font-serif: 'Latin Modern', Georgia, 'Times New Roman', serif;
  --font-mono:  Menlo, Monaco, Consolas, 'Courier New', monospace;

  --max-width: 860px;
  --nav-height: 52px;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, h4, p, ul, ol, li, figure, dl, dd { margin: 0; }

/* ---- Base ---- */
html {
  font-size: 1rem;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-height) + 24px);
}

body {
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text);
  background-color: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
}

/* ---- Navigation ---- */
nav.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background: var(--bg-nav);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

nav.site-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: 2.5rem;
}

nav.site-nav a {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

nav.site-nav a:hover,
nav.site-nav a.active {
  color: var(--accent);
}

/* ---- Page wrapper ---- */
.page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

/* ---- Hero / About ---- */
.hero {
  margin-bottom: 2rem;
}

/* Float the photo right so all text wraps around it */
.hero-photo {
  float: right;
  margin: 0 0 1.5rem 2.5rem;
}

.hero-photo img {
  width: 200px;
  height: 260px;
  object-fit: cover;
  object-position: center top;
  object-position: 70% top;
  border-radius: 4px;
  display: block;
  border: 1px solid var(--border);
  filter: light-dark(none, brightness(0.88) contrast(1.05));
}

/* Clear float after the about section */
#about::after {
  content: '';
  display: table;
  clear: both;
}

.hero-text { display: block; }

.hero-title-block { margin-bottom: 1.1rem; }

.hero-text h1 {
  font-size: 2.2rem;
  font-weight: bold;
  line-height: 1.2;
  margin-bottom: 0.35rem;
  letter-spacing: -0.01em;
}

.hero-text .subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-style: italic;
}

.hero-text .contact-info {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.8;
  margin-bottom: 1.1rem;
}

.hero-text .contact-info a {
  color: var(--text-muted);
  text-decoration: none;
}

.hero-text p {
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
  margin-top: 0.9rem;
  font-size: 0.975rem;
}

.hero-bio {
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
  margin-top: 0.9rem;
  font-size: 0.975rem;
}

/* ---- Section headings ---- */
section {
  margin-top: 3rem;
}

.section-rule {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.4rem;
}

.section-rule h2 {
  font-size: 1.15rem;
  font-weight: bold;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--text);
}

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

/* ---- Publications ---- */
.pub-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.pub-item {
  padding: 1rem 1.2rem;
  border-left: 2px solid var(--accent);
  background: var(--surface);
  border-radius: 0 4px 4px 0;
}

.pub-title {
  font-style: italic;
  font-size: 0.975rem;
  font-weight: normal;
}

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

.pub-title a:hover { color: var(--accent); }

.pub-authors {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.pub-venue {
  font-size: 0.88rem;
  margin-top: 0.15rem;
}

.pub-venue .venue-name {
  font-style: italic;
  color: var(--accent);
}

.pub-venue .venue-detail {
  color: var(--text-muted);
}

/* ---- Notes / Links lists ---- */
.item-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.item-list li {
  font-size: 0.96rem;
}

.item-list li::before {
  content: '—';
  margin-right: 0.5rem;
  color: var(--text-muted);
}

.item-list a {
  color: var(--accent);
  text-decoration: none;
}

.item-list a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ---- Teaching ---- */
.teaching-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.teaching-item {
  display: flex;
  gap: 1rem;
  align-items: baseline;
  font-size: 0.96rem;
}

.teaching-role {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.88rem;
  white-space: nowrap;
  min-width: 80px;
}

/* ---- Graph background canvas ---- */
#graph-bg {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.75;
}

@media (prefers-color-scheme: light) {
  #graph-bg { opacity: 1; }
}

body {
  position: relative;
}

/* Nav, content, and footer sit above the canvas */
nav.site-nav, main.page, footer {
  position: relative;
  z-index: 1;
}

/* Paint a solid background behind the content column so the graph
   is only visible in the left/right margins */
main.page {
  background-color: var(--bg);
  box-shadow: 0 0 40px 20px var(--bg);
}

footer {
  background-color: var(--bg);
}

/* ---- Social links ---- */
.social-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  margin: 0;
}

.social-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.84rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  transition: color 0.15s, border-color 0.15s;
}

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

.social-links svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ---- Pub item inner layout ---- */
.pub-item {
  display: flex;
  gap: 1.2rem;
  align-items: flex-start;
}

.pub-body {
  flex: 1;
  min-width: 0;
}

.pub-figure {
  flex-shrink: 0;
  width: 200px;
}

.pub-figure img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 3px;
  border: 1px solid var(--border);
  object-fit: cover;
  filter: light-dark(none, brightness(0.85));
}

/* ---- Publication group label ---- */
.pub-group-label {
  font-size: 0.78rem;
  font-weight: normal;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
  line-height: 1;
}

/* ---- Pub item: in-progress variant ---- */
.pub-item-wip {
  border-left-color: var(--border);
  opacity: 0.82;
}

/* ---- Pub links row ---- */
.pub-links {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.45rem;
  flex-wrap: wrap;
}

.pub-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.77rem;
  font-family: var(--font-mono);
  padding: 0.15rem 0.55rem;
  border-radius: 3px;
  text-decoration: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: color 0.15s, border-color 0.15s;
}

.pub-tag:hover { color: var(--accent); border-color: var(--accent); }
.pub-tag-gh:hover { color: var(--text); border-color: var(--text); }

/* ---- Publication figure — clickable ---- */
.pub-figure img {
  cursor: zoom-in;
  transition: opacity 0.15s;
}
.pub-figure img:hover { opacity: 0.85; }

/* ---- Lightbox overlay ---- */
#lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.72);
  align-items: center;
  justify-content: center;
  padding: 2rem;
  cursor: zoom-out;
}
#lightbox.open { display: flex; }

#lightbox img {
  max-width: min(820px, 100%);  /* slightly narrower than content canvas */
  max-height: 90vh;
  width: auto;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  object-fit: contain;
  cursor: default;
}

/* ---- Links ---- */
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
a:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---- Footer ---- */
footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
  .hero-photo {
    float: none;
    margin: 0 0 1.2rem 0;
  }

  .hero-photo img {
    width: 140px;
    height: 180px;
  }

  nav.site-nav ul {
    gap: 1.2rem;
  }

  .page {
    padding: 2rem 1rem 3rem;
  }
}
