/* ===== Base — clean, centered, system-sans (Notion-adjacent, more confident) ===== */
:root {
  --ink: #272a25;            /* primary text */
  --ink-soft: #565a51;       /* secondary text — AA on bg */
  --muted: #828777;          /* tertiary — AA-compliant small text */
  --link: #3a7d52;           /* accent (sage green) */
  --btn: #3a7d52;            /* CTA button bg — AA with white text */
  --sans: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --rule: #e3e7dd;
  --bg: #f7f8f5;             /* faint green-tinted off-white (sage) */
  --surface: #eef1ea;        /* cards / thumbnails / toggle */
  --surface-border: #dfe4d8;
  --thumb-shadow: rgba(30, 40, 25, 0.10);
  --x-icon-invert: 0;
  --max: 860px;
  color-scheme: light;
}

/* Dark palette — system preference, unless toggle forced light. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e6e8e1;
    --ink-soft: #aeb2a7;
    --muted: #878b7f;
    --link: #86c79b;
    --btn: #4f9469;
    --rule: #2c2f29;
    --bg: #181a17;
    --surface: #21241f;
    --surface-border: #363a32;
    --thumb-shadow: rgba(0, 0, 0, 0.45);
    --x-icon-invert: 1;
    color-scheme: dark;
  }
}

/* Manual override via the toggle (wins over system). */
:root[data-theme="dark"] {
  --ink: #e6e8e1;
  --ink-soft: #aeb2a7;
  --muted: #878b7f;
  --link: #86c79b;
  --btn: #4f9469;
  --rule: #2c2f29;
  --bg: #181a17;
  --surface: #21241f;
  --surface-border: #363a32;
  --thumb-shadow: rgba(0, 0, 0, 0.45);
  --x-icon-invert: 1;
  color-scheme: dark;
}

/* Manual override: force light even if the OS prefers dark. */
:root[data-theme="light"] {
  --ink: #272a25;
  --ink-soft: #565a51;
  --muted: #828777;
  --link: #3a7d52;
  --btn: #3a7d52;
  --rule: #e3e7dd;
  --bg: #f7f8f5;
  --surface: #eef1ea;
  --surface-border: #dfe4d8;
  --thumb-shadow: rgba(30, 40, 25, 0.10);
  --x-icon-invert: 0;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Source Serif 4", Georgia, "Times New Roman", "Apple SD Gothic Neo", "Malgun Gothic", serif;
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.page {
  max-width: var(--max);
  margin: 0 auto;
  padding: 56px 24px 96px;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Profile links (chips, top-right of hero) ===== */
.toplinks {
  margin-left: auto;
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
.toplinks a {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  transition: color 0.15s ease;
}
.toplinks a:hover {
  color: var(--link);
  text-decoration: none;
}
.toplinks .ico-img { width: 18px; height: 18px; display: block; flex: none; }
.toplinks a:first-child .ico-img { color: var(--ink-soft); }
.toplinks a:first-child:hover .ico-img { color: var(--link); }
/* X glyph is solid black; invert to white in dark mode. */
.toplinks .ico-x { filter: invert(var(--x-icon-invert)); }

#theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--surface-border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}
#theme-toggle:hover { color: var(--ink); border-color: var(--ink-soft); }
#theme-toggle svg { display: block; }
#theme-toggle .icon-sun { display: none; }
#theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] #theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] #theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) #theme-toggle .icon-moon { display: none; }
}

/* ===== Hero: photo + links | name ===== */
.hero {
  display: flex;
  align-items: center;
  gap: 36px;
  margin-bottom: 56px;
}
.hero-photo {
  flex: none;
}
.hero-photo img {
  width: 168px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 16px;
  display: block;
}
.hero-head h1 {
  font-size: 42px;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.1;
  margin: 0 0 10px;
}
.hero-head .tagline {
  margin: 0;
  font-family: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  color: var(--ink-soft);
  font-weight: 400;
}

/* ===== Bio ===== */
.hero-bio {
  margin-bottom: 64px;
}
.hero-bio p {
  margin: 0 0 16px;
  color: var(--ink);
}
.hero-bio p:last-child { margin-bottom: 0; }

/* ===== Section headings ===== */
.section-title {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 12px;
  letter-spacing: 0;
}
.rule {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 0 0 32px;
}
/* tighten the gap between a section and the one above it */
.entry + .section-title,
.cta-lead + .section-title,
.foot { margin-top: 64px; }
.section-title:not(:first-of-type) { margin-top: 56px; }

/* ===== Publication / project entries ===== */
.entry {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 28px;
  align-items: start;
  margin-bottom: 40px;
}
.entry-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  transition: transform 0.18s ease;
}
.entry-thumb:hover {
  box-shadow: 0 6px 22px var(--thumb-shadow);
  transform: translateY(-2px);
}
.entry-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;     /* show the whole figure, never crop content */
}
.entry-title {
  display: block;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.5;
  margin-bottom: 8px;
}
.entry-title:hover { color: var(--link); text-decoration: none; }
.entry-authors {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.55;
}
.entry-authors.clamp2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.entry-authors u { text-decoration: underline; font-weight: 700; color: var(--ink); }
.authors-toggle {
  margin: 0 0 6px;
  padding: 0;
  border: none;
  background: none;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--link);
  cursor: pointer;
}
.authors-toggle:hover { text-decoration: underline; }
.entry-note {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--muted);
}
.entry-venue {
  margin: 0;
  font-size: 14px;
  color: var(--ink-soft);
}

/* ===== Call to action (replaces calendar embed) ===== */
.cta-lead {
  margin: 0 0 20px;
  color: var(--ink-soft);
  max-width: 60ch;
}
.cta-button {
  display: inline-block;
  padding: 12px 22px;
  border-radius: 10px;
  background: var(--btn);
  color: #fff;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.01em;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  box-shadow: 0 2px 10px rgba(37, 99, 217, 0.25);
}
.cta-button:hover {
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(37, 99, 217, 0.32);
  opacity: 0.96;
}

/* ===== Footer ===== */
.foot {
  padding-top: 24px;
  border-top: 1px solid var(--rule);
  font-size: 13.5px;
  color: var(--muted);
}

/* ===== Responsive ===== */
@media (max-width: 720px) {
  .page { padding: 36px 20px 72px; }
  .hero-head h1 { font-size: 30px; }
  .hero { gap: 18px 22px; flex-wrap: wrap; }
  .hero-photo img { width: 120px; }
  .toplinks {
    margin-left: 0;
    flex-basis: 100%;
    flex-direction: column;
    gap: 10px;
  }
  .entry {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .entry-thumb { aspect-ratio: 16 / 9; max-height: 220px; }
  .section-title { font-size: 24px; }
}
