/* ============================================================
   Progenesis Arxiv — Academic Research Profile
   Art Direction: Authoritative, scholarly, precise
   Palette: Cool slate-blue surfaces, navy text, teal accent
   Typography: DM Serif Display (headings) + Source Sans 3 (body)
   ============================================================ */

/* ---------- Design Tokens ---------- */
:root {
  /* Type Scale */
  --text-xs:   clamp(0.75rem,  0.7rem  + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem  + 0.35vw, 1rem);
  --text-base: clamp(1rem,     0.95rem + 0.25vw, 1.125rem);
  --text-lg:   clamp(1.125rem, 1rem    + 0.75vw, 1.5rem);
  --text-xl:   clamp(1.5rem,   1.2rem  + 1.25vw, 2.25rem);
  --text-2xl:  clamp(2rem,     1.2rem  + 2.5vw,  3rem);

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;

  /* Fonts */
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body: 'Source Sans 3', 'Segoe UI', system-ui, sans-serif;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Transitions */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------- Light Theme ---------- */
:root, [data-theme="light"] {
  --color-bg:            #f8f9fc;
  --color-surface:       #ffffff;
  --color-surface-alt:   #f0f2f7;
  --color-border:        #d8dce6;
  --color-divider:       #e2e6ee;

  --color-text:          #1a1f36;
  --color-text-muted:    #5c6478;
  --color-text-faint:    #9aa0b2;

  --color-primary:       #1a5276;
  --color-primary-hover: #154360;
  --color-accent:        #2471a3;
  --color-accent-light:  #d4e6f1;
  --color-accent-lighter:#eaf2f8;

  --shadow-sm: 0 1px 3px rgba(26, 31, 54, 0.06);
  --shadow-md: 0 4px 12px rgba(26, 31, 54, 0.08);
  --shadow-lg: 0 8px 24px rgba(26, 31, 54, 0.1);
}

/* ---------- Dark Theme ---------- */
[data-theme="dark"] {
  --color-bg:            #0f1117;
  --color-surface:       #181b24;
  --color-surface-alt:   #1e2130;
  --color-border:        #2a2e3e;
  --color-divider:       #252838;

  --color-text:          #d4d7e0;
  --color-text-muted:    #8b90a4;
  --color-text-faint:    #5a5f74;

  --color-primary:       #5dade2;
  --color-primary-hover: #85c1e9;
  --color-accent:        #5dade2;
  --color-accent-light:  #1c3045;
  --color-accent-lighter:#141e2a;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
}

/* System preference fallback */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg:            #0f1117;
    --color-surface:       #181b24;
    --color-surface-alt:   #1e2130;
    --color-border:        #2a2e3e;
    --color-divider:       #252838;
    --color-text:          #d4d7e0;
    --color-text-muted:    #8b90a4;
    --color-text-faint:    #5a5f74;
    --color-primary:       #5dade2;
    --color-primary-hover: #85c1e9;
    --color-accent:        #5dade2;
    --color-accent-light:  #1c3045;
    --color-accent-lighter:#141e2a;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
  }
}

/* ---------- Page Layout ---------- */
.page-container {
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-6) 0;
}

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--space-8);
  align-items: start;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: var(--space-6);
  max-height: calc(100dvh - var(--space-12));
  overflow-y: auto;
  padding-right: var(--space-2);
  /* Thin scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }

.profile-photo-wrap {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--color-border);
  margin-bottom: var(--space-4);
}
.profile-photo {
  width: 100%;
  height: auto;
  display: block;
}

/* Mobile-only name (hidden on desktop) */
.sidebar-name-mobile,
.sidebar-title-mobile {
  display: none;
}

/* Community pills */
.pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.pill {
  font-size: var(--text-xs);
  font-weight: 500;
  padding: var(--space-1) var(--space-3);
  border-radius: 999px;
  background: var(--color-accent-lighter);
  color: var(--color-primary);
  border: 1px solid var(--color-accent-light);
  letter-spacing: 0.02em;
}

.sidebar-rule {
  border: none;
  border-top: 1px solid var(--color-divider);
  margin: var(--space-4) 0;
}

/* Sidebar section title */
.sidebar-section-title {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-3);
}

/* Badge links */
.sidebar-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.badge-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 400;
}
.badge-link:hover {
  background: var(--color-surface-alt);
  color: var(--color-primary);
  text-decoration: none;
}

.badge-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.75;
}
[data-theme="dark"] .badge-icon {
  filter: brightness(1.6) saturate(0.8);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .badge-icon {
    filter: brightness(1.6) saturate(0.8);
  }
}

/* ---------- Main Content ---------- */
.main-content {
  min-width: 0; /* prevent grid blowout */
}

/* Header */
.main-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-6);
  border-bottom: 2px solid var(--color-primary);
}

.main-name {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 400;
  color: var(--color-text);
  line-height: 1.15;
  flex: 1 1 auto;
}

.main-credentials {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  letter-spacing: 0.04em;
  flex: 0 0 auto;
}

/* Theme Toggle */
.theme-toggle {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  margin-left: auto;
}
.theme-toggle:hover {
  background: var(--color-surface-alt);
  color: var(--color-primary);
}

/* Show/hide sun/moon */
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .icon-sun { display: none; }
  :root:not([data-theme]) .icon-moon { display: block; }
}

/* ---------- Bio ---------- */
.bio {
  margin-bottom: var(--space-10);
}
.bio p {
  font-size: var(--text-base);
  color: var(--color-text);
  margin-bottom: var(--space-4);
  line-height: 1.7;
}
.bio p:last-child {
  margin-bottom: 0;
}

.strengths-heading {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-3);
  margin-top: var(--space-2);
}

.strengths-list {
  list-style: none;
  padding-left: 0;
  margin-bottom: var(--space-4);
}
.strengths-list li {
  position: relative;
  padding-left: var(--space-5);
  font-size: var(--text-base);
  color: var(--color-text);
  margin-bottom: var(--space-2);
  line-height: 1.6;
}
.strengths-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 8px;
  height: 8px;
  background: var(--color-primary);
  border-radius: 2px;
  transform: rotate(45deg);
}

/* ---------- Publications ---------- */
.section-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 400;
  color: var(--color-text);
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-divider);
}

.pub {
  padding: var(--space-5) 0;
  border-bottom: 1px solid var(--color-divider);
}
.pub:last-child {
  border-bottom: none;
}

.pub-title {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-2);
  line-height: 1.4;
}

.pub-cite {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.6;
  margin-bottom: var(--space-3);
}
.pub-cite em {
  font-style: italic;
}
.pub-cite a {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.pub-cite a:hover {
  color: var(--color-primary-hover);
}

.pub-links {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.pub-link {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  text-decoration: none;
  background: var(--color-surface);
}
.pub-link:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-accent-lighter);
  text-decoration: none;
}

/* ---------- Footer ---------- */
.site-footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6);
  border-top: 1px solid var(--color-divider);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-4);
}
.site-footer p {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}
.site-footer a {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  text-decoration: none;
}
.site-footer a:hover {
  color: var(--color-primary);
}

/* ---------- More Profiles Collapsible ---------- */
.more-profiles {
  margin-top: var(--space-2);
}

.more-profiles-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
  cursor: pointer;
  border: none;
  background: none;
}
.more-profiles-toggle:hover {
  color: var(--color-primary);
  background: var(--color-surface-alt);
}

.more-chevron {
  flex-shrink: 0;
  transition: transform 250ms var(--ease);
}
.more-profiles-toggle[aria-expanded="true"] .more-chevron {
  transform: rotate(180deg);
}

.more-profiles-list {
  overflow: hidden;
}
.more-profiles-list[hidden] {
  display: none;
}

/* Slide-in animation for revealed links */
.more-profiles-list .badge-link {
  opacity: 0;
  transform: translateY(-6px);
  animation: fadeDown 0.25s var(--ease) forwards;
}
@keyframes fadeDown {
  to { opacity: 1; transform: translateY(0); }
}
.more-profiles-list .badge-link:nth-child(1)  { animation-delay: 0.02s; }
.more-profiles-list .badge-link:nth-child(2)  { animation-delay: 0.04s; }
.more-profiles-list .badge-link:nth-child(3)  { animation-delay: 0.06s; }
.more-profiles-list .badge-link:nth-child(4)  { animation-delay: 0.08s; }
.more-profiles-list .badge-link:nth-child(5)  { animation-delay: 0.10s; }
.more-profiles-list .badge-link:nth-child(6)  { animation-delay: 0.12s; }
.more-profiles-list .badge-link:nth-child(7)  { animation-delay: 0.14s; }
.more-profiles-list .badge-link:nth-child(8)  { animation-delay: 0.16s; }
.more-profiles-list .badge-link:nth-child(9)  { animation-delay: 0.18s; }
.more-profiles-list .badge-link:nth-child(10) { animation-delay: 0.20s; }
.more-profiles-list .badge-link:nth-child(n+11) { animation-delay: 0.22s; }

/* ---------- Scroll Reveal Animation ---------- */
.pub {
  opacity: 0;
  transform: translateY(12px);
  animation: fadeUp 0.4s var(--ease) forwards;
}

@keyframes fadeUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Stagger animation for publications */
.pub:nth-child(1)  { animation-delay: 0.04s; }
.pub:nth-child(2)  { animation-delay: 0.08s; }
.pub:nth-child(3)  { animation-delay: 0.12s; }
.pub:nth-child(4)  { animation-delay: 0.16s; }
.pub:nth-child(5)  { animation-delay: 0.2s; }
.pub:nth-child(6)  { animation-delay: 0.24s; }
.pub:nth-child(7)  { animation-delay: 0.28s; }
.pub:nth-child(8)  { animation-delay: 0.32s; }
.pub:nth-child(9)  { animation-delay: 0.36s; }
.pub:nth-child(10) { animation-delay: 0.4s; }
.pub:nth-child(n+11) { animation-delay: 0.44s; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .page-container {
    padding: var(--space-4);
  }

  .layout {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  .sidebar {
    position: static;
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .profile-photo-wrap {
    max-width: 200px;
    margin: 0 auto var(--space-4);
  }

  .sidebar-name-mobile {
    display: block;
    font-family: var(--font-display);
    font-size: var(--text-xl);
    text-align: center;
    color: var(--color-text);
    margin-bottom: var(--space-1);
  }
  .sidebar-title-mobile {
    display: block;
    font-size: var(--text-xs);
    font-weight: 600;
    text-align: center;
    color: var(--color-text-muted);
    letter-spacing: 0.03em;
    margin-bottom: var(--space-4);
  }

  .pills {
    justify-content: center;
  }

  .sidebar-links {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
  }

  .main-header {
    flex-direction: column;
    gap: var(--space-2);
    align-items: flex-start;
  }

  /* Hide desktop name/credentials on mobile since they show in sidebar */
  .main-name,
  .main-credentials {
    display: none;
  }

  .theme-toggle {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    z-index: 50;
    box-shadow: var(--shadow-md);
  }

  .main-header {
    border-bottom: none;
    margin-bottom: var(--space-4);
    padding-bottom: 0;
  }

  .site-footer {
    flex-direction: column;
    text-align: center;
    gap: var(--space-2);
    padding: var(--space-6) var(--space-4);
  }
}

/* Extra small screens */
@media (max-width: 480px) {
  .sidebar-links {
    grid-template-columns: 1fr;
  }
}
