:root {
  --bg: #ffffff;
  --bg-alt: #f5f7fa;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #5b6676;
  --line: #e2e7ee;
  --accent: #1f4e79;
  --accent-soft: #e8f0f8;
  --accent-strong: #163a5b;
  --on-accent: #ffffff;
  --good: #1e7a4c;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --radius: 14px;
  --maxw: 1080px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141b;
    --bg-alt: #141b24;
    --card: #18212c;
    --text: #e6ebf2;
    --muted: #9aa6b6;
    --line: #263241;
    --accent: #7fb2e5;
    --accent-soft: #1b2b3d;
    --accent-strong: #a9cdf0;
    --on-accent: #0f141b;
    --good: #5fc694;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  }
}
/* dark theme chosen with the toggle, whatever the system setting */
:root[data-theme="dark"] {
  --bg: #0f141b;
  --bg-alt: #141b24;
  --card: #18212c;
  --text: #e6ebf2;
  --muted: #9aa6b6;
  --line: #263241;
  --accent: #7fb2e5;
  --accent-soft: #1b2b3d;
  --accent-strong: #a9cdf0;
  --on-accent: #0f141b;
  --good: #5fc694;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
}
:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 34px; height: 30px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); cursor: pointer;
}
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .moon { display: inline; }
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: inline; }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16.5px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* bilingual content: only the active language is shown */
body.lang-en .fr, body.lang-fr .en { display: none !important; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }

/* ---------- header ---------- */
header.top {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
header.top .wrap { display: flex; align-items: center; gap: 18px; height: 60px; }
.brand { font-weight: 700; color: var(--text); letter-spacing: -.01em; white-space: nowrap; }
.brand span { color: var(--accent); }
nav.links { display: flex; gap: 18px; margin-left: auto; font-size: 14.5px; }
nav.links a { color: var(--muted); }
nav.links a:hover { color: var(--text); text-decoration: none; }
.lang { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; flex-shrink: 0; }
.lang button {
  font: inherit; font-size: 13px; font-weight: 600; padding: 4px 11px; border: 0; cursor: pointer;
  background: transparent; color: var(--muted);
}
.lang button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
@media (max-width: 820px) { nav.links { display: none; } .theme-toggle { margin-left: auto; } }

/* ---------- hero ---------- */
.hero { padding-top: 72px; padding-bottom: 48px; }
.hero h1 { font-size: clamp(34px, 6vw, 52px); line-height: 1.08; margin: 0 0 10px; letter-spacing: -.025em; }
.hero .role { font-size: clamp(18px, 2.6vw, 23px); color: var(--accent); font-weight: 600; margin: 0 0 18px; }
.hero .pitch { font-size: 18.5px; max-width: 720px; margin: 0 0 14px; }
.hero .where { color: var(--muted); margin: 0 0 26px; font-size: 15px; }
.cta { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 10px;
  font-weight: 600; font-size: 15px; border: 1px solid var(--line); color: var(--text); background: var(--card);
}
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-strong); }
.btn svg { width: 17px; height: 17px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 44px; }
.stat { background: var(--bg-alt); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat b { display: block; font-size: 26px; color: var(--accent); letter-spacing: -.02em; line-height: 1.2; }
.stat span { font-size: 14px; color: var(--muted); }
@media (max-width: 820px) { .stats { grid-template-columns: repeat(2, 1fr); } }

/* ---------- sections ---------- */
section { padding: 64px 0; }
section.alt { background: var(--bg-alt); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: 12.5px; font-weight: 700; color: var(--accent); margin: 0 0 6px; }
h2 { font-size: clamp(26px, 3.6vw, 34px); margin: 0 0 14px; letter-spacing: -.02em; line-height: 1.2; }
.lead { color: var(--muted); max-width: 760px; margin: 0 0 34px; font-size: 17px; }

.about-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 40px; align-items: start; }
.about-grid p { margin: 0 0 14px; }
.facts { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); }
.facts dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 9px 14px; font-size: 15px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; }
@media (max-width: 820px) { .about-grid { grid-template-columns: 1fr; } }

/* ---------- projects ---------- */
.project {
  display: grid; grid-template-columns: 1.05fr 1fr; gap: 34px; align-items: start;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 28px;
  box-shadow: var(--shadow); margin-bottom: 26px;
}
.project.flip .media { order: 2; }
.project .media figure { margin: 0; }
.project .media img { border-radius: 10px; border: 1px solid var(--line); background: #fff; }
.project .media figcaption { font-size: 13px; color: var(--muted); margin-top: 8px; }
.project .tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.pill { font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); }
.pill.muted { background: var(--bg-alt); color: var(--muted); border: 1px solid var(--line); }
.project h3 { font-size: 23px; margin: 0 0 8px; letter-spacing: -.015em; line-height: 1.25; }
.project .meta { font-size: 14px; color: var(--muted); margin: 0 0 14px; }
.project p { margin: 0 0 12px; }
.results { list-style: none; padding: 0; margin: 4px 0 16px; }
.results li { padding-left: 24px; position: relative; margin-bottom: 7px; font-size: 15.5px; }
.results li::before { content: ""; position: absolute; left: 3px; top: 9px; width: 9px; height: 9px; border-radius: 3px; background: var(--good); }
.results b { color: var(--text); }
.stack { font-size: 14px; color: var(--muted); margin: 0 0 14px; }
.repo-links { display: flex; flex-wrap: wrap; gap: 8px; }
.repo-links a { font-size: 14px; font-weight: 600; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); display: inline-flex; align-items: center; gap: 6px; }
.repo-links a:hover { border-color: var(--accent); text-decoration: none; }
.repo-links svg { width: 15px; height: 15px; }
@media (max-width: 880px) { .project { grid-template-columns: 1fr; padding: 22px; } .project.flip .media { order: 0; } }

.small-projects { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.small { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.small h4 { margin: 0 0 6px; font-size: 18px; }
.small p { margin: 0 0 10px; font-size: 15px; }
@media (max-width: 760px) { .small-projects { grid-template-columns: 1fr; } }

/* ---------- publications / timeline ---------- */
.pubs { display: grid; gap: 14px; }
.pub { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 10px; padding: 16px 20px; }
.pub .title { font-weight: 600; font-style: italic; }
.pub .venue { color: var(--muted); font-size: 14.5px; }

.timeline { position: relative; margin-left: 8px; }
.timeline::before { content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding-left: 28px; margin-bottom: 28px; }
.tl-item::before { content: ""; position: absolute; left: -6px; top: 6px; width: 14px; height: 14px; border-radius: 50%; background: var(--bg); border: 3px solid var(--accent); }
.tl-item h4 { margin: 0; font-size: 18px; }
.tl-item .org { color: var(--accent); font-weight: 600; font-size: 15px; }
.tl-item .when { color: var(--muted); font-size: 14px; }
.tl-item ul { margin: 8px 0 0; padding-left: 18px; }
.tl-item li { margin-bottom: 4px; font-size: 15.5px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; }
@media (max-width: 820px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- skills ---------- */
.skills { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.skill-group { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.skill-group h4 { margin: 0 0 10px; font-size: 15.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips span { font-size: 13.5px; padding: 4px 10px; border-radius: 8px; background: var(--bg-alt); border: 1px solid var(--line); }
@media (max-width: 880px) { .skills { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .skills { grid-template-columns: 1fr; } }

/* ---------- contact / footer ---------- */
.contact { text-align: center; }
.contact .lead { margin-left: auto; margin-right: auto; }
.contact .cta { justify-content: center; }
footer { border-top: 1px solid var(--line); padding: 26px 0 40px; color: var(--muted); font-size: 13.5px; }
footer p { margin: 4px 0; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
@media print {
  header.top, .lang, .cta { display: none; }
  section { padding: 20px 0; }
  .project, .small, .facts, .skill-group { box-shadow: none; break-inside: avoid; }
}

/* ---------- portrait in the hero ---------- */
.hero-top { display: grid; grid-template-columns: 1fr auto; gap: 40px; align-items: center; }
.avatar {
  width: 260px; height: 260px; border-radius: 50%; object-fit: cover;
  border: 4px solid var(--card); box-shadow: 0 0 0 2px var(--accent), var(--shadow);
}
@media (max-width: 820px) {
  .hero-top { grid-template-columns: 1fr; gap: 24px; }
  .avatar { width: 140px; height: 140px; order: -1; }
}
