/* =====================================================================
   style.css: colours, fonts, layout and responsive rules
   Breakpoints:
     Desktop = 1024px and wider (default rules, sidebar always visible)
     Tablet  = 641px to 1023px  (@media max-width: 1023px, sidebar becomes a slide-in menu)
     Mobile  = 640px and narrower (@media max-width: 640px)
   ===================================================================== */

/* ---------- 1. COLOURS, FONTS AND SIZES (safe to edit) ---------- */
:root {
  --bg: #ffffff;
  --sidebar-bg: #fafbfc;
  --surface: #ffffff;
  --text: #1f2937;
  --heading: #1b365d;
  --muted: #556070;
  --primary: #0066cc;          /* MAIN ACCENT COLOUR: change this to restyle the site */
  --on-primary: #ffffff;
  --tile-bg: #eef1f5;
  --tag-bg: #e8f1fb;
  --tag-text: #0b5cab;
  --border: #e4e8ee;
  --header-bg: rgba(255, 255, 255, 0.9);
  --hero-glow: rgba(120, 176, 230, 0.35);
  --btn-shadow: 0 6px 16px rgba(0, 102, 204, 0.3);
  --warn-bg: #fef3c7;
  --warn-text: #92400e;
  --shadow: 0 4px 18px rgba(31, 41, 55, 0.06);
  --shadow-hover: 0 10px 28px rgba(31, 41, 55, 0.13);
  --radius: 12px;
  --sidebar-width: 300px;
  --topbar-height: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;          /* BODY FONT */
  --font-serif: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;               /* HEADING FONT */
}

[data-theme="dark"] {
  --bg: #0f1720;
  --sidebar-bg: #121c27;
  --surface: #17222f;
  --text: #dbe3ec;
  --heading: #eaf2fb;
  --muted: #9aa8b8;
  --primary: #4da3ff;
  --on-primary: #06121f;
  --tile-bg: #1f2c3a;
  --tag-bg: #16314d;
  --tag-text: #9ccbff;
  --border: #2a3a4b;
  --header-bg: rgba(15, 23, 32, 0.9);
  --hero-glow: rgba(77, 163, 255, 0.18);
  --btn-shadow: 0 6px 16px rgba(77, 163, 255, 0.25);
  --warn-bg: #78350f;
  --warn-text: #fde68a;
  --shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  --shadow-hover: 0 10px 28px rgba(0, 0, 0, 0.5);
}

[data-theme="forest"] {
  --bg: #f4f8f4;
  --sidebar-bg: #eef4ee;
  --surface: #ffffff;
  --text: #1e2b22;
  --heading: #14452a;
  --muted: #52645a;
  --primary: #1f7a4d;
  --tile-bg: #e1ece3;
  --tag-bg: #e1f0e6;
  --tag-text: #176239;
  --border: #d5e2d8;
  --header-bg: rgba(244, 248, 244, 0.9);
  --hero-glow: rgba(110, 190, 140, 0.35);
  --btn-shadow: 0 6px 16px rgba(31, 122, 77, 0.3);
}

/* ---------- 2. BASIC RESET ---------- */
*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-height) + 12px);
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  transition: background 0.25s ease, color 0.25s ease;
}

img { max-width: 100%; height: auto; }
a { color: var(--primary); }

h1, h2, h3 {
  font-family: var(--font-serif);
  color: var(--heading);
  line-height: 1.2;
  margin: 0 0 0.5rem;
}
h3 { font-size: 1.15rem; }
p { margin: 0 0 0.9rem; }

:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }

.container { width: min(1024px, 100% - 3rem); margin-inline: auto; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--primary);
  color: var(--on-primary);
  padding: 0.6rem 1rem;
  z-index: 100;
}
.skip-link:focus { left: 0; }

/* Small line icons used in buttons and the menu */
.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- 3. FALLING BACKGROUND SYMBOLS ---------- */
.bg-glyphs {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.glyph {
  position: absolute;
  top: -10vh;
  color: var(--primary);
  opacity: 0.1;
  user-select: none;
  animation-name: glyph-fall;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
@keyframes glyph-fall {
  from { transform: translateY(0) rotate(0deg); }
  to   { transform: translateY(120vh) rotate(360deg); }
}

/* ---------- 4. SIDEBAR ---------- */
.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--sidebar-width);
  z-index: 30;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem 1.5rem 1.25rem;
  text-decoration: none;
  color: var(--heading);
}
.side-avatar {
  flex: 0 0 auto;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--primary);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  display: grid;
  place-items: center;
  background: var(--tag-bg);
  color: var(--primary);
  font-family: var(--font-serif);
  font-weight: 800;
}
.side-brand-text { display: flex; flex-direction: column; min-width: 0; }
.side-name {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.2;
}
.side-title { font-size: 0.85rem; color: var(--muted); line-height: 1.3; margin-top: 0.2rem; }

.side-nav { padding: 0.75rem 1rem; }
.side-nav ul { list-style: none; margin: 0; padding: 0; }
.side-nav li { margin-bottom: 0.3rem; }
.side-nav a {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.5rem 0.65rem;
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}
.nav-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--tile-bg);
  color: var(--muted);
}
.side-nav a:hover { background: var(--tile-bg); }
.side-nav a:hover .nav-icon { background: var(--tag-bg); color: var(--primary); }

.sidebar-links {
  margin-top: auto;
  display: flex;
  justify-content: space-around;
  gap: 0.25rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}
.profile-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.95rem;
  text-decoration: none;
}
.profile-icon:hover { background: var(--tile-bg); color: var(--primary); }

.icon-btn.sidebar-close { display: none; position: absolute; top: 0.75rem; right: 0.75rem; }
.sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.4);
}

/* ---------- 5. MAIN AREA AND TOP BAR ---------- */
.main-area {
  position: relative;
  z-index: 1;
  margin-left: var(--sidebar-width);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: var(--topbar-height);
  padding: 0 1.5rem;
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}
.topbar-left { display: flex; align-items: center; gap: 1rem; }

.clock { display: flex; flex-direction: column; line-height: 1.15; margin-left: 0.5rem; }
.clock-time { font-weight: 700; color: var(--heading); font-size: 1.05rem; }
.clock-date { font-size: 0.75rem; color: var(--muted); text-align: right; }

.theme-select {
  min-height: 44px;
  padding: 0.4rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--tile-bg); }

/* The ☰ button is hidden on desktop */
.menu-btn { display: none; flex-direction: column; gap: 4px; }
.menu-bar { display: block; width: 18px; height: 2px; background: currentColor; border-radius: 2px; }

/* ---------- 6. BUTTONS ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  border: 1px solid var(--primary);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--btn-shadow); }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-small { min-height: 38px; padding: 0.3rem 1rem; font-size: 0.88rem; }

.button-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; }

/* Links that still contain placeholder addresses */
.is-placeholder {
  opacity: 0.55;
  border-style: dashed;
  pointer-events: none;
}
.is-placeholder::after {
  content: " (add link)";
  font-size: 0.75em;
  font-weight: 400;
  margin-left: 0.3em;
}
.profile-icon.is-placeholder::after { content: none; }

/* ---------- 7. HERO ---------- */
.hero { padding: 2.5rem 0 1.5rem; }
.hero-card {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 2.5rem;
  align-items: center;
  padding: 3rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background:
    radial-gradient(ellipse at 18% 25%, var(--hero-glow), transparent 55%),
    var(--surface);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 1.5rem;
  padding: 0.4rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.85rem;
  color: var(--text);
}
.pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 3px var(--tag-bg);
}

.hero h1 { font-size: clamp(2.2rem, 2.8vw, 2.6rem); font-weight: 600; margin-bottom: 0.6rem; }
.hero-subtitle {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--heading);
  opacity: 0.85;
  margin-bottom: 1rem;
}
.hero-intro { max-width: 65ch; color: var(--muted); font-size: 1.05rem; }

.hero-photo-wrap { display: flex; justify-content: center; }
.hero-photo {
  width: 100%;
  max-width: 230px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid var(--primary);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}
div.hero-photo {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--tag-bg), var(--tile-bg));
  color: var(--primary);
  font-family: var(--font-serif);
  font-size: 3.5rem;
  font-weight: 700;
}

/* ---------- 8. STATS, DIVIDER ---------- */
.stats { padding: 1rem 0 0; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
.stat { text-align: center; padding: 1.25rem; }
.stat-number {
  display: block;
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}
.stat-label { display: block; color: var(--muted); font-size: 0.95rem; }

.divider {
  border: 0;
  height: 1px;
  margin: 3rem 0 0;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}

/* ---------- 9. SECTIONS AND CARDS ---------- */
.section { padding: 3.5rem 0; }
.section-head { margin-bottom: 2rem; }
.section-head h2 { font-size: clamp(1.8rem, 3vw, 2.3rem); font-weight: 600; }
.section-lead { color: var(--muted); max-width: 70ch; margin-top: 0.5rem; }

.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--primary);
}
.eyebrow::before { content: ""; width: 28px; height: 1px; background: currentColor; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }

.tag-list { display: flex; flex-wrap: wrap; gap: 0.5rem; list-style: none; margin: 0.75rem 0 0; padding: 0; }
.tag {
  background: var(--tag-bg);
  color: var(--tag-text);
  padding: 0.2rem 0.75rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
}

/* About */
.about-grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 1.5rem; align-items: start; }
.stack { display: grid; gap: 1.5rem; }
.skills-card { margin-top: 1.5rem; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { margin-bottom: 0.9rem; }
.plain-list li:last-child { margin-bottom: 0; }
.item-meta { display: block; color: var(--muted); font-size: 0.92rem; }

.placeholder-text {
  background: var(--warn-bg);
  color: var(--warn-text);
  padding: 0 0.35em;
  border-radius: 4px;
}

/* ---------- 10. PUBLICATIONS ---------- */
.notice {
  background: var(--warn-bg);
  color: var(--warn-text);
  border-left: 4px solid var(--warn-text);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.filter-bar { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.5rem; }
.filter-btn {
  min-height: 40px;
  padding: 0.35rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.filter-btn:hover { background: var(--tag-bg); }
.filter-btn[aria-pressed="true"] {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
}

.pub-list { display: grid; gap: 1.25rem; }
.pub-badges { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.6rem; }
.badge {
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.15rem 0.65rem;
  border-radius: 999px;
}
.badge-placeholder { background: var(--warn-bg); color: var(--warn-text); }
.pub-title { overflow-wrap: anywhere; }
.pub-authors { color: var(--muted); margin-bottom: 0.3rem; }
.pub-journal { margin-bottom: 0; }
.pub-year { font-weight: 700; }
.pub-links { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.9rem; }
.empty-message { color: var(--muted); text-align: center; margin-top: 1rem; }

/* ---------- 11. CV AND CONTACT ---------- */
.cv-card { text-align: center; padding: 2rem 1.5rem; }
.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.contact-email { font-size: 1.1rem; font-weight: 600; overflow-wrap: anywhere; }
.link-list { display: flex; flex-wrap: wrap; gap: 0.6rem; list-style: none; margin: 0.5rem 0 0; padding: 0; }

/* ---------- 12. FOOTER ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.75rem 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
}
.site-footer p { margin: 0; }

/* ---------- 13. SCROLL FADE-IN (only active when JavaScript runs) ---------- */
.js .reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease, transform 0.6s ease, box-shadow 0.2s ease;
}
.js .reveal.is-visible { opacity: 1; transform: none; }

/* =====================================================================
   TABLET VERSION: 641px to 1023px
   The sidebar turns into a menu that slides in from the left.
   ===================================================================== */
@media (max-width: 1023px) {
  .main-area { margin-left: 0; }

  .sidebar {
    width: min(320px, 85vw);
    z-index: 70;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.25s ease, visibility 0s linear 0.25s;
    box-shadow: var(--shadow-hover);
  }
  .sidebar.is-open {
    transform: none;
    visibility: visible;
    transition: transform 0.25s ease, visibility 0s;
  }
   .icon-btn.sidebar-close { display: inline-flex; }
  .menu-btn { display: inline-flex; }
  .clock { margin-left: 0; }
  .topbar { padding: 0 1rem; }

  .hero-card { grid-template-columns: 1fr 180px; gap: 2rem; padding: 2.25rem; }
  .hero-photo { max-width: 180px; }
  div.hero-photo { font-size: 2.8rem; }

  .section { padding: 3rem 0; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .about-grid { grid-template-columns: 1fr; }
  .contact-grid { grid-template-columns: 1fr; }
}

/* =====================================================================
   MOBILE VERSION: 640px and narrower
   ===================================================================== */
@media (max-width: 640px) {
  .container { width: min(1024px, 100% - 2rem); }

  .hero { padding: 1.5rem 0 1rem; }
  .hero-card { grid-template-columns: 1fr; gap: 1.5rem; padding: 1.5rem; }
  .hero-photo-wrap { order: -1; }
  .hero-photo { max-width: 160px; }
  div.hero-photo { font-size: 2.3rem; }
  .hero-subtitle { font-size: 1.15rem; }
  .hero-intro { font-size: 1rem; }

  .button-row { flex-direction: column; }
  .button-row .btn { width: 100%; }

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

  .section { padding: 2.5rem 0; }
  .grid-3 { grid-template-columns: 1fr; }
  .card { padding: 1.25rem; }

  .theme-select { font-size: 0.85rem; padding: 0.4rem 0.6rem; }
  .pub-links .btn, .link-list .btn { min-height: 44px; }
}

/* ---------- Respect visitors who prefer less motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
  .card, .btn, .sidebar { transition: none; }
}
/* ---------- CV button when the PDF has not been uploaded yet ---------- */
.is-unavailable {
  opacity: 0.55;
  border-style: dashed;
  pointer-events: none;
}
.is-unavailable::after {
  content: " (coming soon)";
  font-size: 0.75em;
  font-weight: 400;
  margin-left: 0.3em;
}
/* =====================================================================
   PUBLICATIONS: filter panel, cards, and the active sidebar link
   (matches the reference publications page)
   ===================================================================== */

/* ---------- Filter panel ---------- */
.filter-panel { display: none; }
.js .filter-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
  padding: 1.25rem;
  margin-bottom: 1.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.field { display: flex; flex-direction: column; gap: 0.4rem; }
.field-grow { flex: 1 1 220px; }
.field-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.field-input {
  width: 100%;
  min-height: 44px;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
}
.field select.field-input { min-width: 150px; cursor: pointer; }

.view-toggle {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}
.view-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 36px;
  padding: 0.3rem 0.9rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.view-btn[aria-pressed="true"] {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow);
}
.icon-sm { width: 16px; height: 16px; }

/* ---------- Publication cards ---------- */
.pub-card { position: relative; padding: 1.4rem 1.5rem; }
.pub-card:hover {
  border-color: var(--primary);
  box-shadow: 0 14px 34px var(--hero-glow);
}
.pub-main { padding-right: 3rem; }
.pub-title { font-size: 1.2rem; margin-bottom: 0.5rem; }
.pub-authors { color: var(--text); font-weight: 500; margin-bottom: 0.7rem; }

.pub-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1.1rem;
  color: var(--muted);
  font-size: 0.95rem;
}
.meta-item { display: inline-flex; align-items: center; gap: 0.45rem; }
.pub-year { font-weight: 600; }

.type-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.75rem;
  font-weight: 700;
}
.type-journal { background: #e3f5e8; color: #1c6b3a; border-color: #bfe5cb; }
.type-preprint { background: #ece7fb; color: #5b3fc4; border-color: #d6cdf6; }
.type-review, .type-placeholder { background: var(--warn-bg); color: var(--warn-text); }
[data-theme="dark"] .type-journal { background: #12301f; color: #8fe0ad; border-color: #1f4d33; }
[data-theme="dark"] .type-preprint { background: #2a2150; color: #c4b5fd; border-color: #3d3274; }

/* Details that collapse (Compact view hides them) */
.pub-extra { display: none; margin-top: 0.9rem; }
.pub-card.is-open .pub-extra { display: block; }
.pub-tags { margin: 0 0 0.9rem; }
.pub-tags .tag {
  background: var(--tile-bg);
  color: var(--muted);
  font-weight: 500;
  font-size: 0.78rem;
  border-radius: 8px;
}
.pub-summary { color: var(--text); margin-bottom: 0.9rem; }
.pub-links .btn { border-radius: 10px; }

/* Collapse / expand arrow */
.pub-toggle {
  display: none;
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.js .pub-toggle { display: inline-flex; }
.pub-toggle:hover { color: var(--primary); border-color: var(--primary); }
.pub-toggle .icon { transition: transform 0.2s ease; }
.pub-card:not(.is-open) .pub-toggle .icon { transform: rotate(180deg); }

/* ---------- Active link in the sidebar (changes as you scroll) ---------- */
.side-nav a { position: relative; }
.side-nav a.is-active {
  background: var(--tag-bg);
  color: var(--primary);
  font-weight: 600;
}
.side-nav a.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 3px;
  height: 22px;
  border-radius: 3px;
  background: var(--primary);
  transform: translateY(-50%);
}
.side-nav a.is-active .nav-icon { background: rgba(0, 102, 204, 0.15); color: var(--primary); }
[data-theme="dark"] .side-nav a.is-active .nav-icon { background: rgba(77, 163, 255, 0.25); }
[data-theme="forest"] .side-nav a.is-active .nav-icon { background: rgba(31, 122, 77, 0.18); }

/* ---------- Mobile (640px and narrower) ---------- */
@media (max-width: 640px) {
  .js .filter-panel { flex-direction: column; align-items: stretch; }
  .field select.field-input { width: 100%; }
  .view-toggle { align-self: flex-start; }
  .pub-card { padding-bottom: 3.75rem; }
  .pub-main { padding-right: 0; }
}
/* ---------- Publications: Compact view (card is closed) ---------- */
.pub-card:not(.is-open) .pub-authors,
.pub-card:not(.is-open) .meta-category {
  display: none;
}
.pub-card:not(.is-open) {
  padding-top: 1.1rem;
  padding-bottom: 1.1rem;
}
.pub-card:not(.is-open) .pub-title {
  font-size: 1.1rem;
  margin-bottom: 0.55rem;
}
.pub-card:not(.is-open) .pub-main {
  padding-right: 3rem;
}
/* Keep the arrow centred on the right side while the card is compact */
.pub-card:not(.is-open) .pub-toggle {
  top: 50%;
  bottom: auto;
  transform: translateY(-50%);
}
/* ---------- Publications: hide the Placeholder and Journal badges (both views) ---------- */
.type-placeholder,
.type-journal {
  display: none;
}

/* ---------- Publications: DOI button beside the year in Compact view ---------- */
.compact-doi { display: none; }
.pub-card:not(.is-open) .compact-doi { display: inline-flex; }

/* In Compact view the bottom button row is hidden (the DOI is shown beside the year instead) */
.pub-card:not(.is-open) .pub-links { display: none; }
/* =====================================================================
   CV VIEWER
   ===================================================================== */
.cv-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1.25rem; }

.cv-viewer {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.cv-frame {
  display: block;
  width: 100%;
  height: 80vh;
  min-height: 520px;
  border: 0;
  background: var(--surface);
}
.cv-fallback { display: none; margin: 0; padding: 1.25rem; color: var(--muted); }

/* Hidden automatically until your cv.pdf has been uploaded (set by script.js) */
.cv-missing .cv-viewer { display: none; }

/* Tablet */
@media (max-width: 1023px) {
  .cv-frame { height: 70vh; }
}

/* Mobile: phones cannot show an embedded PDF reliably, so use buttons instead */
@media (max-width: 640px) {
  .cv-frame { display: none; }
  .cv-fallback { display: block; }
  .cv-actions .btn { width: 100%; }
}

/* LOGO IN THE TOP BAR */
.site-logo { display: inline-flex; flex: 0 0 auto;}
.site-logo img { display: block; width: 56px; height: 56px; object-fit: contain; border-radius: 8px; }
/* =====================================================================
   CV PREVIEW ON TABLET AND PHONE (pages drawn by script.js)
   ===================================================================== */
.cv-pages { display: none; }

@media (max-width: 1023px) {
  .cv-frame { display: none; }
  .cv-pages {
    display: block;
    max-height: 75vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.5rem;
    background: var(--tile-bg);
  }
  .cv-pages:empty { display: none; }
  .cv-pages canvas {
    display: block;
    width: 100%;
    height: auto;
    margin: 0 auto 0.5rem;
    background: #ffffff;
    box-shadow: var(--shadow);
  }
  .cv-viewer.has-pages .cv-fallback { display: none; }
  .cv-viewer.cv-failed .cv-fallback { display: block; }
}
/* =====================================================================
   OFFICIAL PROFILE LOGOS IN THE SIDEBAR
   ===================================================================== */
.profile-icon img {
  display: block;
  width: 20px;
  height: 20px;
  object-fit: contain;
  transition: transform 0.15s ease;
}
.profile-icon:hover img { transform: scale(1.12); }
/* =====================================================================
   CONTACT PAGE: form + info cards
   ===================================================================== */
.contact-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: stretch;
}
.contact-side { display: grid; gap: 1.5rem; align-content: start; }

/* Form */
.contact-form { padding: 1.75rem; }
.form-field { display: flex; flex-direction: column; gap: 0.45rem; margin-bottom: 1.15rem; }
.form-field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--heading);
}
.form-field input,
.form-field textarea {
  width: 100%;
  min-height: 46px;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-field textarea { min-height: 140px; resize: vertical; }
.form-field input::placeholder,
.form-field textarea::placeholder { color: var(--muted); opacity: 0.75; }
.form-field input:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--tag-bg);
}
.form-field .is-invalid { border-color: #c0392b; }

.contact-submit { width: 100%; border-radius: 10px; }
.form-status { margin: 0.9rem 0 0; font-size: 0.9rem; color: var(--muted); min-height: 1.3em; }
.form-status.is-error { color: #c0392b; }

/* Info cards */
.contact-info h3 { margin-bottom: 0.4rem; }
.contact-info p:last-child { margin-bottom: 0; }
.contact-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  border-radius: 12px;
  background: var(--tile-bg);
  color: var(--primary);
}

@media (max-width: 1023px) {
  .contact-layout { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .contact-form { padding: 1.25rem; }
}
.form-status.is-success { color: var(--primary); font-weight: 600; }
.contact-submit:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
/* ---------- Publications: tabs ---------- */
.pub-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.pub-tab {
  min-height: 44px;
  padding: 0.5rem 1.1rem;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.pub-tab:hover { color: var(--primary); }
.pub-tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }

.type-conference { background: #ece7fb; color: #5b3fc4; border-color: #d6cdf6; }
[data-theme="dark"] .type-conference { background: #2a2150; color: #c4b5fd; border-color: #3d3274; }

@media (max-width: 640px) {
  .pub-tab { flex: 1 1 100%; text-align: left; }
}
