/* ---------------------------------------------------------------
   Personal site — base styles
   Clean, academic look with a single accent color, in light and
   dark variants. Edit the CSS custom properties below to re-theme
   the whole site.

   Theme resolution (see also main.js and the inline script in
   base.html's <head>):
   - No saved preference -> follows the OS/browser color-scheme
     (the prefers-color-scheme block below).
   - Saved preference ("light"/"dark" in localStorage) -> the
     matching [data-theme="..."] block always wins, in both
     directions, regardless of OS setting.
------------------------------------------------------------------ */

:root {
  --color-bg: #ffffff;
  --color-bg-alt: #f6f7f9;
  --color-text: #1f2430;
  --color-text-muted: #5b6270;
  --color-border: #e3e5ea;
  --color-accent: #1e5eab;
  --color-accent-dark: #143f73;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-heading: var(--font-body);
  --max-width: 920px;

  /* Blue "panel" card used to frame the main sections (Biography, Papers, ...) */
  --card-bg-start: #eaf3ff;
  --card-bg-end: #d5e6fa;
  --card-border: rgba(30, 94, 171, 0.2);
  --card-shadow: rgba(30, 94, 171, 0.28);
  --card-highlight: rgba(255, 255, 255, 0.65);
}

/* OS/browser prefers dark, and the visitor hasn't overridden it */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #14171e;
    --color-bg-alt: #1b1f28;
    --color-text: #e7e9ee;
    --color-text-muted: #9aa1b0;
    --color-border: #2b2f3a;
    --color-accent: #6ba6e8;
    --color-accent-dark: #9fc6f0;

    --card-bg-start: #1d2c42;
    --card-bg-end: #131d2d;
    --card-border: rgba(255, 255, 255, 0.08);
    --card-shadow: rgba(0, 0, 0, 0.55);
    --card-highlight: rgba(255, 255, 255, 0.06);
  }
}

/* Visitor explicitly chose dark (wins over OS setting either way) */
:root[data-theme="dark"] {
  --color-bg: #14171e;
  --color-bg-alt: #1b1f28;
  --color-text: #e7e9ee;
  --color-text-muted: #9aa1b0;
  --color-border: #2b2f3a;
  --color-accent: #6ba6e8;
  --color-accent-dark: #9fc6f0;

  --card-bg-start: #1d2c42;
  --card-bg-end: #131d2d;
  --card-border: rgba(255, 255, 255, 0.08);
  --card-shadow: rgba(0, 0, 0, 0.55);
  --card-highlight: rgba(255, 255, 255, 0.06);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  font-size: 16px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

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

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--color-accent);
  color: #fff;
  padding: 0.5rem 1rem;
  z-index: 100;
}
.skip-link:focus { left: 0; }

img { max-width: 100%; display: block; }

.icon {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.15em;
  flex-shrink: 0;
}

h1, h2, h3, h4 { font-family: var(--font-heading); line-height: 1.25; color: var(--color-text); }
h1 { font-size: 1.9rem; margin: 0 0 0.25rem; }
h2 { font-size: 1.5rem; margin: 2.5rem 0 1rem; padding-top: 1rem; border-top: 1px solid var(--color-border); }
h3 { font-size: 1.15rem; margin: 1.75rem 0 0.75rem; }
h4 { font-size: 1rem; margin: 1.25rem 0 0.35rem; }

/* Header */
.site-header {
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand { display: flex; align-items: center; gap: 0.6rem; color: var(--color-text); }
.brand:hover { text-decoration: none; }
.brand-photo { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 600; font-size: 0.95rem; }
.brand-title { font-size: 0.78rem; color: var(--color-text-muted); }

.menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--color-text);
}

.site-nav { display: flex; align-items: center; gap: 1.25rem; }
.site-nav ul { list-style: none; display: flex; gap: 1.1rem; margin: 0; padding: 0; }
.site-nav a { color: var(--color-text); font-size: 0.92rem; font-weight: 500; }
.site-nav a.active { color: var(--color-accent); }

/* Language switch grouped together with the theme toggle */
.header-controls { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; }
.lang-switch a {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}
.lang-switch a:hover { color: var(--color-accent); border-color: var(--color-accent); text-decoration: none; }

/* Light/dark theme toggle button */
.theme-toggle {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--color-text);
  font-size: 1rem;
  line-height: 1;
}
.theme-toggle:hover { border-color: var(--color-accent); color: var(--color-accent); }
.theme-toggle-icon.theme-icon-sun { display: none; }
.theme-toggle-icon.theme-icon-moon { display: inline; }

/* Effective theme is dark (OS preference, unless overridden) -> show sun (switch to light) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-icon-sun { display: inline; }
  :root:not([data-theme="light"]) .theme-icon-moon { display: none; }
}
/* Visitor explicitly chose dark -> show sun (switch to light), wins over OS setting */
:root[data-theme="dark"] .theme-icon-sun { display: inline; }
:root[data-theme="dark"] .theme-icon-moon { display: none; }
/* Visitor explicitly chose light -> always show moon (switch to dark), wins over OS setting */
:root[data-theme="light"] .theme-icon-sun { display: none; }
:root[data-theme="light"] .theme-icon-moon { display: inline; }

/* Main content */
main { max-width: var(--max-width); margin: 0 auto; padding: 0 1.25rem 3rem; }

/* Hero */
.hero { padding: 2.5rem 0 1rem; }
.hero-inner { display: flex; gap: 1.75rem; align-items: flex-start; flex-wrap: wrap; }
.hero-photo { width: 140px; height: 140px; border-radius: 12px; object-fit: cover; background: var(--color-bg-alt); flex-shrink: 0; }
.hero-text { flex: 1; min-width: 260px; }
.hero-role { color: var(--color-text-muted); margin: 0.1rem 0 0.5rem; font-size: 1.05rem; }
.hero-affiliations { font-size: 0.92rem; margin: 0 0 0.75rem; }
.hero-affiliations a { margin-right: 0; }
.hero-contact { display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; font-size: 0.88rem; }
.hero-contact a { display: inline-flex; align-items: center; gap: 0.35rem; }

.hero-interests {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.9rem;
}
.hero-interests-label { color: var(--color-text-muted); }
.hero-interests ul { list-style: none; padding: 0; margin: 0.35rem 0 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.hero-interests li {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.82rem;
}

/* In-page section nav */
.section-nav {
  position: sticky;
  top: 57px;
  background: var(--color-bg);
  padding-bottom: 0.85rem;
  margin-bottom: 1.75rem;
  z-index: 10;
}
.section-nav ul { list-style: none; display: flex; justify-content: center; gap: 1.25rem; margin: 0; padding: 0.6rem 0 0; flex-wrap: wrap; }
.section-nav a { font-size: 0.88rem; font-weight: 600; color: var(--color-text-muted); }
.section-nav a:hover { color: var(--color-accent); text-decoration: none; }

/* Decorative divider under the section nav, instead of a plain border */
.section-nav::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 140px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--color-accent), transparent);
}
/* Blue "panel" card wrapping each main section (Biography, Papers, Teaching, Projects) */
.page-section {
  scroll-margin-top: 100px;
  margin-bottom: 2.25rem;
  padding: 1.75rem 1.75rem 2.25rem;
  border-radius: 18px;
  border: 1px solid var(--card-border);
  background: linear-gradient(155deg, var(--card-bg-start), var(--card-bg-end));
  box-shadow:
    inset 0 1px 0 var(--card-highlight),
    0 18px 30px -14px var(--card-shadow),
    0 6px 14px -8px var(--card-shadow);
}
.page-section h2 {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

/* About / education */
.about-intro { font-size: 1.02rem; text-align: justify; text-justify: inter-word; hyphens: auto; }
.education-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}
.education-item {
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  background: var(--color-bg);
  box-shadow: 0 4px 10px -6px var(--card-shadow);
}
.education-item h4 { margin-top: 0; }
.education-item .period { display: block; color: var(--color-text-muted); font-weight: 400; font-size: 0.85rem; margin-top: 0.15rem; }
.education-item p { margin: 0.4rem 0; font-size: 0.9rem; }

/* Papers */
.paper-list { padding-left: 1.25rem; }
.paper-list li { margin-bottom: 0.85rem; font-size: 0.94rem; }

/* Teaching */
.course-list { list-style: none; padding: 0; }
.course-list li { padding: 0.35rem 0; border-bottom: 1px solid var(--color-border); font-size: 0.94rem; }
.course-code { color: var(--color-accent); font-weight: 600; font-size: 0.85rem; margin-right: 0.35rem; }
.thesis-list { padding-left: 1.25rem; font-size: 0.94rem; }

/* Projects */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.project-card {
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  background: var(--color-bg);
  box-shadow: 0 4px 10px -6px var(--card-shadow);
}
.project-card h4 { margin-top: 0; }
.project-meta { font-size: 0.82rem; color: var(--color-text-muted); margin: 0 0 0.4rem; }
.project-supported { font-size: 0.85rem; margin: 0.2rem 0; }
.project-desc { font-size: 0.9rem; margin: 0.4rem 0 0.6rem; }
.project-tags { margin: 0.5rem 0 0; }
.project-tags dt { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--color-text-muted); margin-top: 0.5rem; }
.project-tags dd { margin: 0.3rem 0 0; display: flex; flex-wrap: wrap; gap: 0.3rem; }
.tag {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.1rem 0.5rem;
  font-size: 0.78rem;
}

/* Materials page */
.materials-intro { color: var(--color-text-muted); }
.course-materials { padding-top: 1rem; border-top: 1px solid var(--color-border); margin-top: 1.5rem; scroll-margin-top: 100px; }
.course-description { color: var(--color-text-muted); font-size: 0.92rem; }
.materials-file-list { list-style: none; padding: 0; }
.materials-file-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  background: var(--color-bg-alt);
  font-size: 0.92rem;
}
.materials-date { color: var(--color-text-muted); font-size: 0.8rem; white-space: nowrap; }
.materials-empty { color: var(--color-text-muted); font-style: italic; font-size: 0.9rem; }

/* Footer */
.site-footer { border-top: 1px solid var(--color-border); margin-top: 3rem; background: var(--color-bg-alt); }
.footer-inner { max-width: var(--max-width); margin: 0 auto; padding: 1.5rem 1.25rem; font-size: 0.85rem; color: var(--color-text-muted); text-align: center; }
.footer-contact { display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; margin-bottom: 0.6rem; }
.footer-contact a { display: inline-flex; align-items: center; gap: 0.35rem; }
.footer-logos { display: flex; gap: 1rem; margin-bottom: 0.6rem; }
.footer-affiliations a { color: var(--color-text-muted); }

/* Responsive */
@media (max-width: 720px) {
  .menu-toggle { display: inline-flex; align-items: center; gap: 0.4rem; }
  .site-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem 1.25rem;
    gap: 0.9rem;
    display: none;
  }
  .site-nav.open { display: flex; }
  .site-nav ul { flex-direction: column; gap: 0.75rem; }
  .section-nav { top: 0; }
  .hero-photo { width: 96px; height: 96px; }
}
