/* ── Design tokens ────────────────────────────────────────
   Values are 1:1 with the literals they replaced — changing a
   token here changes every use site consistently. */
:root {
  --derek-red: #c01b13;      /* CIFAR chair, Post-Doc rank */
  --derek-blue: #1b4ddb;     /* Ph.D. rank */
  --derek-green: #1d8b3f;    /* M.Sc. rank */
  --derek-purple: #4b2e83;   /* Mila-Ubisoft chair */
  --derek-ink: #212529;      /* borders/buttons matching body ink */
  --derek-info-col: 5.6em;   /* icon/logo column width in the about card */

  /* Normalized scales (one radius + pill, two shadows, three muted steps) */
  --derek-radius: 0.35rem;
  --derek-radius-pill: 999px;
  --derek-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.22);
  --derek-shadow-lg: 0 8px 20px rgba(0, 0, 0, 0.25);
  --derek-muted-strong: 0.55; /* de-emphasized but still readable */
  --derek-muted: 0.65;        /* secondary text/counts */
  --derek-muted-soft: 0.85;   /* barely dimmed */
}

.about-card {
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  width: 100%;
  max-width: none;
  margin-left: auto;
  margin-right: auto;
}

#about-me,
#research-themes,
#research-group,
#teaching {
  width: 100%;
  max-width: none;
  margin-left: auto;
  margin-right: auto;
}

@font-face {
  font-family: "HQPIcons";
  src: url("../files/hqp-fonts/OXYGENE1-webfont.woff") format("woff"),
       url("../files/hqp-fonts/OXYGENE1-webfont.ttf") format("truetype"),
       url("../files/hqp-fonts/OXYGENE1-webfont.svg#webfont") format("svg");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

.about-layout {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  align-items: stretch;
  width: 100%;
}

.about-left {
  text-align: left;
}

.about-name-block {
  margin-top: 0.1rem;
}

.about-right {
  flex: 1;
  width: 100%;
}

.about-name {
  font-weight: inherit;
  letter-spacing: -0.015em;
  margin-bottom: 0.25rem;
  margin-top: 0;
  text-shadow: none;
}

.about-role {
  font-weight: 600;
  margin-bottom: 0.25rem;
  font-size: 0.65em;
}

.about-name-break {
  line-height: 0.5;
}

.theme-entry {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  align-items: center;
}

.theme-image {
  width: 120px;
  height: auto;
  border-radius: var(--derek-radius);
  flex-shrink: 0;
  align-self: center;
}

.theme-title {
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.theme-desc {
  margin-bottom: 0.25rem;
}

.theme-links {
  font-size: 0.95em;
}

.hqp-block {
  margin-bottom: 1.25rem;
}

.hqp-legend {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.25rem 0.4rem;
  margin-bottom: 1rem;
  max-width: 60%;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

.hqp-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.95em;
}

.hqp-icon::before {
  font-family: "HQPIcons";
  content: attr(data-icon);
  font-size: 1.2em;
  line-height: 1;
}

.rank-r .hqp-icon::before {
  color: var(--derek-red);
}

.rank-b .hqp-icon::before {
  color: var(--derek-blue);
}

.rank-c .hqp-icon::before {
  color: var(--derek-green);
}

.rank-g .hqp-icon::before {
  color: var(--derek-ink);
}

.hqp-section {
  margin-bottom: 1rem;
}

.hqp-title {
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.hqp-title i {
  margin-right: 0.35rem;
}

.hqp-stats {
  opacity: var(--derek-muted);
  font-weight: 400;
}

.hqp-stat {
  display: inline-flex;
  align-items: baseline;
  gap: 0.2rem;
  margin-right: 0.4rem;
}

.hqp-stat:last-child {
  margin-right: 0;
}

.hqp-stats-note {
  opacity: var(--derek-muted);
  font-weight: 400;
  margin-left: 0.4rem;
  font-size: 0.9em;
}
.hqp-name {
  cursor: help;
}

.hqp-tooltip {
  min-width: 33vw;
  max-width: 90vw;
  font-size: 0.85rem;
  line-height: 1.3;
  text-align: left;
}

.tooltip-inner {
  min-width: 33vw;
  max-width: 90vw;
  width: max-content;
  text-align: left;
  overflow-wrap: anywhere;
}

.hqp-tooltip-name {
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.hqp-tooltip-row {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 0.4rem;
  margin-bottom: 0.2rem;
  align-items: start;
}

.hqp-tooltip-row:last-child {
  margin-bottom: 0;
}

.hqp-tooltip-label {
  font-weight: 600;
  opacity: var(--derek-muted);
}
.navbar {
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
  /* Frosted glass: translucent white + blur over scrolling content */
  background-color: rgba(255, 255, 255, 0.82) !important;
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
}

/* Reading-progress bar along the navbar's bottom edge
   (--derek-scroll is set by _includes/enhancements.html) */
.navbar::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: calc(var(--derek-scroll, 0) * 100%);
  background: var(--bs-link-color, #0000cc);
  pointer-events: none;
}

.navbar .nav-link,
.navbar .navbar-brand {
  padding-top: 0.2rem;
  padding-bottom: 0.2rem;
}

.navbar .navbar-brand {
  margin-top: 0;
  margin-bottom: 0;
}

.hqp-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.2rem 1rem;
}

@media (max-width: 1000px) {
  .hqp-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 770px) {
  .hqp-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .courses-columns {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .hqp-grid {
    grid-template-columns: 1fr;
  }
}

.hqp-item {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.35rem;
}

.hqp-text {
  display: block;
}

.hqp-year {
  font-size: 0.6em;
  opacity: var(--derek-muted);
  display: inline;
  margin-left: 0.15rem;
}

.hqp-year i {
  margin-right: 0.1rem;
}

.hqp-graduated .is-hidden {
  display: none;
}

.courses-grid .is-hidden {
  display: none;
}

.courses-more {
  margin-top: 0.75rem;
}

.hqp-more {
  display: block;
  width: fit-content;
  border: 1px solid var(--derek-ink);
  background: transparent;
  padding: 0.2rem 0.5rem;
  color: var(--derek-ink);
  text-decoration: none;
  font-weight: 600;
  margin: 0.5rem auto 0;
  border-radius: var(--derek-radius-pill);
  box-shadow: var(--derek-shadow-sm);
}

.courses-block {
  margin-top: 1rem;
}

.courses-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
}

.courses-subtitle {
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.courses-grid {
  display: grid;
  gap: 0.4rem 0;
}

.course-row {
  display: grid;
  grid-template-columns: 0.2fr 3.3fr 0.5fr;
  column-gap: 0.75rem;
  row-gap: 0.1rem;
  align-items: baseline;
}

.course-row.is-archived {
  opacity: var(--derek-muted);
}

.course-code {
  font-weight: 600;
}

.course-code-prefix {
  font-size: 0.5em;
  letter-spacing: 0.02em;
  margin-right: 0.05em;
}

.course-code,
.course-title {
  grid-row: 1 / span 2;
}

.course-term {
  grid-column: 3;
  grid-row: 1;
  text-align: left;
}

.course-notes {
  grid-column: 3;
  grid-row: 2;
  font-size: 0.65em;
  opacity: var(--derek-muted-strong);
  text-align: left;
  margin-top: -0.1rem;
}

.about-chair-group {
  margin-bottom: 0.25rem;
}

.about-roles {
  margin-bottom: 0.4rem;
}

.about-chair {
  display: inline-block;
  font-weight: 600;
  margin-right: 0.75rem;
}

.about-chair-compact {
  display: none;
}

.about-chair-join {
  margin: 0 0.15rem;
}

.about-chair-icon {
  display: inline-block;
  margin-left: 0.2rem;
  width: 1em;
  height: 1em;
  vertical-align: text-bottom;
}

@media (max-width: 705px) and (min-width: 577px),
       (max-width: 390px) {
  .about-chair-full {
    display: none;
  }

  .about-chair-compact {
    display: inline-flex;
    align-items: baseline;
  }

  .about-chair-compact .about-chair {
    margin-right: 0;
  }
}

.about-chair.cifar {
  color: var(--derek-red);
}

.about-chair.mila {
  color: var(--derek-purple);
}

.about-chair-link {
  text-decoration: none;
}

.about-chair-link:hover .about-chair,
.about-chair-link:hover .about-chair-text {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.15em;
  text-decoration-color: currentColor;
}

.about-former {
  font-size: 0.9em;
  color: inherit;
  margin-bottom: 0;
  line-height: 1.3;
}

.about-former-compact {
  display: none;
}

.about-roles .about-former + .about-former {
  margin-top: 0.15rem;
}

@media (max-width: 620px) and (min-width: 577px),
       (max-width: 390px) {
  .about-former-full {
    display: none;
  }

  .about-former-compact {
    display: inline;
  }
}

.about-photo {
  width: 180px;
  height: 180px;
  object-fit: cover;
  border-radius: 0;
  border: 0;
  box-shadow: none;
}

.about-info-text {
  position: relative;
  line-height: 1.3;
}

.about-info-text,
.about-email {
  padding-left: calc(var(--derek-info-col) + 0.6rem);
}

.about-info-pin {
  position: absolute;
  left: 0;
  top: 0.1rem;
  width: var(--derek-info-col);
  text-align: center;
  font-size: 1.3rem;
}

/* Single source of truth for the email row (was split across two
   contradictory blocks at opposite ends of this file; this reproduces
   the exact computed result of both applying together). */
.about-email {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.about-email .bi-envelope {
  position: absolute;
  left: 0.45em;
  top: -0.3em;
  width: var(--derek-info-col);
  text-align: center;
  font-size: 1.1rem;
}

.about-affiliations {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.about-affiliation {
  display: grid;
  grid-template-columns: var(--derek-info-col) 1fr;
  column-gap: 0.6rem;
  align-items: start;
}

.about-affiliation-logo {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  padding-top: 0.2em;
}

.about-affiliation-logo-img {
  width: 4.4em;
  height: auto;
}

.about-affiliation-logo-mcgill {
  width: 5.28em;
}

.about-affiliation-text div {
  line-height: 1.3;
}

.about-affiliation-role {
  display: block;
  font-variant-caps: small-caps;
  font-size: 0.75em;
  opacity: var(--derek-muted-soft);
}

.about-affiliation-link {
  color: inherit;
  text-decoration: none;
}

.about-affiliation-link:hover {
  text-decoration: underline;
}

.about-affiliation-mobile {
  display: none;
}

.about-affiliation-mobile-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: 0.6rem;
  row-gap: 0.1rem;
  justify-items: start;
}

.about-mobile-affil {
  font-weight: 600;
}

.about-mobile-affil-ece {
  grid-column: 1;
  grid-row: 1;
}

.about-mobile-affil-mgmt {
  grid-column: 2;
  grid-row: 1;
}

.about-mobile-affil-cs {
  grid-column: 3;
  grid-row: 1;
}

.about-mobile-affil-cim {
  grid-column: 1;
  grid-row: 3;
}

.about-mobile-affil-mila {
  grid-column: 2;
  grid-row: 3;
}

.about-mobile-role {
  font-variant-caps: small-caps;
  font-size: 0.75em;
}

.about-mobile-role-primary {
  grid-column: 1;
  grid-row: 2;
}

.about-mobile-role-courtesy {
  grid-column: 2 / 4;
  grid-row: 2;
}

.about-mobile-role-director {
  grid-column: 1;
  grid-row: 4;
}

.about-mobile-role-core {
  grid-column: 2;
  grid-row: 4;
}

.about-muted {
  /* was 0.3 — raised for WCAG contrast (0.3 on white ≈ 1.9:1) */
  opacity: var(--derek-muted-strong);
}

@media (max-width: 576px) {
  .about-affiliation-mobile-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: 0.9rem;
    row-gap: 0.2rem;
  }

  .about-mobile-role-courtesy {
    grid-column: 2;
  }

  .about-affiliation {
    grid-template-columns: 1fr;
    row-gap: 0.3rem;
  }

  .about-affiliation-logo {
    display: none;
  }

  .about-affiliation-logo-img {
    width: 4.4em;
  }

  .about-affiliation-full {
    display: none;
  }

  .about-affiliation-mobile {
    display: block;
  }

  .theme-entry {
    flex-direction: row;
  }

  .theme-image {
    width: 88px;
    max-width: none;
  }

  .hqp-legend {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 100%;
  }

  .hqp-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .course-term,
  .course-notes {
    text-align: left;
  }

  .about-affiliation-cim,
  .about-affiliation-mila {
    display: none;
  }

  .about-info-text,
  .about-email {
    padding-left: 0;
  }

  .about-info-pin {
    display: none;
  }

  .about-email .bi-envelope {
    display: none;
  }
}

body.email-spotlight-active > *:not(.email-spotlight-clone):not(.email-spotlight-countdown) {
  opacity: 0.1;
  transition: opacity 0.2s ease;
}

.email-spotlight-clone {
  position: fixed;
  z-index: 2000;
  pointer-events: none;
}

.email-spotlight-countdown {
  position: fixed;
  z-index: 2001;
  transform: translate(-50%, -50%);
  pointer-events: none;
  width: 64px;
  height: 64px;
}

.email-spotlight-countdown svg {
  width: 100%;
  height: 100%;
}

.email-spotlight-countdown .countdown-track {
  fill: none;
  stroke: rgba(var(--bs-body-color-rgb, 33, 37, 41), 0.2);
  stroke-width: 8;
}

.email-spotlight-countdown .countdown-progress {
  fill: none;
  stroke: var(--bs-body-color, #212529);
  stroke-width: 8;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}

.email-spotlight-countdown .countdown-text {
  font-size: 40px;
  font-weight: 600;
  fill: var(--bs-body-color, #212529);
  text-anchor: middle;
}

.publication-list #bibbase_header {
  display: none;
}

.publication-list .bibbase_icon {
  width: 20px;
  max-height: 16px;
  display: inline-block;
  font-size: 1rem;
  vertical-align: text-top;
  margin-right: 0.25rem;
  filter: grayscale(100%);
}

.publication-list i.bibbase_icon {
  position: relative;
  top: -0.12em;
}

.publication-list .pub-link:hover .bibbase_icon {
  filter: none;
}

.publication-list .bibbase_icon_text {
  font-size: 0.9em;
  margin-right: 0.75rem;
}

.publication-list .bibbase-abstract-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.25rem;
  font-size: 0.9em;
  text-decoration: none;
}

.publication-list .bibbase-bibtex-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.25rem;
  font-size: 0.9em;
  text-decoration: none;
}

.publication-list .bibbase-abstract-caret {
  transition: transform 0.2s ease;
}

.publication-list .bibbase-abstract-link.is-open .bibbase-abstract-caret {
  transform: rotate(180deg);
}

.publication-list .bibbase-bibtex-link.is-open .bibbase-abstract-caret {
  transform: rotate(180deg);
}

.publication-list .bibbase-abstract {
  margin-top: 0.4rem;
  padding: 0.5rem 0.6rem;
  background: rgba(0, 0, 0, 0.04);
  border-radius: var(--derek-radius);
}

.publication-list .bibbase-bibtex {
  margin-top: 0.4rem;
  padding: 0.5rem 0.6rem;
  background: rgba(0, 0, 0, 0.04);
  border-radius: var(--derek-radius);
  font-size: 0.85em;
  white-space: pre-wrap;
}

.publication-list .pub-year-group {
  margin-bottom: 1.2rem;
}

.publication-list .pub-year-label {
  font-weight: 700;
  margin-bottom: 0.6rem;
}

.publication-list .pub-year-count {
  font-weight: 400;
  opacity: var(--derek-muted);
}

.publication-list .pub-item {
  display: grid;
  grid-template-columns: 136px 1fr;
  gap: 0.9rem;
  margin-bottom: 0.8rem;
  align-items: start;
  overflow: visible; /* allow hovered thumbs to rise above text */
}

.publication-list .pub-thumb-wrap {
  width: 128px;
  min-width: 128px;
  padding-top: 0.45rem;
}

.publication-list .pub-thumb {
  width: 100%;
  height: auto;
  border-radius: var(--derek-radius);
  box-shadow: var(--derek-shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Gentle hover lift (was a 3.25× zoom that overlapped neighboring text
   in the two-column layout); click now opens a proper lightbox. */
.publication-list .pub-thumb:hover {
  transform: scale(1.06);
  position: relative;
  z-index: 20;
  box-shadow: var(--derek-shadow-lg);
}

.publication-list .pub-year-group:not(.is-collapsed) .pub-thumb-link {
  cursor: zoom-in;
}

.publication-list .pub-title {
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.publication-list .pub-title a {
  text-decoration: none;
}

.publication-list .pub-title a:hover {
  text-decoration: underline;
}

.publication-list .pub-meta {
  font-size: 0.92em;
  opacity: var(--derek-muted-soft);
  margin-bottom: 0.2rem;
}

.publication-list .pub-links {
  display: flex;
  flex-wrap: wrap;
  column-gap: 0.5rem;
  row-gap: 0.15rem;
  line-height: 1.2;
  margin-top: 0.15rem;
}

.publication-list .pub-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  text-decoration: none;
}

.publication-list .pub-link-gap {
  display: inline-block;
  width: 0.5rem;
}

.publication-list .pub-year-toggle {
  border: 0;
  background: transparent;
  padding: 0;
  margin-right: 0.4rem;
  font-size: 0.9em;
}

.publication-list .pub-year-group.is-collapsed .pub-year-toggle i {
  transform: rotate(-90deg);
}

.publication-list .pub-year-items {
  display: flex;
  flex-direction: column;
}

.publication-list .pub-year-group.is-collapsed .pub-year-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 0.6rem;
}

.publication-list .pub-year-group.is-collapsed .pub-item {
  grid-template-columns: 1fr;
  margin-bottom: 0;
}

.publication-list .pub-year-group.is-collapsed .pub-body {
  display: none;
}

.publication-list .pub-year-group.is-collapsed .pub-thumb-wrap {
  width: 100%;
  min-width: 0;
}

.publication-list .pub-year-group.is-collapsed .pub-thumb {
  height: 56px;
  width: 100%;
  object-fit: contain;
}

@media (max-width: 576px) {
  .publication-list .pub-item {
    grid-template-columns: 56px 1fr;
  }
  .publication-list .pub-thumb-wrap {
    width: 100%;
    min-width: 0;
  }
}

.about-email-image {
  height: 1em;
  width: auto;
}

.navbar-mini-profile {
  display: none;
  align-items: center;
  gap: 0.6rem;
  margin-left: 0.75rem;
}

.navbar-mini-profile .mini-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.navbar-mini-profile img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.8);
}

.navbar-mini-profile .mini-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  color: inherit;
}

.navbar-mini-profile .mini-name {
  font-size: 0.9rem;
  font-weight: 700;
}

.navbar-mini-profile .mini-role {
  font-size: 0.75rem;
  opacity: var(--derek-muted-soft);
}

.navbar-mini-profile .mini-org {
  display: flex;
  align-items: center;
  gap: 0.1rem;
}

.navbar-mini-profile .mini-logo {
  height: 1.5em;
  width: auto;
  background: #fff;
  padding: 0.1rem 0.25rem;
  border-radius: var(--derek-radius);
}

body.show-mini-profile .navbar-mini-profile {
  display: flex;
}

body.show-mini-profile .navbar-brand-text {
  display: none;
}

body.show-mini-profile .navbar-brand {
  display: flex;
  align-items: center;
}

@media (max-width: 576px) {
  .about-card {
    padding: 1.1rem;
  }

  .about-photo {
    width: 150px;
    height: 150px;
  }

  .navbar-mini-profile .mini-org {
    display: none;
  }
}

@media (min-width: 576px) {
  .about-layout {
    flex-direction: row;
    align-items: flex-start;
  }

  .about-left {
    flex: 1 1 0;
    max-width: none;
  }

  .about-right {
    flex: 1 1 0;
  }
}

/* ── Grouped publication versions (preprint + published) ─── */
.pub-version + .pub-version {
  margin-top: 0.55rem;
  padding-top: 0.5rem;
  border-top: 1px dashed rgba(0, 0, 0, 0.14);
  opacity: var(--derek-muted);
  font-size: 0.92em;
}

/* ── Section header refinement ───────────────────────────── */
/* Section headings are h2 in the DOM (Quarto's search only splits pages
   into per-section, jumpable results at h2/h3) but are styled to match the
   h4 look they replaced — Bootstrap's fluid h4 size, then the original
   hairline treatment. Overrides Quarto's default h2 border/margins. */
#research-themes > h2,
#research-group > h2,
#teaching > h2,
#publications > h2,
#funding-sources > h2 {
  font-size: 1.25rem; /* Quarto's h4 size — exact match to the old headings */
  font-weight: 500;
  margin-top: 1.5rem;
  letter-spacing: -0.01em;
  padding-bottom: 0.4rem;
  border-bottom: 1.5px solid rgba(0, 0, 0, 0.15);
  margin-bottom: 1rem;
}

/* ── Funding logos grid ──────────────────────────────────── */
.funding-logos {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.2rem 2rem;
  margin-top: 1.2rem;
}

.funding-logos a {
  display: inline-flex;
  align-items: center;
  opacity: var(--derek-muted-soft);
  transition: opacity 0.15s ease;
}

.funding-logos a:hover {
  opacity: 1.0;
}

.funding-logos img {
  height: 36px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  display: block;
}

@media (max-width: 576px) {
  .funding-logos {
    gap: 1rem 1.5rem;
  }
  .funding-logos img {
    height: 28px;
    max-width: 110px;
  }
}

/* ── Publication toggles & thumbnails (generated markup) ── */

/* Abstract/BibTeX toggles are <button>s (were <a href="#">); strip the
   button chrome so they render identically to the links they replaced.
   (display/gap/font-size come from the .bibbase-*-link rules above.) */
.publication-list .bibbase-abstract-link,
.publication-list .bibbase-bibtex-link {
  border: 0;
  background: transparent;
  padding: 0;
  font-family: inherit;
  line-height: inherit;
  color: var(--bs-link-color, #0000cc);
  cursor: pointer;
}

/* Panels start hidden (was inline style="display:none");
   content is hydrated from files/pub-extras.json on first open. */
.publication-list .bibbase-abstract,
.publication-list .bibbase-bibtex {
  display: none;
}

.publication-list .bibbase-abstract.is-open,
.publication-list .bibbase-bibtex.is-open {
  display: block;
}

/* Thumbnails are wrapped in a focusable anchor (keyboard access). */
.publication-list .pub-thumb-link,
.publication-list .pub-thumb-wrap picture {
  display: block;
}

/* Anchored jump targets clear the fixed navbar + sticky chip bar. */
.publication-list .pub-item,
section.level2 {
  scroll-margin-top: 5.5rem;
}

/* Brief highlight so the eye lands on the right entry after a jump. */
@media (prefers-reduced-motion: no-preference) {
  .publication-list .pub-item:target {
    animation: derek-target-flash 1.8s ease 0.2s both;
  }
}

@keyframes derek-target-flash {
  0%,
  35% {
    background: rgba(0, 0, 204, 0.06);
    box-shadow: 0 0 0 6px rgba(0, 0, 204, 0.06);
    border-radius: var(--derek-radius);
  }

  100% {
    background: transparent;
    box-shadow: none;
  }
}

/* ── Two-column desktop layouts ─────────────────────────── */

/* Research themes: 2 columns ≥ 900 px, 1 column below */
.themes-grid {
  display: grid;
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  .themes-grid {
    grid-template-columns: repeat(2, 1fr);
    column-gap: 2rem;
  }

  /* Remove bottom margin from the last item in each row so the
     section doesn't have extra whitespace below the final row */
  .themes-grid .theme-entry:nth-last-child(-n+2):nth-child(odd),
  .themes-grid .theme-entry:last-child {
    margin-bottom: 0;
  }
}

/* Publication items: 2 columns ≥ 900 px, 1 column below.
   Flex (not grid) guarantees strict LTR row-fill, so an odd-count year's
   lone item always lands in the LEFT column of the last row.
   The collapsed thumbnail grid (higher specificity) still overrides. */
@media (min-width: 900px) {
  .publication-list .pub-year-items {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0 2rem;
  }

  .publication-list .pub-year-items > .pub-item {
    flex: 0 0 calc(50% - 1rem);
    max-width: calc(50% - 1rem);
  }

  /* Per-year subheadings inside the expanded older-years group must
     span the full row width, not occupy a single column slot. */
  .publication-list .pub-year-items > .pub-year-subheader {
    flex: 0 0 100%;
    width: 100%;
  }

  /* Reset item sizing inside collapsed thumbnail grid — grid ignores
     flex-basis but still respects max-width, so we clear it here. */
  .publication-list .pub-year-group.is-collapsed .pub-year-items > .pub-item {
    max-width: none;
  }
}


/* ── Publications year chip bar (built by enhancements.html) ── */
.pub-year-nav {
  position: sticky;
  top: 3rem;
  z-index: 100;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.45rem 0;
  margin-bottom: 0.8rem;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.pub-year-nav a {
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: var(--derek-radius-pill);
  padding: 0.05rem 0.65rem;
  font-size: 0.85em;
  text-decoration: none;
  color: var(--derek-ink);
  background: #fff;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.pub-year-nav a:hover {
  color: var(--bs-link-color, #0000cc);
  border-color: var(--bs-link-color, #0000cc);
}

.pub-year-nav a.is-active {
  background: var(--bs-link-color, #0000cc);
  border-color: var(--bs-link-color, #0000cc);
  color: #fff;
}

/* ── Entrance animations (gated by .derek-anim, added only by JS) ── */
@media (prefers-reduced-motion: no-preference) {
  .derek-anim .theme-entry,
  .derek-anim .pub-item {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.45s ease, transform 0.45s ease;
  }

  /* slight cascade across the two theme columns */
  .derek-anim .themes-grid .theme-entry:nth-child(even) {
    transition-delay: 70ms;
  }

  .derek-anim .theme-entry.is-inview,
  .derek-anim .pub-item.is-inview {
    opacity: 1;
    transform: none;
  }

  /* subtle reveal when an abstract/bibtex panel opens */
  .publication-list .bibbase-abstract.is-open,
  .publication-list .bibbase-bibtex.is-open {
    animation: derek-reveal 0.25s ease;
  }
}

@keyframes derek-reveal {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

/* Never let the animation base state hide content in print */
@media print {
  .derek-anim .theme-entry,
  .derek-anim .pub-item {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ── Publication thumbnail lightbox ── */
.pub-lightbox {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 2rem;
  background: rgba(0, 0, 0, 0.82);
  cursor: zoom-out;
}

.pub-lightbox img {
  max-width: min(90vw, 1100px);
  max-height: 80vh;
  border-radius: var(--derek-radius);
  box-shadow: var(--derek-shadow-lg);
  cursor: default;
}

.pub-lightbox-caption {
  color: #fff;
  font-size: 0.95em;
  text-align: center;
  max-width: 80ch;
}

.pub-lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

@media (prefers-reduced-motion: no-preference) {
  .pub-lightbox {
    animation: derek-fade 0.2s ease;
  }
}

@keyframes derek-fade {
  from {
    opacity: 0;
  }
}
