/* ==========================================================================
   Tokens
   ========================================================================== */
:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface-2: #efede6;
  --text: #16212a;
  --muted: #5a6670;
  --border: #dedad0;
  --accent: #1f7c86;
  --accent-strong: #155e66;
  --accent-soft: #dcefef;
  --shadow: 0 1px 2px rgb(20 30 40 / 0.05), 0 4px 16px rgb(20 30 40 / 0.06);

  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Fraunces", Georgia, "Times New Roman", serif;

  --wrap: 68rem;
  --gutter: clamp(1rem, 4vw, 2rem);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1720;
    --surface: #15212c;
    --surface-2: #1b2935;
    --text: #e6ebef;
    --muted: #9aa8b3;
    --border: #283845;
    --accent: #5cc3cc;
    --accent-strong: #86d6dc;
    --accent-soft: #173a40;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 16px rgb(0 0 0 / 0.25);
  }
}
:root[data-theme="dark"] {
  --bg: #0e1720;
  --surface: #15212c;
  --surface-2: #1b2935;
  --text: #e6ebef;
  --muted: #9aa8b3;
  --border: #283845;
  --accent: #5cc3cc;
  --accent-strong: #86d6dc;
  --accent-soft: #173a40;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 16px rgb(0 0 0 / 0.25);
}

/* ==========================================================================
   Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 5rem; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 1rem/1.65 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; }
h1, h2 { font-family: var(--font-serif); font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 1.1rem; font-weight: 600; }
h4 { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 1.1em; }
p { margin: 0 0 1em; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-strong); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
strong { font-weight: 600; }

.wrap { max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }
.icon { flex: none; vertical-align: -0.2em; }

.skip-link { position: absolute; left: -999px; top: .5rem; background: var(--surface); padding: .5rem 1rem; z-index: 100; }
.skip-link:focus { left: .5rem; }

.eyebrow { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); margin-bottom: .75rem; }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 42rem; }
.minor { font-family: var(--font-sans); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* Spectrum bar: a continuous spectrum with a few dark absorption lines. */
.spectrum {
  height: 6px;
  background:
    linear-gradient(90deg,
      transparent 11.5%, rgb(0 0 0 / .55) 11.5% 12%, transparent 12%,
      transparent 27%, rgb(0 0 0 / .55) 27% 27.4%, transparent 27.4%,
      transparent 38%, rgb(0 0 0 / .45) 38% 38.3%, transparent 38.3%,
      transparent 52.5%, rgb(0 0 0 / .55) 52.5% 53.2%, transparent 53.2%,
      transparent 58%, rgb(0 0 0 / .4) 58% 58.3%, transparent 58.3%,
      transparent 81%, rgb(0 0 0 / .55) 81% 81.6%, transparent 81.6%),
    linear-gradient(90deg, #6b3fa0, #3b5bdb, #1c9fd6, #1fb58f, #9ccc3c, #f2c230, #f08a2c, #d9412b);
  opacity: .85;
}

/* ==========================================================================
   Header & footer
   ========================================================================== */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 1rem; min-height: 3.75rem; }
.brand { display: flex; align-items: center; gap: .6rem; color: var(--text); text-decoration: none; font-weight: 600; margin-right: auto; }
.brand img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.site-nav { display: flex; align-items: center; gap: .25rem; }
.site-nav a { color: var(--muted); text-decoration: none; padding: .4rem .7rem; border-radius: 8px; font-size: .95rem; font-weight: 500; }
.site-nav a:hover { color: var(--text); background: var(--surface-2); }
.site-nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }

.icon-btn {
  display: inline-grid; place-items: center; width: 2.4rem; height: 2.4rem;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.nav-toggle { display: none; }

.theme-toggle .when-dark { display: none; }
:root[data-theme="dark"] .theme-toggle .when-dark { display: inline; }
:root[data-theme="dark"] .theme-toggle .when-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .when-dark { display: inline; }
  :root:not([data-theme="light"]) .theme-toggle .when-light { display: none; }
}

@media (max-width: 720px) {
  .nav-toggle { display: inline-grid; }
  .site-nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; padding: .5rem var(--gutter) 1rem;
    background: var(--bg); border-bottom: 1px solid var(--border);
  }
  .site-nav.open { display: flex; }
  .site-nav a { padding: .7rem .75rem; }
  .theme-toggle { align-self: flex-start; }
  .brand span { font-size: .95rem; }
}

.site-footer { margin-top: 5rem; border-top: 1px solid var(--border); }
.site-footer .spectrum { height: 3px; }
.footer-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; padding-block: 1.75rem; color: var(--muted); font-size: .9rem; }
.footer-inner p { margin: 0; }
.link-row { display: flex; gap: .25rem; list-style: none; margin: 0; padding: 0; }
.link-row a { display: inline-grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 8px; color: var(--muted); }
.link-row a:hover { color: var(--text); background: var(--surface-2); }

/* ==========================================================================
   Components
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 2.6rem; padding: .5rem 1rem;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font: 500 .95rem var(--font-sans); text-decoration: none; cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.btn:hover { border-color: var(--accent); color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
:root[data-theme="dark"] .btn-primary, :root[data-theme="dark"] .btn-primary:hover { color: #0e1720; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-primary, :root:not([data-theme="light"]) .btn-primary:hover { color: #0e1720; }
}
.btn-icon { width: 2.6rem; padding: 0; }

.tags { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; margin: 0; padding: 0; }
.tags li { background: var(--accent-soft); color: var(--text); border-radius: 999px; padding: .2rem .7rem; font-size: .85rem; }

.logo { width: 44px; height: 44px; border-radius: 10px; object-fit: contain; background: #fff; border: 1px solid var(--border); flex: none; }

/* ==========================================================================
   Home
   ========================================================================== */
.hero { position: relative; }
.hero-inner { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: clamp(1.5rem, 5vw, 3.5rem); padding-block: clamp(3rem, 8vw, 5.5rem) clamp(2.5rem, 6vw, 4rem); }
.hero-photo { width: clamp(140px, 22vw, 220px); height: auto; aspect-ratio: 1; border-radius: 50%; object-fit: cover; box-shadow: var(--shadow); }
.hero h1 { font-size: clamp(2.1rem, 5.5vw, 3.4rem); margin-bottom: .35em; }
.honorific { color: var(--muted); font-weight: 500; }
.hero .lead { font-size: clamp(1.05rem, 2vw, 1.25rem); color: var(--text); opacity: .85; }
.location { display: flex; align-items: center; gap: .4rem; color: var(--muted); font-size: .95rem; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.5rem; }
@media (max-width: 640px) {
  .hero-inner { grid-template-columns: 1fr; text-align: left; }
  .hero-photo { width: 120px; }
}

.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin-top: 2.5rem; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.fact { background: var(--surface); padding: 1.1rem 1.25rem; display: flex; flex-direction: column; gap: .15rem; }
.fact-value { font-family: var(--font-serif); font-size: 1.45rem; font-weight: 600; }
.fact-label { color: var(--muted); font-size: .85rem; }
@media (max-width: 720px) { .facts { grid-template-columns: repeat(2, 1fr); } }

.section { margin-top: clamp(3.5rem, 8vw, 5.5rem); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.section-title { font-size: clamp(1.6rem, 3.5vw, 2.1rem); margin-bottom: 1.25rem; }
.more { display: inline-flex; align-items: center; gap: .35rem; font-weight: 500; text-decoration: none; }

.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: clamp(1.5rem, 5vw, 3.5rem); align-items: start; }
@media (max-width: 820px) { .split { grid-template-columns: 1fr; } }
.split aside .tags { margin-top: .25rem; }

.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.timeline-item { display: flex; gap: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.timeline-item h3 { margin-bottom: .15rem; }
.timeline-item p:last-child { margin-bottom: 0; }
.when { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; margin-bottom: .2rem; }
.org { color: var(--muted); font-size: .95rem; margin-bottom: .5rem; }
.org a { color: inherit; font-weight: 500; }

.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
@media (max-width: 960px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .cards { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; display: flex; flex-direction: column; }
.card p { font-size: .95rem; }
.card-kind { font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin-bottom: .5rem; }
.card-links { margin-top: auto; margin-bottom: 0; display: flex; flex-wrap: wrap; gap: .35rem 1rem; }
.card-links a { display: inline-flex; align-items: center; gap: .3rem; font-weight: 500; font-size: .9rem; text-decoration: none; }
.card-links .icon { width: 14px; height: 14px; }

.pubs { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.1rem; }
.pub p { margin: 0; }
.pub-title { font-weight: 600; line-height: 1.4; }
.pub-meta { color: var(--muted); font-size: .88rem; margin-top: .2rem !important; }
.pub-meta strong { color: var(--text); font-weight: 600; }
.pub-links { font-size: .88rem; margin-top: .2rem !important; }

.beyond { display: grid; grid-template-columns: 11rem 1fr; gap: 1.5rem; align-items: center; text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.beyond:hover { border-color: var(--accent); color: var(--text); }
.beyond img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; }
.beyond .section-title { margin-bottom: .5rem; }
.beyond p { margin: 0; color: var(--muted); }
@media (max-width: 560px) { .beyond { grid-template-columns: 1fr; } }

.contact { background: var(--surface-2); padding-block: clamp(3rem, 7vw, 4.5rem); margin-bottom: -5rem; }
.contact-list { list-style: none; padding: 0; margin: 1.5rem 0 0; display: flex; flex-wrap: wrap; gap: .6rem; }
.contact-list a { display: inline-flex; align-items: center; gap: .5rem; padding: .55rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; text-decoration: none; color: var(--text); font-size: .95rem; }
.contact-list a:hover { border-color: var(--accent); }

/* ==========================================================================
   Pages
   ========================================================================== */
.page { padding-top: clamp(2.5rem, 6vw, 4rem); }
.page-header { margin-bottom: 2rem; }
.page-header h1 { font-size: clamp(2rem, 5vw, 3rem); }
.banner { width: 100%; max-height: 18rem; object-fit: cover; border-radius: var(--radius); margin-bottom: 2.5rem; }

.prose { max-width: 44rem; }
.page .prose { font-size: 1.03rem; }
.prose h2 { font-size: 1.65rem; margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.prose h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.prose h3 { margin-top: 1.75rem; font-size: 1.15rem; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin-bottom: .35rem; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }
.prose .pubs { padding-left: 0; margin-block: 1.25rem; }
.prose > p:last-child { margin-bottom: 0; }

.video { position: relative; aspect-ratio: 16 / 9; margin: 1.5rem 0; border-radius: var(--radius); overflow: hidden; background: #000; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr)); gap: .75rem; margin-top: 1.5rem; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; transition: transform .2s; }
.gallery a:hover img { transform: scale(1.02); }

/* ==========================================================================
   CV
   ========================================================================== */
.cv { padding-top: clamp(2.5rem, 6vw, 4rem); max-width: 56rem; }
.cv-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 1.5rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--border); }
.cv-header h1 { font-size: clamp(1.9rem, 5vw, 2.7rem); margin-bottom: .3em; }
.cv-header .lead { font-size: 1.05rem; margin-bottom: .75rem; }
.cv-contact { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; font-size: .92rem; }
.cv-contact a { display: inline-flex; align-items: center; gap: .4rem; color: var(--muted); text-decoration: none; }
.cv-contact a:hover { color: var(--accent); }
.cv-actions { display: flex; gap: .6rem; flex-wrap: wrap; }

.cv-toc { display: flex; flex-wrap: wrap; gap: .4rem; margin: 1.25rem 0 0; }
.cv-toc a { font-size: .88rem; padding: .3rem .75rem; border-radius: 999px; background: var(--surface-2); color: var(--text); text-decoration: none; }
.cv-toc a:hover { background: var(--accent-soft); }

.cv-section { margin-top: 3rem; }
.cv-section > h2 { font-size: 1.5rem; padding-bottom: .5rem; border-bottom: 2px solid var(--accent); display: inline-block; margin-bottom: 1.5rem; }
.cv-entry { display: flex; gap: 1rem; margin-bottom: 2rem; break-inside: avoid-page; }
.cv-entry-body { flex: 1; min-width: 0; }
.cv-entry-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .25rem 1rem; }
.cv-entry-head h3 { margin: 0; }
.cv-entry-head .when { margin: 0; }
.cv-entry ul { padding-left: 1.2rem; margin: .25rem 0 0; }
.cv-entry li { margin-bottom: .3rem; }
.cv-entry .prose p { margin-bottom: 0; font-size: .97rem; }

.skills { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); gap: 1.25rem 2rem; margin: 0; }
.skills dt { font-weight: 600; margin-bottom: .45rem; }
.skills dd { margin: 0; }

.plain { list-style: none; padding: 0; margin: 0 0 1rem; }
.courses { padding-left: 1.2rem; columns: 2 20rem; column-gap: 2.5rem; }
.courses li { margin-bottom: .35rem; break-inside: avoid; }
.note { color: var(--muted); font-size: .9rem; margin-top: 1.25rem; }

/* ==========================================================================
   Print (CV page prints as a clean document)
   ========================================================================== */
@media print {
  :root { --bg: #fff; --surface: #fff; --text: #111; --muted: #444; --border: #ccc; --accent: #155e66; --accent-soft: #eef4f4; }
  @page { margin: 14mm 14mm; }
  body { font-size: 10.5pt; line-height: 1.45; }
  .site-header, .site-footer, .no-print, .skip-link { display: none !important; }
  .cv { padding: 0; max-width: none; }
  .cv-section { margin-top: 1.4rem; }
  .cv-entry { margin-bottom: 1rem; }
  .logo { width: 32px; height: 32px; }
  a { color: inherit; text-decoration: none; }
  .tags li { border: 1px solid var(--border); background: none; padding: 0 .5rem; }
}

/* Talks list (Research page) */
.prose .talks { list-style: none; padding: 0; margin: 1.25rem 0; display: grid; gap: .9rem; }
.talks li { display: grid; grid-template-columns: 5.5rem 1fr; gap: 1rem; margin: 0; }
.talks .when { margin: .1rem 0 0; }
.talks p { margin: 0; }
.talk-title { font-weight: 600; line-height: 1.4; }
.talk-meta { color: var(--muted); font-size: .9rem; margin-top: .15rem !important; }
.talk-kind { color: var(--accent); font-weight: 500; }
@media (max-width: 480px) { .talks li { grid-template-columns: 1fr; gap: .1rem; } }

/* Career spectrum (home page): milestones in _data/timeline.yml are absorption lines */
.career { margin: 0; --k-career: var(--text); --k-paper: var(--accent); --k-cert: #d98a1c; --k-talk: #9a5fd0; --k-article: #d0417e; }
.career-kinds { display: flex; flex-wrap: wrap; gap: .35rem 1.1rem; font-size: .8rem; color: var(--muted); margin-bottom: .9rem; }
.career-kinds span { display: inline-flex; align-items: center; gap: .4rem; }
.career-kinds span::before { content: ""; width: .55rem; height: .55rem; border-radius: 50%; background: var(--k); }
.kind-career { --k: var(--k-career); }
.kind-paper  { --k: var(--k-paper); }
.kind-cert   { --k: var(--k-cert); }
.kind-talk   { --k: var(--k-talk); }

.career-marks { position: relative; height: 1rem; }
.career-marks span {
  position: absolute; bottom: .3rem; width: 7px; height: 7px; border-radius: 50%;
  background: var(--k); transform: translateX(-50%); transition: transform .15s;
}
.career-marks span.active { transform: translateX(-50%) scale(1.7); }

.career-bar {
  position: relative; height: 38px; border-radius: 6px; overflow: hidden; cursor: crosshair; touch-action: pan-y;
  background: linear-gradient(90deg, #6b3fa0, #3b5bdb, #1c9fd6, #1fb58f, #9ccc3c, #f2c230, #f08a2c, #d9412b);
}
.career-bar:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.career-line { position: absolute; top: 0; bottom: 0; width: 2px; transform: translateX(-50%); background: rgb(10 14 20 / .72); transition: width .15s, background-color .15s; }
.career-line.active { width: 4px; background: rgb(10 14 20 / .95); box-shadow: 0 0 0 1px rgb(255 255 255 / .7); }

.career-scale { position: relative; height: 1.6rem; border-top: 1px solid var(--border); }
.career-scale .tick { position: absolute; top: 0; width: 1px; height: 5px; background: var(--muted); opacity: .6; }
.career-scale .tick.major { height: 9px; opacity: 1; }
.career-scale .tick span { position: absolute; top: 11px; left: 50%; transform: translateX(-50%); font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.career-ends { display: flex; justify-content: space-between; font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-top: .35rem; }

.career-caption { margin-top: .9rem; min-height: 7.5rem; }
.career-tip {
  position: relative; width: max-content; max-width: min(100%, 24rem);
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: .1rem .45rem;
  padding: .45rem .7rem; border-radius: 8px; font-size: .88rem; line-height: 1.3;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  transition: margin-left .15s ease-out;
}
/* little arrow pointing up at the selected line */
.career-tip::before {
  content: ""; position: absolute; top: -6px; left: var(--arrow, 50%); width: 10px; height: 10px;
  transform: translateX(-50%) rotate(45deg);
  background: var(--surface); border-left: 1px solid var(--border); border-top: 1px solid var(--border);
}
.career-tip .dot { width: .5rem; height: .5rem; border-radius: 50%; background: var(--k); }
.career-tip .when { margin: 0; font-size: .78rem; }
.career-tip .text { grid-column: 1 / -1; font-weight: 600; }
.career-tip .detail { grid-column: 1 / -1; color: var(--muted); font-size: .84rem; margin-top: .15rem; }
.career-tip .link { grid-column: 1 / -1; font-size: .84rem; font-weight: 500; text-decoration: none; margin-top: .25rem; width: fit-content; }
.career-tip .link:hover { text-decoration: underline; }
.career-tip [hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .career-tip, .career-line, .career-marks span { transition: none; } }

.career-lead { margin-top: -.5rem; margin-bottom: 1.5rem; font-size: 1.02rem; }
.kind-article { --k: var(--k-article); }
