@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@500;600;700&family=IBM+Plex+Serif:wght@400;500;600&display=swap");

/* ===== Theme ===== */

:root {
  --text-color: #1f2d3a;
  --heading-color: #274257;
  --title-color: #33566f;
  --link-color: #2d6786;
  --link-hover: #204e67;
  --brand-color: #2f5f98;
  --border-color: #d7dfe5;
  --bg-color: #ffffff;
  --topbar-bg: #f3f7fa;
  --button-bg: #d7e2ea;
  --button-text: #1f2d3a;
  --switch-knob: #ffffff;
  --nav-hover-color: #1f4f6b;
}

:root[data-theme="dark"] {
  --text-color: #e5edf4;
  --heading-color: #d6e2ec;
  --title-color: #c8d9e7;
  --link-color: #8cc1de;
  --link-hover: #b5d8eb;
  --brand-color: #9ec7e5;
  --border-color: #2a3b48;
  --bg-color: #111a21;
  --topbar-bg: #18242e;
  --button-bg: #2b4b62;
  --button-text: #e5edf4;
  --switch-knob: #f6fbff;
  --nav-hover-color: #b8d7ea;
}

/* ===== Base page ===== */

body {
  margin: 0;
  padding: 80px 0 0;
  color: var(--text-color);
  background: var(--bg-color);
  font-family: "Charter", "Palatino Linotype", "Book Antiqua", Palatino, "Times New Roman", serif;
  font-size: 18px;
  line-height: 1.7;
}

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

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

/* ===== Fixed Top Navbar ===== */

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 64px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border-color);
  padding: 0 24px;
  box-sizing: border-box;
  z-index: 1000;
}

.topbar-inner {
  width: 100%;
  max-width: 1032px;
  height: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
}

.topbar-left {
  margin-left: 0;
  font-size: 31px;
  font-weight: 700;
  letter-spacing: 0.002em;
  font-family: "Charter", "Palatino Linotype", "Book Antiqua", Palatino, "Times New Roman", serif;
}

.topbar-left a {
  color: var(--brand-color);
  text-decoration: none;
}

.topbar-right {
  margin-left: auto;
  margin-right: 20px;
  display: flex;
  align-items: center;
}

.topbar-right a {
  display: inline-flex;
  align-items: center;
  margin-left: 34px;
  font-size: 17px;
  line-height: 1;
  font-family: "IBM Plex Sans", "Segoe UI", "Helvetica Neue", "Trebuchet MS", Arial, sans-serif;
  font-weight: 500;
}

.topbar-right a:hover {
  color: var(--nav-hover-color);
  text-decoration: none;
}

.topbar-right a[aria-current="page"] {
  color: var(--link-color);
  text-decoration: none;
}

.topbar-right a[aria-current="page"]:hover {
  color: var(--nav-hover-color);
  text-decoration: none;
}

.topbar-right a[href="cv.html"] {
  letter-spacing: 0.03em;
}

.theme-toggle {
  --toggle-track-bg: var(--button-bg);
  margin-left: 22px;
  width: 48px;
  height: 28px;
  border: 1px solid var(--border-color);
  background: var(--toggle-track-bg);
  border-radius: 999px;
  padding: 0;
  position: relative;
  cursor: pointer;
  font-family: "IBM Plex Sans", "Segoe UI", "Helvetica Neue", "Trebuchet MS", Arial, sans-serif;
  transition: background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  --toggle-track-bg: color-mix(in srgb, var(--button-bg) 78%, var(--brand-color) 22%);
  background: var(--toggle-track-bg);
  border-color: color-mix(in srgb, var(--border-color) 72%, var(--brand-color) 28%);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand-color) 16%, transparent);
}

.theme-toggle:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--brand-color) 60%, white);
  outline-offset: 2px;
}

.theme-icon {
  position: absolute;
  top: 8px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  pointer-events: none;
}

.theme-icon-light {
  left: 8px;
  background: #ffd27a;
  box-shadow:
    0 0 0 1px rgba(255, 210, 122, 0.55),
    0 0 0 3px rgba(255, 210, 122, 0.25);
}

.theme-icon-dark {
  right: 8px;
  background: #7aa0c2;
}

.theme-icon-dark::after {
  content: "";
  position: absolute;
  top: 0;
  left: 3px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--toggle-track-bg);
}

.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--switch-knob);
  transition: transform 0.2s ease;
}

.theme-toggle:hover .switch-thumb,
.theme-toggle:focus-visible .switch-thumb {
  transform: translateX(2px);
}

:root[data-theme="dark"] .switch-thumb {
  transform: translateX(20px);
}

:root[data-theme="dark"] .theme-toggle:hover .switch-thumb,
:root[data-theme="dark"] .theme-toggle:focus-visible .switch-thumb {
  transform: translateX(18px);
}

/* ===== Content containers ===== */

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 30px 24px 44px;
  box-sizing: border-box;
  animation: page-fade-in 560ms ease-out both;
}

@keyframes page-fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* ===== Profile layout ===== */

.profile {
  display: flex;
  gap: 36px;
  align-items: flex-start;
}

.profile-text {
  flex: 1;
  max-width: 720px;
}

.profile-aside {
  width: 300px;
  padding-left: 28px;
}

.profile img {
  width: 280px;
  height: auto;
  border-radius: 16px;
  display: block;
}

.profile-email {
  margin-top: 14px;
  font-size: 16px;
  text-align: center;
}

.profile-pronouns {
  margin-top: 4px;
  font-size: 14px;
  text-align: center;
  color: var(--heading-color);
}

.profile-links {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  gap: 24px;
}

.profile-link-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  opacity: 0.85;
  transition: opacity 0.15s ease;
}

.profile-link-icon:hover {
  opacity: 1;
  text-decoration: none;
}

.profile-favicon {
  width: 14px;
  height: 14px;
  object-fit: contain;
  display: block;
  transform-origin: center;
  transform: scale(1);
}

/* ===== Paper list styling ===== */

.paper {
  margin-bottom: 0;
  padding: 10px 0 20px;
}

.paper-title {
  margin-bottom: 6px;
  font-size: 20px;
  font-weight: 650;
  line-height: 1.35;
}

.paper-title a {
  color: var(--heading-color);
}

.paper-title a:hover {
  color: var(--link-color);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.paper-authors {
  margin-top: 2px;
  font-size: 16px;
  color: var(--heading-color);
}

.paper-conf {
  margin-top: 4px;
  font-style: italic;
  font-size: 16px;
}

.back-link {
  margin: 0 0 10px;
  font-size: 14px;
}

.paper-meta {
  margin: 0 0 12px;
}

.paper-meta p {
  margin: 0 0 4px;
}

.resource-links a {
  white-space: nowrap;
}

.resource-link {
  display: inline-block;
  margin-right: 12px;
}

.resource-sep {
  opacity: 0.6;
  margin-right: 12px;
}

.papers-list-fade {
  opacity: 0;
  transition: opacity 560ms ease-out;
}

.papers-list-fade.is-visible {
  opacity: 1;
}

.page-header {
  position: relative;
}

.research-page-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 26px;
}

.research-page-header .page-title {
  margin: 0;
  flex: 1 1 auto;
}

.research-profile-links {
  margin: 0 0 0 auto;
  flex: 0 0 auto;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 12px;
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--topbar-bg);
  height: 40px;
  box-sizing: border-box;
}

.research-profile-links .profile-link-icon {
  width: 32px;
  height: 32px;
}

.research-profile-links .profile-favicon {
  width: 22px;
  height: 22px;
}

.page-header.with-back-link .back-link {
  margin: 0 0 10px;
}

.page-header.with-back-link .back-link a {
  display: inline-block;
  padding: 3px 10px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--topbar-bg);
  text-decoration: none;
}

.page-header.with-back-link .back-link a:hover {
  background: var(--button-bg);
  text-decoration: none;
}

.page-title {
  margin: 0 0 22px;
  font-size: 34px;
  color: var(--heading-color);
}

.container > .page-title + .profile,
.container > .page-title + .cv-actions {
  margin-top: 12px;
}

.conf-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--topbar-bg);
  color: var(--text-color);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.02em;
  font-style: normal;
  text-decoration: none;
}

.conf-badge:hover {
  color: var(--text-color);
  background: var(--button-bg);
  text-decoration: none;
}

p {
  margin: 0 0 1em;
}

.profile-text p {
  margin-top: 0;
}

.profile-text .about-para {
  margin-top: 0;
}

.profile-text .about-para-single {
  margin-bottom: 1em;
}

.profile-text .about-para-wide {
  margin-bottom: 2em;
}

.closing-highlight {
  margin: 0;
  font-size: 18px;
  line-height: 1.45;
  color: var(--heading-color);
  font-weight: 500;
}

/* ===== Teaching list ===== */

.course {
  margin-bottom: 18px;
}

.teaching-list {
  margin: 0;
  padding-left: 22px;
}

.teaching-list li {
  margin-bottom: 12px;
  padding: 5px 0 8px;
  border-bottom: 1px solid color-mix(in srgb, var(--border-color) 72%, transparent);
}

.teaching-course-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
}

.teaching-course-terms {
  margin-top: 6px;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.8;
  color: var(--text-color);
}

.course-code {
  font-weight: 700;
  letter-spacing: 0.01em;
}

.course-level {
  display: inline-block;
  margin-left: 0;
  padding: 3px 11px;
  border: 1px solid color-mix(in srgb, var(--brand-color) 45%, var(--border-color));
  border-radius: 999px;
  background: color-mix(in srgb, var(--topbar-bg) 72%, var(--brand-color) 28%);
  color: var(--heading-color);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.012em;
  font-style: normal;
  white-space: nowrap;
  box-shadow: none;
}

.course-level-subtle {
  border-color: color-mix(in srgb, var(--border-color) 90%, var(--brand-color) 10%);
  background: color-mix(in srgb, var(--topbar-bg) 92%, var(--brand-color) 8%);
  color: var(--heading-color);
  opacity: 0.9;
  font-weight: 600;
}

.research-note {
  margin-top: 14px;
  padding: 6px 0;
  border-left: 0;
  border-radius: 0;
  background: transparent;
  font-size: 14px;
  color: var(--heading-color);
  opacity: 0.85;
}

/* ===== Service page ===== */

.service-subhead {
  margin: 22px 0 6px;
  font-size: 18px;
  font-weight: 600;
  color: var(--heading-color);
  opacity: 0.92;
}

.service-list {
  margin: 0 0 8px;
  padding-left: 22px;
}

.service-list li {
  margin-bottom: 4px;
  font-size: 17px;
  line-height: 1.6;
}

/* ===== CV page ===== */

.cv-actions {
  margin: 0 0 12px;
}

.cv-frame {
  width: 100%;
  height: min(78vh, 980px);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: #ffffff;
}

/* ===== Headings ===== */

h2,
h3 {
  color: var(--heading-color);
  line-height: 1.35;
  font-family: "Charter", "Palatino Linotype", "Book Antiqua", Palatino, "Times New Roman", serif;
  font-weight: 700;
  letter-spacing: 0.002em;
}

/* ===== Mobile ===== */

@media (max-width: 800px) {
  body {
    padding-top: 120px;
    font-size: 17px;
  }

  .topbar {
    height: auto;
    padding: 12px 20px;
  }

  .topbar-inner {
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .topbar-left {
    margin-left: 0;
    font-size: 28px;
  }

  .topbar-right {
    margin-left: 0;
    margin-right: 0;
  }

  .topbar-right a {
    margin: 0 24px 0 0;
    font-size: 16px;
  }

  .theme-toggle {
    margin: 0;
  }

  .theme-icon-light {
    left: 7px;
  }

  .theme-icon-dark {
    right: 7px;
  }

  .profile {
    flex-direction: column;
    gap: 22px;
  }

  .profile-aside {
    width: auto;
    border-top: 0;
    padding-left: 0;
    padding-top: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .profile img {
    width: min(100%, 300px);
    margin: 0 auto;
  }

  .page-title {
    font-size: 30px;
  }

  .research-profile-links {
    gap: 8px;
    padding: 4px 8px;
    height: 34px;
  }

  .research-profile-links .profile-link-icon {
    width: 26px;
    height: 26px;
  }

  .research-profile-links .profile-favicon {
    width: 18px;
    height: 18px;
  }

  .page-header.with-back-link .back-link {
    margin-bottom: 6px;
    display: block;
  }
}

@media (prefers-reduced-motion: reduce) {
  .container {
    animation: none;
  }

  .papers-list-fade {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ───── PRISM demo card (temporary tab, gated by site.prism_demo.enabled) ───── */
.demo-card {
  margin-top: 24px;
  padding: 24px 28px;
  border: 1px solid var(--border, #d8dde6);
  border-radius: 14px;
  background: var(--panel, #f7f8fb);
  max-width: 780px;
}
.demo-card-title {
  margin: 0 0 8px 0;
  font-size: 1.15em;
}
.demo-card-lead {
  margin: 0 0 16px 0;
  color: var(--muted, #5d6573);
}
.demo-cta {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 8px;
  background: var(--accent, #3b6fc7);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  margin-bottom: 18px;
}
.demo-cta:hover { filter: brightness(1.08); }
.demo-credentials {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  margin: 0 0 16px 0;
  font-size: 0.92em;
}
.demo-credentials dt { font-weight: 600; color: var(--muted, #5d6573); }
.demo-credentials dd { margin: 0; }
.demo-note {
  margin: 10px 0 0 0;
  font-size: 0.88em;
  color: var(--muted, #5d6573);
  line-height: 1.55;
}
.demo-note code { font-size: 0.9em; }
.demo-note-ops { padding-top: 10px; border-top: 1px dashed var(--border, #d8dde6); margin-top: 14px; }
.demo-repo { font-size: 0.85em; color: var(--muted, #5d6573); margin-top: 14px; line-height: 1.55; }

/* PRISM demo — deep-link list under the CTA */
.demo-link-list {
  list-style: none;
  padding: 0;
  margin: 0 0 18px 0;
  display: grid;
  gap: 8px;
}
.demo-link-list li {
  padding: 10px 14px;
  border: 1px solid var(--border, #d8dde6);
  border-radius: 8px;
  background: var(--bg, #fff);
  font-size: 0.92em;
  line-height: 1.5;
}
.demo-link-list li a {
  font-weight: 600;
  color: var(--accent, #3b6fc7);
  text-decoration: none;
}
.demo-link-list li a:hover { text-decoration: underline; }

/* PRISM demo — live dev-state strip above the CTA card */
.demo-dev-state {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px 24px;
  margin: 20px 0 24px 0;
  padding: 16px 20px;
  border: 1px solid var(--border, #d8dde6);
  border-left: 3px solid var(--accent, #3b6fc7);
  border-radius: 10px;
  background: var(--panel, #f7f8fb);
  max-width: 780px;
}
.demo-dev-state-cell dt {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted, #5d6573);
  margin: 0 0 2px 0;
  font-weight: 600;
}
.demo-dev-state-cell dd {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink, #1e2430);
  line-height: 1.45;
}
.demo-dev-state-cell dd code {
  font-size: 1em;
  font-weight: 600;
  color: var(--accent, #3b6fc7);
}
