/* ───────────── Palette: muted violet ───────────── */
:root {
  --bg:          #16121f;
  --card:        #1f1a2c;
  --card-glass:  rgba(31, 26, 44, 0.6);
  --card-edge:   rgba(157, 138, 208, 0.20);
  --text:        #ebe7f2;
  --muted:       #a79fb8;
  --accent:      #9d8ad0;
  --accent-2:    #bcaee6;   /* link hover: a lighter shade of the same violet */
  --rule:        rgba(157, 138, 208, 0.16);
  --u-line:      rgba(157, 138, 208, 0.5);

  /* read by lattice.js */
  --lattice-point: 157, 138, 208;
  --lattice-line:  120, 104, 170;
  --lattice-glow:  188, 174, 230;

  --serif: "Inter", sans-serif;
  --sans:  "Inter", system-ui, -apple-system, sans-serif;
  --mono:  "JetBrains Mono", ui-monospace, monospace;
  color-scheme: dark;
}

/* Light mode: follows the system setting unless the visitor picked a mode
   with the toggle (stored as data-theme on <html>). Keep both blocks in sync. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg:          #f5f3f9;
    --card:        #ffffff;
    --card-glass:  rgba(255, 255, 255, 0.62);
    --card-edge:   rgba(90, 70, 160, 0.14);
    --text:        #1e1a29;
    --muted:       #5d566b;
    --accent:      #5a46a0;
    --accent-2:    #3f2f7a;
    --rule:        rgba(90, 70, 160, 0.12);
    --u-line:      rgba(90, 70, 160, 0.4);
    --lattice-point: 90, 70, 160;
    --lattice-line:  120, 105, 170;
    --lattice-glow:  90, 70, 160;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg:          #f5f3f9;
  --card:        #ffffff;
  --card-glass:  rgba(255, 255, 255, 0.62);
  --card-edge:   rgba(90, 70, 160, 0.14);
  --text:        #1e1a29;
  --muted:       #5d566b;
  --accent:      #5a46a0;
  --accent-2:    #3f2f7a;
  --rule:        rgba(90, 70, 160, 0.12);
  --u-line:      rgba(90, 70, 160, 0.4);
  --lattice-point: 90, 70, 160;
  --lattice-line:  120, 105, 170;
  --lattice-glow:  90, 70, 160;
  color-scheme: light;
}

/* ───────────── Base ───────────── */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font: 400 17px/1.65 var(--sans);
  color: var(--text);
  background: var(--bg);
}
::selection { background: var(--accent); color: var(--bg); }

#lattice {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
}

.site-header, .content { position: relative; z-index: 1; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--u-line);
  text-underline-offset: 3px;
  transition: color .15s, text-decoration-color .15s;
}
a:hover { color: var(--accent-2); text-decoration-color: currentColor; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; }
h2 { font-size: 1.35rem; margin: 0 0 1rem; color: var(--accent); }

/* ───────────── Header ───────────── */
.site-header {
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  padding: 1.6rem 16px;
  display: flex;
  flex-wrap: wrap;
  gap: .6rem 1.5rem;
  align-items: baseline;
  justify-content: space-between;
}
.brand {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}
nav { display: flex; gap: 1.2rem; flex-wrap: wrap; }
nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  font-size: .95rem;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
}
nav a:hover, nav a.active { color: var(--text); border-bottom-color: var(--accent); }

/* Light/dark toggle: shows the sun in dark mode, the moon in light mode */
.theme-toggle {
  align-self: center;
  display: inline-flex;
  padding: 4px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--text); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .theme-toggle .icon-sun { display: none; }
  :root:not([data-theme="dark"]) .theme-toggle .icon-moon { display: block; }
}
:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* ───────────── Main ───────────── */
.content {
  flex: 1;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  padding: 0 16px 3rem;
  /* clicks pass through empty space to the lattice */
  pointer-events: none;
}
.content > * { pointer-events: auto; }

.card {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 18px;
  padding: 1.6rem 1.8rem;
  margin: 0 0 1.4rem;
}
/* glass variant: translucent cards, the lattice shows through softly */
.cards-glass .card {
  background: var(--card-glass);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.prose p:first-child { margin-top: 0; }
.prose p:last-child { margin-bottom: 0; }
.prose strong { color: var(--text); font-weight: 600; }
.prose em { color: var(--accent); }

.hero {
  display: flex;
  gap: 1.6rem;
  align-items: center;
  margin: 2.5rem 0 2rem;
  pointer-events: none;
}
.hero > * { pointer-events: auto; }
.hero h1 {
  font-size: clamp(2.2rem, 7vw, 3.6rem);
  margin: 0 0 .4rem;
  color: var(--text);
}
.tagline { margin: 0 0 1rem; color: var(--muted); font-size: 1.05rem; }
.avatar {
  width: 128px; height: 128px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent);
  box-shadow: 0 0 0 6px var(--rule);
  flex-shrink: 0;
}
.links { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.links a {
  display: inline-block;
  font-family: var(--mono);
  font-size: .8rem;
  padding: .25rem .7rem;
  border-radius: 999px;
  border: 1px solid var(--card-edge);
  background: var(--card);
  text-decoration: none;
}
.links a:hover { border-color: var(--accent-2); }

.page-title { font-size: 2.3rem; margin: 2rem 0 1.4rem; color: var(--text); }

/* ───────────── Lists: news, timeline, publications ───────────── */
.news, .timeline, .pubs { list-style: none; margin: 0; padding: 0; }
.news li, .timeline li, .pubs li {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 1rem;
  padding: .75rem 0;
  border-top: 1px solid var(--rule);
}
.news li:first-child, .timeline li:first-child, .pubs li:first-child { border-top: 0; padding-top: 0; }
.news time, .when, .venue {
  font-family: var(--mono);
  font-size: .8rem;
  color: var(--accent);
  padding-top: .2rem;
}
.where, .authors, .note { display: block; color: var(--muted); font-size: .93rem; }
.timeline p { margin: .3rem 0 0; font-size: .93rem; }
.authors u { text-decoration-color: var(--accent); text-underline-offset: 3px; color: var(--text); }
.pub-links { display: flex; gap: .8rem; margin-top: .3rem; font-family: var(--mono); font-size: .78rem; }

@media (max-width: 560px) {
  body { font-size: 16px; }
  .hero { flex-direction: column; align-items: flex-start; margin-top: 1rem; }
  .card { padding: 1.2rem 1.1rem; border-radius: 14px; }
  .news li, .timeline li, .pubs li { grid-template-columns: 1fr; gap: .2rem; }
}
