/* ============================================================
   Design System — Loucas Pillaud-Vivien
   Modern, pastel, chic. Sidebar nav. Compact.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=Inter:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Muted pastel palette */
  --accent:    #5A7CA5;   /* dusty steel blue — primary */
  --warm:      #C2907A;   /* muted terracotta */
  --sage:      #7E9E87;   /* sage green */
  --lavender:  #9A8BB5;   /* dusty lavender */
  --sand:      #B5A67D;   /* antique sand */

  /* Text & background */
  --text:       #2D3038;
  --text-light: #5A5E68;
  --text-muted: #8B8F99;
  --bg:         #FAFAF8;
  --bg-off:     #F3F2EF;
  --border:     rgba(0, 0, 0, 0.07);

  /* Sidebar */
  --sidebar-w:  220px;
  --sidebar-bg: #F3F2EF;

  /* Typography */
  --font-display: 'DM Serif Display', serif;
  --font-body:    'Inter', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  /* Spacing */
  --s1: 0.25rem;
  --s2: 0.5rem;
  --s3: 1rem;
  --s4: 1.5rem;
  --s5: 2rem;
  --s6: 3rem;
  --s7: 4rem;
  --s8: 6rem;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 14.5px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.65;
  text-align: justify;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

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

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}
a:hover { color: var(--text); }

/* --- Typography --- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.25;
  color: var(--text);
}

h1 { font-size: 1.9rem; letter-spacing: -0.01em; }
h2 { font-size: 1.35rem; margin-bottom: var(--s3); }
h3 { font-size: 1.05rem; margin-bottom: var(--s2); }

p { margin-bottom: var(--s3); }
p:last-child { margin-bottom: 0; }

/* ============================================================
   Layout: Sidebar + Main
   ============================================================ */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  padding: var(--s5) var(--s4);
  display: flex;
  flex-direction: column;
  z-index: 100;
  border-right: 1px solid var(--border);
}

.sidebar__name {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
  margin-bottom: var(--s1);
  line-height: 1.3;
}
.sidebar__name:hover { color: var(--text); }

.sidebar__title {
  font-family: var(--font-body);
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-bottom: var(--s5);
  line-height: 1.4;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar__nav a {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--text-light);
  padding: 6px 10px;
  border-radius: 6px;
  transition: all 0.15s;
  text-decoration: none;
}

.sidebar__nav a:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text);
}

.sidebar__nav a.active {
  background: rgba(90, 124, 165, 0.1);
  color: var(--accent);
  font-weight: 500;
}

.sidebar__spacer { flex: 1; }

.sidebar__footer {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.sidebar__footer a {
  color: var(--text-muted);
  border-bottom: 1px solid transparent;
}
.sidebar__footer a:hover {
  color: var(--text-light);
  border-bottom-color: var(--text-muted);
}

/* Mobile sidebar toggle */
.sidebar__toggle { display: none; }
.sidebar__hamburger {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 1001;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 8px;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
}
.sidebar__hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  transition: transform 0.3s, opacity 0.3s;
}

/* --- Main content --- */
.main {
  grid-column: 2;
  max-width: 780px;
  padding: var(--s5) var(--s6);
  width: 100%;
}

.section {
  margin-bottom: var(--s6);
}

.section-divider {
  height: 1px;
  background: var(--accent);
  margin: var(--s5) 0;
}

/* Scroll reveal */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   Typewriter quote
   ============================================================ */
.quote-container {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.6;
  min-height: 2em;
  color: var(--accent);
  margin-bottom: var(--s5);
}

.quote-container .cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: currentColor;
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 0.8s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ============================================================
   Briefly (bio + photo)
   ============================================================ */
.briefly {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: var(--s5);
  align-items: start;
}

.briefly__photo {
  border-radius: 6px;
  width: 100%;
}

.briefly__text {
  font-size: 0.92rem;
  text-align: justify;
}
.briefly__text a { border-bottom: 1px solid rgba(90, 124, 165, 0.3); }
.briefly__text a:hover { border-bottom-color: var(--accent); }

/* Research prose */
.research-prose {
  font-size: 0.92rem;
  text-align: justify;
  line-height: 1.7;
}
.research-prose p { margin-bottom: var(--s3); }

/* ============================================================
   Contact
   ============================================================ */
.contact-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  font-size: 0.88rem;
}

.contact-list li {
  display: flex;
  align-items: baseline;
  gap: var(--s3);
}

.contact-list .label {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  min-width: 60px;
}

/* ============================================================
   Research Interests — Dynamic cards
   ============================================================ */
.interests-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s3);
}

.interest-card {
  padding: var(--s3) var(--s4);
  border-radius: 8px;
  background: var(--bg-off);
  border: 1px solid transparent;
  font-size: 0.88rem;
  line-height: 1.5;
  transition: all 0.25s ease;
  cursor: default;
  position: relative;
  overflow: hidden;
}

.interest-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.interest-card:hover {
  border-color: var(--border);
  background: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

.interest-card:hover::before {
  opacity: 1;
}

.interest-card:nth-child(1)::before { background: var(--sage); }
.interest-card:nth-child(2)::before { background: var(--warm); }
.interest-card:nth-child(3)::before { background: var(--lavender); }
.interest-card:nth-child(4)::before { background: var(--accent); }
.interest-card:nth-child(5)::before { background: var(--sand); }

/* Last card spans full width if odd count */
.interest-card:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

/* ============================================================
   Publications
   ============================================================ */
.pub-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

.pub-item {
  padding-bottom: var(--s4);
  border-bottom: 1px solid var(--border);
}

.pub-item:last-child { border-bottom: none; }

.pub-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1rem;
  margin-bottom: var(--s1);
  line-height: 1.35;
}

.pub-authors {
  font-size: 0.82rem;
  color: var(--text-light);
  margin-bottom: var(--s1);
}

.pub-venue {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
}

.pub-links {
  display: flex;
  gap: var(--s3);
  margin-top: var(--s2);
  font-size: 0.78rem;
  align-items: center;
}

.pub-links a {
  color: var(--accent);
  font-weight: 500;
  letter-spacing: 0.02em;
  font-size: 0.75rem;
}

/* ============================================================
   Accordion
   ============================================================ */
.accordion-trigger {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
  background: none;
  border: none;
  font-family: var(--font-body);
  padding: 0;
  transition: color 0.2s;
}

.accordion-trigger:hover { color: var(--text); }

.accordion-trigger .chevron {
  display: inline-block;
  transition: transform 0.3s ease;
  font-size: 0.6rem;
}

.accordion-trigger[aria-expanded="true"] .chevron {
  transform: rotate(90deg);
}

.accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease, opacity 0.3s ease;
  opacity: 0;
}

.accordion-content.open { opacity: 1; }

.accordion-body {
  padding: var(--s3) 0 var(--s2);
  font-size: 0.82rem;
  color: var(--text-light);
  line-height: 1.65;
}

/* ============================================================
   See-all link
   ============================================================ */
.see-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  font-size: 0.88rem;
  margin-top: var(--s4);
  color: var(--accent);
  transition: gap 0.2s;
}
.see-all:hover { gap: 10px; }

/* ============================================================
   Presentations
   ============================================================ */
.pres-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.pres-item { font-size: 0.88rem; line-height: 1.5; }
.pres-title { font-weight: 500; }
.pres-meta { color: var(--text-muted); font-size: 0.82rem; font-style: italic; }
.pres-links {
  display: inline-flex;
  gap: var(--s3);
  margin-left: var(--s2);
}
.pres-links a {
  font-weight: 500;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

/* ============================================================
   Footer (in-main)
   ============================================================ */
.footer {
  margin-top: var(--s7);
  padding: var(--s5) 0;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.footer a { color: var(--text-muted); }
.footer a:hover { color: var(--text-light); }

.footer__links {
  display: flex;
  gap: var(--s4);
  list-style: none;
  margin-bottom: var(--s2);
}

/* ============================================================
   Research Map Page
   ============================================================ */
.graph-page .main {
  max-width: 100%;
  padding-right: var(--s5);
}

.graph-tabs {
  display: flex;
  gap: var(--s2);
  margin-bottom: var(--s3);
}

.graph-tab {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.82rem;
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: none;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-light);
}

.graph-tab.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(90, 124, 165, 0.06);
}

.graph-tab:hover:not(.active) { border-color: rgba(0,0,0,0.15); }

.graph-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: var(--s3);
  height: calc(100vh - 200px);
  min-height: 480px;
}

.graph-canvas {
  border: 1px solid #2a2e3e;
  border-radius: 8px;
  background: #1a1e2e;
  position: relative;
  overflow: hidden;
}

.graph-controls {
  position: absolute;
  bottom: var(--s3);
  right: var(--s3);
  display: flex;
  gap: var(--s2);
  z-index: 10;
}

.graph-controls button {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  color: var(--text-light);
}

.graph-controls button:hover { background: var(--bg-off); }

.graph-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: var(--s4);
  overflow-y: auto;
  background: white;
}

.graph-panel h3 {
  font-family: var(--font-display);
  margin-bottom: var(--s3);
}

.graph-panel .panel-empty {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-style: italic;
}

.graph-panel .panel-title {
  font-family: var(--font-display);
  font-size: 1rem;
  margin-bottom: var(--s2);
}

.graph-panel .panel-authors { font-size: 0.82rem; color: var(--text-light); margin-bottom: var(--s2); }
.graph-panel .panel-venue { font-size: 0.82rem; color: var(--text-muted); font-style: italic; margin-bottom: var(--s3); }
.graph-panel .panel-abstract { font-size: 0.82rem; line-height: 1.6; color: var(--text-light); margin-bottom: var(--s3); }
.graph-panel .panel-tags { display: flex; flex-wrap: wrap; gap: var(--s2); margin-bottom: var(--s3); }
.graph-panel .panel-link { font-weight: 500; font-size: 0.82rem; }

/* Filters */
.graph-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  margin-bottom: var(--s3);
  align-items: center;
}

.filter-btn {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.72rem;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1.5px solid;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.02em;
}

.filter-btn.active { color: white !important; }

.filter-btn[data-theme="kernel-methods"]  { border-color: var(--accent);   color: var(--accent); }
.filter-btn[data-theme="sgd-dynamics"]    { border-color: var(--warm);     color: var(--warm); }
.filter-btn[data-theme="gradient-flows"]  { border-color: var(--sage);     color: var(--sage); }
.filter-btn[data-theme="index-models"]    { border-color: var(--lavender); color: var(--lavender); }
.filter-btn[data-theme="variational"]     { border-color: var(--sand);     color: var(--sand); }

.filter-btn.active[data-theme="kernel-methods"]  { background: var(--accent); }
.filter-btn.active[data-theme="sgd-dynamics"]    { background: var(--warm); }
.filter-btn.active[data-theme="gradient-flows"]  { background: var(--sage); }
.filter-btn.active[data-theme="index-models"]    { background: var(--lavender); }
.filter-btn.active[data-theme="variational"]     { background: var(--sand); }

.filter-search {
  font-family: var(--font-body);
  font-size: 0.82rem;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  transition: border-color 0.2s;
  width: 180px;
  background: white;
}

.filter-search:focus { border-color: var(--accent); }

/* Legend */
.graph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: var(--s3);
  align-items: center;
}

.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-shape { width: 12px; height: 12px; border: 1.5px solid var(--text-muted); }
.legend-shape.circle { border-radius: 50%; }
.legend-shape.square { border-radius: 2px; }
.legend-shape.diamond { transform: rotate(45deg); width: 10px; height: 10px; }
.legend-color { width: 10px; height: 10px; border-radius: 50%; }

/* Tags */
.tag {
  display: inline-block;
  font-weight: 500;
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.02em;
}

.tag--kernel-methods  { background: rgba(90, 124, 165, 0.12);  color: var(--accent); }
.tag--sgd-dynamics    { background: rgba(194, 144, 122, 0.15); color: var(--warm); }
.tag--gradient-flows  { background: rgba(126, 158, 135, 0.15); color: var(--sage); }
.tag--index-models    { background: rgba(154, 139, 181, 0.15); color: var(--lavender); }
.tag--variational     { background: rgba(181, 166, 125, 0.15); color: #8a7e5c; }

/* ============================================================
   Markdown content pages
   ============================================================ */
.page-content h1 { margin-bottom: var(--s5); }

.md-content h2 {
  margin-top: var(--s5);
  margin-bottom: var(--s3);
  padding-bottom: var(--s2);
  border-bottom: 1px solid var(--border);
}

.md-content h3 { margin-top: var(--s4); }

.md-content ul, .md-content ol {
  padding-left: var(--s4);
  margin-bottom: var(--s3);
}

.md-content li { margin-bottom: var(--s2); font-size: 0.92rem; }
.md-content a { border-bottom: 1px solid rgba(90, 124, 165, 0.3); }
.md-content a:hover { border-bottom-color: var(--accent); }
.md-content strong { font-weight: 600; }

/* ============================================================
   Acknowledgments
   ============================================================ */
.ack-intro {
  font-size: 0.88rem;
  color: var(--text-light);
  font-style: italic;
  margin-bottom: var(--s4);
  max-width: 550px;
}

.shuffle-btn {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.82rem;
  padding: 6px 16px;
  border: 1.5px solid var(--warm);
  border-radius: 6px;
  background: transparent;
  color: var(--warm);
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: var(--s5);
}

.shuffle-btn:hover { background: var(--warm); color: white; }

.ack-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s3);
}

.ack-card {
  padding: var(--s4);
  border-radius: 8px;
  background: white;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.ack-card:nth-child(5n+1) { border-left-color: var(--accent); }
.ack-card:nth-child(5n+2) { border-left-color: var(--warm); }
.ack-card:nth-child(5n+3) { border-left-color: var(--sage); }
.ack-card:nth-child(5n+4) { border-left-color: var(--lavender); }
.ack-card:nth-child(5n+5) { border-left-color: var(--sand); }

.ack-person { font-family: var(--font-display); font-size: 1rem; margin-bottom: var(--s2); }
.ack-text { font-size: 0.88rem; color: var(--text-light); line-height: 1.6; }

/* ============================================================
   About
   ============================================================ */
.about-header {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: var(--s5);
  align-items: start;
  margin-bottom: var(--s5);
}

.about-photo { border-radius: 6px; width: 100%; }

.review-section h3 { margin-top: var(--s4); }

.review-list {
  list-style: none;
  padding: 0;
  margin-bottom: var(--s3);
}

.review-list li {
  font-size: 0.88rem;
  padding: var(--s1) 0;
  padding-left: var(--s3);
  position: relative;
}

.review-list li::before {
  content: '\2013';
  position: absolute;
  left: 0;
  color: var(--text-muted);
}

/* ============================================================
   Blog
   ============================================================ */
.coming-soon {
  padding: var(--s8) 0;
  color: var(--text-muted);
}

.coming-soon h2 {
  font-size: 1.5rem;
  margin-bottom: var(--s3);
  color: var(--text-light);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.08);
  }

  .sidebar__toggle:checked ~ .sidebar {
    transform: translateX(0);
  }

  .sidebar__hamburger { display: flex; }

  .main {
    grid-column: 1;
    padding: var(--s5) var(--s4);
    padding-top: calc(var(--s5) + 52px); /* room for hamburger */
  }

  .briefly { grid-template-columns: 1fr; }
  .briefly__photo { max-width: 180px; }
  .about-header { grid-template-columns: 1fr; }
  .about-photo { max-width: 160px; }
  .interests-grid { grid-template-columns: 1fr; }

  .graph-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .graph-canvas { min-height: 400px; }
  .graph-panel { max-height: 280px; }
}

/* ============================================================
   Reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .accordion-content { transition: none; }
  .quote-container .cursor { animation: none; }
  .ack-card { transition: none; }
  .interest-card { transition: none; }
  .interest-card:hover { transform: none; }
  * { scroll-behavior: auto !important; }
}

/* ============================================================
   Print
   ============================================================ */
@media print {
  .sidebar, .graph-controls, .shuffle-btn { display: none; }
  .layout { grid-template-columns: 1fr; }
  .main { grid-column: 1; padding: 0; }
  body { font-size: 11px; }
  .pub-item { break-inside: avoid; }
  a { color: var(--text); }
}
