/* --- Custom Properties --- */

:root {
  /* Accent — used sparingly: links, active states, highlights */
  --color-accent: #2b6cb0;
  --color-accent-hover: #1f5184;
  --color-accent-wash: rgba(43, 108, 176, 0.08);
  --color-accent-wash-strong: rgba(43, 108, 176, 0.14);

  /* Text (cool near-black + muted gray) */
  --color-text: #1f2328;
  --color-text-muted: #59636e;

  /* Borders & surfaces (consistent cool gray scale) */
  --color-border: #d1d9e0;
  --color-border-muted: #e4e8ec;
  --color-surface: #f6f8fa;
  --color-surface-2: #eaeef2;
}

/* --- Global --- */

html {
  scroll-behavior: smooth;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body {
  font-family: "IBM Plex Serif", Georgia, "Times New Roman", serif;
  background-color: white;
  color: var(--color-text);
  line-height: 1.65;
  margin: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

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

a:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

/* --- Navigation --- */

.top-nav {
  position: sticky;
  top: 0;
  width: 100%;
  background: white;
  border-bottom: 1px solid var(--color-border);
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  z-index: 1000;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.top-nav a {
  text-decoration: none;
  color: var(--color-text);
  font-weight: 500;
  font-size: 1rem;
  padding: 0.1rem 0.15rem;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.top-nav a:hover {
  color: var(--color-accent);
  border-bottom-color: var(--color-border);
}

.top-nav a.active {
  color: var(--color-accent);
  font-weight: 600;
  border-bottom-color: var(--color-accent);
}

/* --- Layout --- */

section,
article.markdown-body {
  scroll-margin-top: 80px;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
  padding-bottom: 2rem;
}

/* --- Markdown body --- */

.markdown-body img:not(.float-img-left):not(.float-img-right):not(.profile-photo):not(.showcase-img) {
  max-width: 100%;
  width: 100%;
  height: auto;
  display: block;
  margin: 1rem auto;
}

.markdown-body h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--color-border-muted);
  padding-bottom: 0.3rem;
}

.markdown-body h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  color: var(--color-text);
}

.markdown-body h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  color: var(--color-text-muted);
}

/* Main page: section headings are demoted (h2/h3) so the page has a single
   h1, but they keep the original visual sizing of the old h1/h2. */
.main-body h2 {
  font-size: 2rem;
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--color-border-muted);
  padding-bottom: 0.3rem;
  color: var(--color-text);
}

.main-body h3 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  color: var(--color-text-muted);
}

/* --- Profile header --- */

.profile-header {
  display: flex;
  align-items: flex-start;
  gap: 2rem;
  margin: 1.5rem 0 1.5rem;
}

.profile-card {
  flex: 1;
  min-width: 0;
}

.profile-card > :first-child {
  margin-top: 0;
}

.profile-card > :last-child {
  margin-bottom: 0;
}

.profile-name {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--color-text);
  margin: 0 0 0.25rem;
}

.profile-role {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--color-text-muted);
  margin: 0 0 1rem;
  line-height: 1.4;
}

.profile-contact {
  font-size: 0.95rem;
  line-height: 1.7;
  margin: 0;
}

.profile-photo-wrap {
  flex-shrink: 0;
  width: 190px;
  max-width: 50%;
}

.profile-photo {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 0;
}

@media (max-width: 700px) {
  .profile-header {
    flex-direction: column-reverse;
    align-items: center;
    gap: 1rem;
    text-align: center;
  }

  .profile-photo-wrap {
    width: 160px;
    max-width: 50%;
  }
}

/* --- Images --- */

figure {
  margin: 0;
}

.float-img-left {
  float: left;
  width: 40%;
  margin: 0 1em 1em 0;
}

.float-img-right {
  float: right;
  width: 40%;
  margin: 0 0 1em 1em;
}

.image-center {
  display: block;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.image-center img {
  display: block;
  margin: 0 auto;
}

.image-wrap {
  margin-bottom: 1rem;
}

.image-caption {
  font-style: italic;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
  text-align: center;
  line-height: 1.3;
}

.image-row {
  display: flex;
  gap: 2%;
  justify-content: center;
  flex-wrap: wrap;
  margin: 1.5rem 0;
}

.image-row .image-wrap {
  margin: 0;
}

.image-row img {
  width: 100%;
  height: auto;
}

/* --- Research showcase (2x2 tiled grid) --- */

.research-showcase {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 1.5rem 0 2rem;
}

.showcase-tile {
  margin: 0;
}

.showcase-tile a {
  display: block;
}

.showcase-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
  margin: 0;
}

.showcase-tile figcaption {
  font-style: italic;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: 0.35rem;
  text-align: center;
  line-height: 1.3;
}

/* --- Video --- */

.video-wrap {
  width: 70%;
  margin: 1.5rem auto;
  text-align: center;
}

.video-wrap video {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
}

.video-row {
  display: flex;
  gap: 2%;
  justify-content: center;
  align-items: flex-start;
  margin: 1.5rem 0;
}

.video-row .video-wrap {
  width: 49%;
}

/* --- Code --- */

details {
  margin-bottom: 1rem;
}

.code-block summary {
  cursor: pointer;
  font-weight: bold;
  margin: 0.5rem 0;
  color: var(--color-accent);
}

/* --- Publications --- */

.pub-entry {
  margin-bottom: 1.25rem;
}

.pub-citation {
  margin: 0 0 0.4rem;
  line-height: 1.45;
}

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

.pub-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.pub-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  border: none;
  border-radius: 999px;
  padding: 0.15rem 0.65rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.pub-pill:hover {
  background: var(--color-border);
  color: var(--color-text);
}

.pub-pill .copy-icon {
  flex-shrink: 0;
}

.pub-pill.copied {
  background: var(--color-accent-wash-strong);
  color: var(--color-accent);
}

.copy-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--color-text);
  color: var(--color-bg, #fff);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translateY(0.5rem);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  z-index: 100;
}

.copy-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.codehilite {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.95rem;
  line-height: 1.5;
}

.codehilite pre {
  margin: 0;
  font-family: "JetBrains Mono", ui-monospace, Consolas, Menlo, Monaco, monospace;
  background: none;
  border: none;
}

/* --- Tables --- */

table {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0;
}

th, td {
  border: 1px solid var(--color-border);
  padding: 0.4rem 0.75rem;
  text-align: left;
}

th {
  background-color: var(--color-surface);
  font-weight: 600;
}

/* --- Blog index --- */

.blog-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.5rem 0 2rem;
}

.filter-btn {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.25rem 0.85rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.filter-btn:hover {
  background: var(--color-surface-2);
  border-color: var(--color-text-muted);
}

.filter-btn.active {
  background: var(--color-text);
  border-color: var(--color-text);
  color: white;
}

.blog-entry {
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--color-border-muted);
}

.blog-entry h3 {
  margin: 0 0 0.2rem;
}

.blog-entry h3 a {
  color: var(--color-text);
}

.blog-entry h3 a:hover {
  color: var(--color-text);
  text-decoration: underline;
  text-decoration-color: var(--color-border);
  text-underline-offset: 0.2em;
}

.blog-date {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--color-text-muted);
  margin: 0 0 0.4rem;
}

.blog-desc {
  margin: 0 0 0.7rem;
  text-align: left;
}

.blog-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag-pill {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  border: none;
  border-radius: 999px;
  padding: 0.15rem 0.65rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.tag-pill:hover {
  background: var(--color-border);
}

/* --- Post navigation (prev/next) --- */

.post-nav {
  max-width: 800px;
  margin: 2.5rem auto 0;
  padding: 1.5rem 0 0;
  border-top: 1px solid var(--color-border-muted);
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
}

.post-nav-link {
  display: flex;
  flex-direction: column;
  max-width: 48%;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.post-nav-prev {
  text-align: left;
}

.post-nav-next {
  text-align: right;
  margin-left: auto;
}

.post-nav-empty {
  visibility: hidden;
}

.post-nav-dir {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: 0.2rem;
}

.post-nav-title {
  font-weight: 600;
  color: var(--color-accent);
}

.post-nav-link:hover .post-nav-title {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

/* --- Footer --- */

.site-footer {
  text-align: center;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-top: 3rem;
  padding: 1rem 0;
  border-top: 1px solid var(--color-border-muted);
}

.site-footer a {
  color: var(--color-accent);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

/* --- Back to top --- */

.back-to-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(0.5rem);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  z-index: 1000;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  color: var(--color-accent);
  border-color: var(--color-accent);
}

/* --- Misc --- */

hr {
  border: none;
  height: 1px;
  background: var(--color-border);
}

.cv-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.cv-line span:first-child {
  font-weight: 500;
}

.cv-line span:last-child {
  white-space: nowrap;
  color: var(--color-text-muted);
}

.cv-sub {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin: 0.1rem 0 0.75rem;
}

/* --- Responsive --- */

@media (max-width: 700px) {
  .markdown-body {
    padding: 0 1rem;
  }

  .top-nav {
    padding: 0.6rem 0.5rem;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .top-nav a {
    font-size: 0.95rem;
    padding: 0.3rem 0.4rem;
  }

  .image-row {
    flex-direction: column;
  }

  .image-row .image-wrap {
    width: 100% !important;
  }

  .video-row {
    flex-direction: column;
  }

  .video-row .video-wrap {
    width: 100%;
  }

  .post-nav {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}
