/**
 * "Meet the Team" photo grid — About page only. A 2D flip effect
 * (front photo <-> back bio panel), distinct from and independent of
 * the homepage's scrollable team-row shelf (components/team-row.css).
 *
 * Mobile: 1 column. Tablet (36rem+): 2 columns, uniform card size.
 * Desktop (62rem+): 6-track grid — the first two team members (the
 * CPT's existing drag-to-reorder order, i.e. owners/dentists first)
 * span 3 tracks each (2 per row, ~50% width), everyone else spans 2
 * tracks (3 per row, ~33% width) — a clean grid-span equivalent of
 * "featured cards render 1.5x larger."
 */

.team-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg) var(--space-md);
  list-style: none;
  margin: 0;
  padding: 0;
}

@media (min-width: 36rem) {
  .team-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 62rem) {
  .team-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .team-grid__card {
    grid-column: span 2;
  }

  .team-grid__card--featured {
    grid-column: span 3;
  }
}

.team-grid__card {
  display: flex;
  flex-direction: column;
}

.team-grid__inner {
  position: relative;
  aspect-ratio: 6 / 7; /* matches the six08-portrait (480x560) image size */
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

/* --- Front/back faces, absolutely stacked, cross-faded --- */

.team-grid__face {
  position: absolute;
  inset: 0;
  transition: opacity var(--duration-base) var(--ease-standard);
}

.team-grid__face--front {
  z-index: 1;
  opacity: 1;
}

.team-grid__face--back {
  z-index: 2;
  opacity: 0;
  display: flex;
  flex-direction: column;
  background: var(--color-primary-600);
  color: var(--color-text-on-dark);
  padding: var(--space-md);
  /* Invisible but stacked above the front face — without this it
     swallows taps meant for the front's Bio button. */
  pointer-events: none;
}

.team-grid__card:hover .team-grid__face--front,
.team-grid__card:focus-within .team-grid__face--front,
.team-grid__card.is-flipped .team-grid__face--front {
  opacity: 0;
}

.team-grid__card:hover .team-grid__face--back,
.team-grid__card:focus-within .team-grid__face--back,
.team-grid__card.is-flipped .team-grid__face--back {
  opacity: 1;
  pointer-events: auto;
}

/* Set by team-grid.js when the close button is used, and cleared once
   the pointer/focus leaves the card — overrides the hover/focus-within
   flip above, which would otherwise keep the bio showing (the pointer
   is still over the card, and the close button still has focus, at the
   moment it's clicked; touch browsers also leave :hover stuck on). */
.team-grid__card.is-dismissed .team-grid__face--front {
  opacity: 1;
}

.team-grid__card.is-dismissed .team-grid__face--back {
  opacity: 0;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .team-grid__face {
    transition: none;
  }
}

.team-grid__photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}

.team-grid__photo--placeholder {
  background: var(--color-bg-muted);
}

/* --- Bio trigger (front) --- */

.team-grid__flip {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  background: rgba(20, 37, 36, 0.6);
  color: var(--color-white);
  border-radius: var(--radius-pill);
  padding: var(--space-3xs) var(--space-sm);
  font-size: var(--fs-eyebrow);
  transition: background var(--duration-fast) var(--ease-standard);
}

.team-grid__flip:hover,
.team-grid__flip:focus-visible {
  background: rgba(20, 37, 36, 0.85);
}

/* Hidden once flipped (hover/focus/tap) — the back face's close
   button takes over as the way back. */
.team-grid__card:hover .team-grid__flip,
.team-grid__card:focus-within .team-grid__flip,
.team-grid__card.is-flipped .team-grid__flip {
  opacity: 0;
  pointer-events: none;
}

.team-grid__card.is-dismissed .team-grid__flip {
  opacity: 1;
  pointer-events: auto;
}

/* --- Close button (back) --- */

.team-grid__close {
  align-self: flex-end;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.15);
  color: var(--color-white);
  transform: rotate(45deg); /* turns the shared "plus" icon into an "x" */
  transition: background var(--duration-fast) var(--ease-standard);
}

.team-grid__close:hover,
.team-grid__close:focus-visible {
  background: rgba(255, 255, 255, 0.3);
}

.team-grid__close svg {
  width: 18px;
  height: 18px;
}

/* --- Bio text --- */

.team-grid__bio-wrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin-top: var(--space-2xs);
}

.team-grid__bio {
  margin: 0;
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--color-text-on-dark);
  white-space: pre-line;
}

/* --- Meta (always visible, below the flip area) --- */

.team-grid__meta {
  display: flex;
  flex-direction: column;
  text-align: center;
  padding-block: var(--space-sm);
}

.team-grid__name {
  color: var(--color-ink);
  font-size: var(--fs-h6);
}

.team-grid__title {
  font-size: var(--fs-eyebrow);
  color: var(--color-primary-700);
}
