/* =========================================================================
   Paul Robineau – personal site
   Single hand-written stylesheet. No framework, no build step.
   System fonts only (zero font downloads). Light + dark via prefers-color-scheme.
   ========================================================================= */

/* ---- Design tokens ---------------------------------------------------- */
:root {
  --blue:        #2f5277;   /* primary, derived from the old #35557b */
  --blue-dark:   #233d5a;
  --blue-soft:   #e7eef6;
  --accent:       #8a7218;   /* dark gold, derived from the home photo's aura (#ffd42d) */
  --ink:         #1c2733;   /* body text */
  --ink-soft:    #51606e;   /* secondary text */
  --line:        #dde4ea;   /* borders */
  --bg:          #ffffff;
  --bg-alt:      #f5f8fb;   /* section / card background */
  --link:        #2f5277;
  --link-hover:  #1c3f63;
  --focus:       #1d6fb8;
  /* Footer keeps its own dark tokens so it never inverts in dark mode. */
  --footer-bg:   #233d5a;
  --footer-ink:  #cdd8e4;
  --footer-muted:#9fb0c2;
  --maxw:        72rem;
  --radius:      10px;
  --shadow:      0 1px 2px rgba(28, 39, 51, .06), 0 4px 16px rgba(28, 39, 51, .06);
}

:root { color-scheme: light; }

/* Dark palette. The declarations live in one place (--dark-palette mixin via
   the shared selector list below) but CSS has no mixins, so the block is
   applied to two situations:
     1. the OS prefers dark AND the visitor has not forced light;
     2. the visitor explicitly chose dark with the theme toggle.
   Keep the two token lists in sync if you edit the palette. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --blue:       #7fa9d6;
    --blue-dark:  #9fc0e6;
    --blue-soft:  #1b2d40;
    --accent:     #ffd946;   /* the home photo's aura yellow (#ffd42d), brightened for dark mode */
    --ink:        #e6edf3;
    --ink-soft:   #a7b4c0;
    --line:       #2a3744;
    --bg:         #0f161d;
    --bg-alt:     #161f29;
    --link:       #8fb8e2;
    --link-hover: #b9d4f0;
    --focus:      #6cb0ec;
    --shadow:     0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .35);
    /* A touch darker than the page so the footer still reads as a footer. */
    --footer-bg:  #0a1018;
    --footer-ink: #c5d2df;
    --footer-muted:#8493a3;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --blue:       #7fa9d6;
  --blue-dark:  #9fc0e6;
  --blue-soft:  #1b2d40;
  --accent:     #ffd946;
  --ink:        #e6edf3;
  --ink-soft:   #a7b4c0;
  --line:       #2a3744;
  --bg:         #0f161d;
  --bg-alt:     #161f29;
  --link:       #8fb8e2;
  --link-hover: #b9d4f0;
  --focus:      #6cb0ec;
  --shadow:     0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .35);
  --footer-bg:  #0a1018;
  --footer-ink: #c5d2df;
  --footer-muted:#8493a3;
}

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

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

img, svg, video { max-width: 100%; height: auto; display: block; }

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

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }

h1, h2, h3, h4 { line-height: 1.25; color: var(--ink); font-weight: 700; }
h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
h3 { font-size: 1.2rem; }

p + p { margin-top: .85rem; }

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 200;
  background: var(--blue); color: #fff; padding: .6rem 1rem; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

/* ---- Layout helpers --------------------------------------------------- */
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: 1.25rem; }
.section { padding-block: 3rem; }
.section--alt { background: var(--bg-alt); }
main { flex: 1 0 auto; }

/* ---- Header / nav ----------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.nav {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem;
  max-width: var(--maxw); margin-inline: auto; padding: .7rem 1.25rem;
}
.nav__brand { font-weight: 700; font-size: 1.15rem; color: var(--ink); margin-right: auto; }
.nav__brand:hover { text-decoration: none; color: var(--blue); }
.nav__links { display: flex; flex-wrap: wrap; gap: .25rem .5rem; list-style: none; }
.nav__links a {
  display: block; padding: .35rem .7rem; border-radius: 999px;
  color: var(--ink-soft); font-weight: 600; font-size: .95rem;
}
.nav__links a:hover { background: var(--blue-soft); color: var(--blue-dark); text-decoration: none; }
.nav__links a[aria-current="page"] { background: var(--blue); color: #fff; }

/* Theme toggle (revealed by theme.js; hidden for no-JS visitors) */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.1rem; height: 2.1rem; padding: 0;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg); color: var(--ink-soft); cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.theme-toggle:hover { background: var(--blue-soft); color: var(--blue-dark); border-color: var(--blue); }
.theme-toggle svg { width: 1.15rem; height: 1.15rem; }
.theme-toggle .ti { display: none; fill: currentColor; }
/* Show the icon for the active mode (defaults to the auto icon pre-JS). */
.theme-toggle:not([data-mode]) .ti--auto,
.theme-toggle[data-mode="auto"] .ti--auto,
.theme-toggle[data-mode="light"] .ti--light,
.theme-toggle[data-mode="dark"] .ti--dark { display: block; }

/* ---- Hero (home) ------------------------------------------------------ */
.hero {
  display: grid; gap: 2.5rem; align-items: center;
  grid-template-columns: 1fr; padding-block: 3rem 1rem;
}
@media (min-width: 56rem) {
  .hero { grid-template-columns: 1.4fr 1fr; }
}
.eyebrow {
  color: var(--accent); font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  font-size: .8rem;
}
.hero__intro .eyebrow { margin-bottom: .5rem; }
.hero__intro p.lead { font-size: 1.2rem; color: var(--ink-soft); margin-top: 1rem; }
.hero__photo {
  justify-self: center; max-width: 360px; width: 100%;
}
/* The photo is a circular PNG with transparent corners, so no clip/box needed. */
.hero__photo img { width: 100%; height: auto; }

.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  background: var(--blue); color: #fff; font-weight: 600;
  padding: .65rem 1.15rem; border-radius: 999px; margin-top: 1.5rem;
}
.btn:hover { background: var(--blue-dark); color: #fff; text-decoration: none; }
.btn svg { width: 1.1em; height: 1.1em; fill: currentColor; }

.btn--ghost { background: transparent; color: var(--blue); border: 1.5px solid var(--blue); }
.btn--ghost:hover { background: var(--blue-soft); color: var(--blue-dark); }

/* ---- Facet cards (home) ---------------------------------------------- */
.cards { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }
@media (min-width: 40rem) { .cards { grid-template-columns: repeat(2, 1fr); } }

.card {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.5rem; box-shadow: var(--shadow); border-top: 3px solid var(--blue);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 2px 4px rgba(28, 39, 51, .08), 0 10px 28px rgba(28, 39, 51, .12);
  border-color: var(--blue);
}
.card h3 { margin-bottom: .6rem; color: var(--blue); }
.card p { color: var(--ink-soft); font-size: .98rem; }
.card p + p { margin-top: .7rem; }

/* ---- Generic prose / articles ---------------------------------------- */
.lead-block { max-width: 48rem; }
.section > .wrap > h2 { margin-bottom: 1.5rem; }
.section-intro { color: var(--ink-soft); max-width: 48rem; margin-bottom: 2rem; }

/* Entry: image-beside-text block used on PhD / academic / associative */
.entry {
  display: grid; gap: 1.5rem; align-items: start;
  grid-template-columns: 1fr;
  padding-block: 2rem; border-top: 1px solid var(--line);
}
.entry:first-of-type { border-top: 0; }
/* A figure block right after an entry should sit the same distance from the
   text as figures sit from each other (so 2.2->2.3-5 matches 2.1->2.2, etc.). */
.entry:has(+ .figpanel), .entry:has(+ figure) { padding-bottom: 0; }
@media (min-width: 52rem) {
  .entry--media { grid-template-columns: 1.3fr 1fr; }
  .entry--media.entry--flip { grid-template-columns: 1fr 1.3fr; }
  .entry--flip .entry__body { order: 2; }
  /* Intro: figures column wider than the text. */
  .entry--introphd { grid-template-columns: 1fr 1.4fr; }
  /* Figure-led sections: give the figures more room than the default. */
  .entry--figwide { grid-template-columns: 1fr 1.25fr; }
  .entry--figwide.entry--flip { grid-template-columns: 1.25fr 1fr; }
}
/* Intro figures stacked in a single column, kept small so the stack ends
   roughly level with the intro text. */
.figstack { display: grid; gap: 2rem; }
.figstack figure { margin: 0; }
.figstack img { max-height: 260px; width: auto; }
.entry__body h3 { color: var(--blue); margin-bottom: .75rem; }
/* Text-only entries (no figure column) keep a column width in line with the
   text column of the figure sections, rather than sprawling full-width. */
.entry:not(.entry--media) .entry__body { max-width: 44rem; }
.entry__media img { border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-alt); }
.logo-strip { display: flex; align-items: center; justify-content: center; padding: 1rem; }
/* Uniform chip so every logo (transparent, white-bg, or colour) reads the same in both themes. */
.logo-strip img {
  max-height: 190px; width: auto;
  background: #fff; padding: 1rem;
  border: 1px solid var(--line); border-radius: var(--radius);
}

/* Keep anchored headings clear of the sticky header. */
:where(h2, h3)[id] { scroll-margin-top: 5rem; }

/* Figures */
figure { margin: 1.25rem 0; }
figure img, figure video { border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-alt); margin-inline: auto; }
figcaption { font-size: .88rem; color: var(--ink-soft); margin-top: .5rem; text-align: center; }
.figure-grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.figure-grid figure { margin: 0; }

/* Figure panel: a group of related figures embedded on ONE shared white card
   (kept white in both themes; light-theme tokens scoped in so captions/links
   stay readable on the white background). */
.figpanel {
  --ink-soft: #51606e; --link: #2f5277; --link-hover: #1c3f63;
  color: #1c2733;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: .85rem 1rem; margin: 1.25rem 0;
  display: flex; flex-wrap: wrap; gap: .75rem 1rem;
  align-items: flex-start; justify-content: center;
}
.figpanel figure { margin: 0; flex: 1 1 0; min-width: 140px; text-align: center; }
/* Fill each cell so figures in a row share a size (the 110px clip matches the SRRF images). */
.figpanel img, .figpanel video { border: 0; background: none; border-radius: 4px; width: 100%; height: auto; }
.figpanel figcaption { color: var(--ink-soft); }

/* Refined in-page table of contents (PhD) */
.toc {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem .95rem;
  margin: 0 0 2rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line);
}
.toc__label {
  font-size: .78rem; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink-soft);
}
.toc ol { display: flex; flex-wrap: wrap; gap: .35rem .95rem; list-style: none; counter-reset: toc; }
.toc li { counter-increment: toc; }
.toc a { font-size: .93rem; font-weight: 600; }
.toc a::before { content: counter(toc) ". "; color: var(--accent); font-weight: 700; }

/* ---- Featured publications (curated cards) ---------------------------- */
.feat-grid { display: grid; gap: 1.25rem; grid-template-columns: 1fr; margin-bottom: 2.5rem; }
.feat {
  display: grid; gap: 1.25rem; align-items: center;
  grid-template-columns: 1fr;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  border-left: 3px solid var(--accent); box-shadow: var(--shadow); padding: 1.25rem;
  transition: transform .18s ease, box-shadow .18s ease;
}
.feat:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(28, 39, 51, .08), 0 10px 28px rgba(28, 39, 51, .12);
}
@media (min-width: 40rem) {
  .feat { grid-template-columns: 200px 1fr; }
}
.feat__media img { border-radius: 8px; border: 1px solid var(--line); background: var(--bg-alt); width: 100%; }
.feat__body { font-size: .97rem; }
.feat__body i { color: var(--ink); }

/* ---- Publications list ----------------------------------------------- */
.pub-group { margin-bottom: 1.75rem; }
.pub-group h3 {
  color: var(--blue); border-bottom: 2px solid var(--blue-soft);
  padding-bottom: .3rem; margin-bottom: .75rem;
}
.pub-sub { font-size: .95rem; font-weight: 700; color: var(--ink-soft); margin: .75rem 0 .25rem; }
.pub-list { list-style: none; counter-reset: pub; display: grid; gap: .6rem; }
.pub-list li {
  position: relative; padding-left: 2.2rem; font-size: .97rem; color: var(--ink);
}
.pub-list li::before {
  counter-increment: pub; content: counter(pub);
  position: absolute; left: 0; top: .05rem;
  background: var(--blue-soft); color: var(--blue-dark); font-weight: 700; font-size: .8rem;
  width: 1.6rem; height: 1.6rem; border-radius: 50%;
  display: grid; place-items: center;
}
.tag {
  display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .03em;
  text-transform: uppercase; padding: .1rem .5rem; border-radius: 999px;
  background: var(--accent); color: var(--bg); vertical-align: middle; margin-left: .35rem;
}
.tag--src { background: var(--blue); }       /* HAL/ORCID – auto-pulled */
.tag--manual { background: var(--accent); }  /* Manually added */

/* ---- Blog ------------------------------------------------------------- */
/* Index: a simple reverse-chronological list of posts. */
.post-list { list-style: none; display: grid; gap: 0; margin-top: 1rem; }
.post-card { padding: 1.6rem 0; border-top: 1px solid var(--line); }
.post-list > li:first-child .post-card { border-top: 0; padding-top: .25rem; }
.post-card__date {
  font-size: .8rem; font-weight: 700; letter-spacing: .03em;
  text-transform: uppercase; color: var(--accent);
}
.post-card h2 { font-size: 1.3rem; margin: .3rem 0 .45rem; }
.post-card h2 a { color: var(--ink); }
.post-card h2 a:hover { color: var(--blue); text-decoration: none; }
.post-card p { color: var(--ink-soft); }

/* A single post: a readable, centred prose column. */
.post { max-width: 44rem; margin-inline: auto; padding-inline: 1.25rem; }
.post__meta {
  font-size: .82rem; font-weight: 700; letter-spacing: .03em;
  text-transform: uppercase; color: var(--accent);
}
.post > h1 { margin: .4rem 0 1.5rem; }
.post__body > * + * { margin-top: 1rem; }
.post__body h2 { margin-top: 2rem; font-size: 1.4rem; }
.post__body h3 { margin-top: 1.5rem; }
.post__body blockquote {
  margin: 1.25rem 0; padding: .25rem 0 .25rem 1.1rem;
  border-left: 3px solid var(--accent); color: var(--ink-soft); font-style: italic;
}
.post__body ul, .post__body ol { padding-left: 1.4rem; }
.post__body li + li { margin-top: .35rem; }
.post__body img, .post__body figure { margin: 1.5rem 0; }
.post-back { display: inline-flex; align-items: center; gap: .4rem; margin-top: 2.75rem; font-weight: 600; }

/* ---- Legal page ------------------------------------------------------- */
.legal dt { font-weight: 700; color: var(--blue); margin-top: 1.25rem; }
.legal dd { margin: .25rem 0 0; color: var(--ink-soft); }

/* ---- Footer ----------------------------------------------------------- */
.site-footer {
  background: var(--footer-bg); color: var(--footer-ink);
  margin-top: 3rem; padding-block: 2.5rem;
}
.site-footer a { color: #fff; }
.footer-grid {
  display: grid; gap: 2rem; grid-template-columns: 1fr;
}
@media (min-width: 40rem) { .footer-grid { grid-template-columns: repeat(3, 1fr); } }
.site-footer h2 { font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: #fff; margin-bottom: .75rem; }
.site-footer ul { list-style: none; display: grid; gap: .4rem; }
.site-footer .social a { display: inline-flex; align-items: center; gap: .55rem; }
.site-footer svg { width: 1.1em; height: 1.1em; fill: currentColor; flex: none; }
.footer-note { margin-top: 2rem; font-size: .82rem; color: var(--footer-muted); }

/* ---- Reduced motion --------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card, .feat { transition: none; }
  .card:hover, .feat:hover { transform: none; }
}

/* ---- Print ------------------------------------------------------------ */
@media print {
  /* Force a light, ink-on-paper rendering regardless of the screen scheme. */
  :root {
    --ink: #000; --ink-soft: #222; --bg: #fff; --bg-alt: #fff;
    --line: #bbb; --link: #000; --blue: #000; --blue-dark: #000;
  }
  body { font-size: 11pt; line-height: 1.4; }
  .site-header, .site-footer, .skip-link, .btn { display: none; }
  .section { padding-block: .75rem; }
  a { color: #000; text-decoration: underline; }
  /* Print the destination of external links so a paper copy stays useful. */
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .85em; word-break: break-all; }
  .card, .feat, figure img, figure video, .entry__media img {
    box-shadow: none; break-inside: avoid;
  }
  .cards, .feat-grid, .figure-grid { display: block; }
  .card, .feat { margin-bottom: 1rem; }
}
