/* ==========================================================================
   Team cards
   Shared by /team and the leadership row on /about-us.
   Requires theme.css first.
   ========================================================================== */

.tm-page {
  padding: var(--ims-section) 0;
  background: var(--ims-paper);
}

.tm-page--alt {
  background: var(--ims-surface);
  border-top: 1px solid var(--ims-rule);
}

.tm-head {
  max-width: 620px;
  margin: 0 0 40px;
}

/* ---- Grid ---------------------------------------------------------------
   auto-fit means the last row fills the width instead of leaving the ragged
   gap the old fixed col-md-3 layout produced with seven cards.
   ------------------------------------------------------------------------ */

.tm-grid {
  display: grid;
  gap: var(--ims-gap-md);
  margin: 0;
  padding: 0;
  list-style: none;
}

.tm-grid--lead {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.tm-grid--compact {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.tm-grid__cell {
  display: flex;
  margin: 0;
}

/* ---- Card --------------------------------------------------------------- */

.tm-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  background: var(--ims-paper);
  border: 1px solid var(--ims-rule);
  border-bottom: 3px solid var(--ims-brand);
  transition: border-color 200ms ease;
}

.tm-page--alt .tm-card {
  background: var(--ims-paper);
}

.tm-card__portrait {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--ims-surface-2);
}

.tm-card__portrait img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Faces sit above centre in most portraits, so bias the crop upward */
  object-position: center 22%;
  filter: grayscale(1);
  transition: filter 300ms ease;
}

.tm-card:hover .tm-card__portrait img {
  filter: grayscale(0);
}

.tm-card__initials {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ims-ink-soft);
}

.tm-card__body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  padding: 20px 22px 24px;
}

.tm-card__name {
  margin: 0 0 4px;
  font-size: 17px;
  line-height: 1.35;
  font-weight: 700;
  color: var(--ims-ink);
}

.tm-card__role {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ims-brand);
}

.tm-card__bio {
  margin: 14px 0 0;
  font-size: 14px;
  line-height: 1.7;
  color: var(--ims-ink-soft);
}

.tm-card__more {
  margin: auto 0 0;
  padding-top: 16px;
  font-size: 14px;
}

/* Compact variant: no bio, tighter padding, smaller type */

.tm-card--compact .tm-card__body {
  padding: 16px 18px 20px;
}

.tm-card--compact .tm-card__name {
  font-size: 15px;
}

.tm-card--compact .tm-card__role {
  font-size: 11px;
}

/* ---- Call to action ----------------------------------------------------- */

.tm-cta {
  padding: 72px 0;
  background: var(--ims-deep);
}

.tm-cta__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--ims-gap-lg);
}

.tm-cta__title {
  margin: 0 0 8px;
  font-size: 26px;
  line-height: 1.3;
  font-weight: 700;
  color: var(--ims-ink-invert);
}

.tm-cta__lead {
  margin: 0;
  font-size: 15px;
  color: var(--ims-ink-invert-soft);
}

.tm-cta__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* ---- Breakpoints -------------------------------------------------------- */

@media (max-width: 767px) {
  .tm-page { padding: var(--ims-section-sm) 0; }

  .tm-grid--compact {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .tm-cta { padding: 52px 0; }
  .tm-cta__title { font-size: 21px; }
  .tm-cta__actions .ims-btn { flex: 1 1 auto; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  .tm-card,
  .tm-card__portrait img {
    transition: none;
  }
}
