/* ============================================================
   FONTS
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;1,400&family=DM+Sans:wght@300;400;500&family=DM+Mono:wght@400&display=swap');

/* ============================================================
   DESIGN TOKENS — nature palette, flat & clean
   ============================================================ */
:root {
  --moss:        #4a7c59;
  --moss-light:  #6a9e78;
  --moss-dim:    #2e5039;
  --fern:        #8db87a;
  --sand:        #e8dfc8;
  --sand-light:  #f5f0e8;
  --bark:        #5c3d2e;
  --bark-light:  #8b6150;
  --stone:       #9e9e8a;
  --stone-light: #d4d4c4;
  --cream:       #faf8f3;
  --ink:         #1e2a1e;
  --ink-soft:    #3d4a3d;

  --status-ongoing:   #4a7c59;
  --status-published: #7b6ba0;
  --status-finished:  #8b6150;

  --sidebar-w: 300px;
  --radius:    10px;
  --radius-sm: 6px;

  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'DM Sans', sans-serif;
  --font-mono:    'DM Mono', monospace;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a   { color: var(--moss); text-decoration: none; }
a:hover { color: var(--moss-dim); text-decoration: underline; }

/* ============================================================
   LAYOUT
   ============================================================ */
.page-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--moss-dim);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 2.5rem 1.8rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
  z-index: 10;
}

.sidebar-photo-wrap {
  /* responsive: up to 140px but never more than 55% of sidebar width */
  width: min(180px, 60%);
  /* aspect-ratio: 1 / 1; */
  margin: 0 auto;
}

.sidebar-photo-wrap img {
  width: 100%;  
  aspect-ratio: 1 / 1;   /* ← enforce square on the img itself */
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.25);
}

.sidebar-photo-placeholder {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: 2px solid rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: rgba(255,255,255,0.5);
}

.sidebar-name {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  text-align: center;
  line-height: 1.25;
}

.sidebar-title {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.65);
  text-align: center;
  font-weight: 300;
  letter-spacing: 0.02em;
  margin-top: -0.6rem;
}

.sidebar-institution {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
  text-align: center;
  margin-top: -0.8rem;
}

.sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,0.12);
  border: none;
}

.sidebar-bio {
  font-size: 0.83rem;
  color: rgba(255,255,255,0.72);
  line-height: 1.6;
}

.sidebar-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: auto;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.81rem;
  color: rgba(255,255,255,0.78);
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.12);
  transition: border-color 0.15s, color 0.15s;
  font-weight: 500;
}

.sidebar-link:hover {
  border-color: rgba(255,255,255,0.3);
  color: #fff;
  text-decoration: none;
}

.sidebar-link svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.cv-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.2rem;
  padding: 0.6rem 1rem;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.85);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}
.cv-btn:hover {
  border-color: rgba(255,255,255,0.5);
  color: #fff;
  text-decoration: none;
}

/* ---- MAIN CONTENT ---- */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 3rem 2.5rem 4rem;
  background: var(--cream);
}

.section-heading {
  font-family: var(--font-display);
  font-size: 1.55rem;
  color: var(--ink);
  font-weight: 700;
  margin-bottom: 1.4rem;
  padding-bottom: 0.55rem;
  border-bottom: 2px solid var(--sand);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.section-heading::before {
  content: '';
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--moss);
  flex-shrink: 0;
}

.content-section { margin-bottom: 3.5rem; }

/* ============================================================
   CARDS — horizontal layout on desktop, stacked on mobile
   ============================================================ */
.cards-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card {
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  border: 1.5px solid var(--stone-light);
  display: flex;
  flex-direction: row;      /* horizontal */
  align-items: stretch;
  transition: border-color 0.18s;
  animation: cardIn 0.35s ease both;
}

.card:hover {
  border-color: var(--moss-light);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* left image strip */
.card-image {
  width: 200px;
  flex-shrink: 0;
  object-fit: cover;
  display: block;
}

.card-image-placeholder {
  width: 200px;
  flex-shrink: 0;
  background: var(--sand-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--stone);
  border-right: 1.5px solid var(--stone-light);
}

.card-body {
  padding: 1rem 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}

.card-abstract {
  font-size: 0.82rem;
  color: var(--ink-soft);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.tag {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  background: var(--sand-light);
  color: var(--moss-dim);
  border: 1px solid var(--sand);
  padding: 0.12rem 0.45rem;
  border-radius: 99px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.68rem;
  font-weight: 500;
  padding: 0.18rem 0.55rem;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  width: fit-content;
}
.status-badge::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.status-ongoing   { background: #e8f4ec; color: var(--status-ongoing); }
.status-published { background: #ede8f4; color: var(--status-published); }
.status-finished  { background: #f4ede8; color: var(--status-finished); }

/* institution footer on card */
.card-institution {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: auto;
  padding-top: 0.5rem;
  border-top: 1px solid var(--sand);
  font-size: 0.73rem;
  color: var(--stone);
}

.card-institution img {
  height: 16px;
  width: auto;
  object-fit: contain;
}

.card-institution-flag { font-size: 0.95rem; line-height: 1; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 32, 20, 0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--cream);
  border-radius: 14px;
  max-width: 720px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  border: 1.5px solid var(--stone-light);
  transform: translateY(20px);
  transition: transform 0.25s ease;
  position: relative;
}

.modal-backdrop.open .modal {
  transform: translateY(0);
}

.modal-close {
  position: sticky;
  top: 0;
  float: right;
  margin: 0.8rem 0.8rem 0 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid var(--stone-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--ink-soft);
  z-index: 5;
  transition: border-color 0.15s;
}
.modal-close:hover { border-color: var(--moss); }

.modal-image {
  width: 100%;
  height: 220px;
  object-fit: cover;
  border-radius: 14px 14px 0 0;
}
.modal-image-placeholder {
  width: 100%;
  height: 140px;
  background: var(--sand-light);
  border-radius: 14px 14px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--stone);
}

.modal-body {
  padding: 1.6rem 1.8rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
  flex: 1;
}

.modal-description {
  font-size: 0.88rem;
  color: var(--ink-soft);
  line-height: 1.7;
}

.modal-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.modal-meta-item {
  background: var(--sand-light);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--sand);
}

.modal-meta-label {
  font-size: 0.66rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--stone);
  margin-bottom: 0.2rem;
}

.modal-meta-value {
  font-size: 0.83rem;
  color: var(--ink-soft);
}

.modal-institution-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--sand-light);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--sand);
}

.modal-institution-flag { font-size: 1.3rem; }

.modal-institution-logo {
  height: 26px;
  width: auto;
  object-fit: contain;
}

.modal-institution-name {
  font-size: 0.83rem;
  color: var(--ink-soft);
  font-weight: 500;
}

.modal-institution-years {
  font-size: 0.75rem;
  color: var(--stone);
  margin-top: 0.1rem;
}

.modal-links-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.modal-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
  text-decoration: none;
}
.modal-link-btn:hover { opacity: 0.85; text-decoration: none; }

.btn-paper  { background: var(--moss);  color: #fff; }
.btn-github { background: var(--bark);  color: #fff; }

/* ============================================================
   MOBILE TOP CARD
   ============================================================ */
.mobile-topcard {
  display: none;
  background: var(--moss-dim);
  padding: 1.8rem 1.5rem 1.4rem;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  text-align: center;
}

.mobile-topcard img.topcard-photo {
  /* responsive: up to 96px but never more than 28% of screen width */
  width: min(96px, 28vw);
  height: min(96px, 28vw);
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.25);
}

.mobile-topcard .topcard-name {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: #fff;
  font-weight: 700;
}

.mobile-topcard .topcard-title {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.65);
  font-weight: 300;
}

.mobile-topcard .topcard-links {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .page-wrapper    { flex-direction: column; }
  .sidebar         { display: none; }
  .mobile-topcard  { display: flex; }

  .main-content { padding: 1.6rem 1rem 3rem; }

  /* on mobile, cards go back to vertical (stacked image on top) */
  .card { flex-direction: column; }
  .card-image,
  .card-image-placeholder {
    width: 100%;
    height: 150px;
    border-right: none;
    border-bottom: 1.5px solid var(--stone-light);
  }

  .modal-meta-grid { grid-template-columns: 1fr; }
  .modal-body { padding: 1.1rem 1.1rem 1.5rem; }
  .modal-title { font-size: 1.2rem; }
}

@media (min-width: 769px) and (max-width: 1100px) {
  :root { --sidebar-w: 260px; }
  .main-content { padding: 2rem 1.8rem 3rem; }
}

/* scrollbars */
.sidebar::-webkit-scrollbar,
.modal::-webkit-scrollbar  { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }
.modal::-webkit-scrollbar-thumb   { background: var(--stone-light); border-radius: 2px; }

/* states */
.loading-message {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--stone);
  font-style: italic;
}

.error-banner {
  background: #fdf0f0;
  border: 1.5px solid #e8b4b4;
  border-radius: var(--radius-sm);
  padding: 1rem 1.4rem;
  color: #8b3030;
  font-size: 0.87rem;
  margin-bottom: 1.5rem;
}


/* ============================================================
   FOCUS CARDS — 3-column grid, lightweight
   ============================================================ */
.focus-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.focus-card {
  background: #fff;
  border-radius: var(--radius);
  border: 1.5px solid var(--stone-light);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.18s;
  display: flex;
  flex-direction: column;
  animation: cardIn 0.35s ease both;
}

.focus-card:hover {
  border-color: var(--moss-light);
}

.focus-card-image {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}

.focus-card-image-placeholder {
  width: 100%;
  height: 120px;
  background: var(--sand-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: var(--stone);
}

.focus-card-body {
  padding: 0.75rem 0.9rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.focus-card-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
}

.focus-card-desc {
  font-size: 0.78rem;
  color: var(--ink-soft);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* responsive: 2 cols on tablet, 1 on mobile */
@media (max-width: 768px) {
  .focus-grid { grid-template-columns: 1fr; }
}

@media (min-width: 769px) and (max-width: 1000px) {
  .focus-grid { grid-template-columns: repeat(2, 1fr); }
}


.section-note {
  margin: 0.35rem 0 1.25rem;
  font-size: 1rem;
  line-height: 1.2;
  color: var(--moss);
  font-weight: 500;
  text-align: center;
}

/* ── BibTeX copy button ── */
.btn-bib {
  background: transparent;
  color: var(--moss);
  border: 1.5px solid var(--moss);
}
.btn-bib:hover {
  background: var(--moss);
  color: #fff;
}
.btn-bib.copied {
  background: var(--moss);
  color: #fff;
  border-color: var(--moss);
}


/* Markdown rendered content in modal */
.modal-description h1,
.modal-description h2,
.modal-description h3 {
  font-family: var(--font-display);
  color: var(--ink);
  margin: 1rem 0 0.4rem;
}
.modal-description h2 { font-size: 1.1rem; }
.modal-description h3 { font-size: 0.95rem; }

.modal-description p  { margin-bottom: 0.75rem; }

.modal-description ul,
.modal-description ol {
  padding-left: 1.4rem;
  margin-bottom: 0.75rem;
}
.modal-description li { margin-bottom: 0.25rem; font-size: 0.88rem; }

.modal-description a  { color: var(--moss); }

.modal-description strong { font-weight: 600; color: var(--ink); }

.modal-description code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: var(--sand-light);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  border: 1px solid var(--sand);
}

.modal-description blockquote {
  border-left: 3px solid var(--moss-light);
  margin: 0.75rem 0;
  padding: 0.4rem 0.9rem;
  color: var(--ink-soft);
  font-style: italic;
}