/* =========================================================================
   Corentin Briat - Personal Site
   Aesthetic: Lab Notebook - warm paper, ink, terracotta accent
   ========================================================================= */

/* --- Design Tokens (Light) -------------------------------------------- */
:root {
  /* Color palette */
  --bg: #f5f0e3;
  --bg-elev: #fbf6e9;
  --bg-card: #ffffff;
  --bg-mute: #ede5d0;
  --text: #1a1611;
  --text-muted: #6b5d4f;
  --text-faint: #a89a82;
  --accent: #c25a3f;
  --accent-hover: #a44a32;
  --accent-soft: rgba(194, 90, 63, 0.10);
  --ink: #1f3a4d;
  --ink-soft: rgba(31, 58, 77, 0.08);
  --border: #ddd1b6;
  --border-soft: rgba(26, 22, 17, 0.08);
  --shadow-sm: 0 1px 2px rgba(26, 22, 17, 0.04);
  --shadow-md: 0 4px 16px rgba(26, 22, 17, 0.06), 0 2px 4px rgba(26, 22, 17, 0.03);
  --shadow-lg: 0 20px 40px -16px rgba(26, 22, 17, 0.18), 0 4px 12px rgba(26, 22, 17, 0.05);

  /* Type */
  --font-display: "Fraunces", "Iowan Old Style", "Charter", Georgia, serif;
  --font-body: "Geist", "Inter Tight", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "Geist Mono", "JetBrains Mono", ui-monospace, monospace;

  /* Sizing & spacing */
  --max-w: 1200px;
  --max-w-text: 720px;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Motion */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 160ms;
  --t-med: 280ms;
  --t-slow: 480ms;

  /* Paper texture overlay opacity */
  --paper-opacity: 0.4;
}

/* --- Dark theme ------------------------------------------------------- */
[data-theme="dark"] {
  --bg: #14110d;
  --bg-elev: #1d1914;
  --bg-card: #211c16;
  --bg-mute: #2a241d;
  --text: #f1e9d6;
  --text-muted: #a89a82;
  --text-faint: #6e6354;
  --accent: #e8825e;
  --accent-hover: #f0926f;
  --accent-soft: rgba(232, 130, 94, 0.12);
  --ink: #7ab0c4;
  --ink-soft: rgba(122, 176, 196, 0.10);
  --border: #3a3128;
  --border-soft: rgba(241, 233, 214, 0.08);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 20px 40px -16px rgba(0, 0, 0, 0.6), 0 4px 12px rgba(0, 0, 0, 0.3);
  --paper-opacity: 0.15;
}

/* --- Reset & base ----------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--t-med) var(--ease), color var(--t-med) var(--ease);
}

/* Subtle paper grain texture */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
  opacity: var(--paper-opacity);
  background-image:
    radial-gradient(circle at 25% 25%, rgba(26, 22, 17, 0.04) 1px, transparent 1px),
    radial-gradient(circle at 75% 75%, rgba(26, 22, 17, 0.03) 1px, transparent 1px);
  background-size: 7px 7px, 11px 11px;
  mix-blend-mode: multiply;
}
[data-theme="dark"] body::before { mix-blend-mode: screen; }

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

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--t-fast) var(--ease);
}
a:hover { color: var(--accent-hover); }

/* Subtle underline on prose links */
.prose a {
  background-image: linear-gradient(to right, var(--accent), var(--accent));
  background-position: 0 100%;
  background-size: 100% 1px;
  background-repeat: no-repeat;
  padding-bottom: 1px;
  transition: background-size var(--t-med) var(--ease);
}
.prose a:hover { background-size: 100% 2px; }

/* --- Typography ------------------------------------------------------- */
h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0 0 0.5em;
  color: var(--text);
  font-variation-settings: "SOFT" 30, "WONK" 0, "opsz" 64;
}

h1 { font-size: clamp(2.4rem, 5vw, 3.6rem); letter-spacing: -0.025em; }
h2 { font-size: clamp(1.7rem, 3vw, 2.2rem); letter-spacing: -0.02em; }
h3 { font-size: clamp(1.25rem, 2vw, 1.45rem); }
h4 { font-size: 1.1rem; }

p { margin: 0 0 1em; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  font-weight: 500;
}

.mono { font-family: var(--font-mono); font-size: 0.9em; }

/* --- Layout primitives ----------------------------------------------- */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
}
.container-text {
  max-width: var(--max-w-text);
  margin: 0 auto;
  padding: 0 24px;
}

/* --- Top navigation -------------------------------------------------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(245, 240, 227, 0.85);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--border-soft);
  transition: background var(--t-med) var(--ease), border-color var(--t-med) var(--ease);
}
[data-theme="dark"] .nav { background: rgba(20, 17, 13, 0.78); }

.nav__inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.nav__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}
.nav__brand:hover { color: var(--text); }

.nav__monogram {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--bg-elev);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  transition: transform var(--t-med) var(--ease);
}
.nav__brand:hover .nav__monogram { transform: rotate(-6deg) scale(1.05); }

.nav__links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}
.nav__link {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.92rem;
  color: var(--text);
  font-weight: 450;
  position: relative;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav__link:hover {
  background: var(--bg-mute);
  color: var(--text);
}
.nav__link.is-active {
  color: var(--accent);
}
.nav__link.is-active::before {
  content: "";
  position: absolute;
  inset: auto 12px -1px 12px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

.nav__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid var(--border-soft);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all var(--t-fast) var(--ease);
}
.icon-btn:hover {
  background: var(--bg-mute);
  border-color: var(--border);
}
.icon-btn svg { width: 18px; height: 18px; }

.theme-toggle .sun { display: none; }
.theme-toggle .moon { display: block; }
[data-theme="dark"] .theme-toggle .sun { display: block; }
[data-theme="dark"] .theme-toggle .moon { display: none; }

.nav__menu-btn { display: none; }

/* Mobile nav */
@media (max-width: 880px) {
  .nav__links {
    position: fixed;
    inset: 64px 0 auto 0;
    flex-direction: column;
    align-items: stretch;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border-soft);
    padding: 16px;
    gap: 2px;
    transform: translateY(-12px);
    opacity: 0;
    pointer-events: none;
    transition: transform var(--t-med) var(--ease), opacity var(--t-med) var(--ease);
  }
  .nav__links.is-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
  .nav__link.is-active::before { display: none; }
  .nav__link.is-active { background: var(--accent-soft); }
  .nav__menu-btn { display: grid; }
}

/* --- Hero ------------------------------------------------------------- */
.hero {
  padding: 80px 0 60px;
  position: relative;
  overflow: hidden;
}

.hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 64px;
  align-items: center;
}

@media (max-width: 800px) {
  .hero { padding: 48px 0 32px; }
  .hero__grid { grid-template-columns: 1fr; gap: 32px; }
  .hero__portrait { order: -1; max-width: 240px; }
}

.hero__eyebrow {
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.hero__eyebrow::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
  max-width: 80px;
}

.hero__name {
  font-size: clamp(2.6rem, 6vw, 4.2rem);
  font-weight: 400;
  font-variation-settings: "SOFT" 50, "opsz" 144;
  margin: 0 0 8px;
  line-height: 1.05;
}
.hero__name .italic { font-style: italic; font-variation-settings: "SOFT" 100, "opsz" 144, "WONK" 1; }

.hero__title {
  font-size: 1.15rem;
  color: var(--text-muted);
  margin: 0 0 24px;
  line-height: 1.5;
}

.hero__lead {
  font-size: 1.05rem;
  color: var(--text);
  margin-bottom: 28px;
  line-height: 1.65;
}

.hero__contact {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 450;
  transition: all var(--t-fast) var(--ease);
}
.chip:hover {
  background: var(--bg-mute);
  border-color: var(--border);
  color: var(--text);
  transform: translateY(-1px);
}
.chip svg { width: 14px; height: 14px; }
.chip--accent {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
}
.chip--accent:hover {
  background: var(--accent);
  color: white;
}

.hero__portrait {
  position: relative;
  aspect-ratio: 1;
  max-width: 380px;
  margin: 0 auto;
  width: 100%;
}
.hero__portrait::before {
  content: "";
  position: absolute;
  inset: -8px;
  background: var(--accent);
  border-radius: var(--radius-lg);
  transform: rotate(-3deg);
  z-index: 0;
  transition: transform var(--t-slow) var(--ease-out);
}
.hero__portrait:hover::before { transform: rotate(-1deg); }
.hero__portrait::after {
  content: "";
  position: absolute;
  inset: 4px -4px -4px 4px;
  border: 1px solid var(--ink);
  border-radius: var(--radius-lg);
  z-index: 0;
  transform: rotate(2deg);
}
.hero__portrait img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-lg);
  background: var(--bg-mute);
  box-shadow: var(--shadow-lg);
}

/* Placeholder portrait letters */
.hero__portrait--placeholder img,
.portrait-placeholder {
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 5rem;
  color: var(--bg);
  background: var(--ink);
}

/* When the actual image is missing, show initials inside the frame */
.hero__portrait.is-fallback img { display: none; }
.hero__portrait.is-fallback::after { display: none; }
.hero__portrait.is-fallback {
  position: relative;
}
.hero__portrait.is-fallback .hero__fallback {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, var(--ink) 0%, color-mix(in srgb, var(--ink) 70%, var(--accent)) 100%);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-lg);
  font-family: var(--font-display);
  color: var(--bg-elev);
  font-size: clamp(4rem, 12vw, 7rem);
  font-weight: 300;
  font-variation-settings: "SOFT" 100, "opsz" 144, "WONK" 1;
  letter-spacing: -0.02em;
  font-style: italic;
}

/* --- Quote block ----------------------------------------------------- */
.quote-block {
  margin: 48px auto 0;
  padding: 32px 36px;
  background: var(--bg-elev);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-soft);
  position: relative;
  max-width: 820px;
  overflow: hidden;
  transition: opacity var(--t-med) var(--ease);
}
.quote-block::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent);
}
.quote-block__mark {
  position: absolute;
  top: 16px;
  right: 24px;
  font-family: var(--font-display);
  font-size: 4rem;
  line-height: 1;
  color: var(--accent);
  opacity: 0.18;
  font-weight: 600;
  font-style: italic;
}
.quote-block__text {
  font-family: var(--font-display);
  font-size: 1.15rem;
  line-height: 1.55;
  font-style: italic;
  color: var(--text);
  margin: 0 0 12px;
  font-variation-settings: "SOFT" 100, "opsz" 28;
}
.quote-block__author {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.quote-block__refresh {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--border-soft);
  color: var(--text-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all var(--t-fast) var(--ease);
}
.quote-block__refresh:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: rotate(180deg);
}
.quote-block__refresh svg { width: 14px; height: 14px; }

/* --- Section heading ------------------------------------------------- */
.section {
  padding: 64px 0;
}
.section--alt { background: var(--bg-elev); }

.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 24px;
  flex-wrap: wrap;
}
.section__title { margin: 0; }
.section__title .num {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--accent);
  margin-right: 8px;
  vertical-align: super;
  font-weight: 500;
}

/* --- Research cards -------------------------------------------------- */
.research-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.research-card {
  display: block;
  padding: 28px;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  color: var(--text);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: all var(--t-med) var(--ease);
}
.research-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  color: var(--text);
}
.research-card::before {
  content: "";
  position: absolute;
  inset: auto -10% -60% -10%;
  height: 100%;
  background: radial-gradient(ellipse at center top, var(--accent-soft), transparent 70%);
  opacity: 0;
  transition: opacity var(--t-med) var(--ease);
}
.research-card:hover::before { opacity: 1; }
.research-card__icon {
  width: 44px;
  height: 44px;
  margin-bottom: 18px;
  display: grid;
  place-items: center;
  background: var(--ink-soft);
  border-radius: 10px;
  color: var(--ink);
  transition: all var(--t-med) var(--ease);
}
.research-card:hover .research-card__icon {
  background: var(--accent);
  color: white;
  transform: rotate(-6deg);
}
.research-card__icon svg { width: 22px; height: 22px; }
.research-card__title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 500;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
  position: relative;
}
.research-card__desc {
  color: var(--text-muted);
  font-size: 0.93rem;
  line-height: 1.55;
  margin: 0 0 18px;
  position: relative;
}
.research-card__more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 500;
  position: relative;
  transition: gap var(--t-fast) var(--ease);
}
.research-card:hover .research-card__more { gap: 12px; }
.research-card__more svg { width: 14px; height: 14px; }

/* --- News list ------------------------------------------------------- */
.news-list { list-style: none; padding: 0; margin: 0; }
.news-item {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 24px;
  padding: 16px 0;
  border-top: 1px solid var(--border-soft);
  align-items: baseline;
}
.news-item:first-child { border-top: 0; padding-top: 0; }
.news-item__date {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}
.news-item__body { color: var(--text); }
.news-item__body a { font-weight: 500; }
@media (max-width: 600px) {
  .news-item { grid-template-columns: 1fr; gap: 4px; }
}

/* --- Page header ----------------------------------------------------- */
.page-header {
  padding: 80px 0 40px;
  border-bottom: 1px solid var(--border-soft);
}
.page-header__inner { max-width: var(--max-w-text); margin: 0 auto; padding: 0 24px; }
.page-header__eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--accent);
  margin-bottom: 12px;
}
.page-header__title {
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  margin: 0 0 16px;
  font-weight: 400;
  font-variation-settings: "SOFT" 50, "opsz" 144;
}
.page-header__title .italic { font-style: italic; }
.page-header__lead {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0;
}

/* --- Prose styles ---------------------------------------------------- */
.prose {
  font-size: 1.02rem;
  line-height: 1.75;
  color: var(--text);
}
.prose h2 {
  font-size: 1.7rem;
  margin: 56px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-soft);
}
.prose h2:first-child { margin-top: 0; }
.prose h3 {
  margin: 32px 0 12px;
  font-size: 1.2rem;
}
.prose p { margin: 0 0 1.25em; }
.prose ul, .prose ol { padding-left: 20px; margin: 0 0 1.25em; }
.prose li { margin: 0.35em 0; padding-left: 6px; }
.prose ul li::marker { color: var(--accent); }
.prose code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 2px 6px;
  background: var(--bg-mute);
  border-radius: 4px;
  border: 1px solid var(--border-soft);
}
.prose blockquote {
  margin: 1.5em 0;
  padding: 14px 22px;
  border-left: 3px solid var(--accent);
  color: var(--text-muted);
  font-style: italic;
  background: var(--bg-elev);
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* --- Timeline (CV) --------------------------------------------------- */
.timeline {
  position: relative;
  padding-left: 28px;
  list-style: none;
  margin: 0;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: var(--border);
}
.timeline__item {
  position: relative;
  padding: 0 0 28px 0;
}
.timeline__item:last-child { padding-bottom: 0; }
.timeline__item::before {
  content: "";
  position: absolute;
  left: -27px;
  top: 8px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
  z-index: 1;
  transition: transform var(--t-fast) var(--ease);
}
.timeline__item:hover::before { transform: scale(1.4); }
.timeline__date {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 4px;
}
.timeline__title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin: 0 0 4px;
  font-weight: 500;
}
.timeline__org {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin: 0;
}
.timeline__org a { color: var(--text-muted); border-bottom: 1px dotted currentColor; }
.timeline__org a:hover { color: var(--accent); }

/* --- Tabs ------------------------------------------------------------ */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border-soft);
  overflow-x: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 12px 16px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  transition: color var(--t-fast) var(--ease);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab:hover { color: var(--text); }
.tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab__count {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: var(--bg-mute);
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--text-muted);
}
.tab.is-active .tab__count { background: var(--accent-soft); color: var(--accent); }

/* --- Publications ---------------------------------------------------- */
.pub-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  margin-bottom: 24px;
  align-items: center;
}
@media (max-width: 700px) {
  .pub-controls { grid-template-columns: 1fr; }
}

.search-input {
  position: relative;
}
.search-input input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text);
  transition: all var(--t-fast) var(--ease);
}
.search-input input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-input::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b5d4f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0.7;
}
[data-theme="dark"] .search-input::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a89a82' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
}

.sort-select {
  padding: 12px 36px 12px 14px;
  background: var(--bg-elev) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b5d4f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  background-size: 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text);
  appearance: none;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}
[data-theme="dark"] .sort-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a89a82' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
.sort-select:focus { outline: none; border-color: var(--accent); }

.pub-count {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.pub-list { list-style: none; padding: 0; margin: 0; }
.pub-item {
  padding: 20px 0;
  border-top: 1px solid var(--border-soft);
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 24px;
  align-items: baseline;
  transition: background var(--t-fast) var(--ease);
}
.pub-item:hover { background: var(--bg-elev); margin: 0 -16px; padding: 20px 16px; }
.pub-item:first-child { border-top: 0; }
.pub-item__year {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 500;
}
.pub-item__year--none { color: var(--text-faint); }
.pub-item__title {
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 500;
  line-height: 1.35;
  margin: 0 0 6px;
  color: var(--text);
  letter-spacing: -0.005em;
}
.pub-item__title a { color: var(--text); }
.pub-item__title a:hover { color: var(--accent); }
.pub-item__authors {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin: 0 0 4px;
}
.pub-item__venue {
  font-size: 0.88rem;
  color: var(--text-faint);
  font-style: italic;
  margin: 0;
}
.pub-item__tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 8px;
  background: var(--ink-soft);
  color: var(--ink);
  vertical-align: middle;
}
.pub-item__tag--journal { background: var(--accent-soft); color: var(--accent); }
.pub-item__tag--book { background: rgba(122, 176, 196, 0.15); color: var(--ink); }
[data-theme="dark"] .pub-item__tag--book { color: var(--ink); }

.pub-item__link {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.82rem;
  font-family: var(--font-mono);
  color: var(--accent);
}
.pub-item__link::after { content: " ↗"; }

@media (max-width: 600px) {
  .pub-item { grid-template-columns: 1fr; gap: 4px; }
  .pub-item:hover { margin: 0 -12px; padding: 20px 12px; }
}

.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}

/* --- Resource categories --------------------------------------------- */
.resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.resource-card {
  padding: 24px;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  transition: all var(--t-fast) var(--ease);
}
.resource-card:hover {
  border-color: var(--border);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.resource-card__title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.resource-card__icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
}
.resource-card__icon svg { width: 16px; height: 16px; }
.resource-list { list-style: none; padding: 0; margin: 0; }
.resource-list li {
  padding: 6px 0;
  font-size: 0.92rem;
  line-height: 1.5;
}
.resource-list a {
  color: var(--text);
  font-weight: 500;
}
.resource-list a:hover { color: var(--accent); }
.resource-list .desc {
  display: block;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 400;
}

/* --- Project card ---------------------------------------------------- */
.project-card {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 36px;
  padding: 32px;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  align-items: center;
  margin-bottom: 32px;
}
@media (max-width: 800px) {
  .project-card { grid-template-columns: 1fr; padding: 24px; }
}
.project-card__img {
  border-radius: var(--radius);
  background: var(--bg-mute);
  aspect-ratio: 4/3;
  overflow: hidden;
}
.project-card__img img { width: 100%; height: 100%; object-fit: cover; }
.project-card__placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--bg-mute), var(--bg-card));
  color: var(--text-faint);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.1rem;
}
.project-card__title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  margin: 0 0 12px;
}
.project-card__meta {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 8px;
}

/* --- Blog list ------------------------------------------------------- */
.blog-list { list-style: none; padding: 0; margin: 0; }
.blog-item {
  display: block;
  padding: 28px 0;
  border-top: 1px solid var(--border-soft);
  color: var(--text);
}
.blog-item:first-child { border-top: 0; }
.blog-item:hover { color: var(--text); }
.blog-item:hover .blog-item__title { color: var(--accent); }
.blog-item__date {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.blog-item__title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin: 0 0 8px;
  font-weight: 500;
  transition: color var(--t-fast) var(--ease);
}
.blog-item__status {
  display: inline-block;
  margin-left: 12px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--ink-soft);
  color: var(--ink);
  vertical-align: middle;
  font-weight: 500;
}

/* --- Footer ---------------------------------------------------------- */
.footer {
  padding: 60px 0 32px;
  border-top: 1px solid var(--border-soft);
  margin-top: 80px;
  background: var(--bg-elev);
}
.footer__grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 48px;
}
@media (max-width: 700px) {
  .footer__grid { grid-template-columns: 1fr 1fr; }
}
.footer h4 {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  font-weight: 500;
  margin: 0 0 14px;
}
.footer ul { list-style: none; padding: 0; margin: 0; }
.footer li { margin: 6px 0; }
.footer a {
  color: var(--text);
  font-size: 0.92rem;
}
.footer a:hover { color: var(--accent); }
.footer__brand {
  font-family: var(--font-display);
  font-size: 1.25rem;
  margin: 0 0 10px;
  font-weight: 500;
}
.footer__desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0 0 16px;
}
.footer__bottom {
  padding-top: 24px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-faint);
  flex-wrap: wrap;
  gap: 12px;
}
.footer__bottom a { color: var(--text-faint); }
.footer__bottom a:hover { color: var(--accent); }

/* --- Equation / formula container ------------------------------------ */
.equation {
  margin: 1.5em 0;
  padding: 18px 24px;
  background: var(--bg-elev);
  border-left: 3px solid var(--ink);
  border-radius: 0 var(--radius) var(--radius) 0;
  overflow-x: auto;
  font-size: 1.05em;
}

/* --- Stat blocks ----------------------------------------------------- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 32px 0;
}
.stat {
  padding: 18px 20px;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}
.stat__num {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 500;
  line-height: 1;
  color: var(--accent);
  font-variation-settings: "opsz" 144;
}
.stat__label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-top: 6px;
}

/* --- Memberships ----------------------------------------------------- */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}
.tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  font-size: 0.83rem;
  color: var(--text);
  transition: all var(--t-fast) var(--ease);
}
.tag:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* --- Reveal on scroll ------------------------------------------------
   Opt-in via .js-on on <html> so content stays visible without JS.    */
.js-on .reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 600ms var(--ease-out), transform 600ms var(--ease-out);
  will-change: opacity, transform;
}
.js-on .reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.js-on .reveal-stagger > * {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 600ms var(--ease-out), transform 600ms var(--ease-out);
  will-change: opacity, transform;
}
.js-on .reveal-stagger.is-visible > * {
  opacity: 1;
  transform: translateY(0);
}
.js-on .reveal-stagger.is-visible > *:nth-child(1) { transition-delay: 0ms; }
.js-on .reveal-stagger.is-visible > *:nth-child(2) { transition-delay: 80ms; }
.js-on .reveal-stagger.is-visible > *:nth-child(3) { transition-delay: 160ms; }
.js-on .reveal-stagger.is-visible > *:nth-child(4) { transition-delay: 240ms; }
.js-on .reveal-stagger.is-visible > *:nth-child(5) { transition-delay: 320ms; }
.js-on .reveal-stagger.is-visible > *:nth-child(6) { transition-delay: 400ms; }

@media (prefers-reduced-motion: reduce) {
  .js-on .reveal, .js-on .reveal-stagger > * { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}

/* --- Back to top button ----------------------------------------------- */
.back-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  border: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity var(--t-med) var(--ease), transform var(--t-med) var(--ease);
  z-index: 90;
}
.back-top.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.back-top:hover { background: var(--accent); color: white; }
.back-top svg { width: 18px; height: 18px; }

/* --- Skip to content (a11y) ------------------------------------------- */
.skip-link {
  position: absolute;
  top: -50px;
  left: 12px;
  background: var(--accent);
  color: white;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  z-index: 200;
  transition: top var(--t-fast) var(--ease);
}
.skip-link:focus { top: 12px; color: white; }
