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

html {
  scroll-behavior: smooth;
  background-color: #fefefe;
}

body {
  font-family: Palatino, "EB Garamond", Georgia, "Times New Roman", serif;
  color: #454545;
  line-height: 1.6;
  font-size: 18px;
}

h1, h2, h3, h4 { font-weight: 400; color: #1c1c19; }

a { color: #990000; text-decoration: underline; }
a:hover { color: #6b0200; }

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


/* === Site Header (two-row, cs.usc.edu style) === */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
  border-bottom: 1px solid #c3c2bb;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-logo {
  flex-shrink: 0;
}

.header-logo img {
  height: 66px;
}

.header-dept {
  text-align: left;
  color: #1c1c19;
  text-decoration: none;
  font-size: 0.95rem;
  line-height: 1.4;
}

.header-dept strong {
  font-size: 1.1rem;
}

.header-dept:hover {
  color: #990000;
}

.header-usc {
  flex-shrink: 0;
}

.header-usc img {
  height: 99px;
}

.header-nav {
  border-top: 1px solid #e8e8e5;
}

.nav-links {
  display: flex;
  justify-content: center;
  gap: 0.25rem;
  max-width: 1200px;
  margin: 0 auto;
}

.nav-links a {
  color: #454545;
  font-size: 0.9rem;
  padding: 0.6rem 1.2rem;
  text-decoration: none;
  display: block;
  transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  color: #990000;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: #1c1c19;
  font-size: 1.5rem;
  cursor: pointer;
}

/* === Sections === */
section {
  max-width: 960px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
}

#research {
  max-width: 1100px;
}

section h2 {
  font-size: 1.8rem;
  color: #1c1c19;
  margin-bottom: 0.5rem;
}

section h3 {
  font-size: 1.3rem;
  color: #44433c;
  margin: 2rem 0 0.75rem;
}

.graph-subtitle {
  color: #5e5d56;
  margin-bottom: 1.5rem;
}

/* === About === */
.about-text {
  font-size: 1.05rem;
  color: #454545;
  line-height: 1.7;
}

/* === Lab Groups === */
.lab-group {
  margin: 2rem 0;
  padding: 1.5rem;
  border-top: 2px solid #990000;
  background: #fff;
}

.lab-group-header {
  display: grid;
  grid-template-columns: 160px 1fr auto;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.lab-group-header > a:first-child {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 160px;
  height: 160px;
}

.lab-group-header > a:first-child > .lab-logo {
  display: block;
  max-width: 140px;
  max-height: 140px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.lab-group-info {
  flex: 1;
}

.lab-group-name {
  font-size: 1.4rem;
  margin-bottom: 0.25rem;
}

.lab-group-name a { color: #1c1c19; text-decoration: none; font-weight: 600; }
.lab-group-name a:hover { color: #990000; }

.lab-desc {
  font-size: 0.95rem;
  color: #5e5d56;
  line-height: 1.5;
}

/* === Faculty (in lab group header) === */
.lab-group-header .faculty-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  text-decoration: none;
  width: 220px;
}

.lab-group-header .faculty-card img {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #c3c2bb;
  transition: border-color 0.2s;
  flex-shrink: 0;
}

.lab-group-header .faculty-card:hover img { border-color: #990000; }

.lab-group-header .faculty-card h4 {
  font-size: 1.05rem;
  margin-bottom: 0.1rem;
  margin-top: 0.4rem;
}

.lab-group-header .faculty-card h4 a { color: #1c1c19; text-decoration: none; font-weight: 600; }
.lab-group-header .faculty-card h4 a:hover { color: #990000; }

.lab-group-header .faculty-card .title {
  font-size: 0.85rem;
  color: #5e5d56;
}

/* === Students === */
.students-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 1.25rem;
  justify-items: center;
}

.student-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  color: #454545;
  text-decoration: none;
  transition: transform 0.2s;
}

.student-card:hover {
  transform: translateY(-2px);
  text-decoration: none;
}

.student-card img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 0.4rem;
  border: 2px solid #c3c2bb;
  transition: border-color 0.2s;
}

.student-card:hover img { border-color: #990000; }

.student-card .name {
  font-size: 0.85rem;
  font-weight: 600;
  display: block;
  color: #1c1c19;
}


/* === Foldable sections === */
details summary {
  cursor: pointer;
  list-style: none;
}

details summary::-webkit-details-marker { display: none; }

details summary h2::before,
details summary h3::before {
  content: '▶';
  font-size: 0.7rem;
  margin-right: 0.5rem;
  display: inline-block;
  transition: transform 0.2s;
  color: #77766f;
}

details[open] summary h2::before,
details[open] summary h3::before {
  transform: rotate(90deg);
}

details .alumni-list { margin-top: 1rem; }

/* === Alumni === */
.alumni-list {
  list-style: none;
  max-width: 600px;
}

.alumni-list li {
  padding: 0.4rem 0;
  font-size: 0.95rem;
  color: #5e5d56;
}

.alumni-list li a {
  color: #1c1c19;
  font-weight: 600;
  text-decoration: none;
}

.alumni-list li a:hover { color: #990000; }

.alumni-list .arrow {
  color: #77766f;
  margin: 0 0.3rem;
}

/* === Footer (cs.usc.edu style) === */
footer {
  background: #1c1c19;
  color: #77766f;
  font-size: 0.85rem;
  margin-top: 2rem;
}

.footer-top {
  max-width: 960px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
  display: flex;
  gap: 3rem;
  align-items: flex-start;
}

.footer-brand img {
  height: 55px;
  flex-shrink: 0;
}

.footer-columns {
  display: flex;
  gap: 3rem;
  flex: 1;
}

.footer-col h4 {
  color: #ffcc00;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
}

.footer-col ul {
  list-style: none;
}

.footer-col ul li {
  padding: 0.2rem 0;
}

.footer-col ul a {
  color: #c3c2bb;
  text-decoration: none;
  font-size: 0.85rem;
}

.footer-col ul a:hover {
  color: #ffcc00;
}

.footer-bottom {
  border-top: 1px solid #2b2a23;
  padding: 1rem 1.5rem;
  text-align: center;
}

.footer-bottom p {
  color: #5e5d56;
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
}

.footer-links a {
  color: #77766f;
  text-decoration: none;
  font-size: 0.75rem;
}

.footer-links a:hover {
  color: #ffcc00;
}

/* === Research Areas === */
.research-areas {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  padding: 0;
  margin: 0 auto 1rem;
  max-width: 900px;
}

.area-btn {
  background: #f5f0eb;
  color: #3a3a32;
  padding: 0.45rem 1rem;
  border-radius: 2rem;
  font-size: 0.88rem;
  border: 1.5px solid #e0d8cf;
  cursor: pointer;
  transition: all 0.2s;
  font-family: Helvetica, Arial, sans-serif;
}

.area-btn:hover {
  border-color: #990000;
  background: #faf5f0;
}

.area-btn.active {
  background: #990000;
  color: #fff;
  border-color: #990000;
}

/* === Research Graph (D3) === */
#graph-container {
  width: 100%;
  height: 600px;
  border: 1px solid #ddd;
  border-radius: 5px;
  background: #fafafa;
  position: relative;
  overflow: hidden;
}

#graph-container svg {
  width: 100%;
  height: 100%;
}

.graph-tooltip {
  position: absolute;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 5px;
  padding: 0.75rem;
  font-size: 0.8rem;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  max-width: 250px;
  z-index: 10;
  display: none;
}

.graph-tooltip h4 { font-size: 0.9rem; margin-bottom: 0.25rem; }
.graph-tooltip .tt-lab { color: #5e5d56; font-size: 0.75rem; margin-bottom: 0.3rem; }
.graph-tooltip .tt-topics { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.graph-tooltip .tt-topic { background: #f0f0f0; padding: 0.1rem 0.4rem; border-radius: 3px; font-size: 0.7rem; }

#detail-panel {
  display: none;
  margin-top: 1.5rem;
  padding: 1.5rem;
  border: 1px solid #ddd;
  border-radius: 5px;
  border-top: 3px solid #990000;
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.detail-header img { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; border: 3px solid #ddd; }
.detail-header h3 { font-size: 1.3rem; margin-bottom: 0.2rem; }
.detail-header h3 a { color: #1c1c19; text-decoration: none; font-weight: 600; }
.detail-header h3 a:hover { color: #990000; }
.detail-meta { font-size: 0.85rem; color: #5e5d56; }

.detail-topics { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.75rem 0; }
.detail-topic { background: #f0f0f0; padding: 0.2rem 0.5rem; border-radius: 3px; font-size: 0.8rem; }

#detail-panel h4 { font-size: 1rem; margin: 1rem 0 0.5rem; color: #333; }

.paper-list { list-style: none; padding: 0; }
.paper-list li { padding: 0.3rem 0; font-size: 0.85rem; border-bottom: 1px solid #f0f0f0; }
.paper-list .paper-year { color: #5e5d56; font-size: 0.75rem; }
.paper-list .paper-cites { color: #990000; font-size: 0.75rem; }

.coauthor-list { display: flex; flex-wrap: wrap; gap: 0.5rem; list-style: none; padding: 0; }
.coauthor-list li { font-size: 0.85rem; background: #f0f0f0; padding: 0.2rem 0.6rem; border-radius: 3px; cursor: pointer; }
.coauthor-list li:hover { background: #e0e0e0; }

.mobile-list { display: none; }

/* === Calendar === */
.calendar-embed {
  max-width: 960px;
  margin: 0 auto;
}

.calendar-embed iframe {
  width: 100%;
  height: 600px;
  border: 0;
  border-radius: 8px;
}

/* === Responsive === */
@media (max-width: 768px) {
  .header-top { padding: 0.5rem 1rem; }
  .header-left { gap: 0.5rem; }
  .header-logo img { height: 48px; }
  .header-dept { font-size: 0.8rem; }
  .header-dept strong { font-size: 0.95rem; }
  .header-usc img { height: 72px; }

  .header-nav .nav-links {
    display: none;
    flex-direction: column;
    align-items: stretch;
  }

  .header-nav .nav-links a {
    padding: 0.75rem 1.5rem;
    text-align: left;
  }

  .nav-links.open { display: flex; }

  .menu-toggle { display: block; }


  .lab-group-header { grid-template-columns: 1fr; text-align: center; justify-items: center; }
  .lab-group-header > a:first-child { width: 80px; height: 80px; }
  .lab-group-header > a:first-child > .lab-logo { max-width: 70px; max-height: 70px; }
  .lab-group-header .faculty-card { flex-direction: column; text-align: center; }
  .lab-group-header .faculty-card img { width: 100px; height: 100px; }

  .students-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 1rem; }
  .student-card img { width: 65px; height: 65px; }

  .footer-top { flex-direction: column; gap: 1.5rem; }
  .footer-columns { flex-direction: column; gap: 1.5rem; }

  #graph-container { height: 400px; }
  .detail-header { flex-direction: column; text-align: center; }

  .mobile-list { display: block; }
  .mobile-list .cluster-group { margin-bottom: 2rem; }
  .mobile-list .cluster-group h3 { font-size: 1.2rem; margin-bottom: 0.75rem; padding-bottom: 0.3rem; border-bottom: 2px solid #ddd; }
  .mobile-list .cluster-members { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 1rem; justify-items: center; }
  .mobile-list .member-card { text-align: center; color: #333; }
  .mobile-list .member-card img { width: 70px; height: 70px; border-radius: 50%; object-fit: cover; border: 2px solid #ddd; margin-bottom: 0.3rem; }
  .mobile-list .member-card .name { font-size: 0.8rem; font-weight: 600; display: block; }
  .mobile-list .member-card .topics-mini { font-size: 0.7rem; color: #5e5d56; }
}
