/* ===== Theme Variables ===== */
:root {
  --bg: #fdfdfd;
  --fg: #282728;
  --accent: #006cac;
  --muted: #e6e6e6;
  --border: #ece9e9;
  --fg-muted: #646464;
  --max-w: 48rem;
}

[data-theme="dark"] {
  --bg: #212737;
  --fg: #eaedf3;
  --accent: #7db8ff;
  --muted: #343f60;
  --border: #3d4663;
  --fg-muted: #9ca3bf;
}

/* ===== Reset ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  border-color: var(--border);
}

html {
  overflow-y: scroll;
  scroll-behavior: smooth;
}

body {
  font-family: 'Google Sans Code', 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--bg);
  color: var(--fg);
  line-height: 1.75;
  font-size: 15.5px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.15s ease, color 0.15s ease;
}

::selection {
  background-color: var(--accent);
  color: var(--bg);
}

/* ===== Links ===== */
a {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-style: dashed;
  text-decoration-color: var(--fg);
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
  outline-offset: 1px;
}

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

a:focus-visible {
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
  text-decoration: none;
}

/* ===== Layout ===== */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1rem;
  width: 100%;
}

main {
  flex: 1;
}

/* ===== Header ===== */
header {
  background-color: var(--bg);
  transition: background-color 0.15s ease;
}

header > .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.site-title {
  font-size: 1.15rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--fg);
}

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

.site-title.home-icon {
  display: inline-flex;
  align-items: center;
}

.site-title.home-icon svg {
  color: currentColor;
}

/* Desktop nav */
nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

nav a {
  text-decoration: none;
  color: var(--fg);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
}

nav a:hover {
  color: var(--accent);
}

nav a.active {
  text-decoration: underline;
  text-decoration-style: wavy;
  text-decoration-thickness: 2px;
  text-underline-offset: 8px;
  text-decoration-color: var(--accent);
}

nav a:focus-visible {
  outline: 2px dashed var(--accent);
  text-decoration: none;
}

/* Theme toggle */
#theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg);
  border-radius: 4px;
  margin-left: 0.25rem;
}

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

#theme-toggle:focus-visible {
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
}

#theme-toggle svg {
  width: 20px;
  height: 20px;
}

/* Mobile menu button */
#menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
  color: var(--fg);
  border-radius: 4px;
}

#menu-btn:hover {
  color: var(--accent);
}

#menu-btn svg {
  width: 24px;
  height: 24px;
}

/* ===== Hero Section (index page) ===== */
.hero {
  padding: 3.5rem 0 2.5rem;
  display: flex;
  align-items: flex-start;
  gap: 2rem;
}

.hero-text {
  flex: 1;
}

.hero-avatar {
  width: 156px;
  height: 156px;
  border-radius: 50%;
  object-fit: cover;
  object-position: 42% 35%;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.hero h1 {
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.5rem;
}

.hero .rss-link {
  display: inline-block;
  margin-bottom: 0.75rem;
}

.hero .rss-link a {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.85rem;
  text-decoration: none;
  color: var(--accent);
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--accent);
  border-radius: 4px;
  opacity: 0.8;
}

.hero .rss-link a:hover {
  opacity: 1;
}

.hero .rss-link svg {
  width: 14px;
  height: 14px;
}

.hero-bio {
  color: var(--fg);
  margin-bottom: 1rem;
}

.hero-bio a {
  color: var(--fg);
  font-weight: 500;
}

.hero-bio a:hover {
  color: var(--accent);
}

/* Social links row */
.social-links-label {
  font-size: 0.9rem;
  color: var(--fg-muted);
  margin-bottom: 0.35rem;
}

.social-links {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.social-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem;
  color: var(--fg);
  text-decoration: none;
  border-radius: 4px;
  transition: color 0.1s;
}

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

.social-links a:focus-visible {
  outline: 2px dashed var(--accent);
  outline-offset: 1px;
}

.social-links svg {
  width: 22px;
  height: 22px;
}

/* ===== Sections ===== */
hr.section-hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0;
}

.section {
  padding: 2.5rem 0;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.section-header h2 {
  font-size: 1.35rem;
  font-weight: 700;
}

.section-header a {
  font-size: 0.9rem;
  text-decoration: none;
  color: var(--accent);
}

.section-header a:hover {
  text-decoration: underline;
  text-decoration-style: dashed;
}

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

.pub-card {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.pub-card:first-child {
  padding-top: 0;
}

.pub-card:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.pub-title {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--fg);
  margin-bottom: 0.15rem;
}

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

.pub-title a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-style: dashed;
  text-underline-offset: 4px;
}

.pub-venue {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--fg-muted);
  font-style: italic;
  margin-bottom: 0.3rem;
}

.pub-venue svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.8;
}

.pub-authors {
  font-size: 0.9rem;
  color: var(--fg-muted);
  line-height: 1.6;
}

.pub-authors a {
  color: var(--fg-muted);
}

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

.pub-authors .me {
  color: var(--fg);
  font-weight: 500;
  text-decoration: none;
}

.pub-links {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.35rem;
}

.pub-links a {
  font-size: 0.85rem;
  color: var(--accent);
  text-decoration: none;
}

.pub-links a:hover {
  text-decoration: underline;
  text-decoration-style: dashed;
}

/* "All publications" link button */
.link-button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  margin-top: 2rem;
}

.link-button:hover {
  text-decoration: underline;
  text-decoration-style: dashed;
}

.link-button svg {
  width: 18px;
  height: 18px;
}

/* ===== Page Header (for inner pages) ===== */
.page-header {
  padding: 3rem 0 1.5rem;
}

.page-header h1 {
  font-size: 1.85rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.page-header p {
  color: var(--fg-muted);
  font-size: 0.95rem;
}

/* ===== About page ===== */
.about-content {
  padding-bottom: 3rem;
}

.about-content img {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 1.5rem 0;
}

.about-content p {
  margin-bottom: 1rem;
}

.about-content p a {
  font-weight: 500;
}

.about-content h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

/* ===== Footer ===== */
footer {
  margin-top: auto;
}

footer hr {
  border: none;
  border-top: 1px solid var(--border);
}

footer .footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem 0;
}

footer .copyright {
  font-size: 0.85rem;
  color: var(--fg-muted);
  text-align: center;
}

footer .copyright a {
  color: var(--fg-muted);
}

footer .copyright a:hover {
  color: var(--accent);
}

footer .social-links {
  justify-content: center;
}

footer .social-links svg {
  width: 18px;
  height: 18px;
}

footer .footer-credit {
  font-size: 0.8rem;
  color: var(--fg-muted);
  text-align: center;
  margin-top: 0.25rem;
}

footer .footer-credit a {
  color: var(--fg-muted);
}

footer .footer-credit a:hover {
  color: var(--accent);
}

/* ===== Blog List ===== */
.blog-list {
  list-style: none;
}

.blog-list li {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.blog-list li:first-child {
  padding-top: 0;
}

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

.blog-list a {
  text-decoration: none;
  display: block;
}

.blog-list a:hover h3 {
  color: var(--accent);
}

.blog-list h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 0.15rem;
  line-height: 1.5;
}

.blog-list .post-date {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--fg-muted);
  font-style: italic;
}

.blog-list .post-date svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.8;
}

.blog-list .post-desc {
  font-size: 0.9rem;
  color: var(--fg-muted);
  margin-top: 0.2rem;
}

/* ===== Back Button ===== */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  padding: 0;
  margin-bottom: 1.5rem;
  text-decoration: none;
}

.back-btn:hover {
  text-decoration: underline;
  text-decoration-style: dashed;
}

.back-btn svg {
  width: 18px;
  height: 18px;
}

/* ===== Prose (Blog Post Content) ===== */
.prose {
  padding-bottom: 3rem;
}

.prose h1 {
  font-size: 1.85rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  line-height: 1.3;
}

.prose .post-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--fg-muted);
  font-style: italic;
  margin-bottom: 2rem;
}

.prose .post-meta svg {
  width: 14px;
  height: 14px;
  opacity: 0.8;
}

.prose h2,
.prose h3,
.prose h4,
.prose th {
  color: var(--fg);
  margin-bottom: 0.75rem;
}

.prose h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-top: 2.5rem;
}

.prose h3 {
  font-size: 1.1rem;
  font-weight: 600;
  font-style: italic;
  margin-top: 2rem;
}

.prose h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 1.5rem;
}

.prose p,
.prose ul,
.prose ol,
.prose table,
.prose figure {
  color: var(--fg);
  margin-bottom: 1.25rem;
}

.prose a {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-style: dashed;
  text-underline-offset: 4px;
}

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

.prose ul,
.prose ol {
  padding-left: 1.75rem;
}

.prose li {
  margin-bottom: 0.35rem;
}

.prose li::marker {
  color: var(--accent);
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.prose img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  margin: 0 auto;
  display: block;
}

.prose figure {
  text-align: center;
}

.prose figcaption {
  font-size: 0.85rem;
  color: var(--fg-muted);
  margin-top: 0.5rem;
  opacity: 0.75;
}

.prose blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  margin: 1.25rem 0;
  opacity: 0.8;
}

.prose code {
  background-color: var(--muted);
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  font-size: 0.9em;
  word-break: break-word;
}

.prose pre {
  background-color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
  margin-bottom: 1.25rem;
}

.prose pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: 0.88em;
  line-height: 1.6;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
}

.prose th,
.prose td {
  border: 1px solid var(--border);
  padding: 0.5rem;
}

.prose th {
  padding: 0.35rem 0.5rem;
}

.prose strong {
  color: var(--fg);
}

.prose em {
  font-style: italic;
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  body {
    font-size: 14.5px;
  }

  .hero {
    padding: 2.5rem 0 2rem;
    flex-direction: column-reverse;
    align-items: center;
    text-align: center;
  }

  .hero-avatar {
    width: 122px;
    height: 122px;
  }

  .hero h1 {
    font-size: 1.5rem;
  }

  .social-links {
    justify-content: center;
  }

  /* Mobile menu */
  #menu-btn {
    display: inline-flex;
  }

  nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--bg);
    flex-direction: column;
    padding: 0.5rem 1rem 1rem;
    border-bottom: 1px solid var(--border);
    gap: 0;
    z-index: 50;
  }

  nav.open {
    display: flex;
  }

  nav a {
    padding: 0.5rem 0.75rem;
  }

  nav .nav-theme-toggle {
    padding: 0.5rem 0.75rem;
  }

  header > .container {
    position: relative;
  }

  .page-header {
    padding: 2rem 0 1rem;
  }
}

@media (min-width: 641px) {
  .nav-theme-toggle {
    display: contents;
  }

  #menu-btn {
    display: none !important;
  }
}
