/* ===== Team page: layout refinements =====
   Loaded after style.css on pages/team.html only. */

/* --- Group photo: 16:9 crop with caption --- */
.team-photo {
  max-width: 960px;
  margin: 0 auto 1rem;
}

.team-photo img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: auto;
  object-fit: contain;
  height: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.team-photo figcaption {
  margin-top: 0.75rem;
  text-align: center;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--text-light);
}

/* --- Section labels are now real headings --- */
h2.team-section-label {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  line-height: 1.4;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-light);
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}

h2.team-section-label:first-child {
  margin-top: 0;
}

/* --- Grid: fill the row instead of a fixed three columns --- */
.team-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
}

/* Cards in stretched tracks keep a capped photo height instead of
   growing into a huge square. */
.team-card .avatar {
  aspect-ratio: auto;
  height: 260px;
}

.team-card .avatar img {
  object-position: 50% 30%;
}

/* Grids with exactly two cards: lay each card out side by side
   (photo left, text right) so the pair fills the row without
   oversized portraits. */
@media (min-width: 900px) {
  .team-grid:has(> .team-card:nth-child(2):last-child) .team-card {
    display: grid;
    grid-template-columns: 200px 1fr;
    align-items: stretch;
  }

  .team-grid:has(> .team-card:nth-child(2):last-child) .team-card .avatar {
    height: 100%;
    min-height: 220px;
  }

  .team-grid:has(> .team-card:nth-child(2):last-child) .team-card .info {
    padding: 1.25rem 1.5rem;
  }
}

/* --- Principal Investigator: full-width horizontal card --- */
.team-card-wide {
  display: grid;
  grid-template-columns: 280px 1fr;
  align-items: stretch;
}

.team-grid .team-card-wide {
  grid-column: 1 / -1;
}

.team-card-wide .avatar {
  height: 100%;
  min-height: 280px;
  aspect-ratio: auto;
}

.team-card-wide .avatar img {
  object-position: 50% 25%;
}

.team-card-wide .info {
  padding: 1.75rem 2rem;
}

.team-card-wide .info h3 {
  font-size: 1.4rem;
}

.team-card-wide .info .role {
  font-size: 1rem;
}

.team-card-wide .info .bio {
  max-width: 65ch;
  font-size: 1rem;
  line-height: 1.7;
}

.team-card-wide .info .links {
  margin-top: 1rem;
  gap: 0.5rem 1rem;
}

.team-card-wide .info .links a {
  font-weight: 500;
  color: var(--primary);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 3px;
}

.team-card-wide .info .links a:hover {
  color: var(--primary-dark);
  text-decoration-color: var(--primary-light);
}

/* --- Tablet --- */
@media (max-width: 768px) {
  .team-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }

  .team-card-wide {
    grid-template-columns: 220px 1fr;
  }

  .team-card-wide .avatar {
    min-height: 220px;
  }

  .team-card-wide .info {
    padding: 1.25rem 1.5rem;
  }
}

/* --- Phones: two compact columns --- */
@media (max-width: 600px) {
  .team-photo {
    margin-bottom: 0.5rem;
  }

  .team-photo img {
    border-radius: var(--radius);
  }

  .team-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
  }

  .team-card .avatar {
    height: 150px;
  }

  .team-card .info {
    padding: 0.85rem 0.9rem 1rem;
  }

  .team-card .info h3 {
    font-size: 1rem;
    line-height: 1.3;
    overflow-wrap: anywhere;
  }

  .team-card .info .role {
    font-size: 0.85rem;
    line-height: 1.35;
  }

  .team-card .info .bio {
    font-size: 0.85rem;
    line-height: 1.5;
  }

  .team-card .info .links {
    gap: 0.4rem 0.75rem;
    margin-top: 0.6rem;
  }

  .team-card .info .links a {
    font-size: 0.85rem;
  }

  /* The PI card stacks: photo on top, text below, full width */
  .team-card-wide {
    display: block;
  }

  .team-card-wide .avatar {
    height: 260px;
    min-height: 0;
  }

  .team-card-wide .info {
    padding: 1.1rem 1.1rem 1.25rem;
  }

  .team-card-wide .info h3 {
    font-size: 1.2rem;
  }

  .team-card-wide .info .role {
    font-size: 0.9rem;
  }

  .team-card-wide .info .bio {
    font-size: 0.92rem;
    line-height: 1.6;
  }

  h2.team-section-label {
    margin-top: 2rem;
    font-size: 0.85rem;
  }
}

@media (max-width: 380px) {
  .team-card .avatar {
    height: 130px;
  }
}
