/*
 * Members-page cards (js/components/member-card.js). Every card is the same
 * size. The card you point at lifts, its photo eases in and the details slide
 * up; the others in its group dim a little and step back. Only opacity and
 * transforms animate, so the effect stays cheap (see the Firefox notes in the
 * project memory).
 */

.mcards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

/* A single card (the faculty) keeps the same width, centred. */
.mcards-solo {
  grid-template-columns: minmax(0, calc((100% - 54px) / 4));
  justify-content: center;
}

.mcard {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 20px;
  border: 1px solid var(--w10);
  background: #12131a;
  overflow: hidden;
  isolation: isolate;
  text-align: left;
  transition:
    transform 0.6s var(--ease),
    border-color 0.5s;
}

.mcard img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
  transition: transform 1s var(--ease);
}

/* Initials, only when a person has no photo and the placeholder is switched off. */
.mc-mono {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 4.5rem;
  font-weight: 300;
  color: var(--accent-pale);
  background: radial-gradient(90% 70% at 30% 20%, var(--accent-25), transparent 65%);
}

/* A soft floor so the name stays readable; the photo itself is not darkened. */
.mcard::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(10, 11, 16, 0) 52%, rgba(10, 11, 16, 0.5) 75%, rgba(10, 11, 16, 0.9));
  pointer-events: none;
}

/* A deeper floor under the details, faded in only on the card in the spotlight. */
.mcard::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(10, 11, 16, 0) 38%, rgba(10, 11, 16, 0.72) 66%, rgba(10, 11, 16, 0.95));
  opacity: 0;
  transition: opacity 0.5s var(--ease);
  pointer-events: none;
}

.mcard:hover::before,
.mcard:focus-visible::before {
  opacity: 1;
}

.mc-dim {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: rgba(10, 11, 16, 0.4);
  opacity: 0;
  transition: opacity 0.5s var(--ease);
  pointer-events: none;
}

.mcard .sp {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), var(--accent-12), transparent 45%);
  opacity: 0;
  transition: opacity 0.5s;
  pointer-events: none;
}

.mc-vname {
  position: absolute;
  left: 16px;
  bottom: 18px;
  z-index: 3;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
  font-family: var(--serif);
  font-size: 1.3rem;
  color: var(--text);
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.5);
  transition: opacity 0.35s;
}

.mc-info {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 18px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 6px;
  opacity: 0;
  transform: translateY(14px);
  transition:
    opacity 0.3s,
    transform 0.5s var(--ease);
}

.mc-name {
  font-family: var(--serif);
  font-size: 1.45rem;
  line-height: 1.08;
  letter-spacing: -0.01em;
  color: var(--text);
}

.mc-role {
  font-family: var(--ui);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--accent-pale);
}

.mc-hl {
  margin-top: 2px;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mc-bid {
  font-size: 12px;
  color: var(--muted);
}

/* The card in the spotlight */
.mcard:hover,
.mcard:focus-visible {
  transform: translateY(-6px);
  border-color: var(--accent-50);
}

.mcard:hover img,
.mcard:focus-visible img {
  transform: scale(1.05);
}

.mcard:hover .sp {
  opacity: 1;
}

.mcard:hover .mc-vname,
.mcard:focus-visible .mc-vname {
  opacity: 0;
}

.mcard:hover .mc-info,
.mcard:focus-visible .mc-info {
  opacity: 1;
  transform: none;
  transition-delay: 0.12s;
}

.mcard:focus-visible {
  outline: 1px solid var(--accent-50);
  outline-offset: 3px;
}

/* Everyone else in the group steps back a little */
.mcards:has(.mcard:hover) .mcard:not(:hover) {
  transform: scale(0.975);
}

.mcards:has(.mcard:hover) .mcard:not(:hover) .mc-dim {
  opacity: 1;
}

/* Touch screens have no hover: show the name and role all the time. */
@media (hover: none) {
  .mc-vname {
    display: none;
  }

  .mc-info {
    opacity: 1;
    transform: none;
  }

  .mc-hl,
  .mc-bid {
    display: none;
  }
}

@media (max-width: 1000px) {
  .mcards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .mcards-solo {
    grid-template-columns: minmax(0, calc((100% - 36px) / 3));
  }
}

@media (max-width: 700px) {
  .mcards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .mcards-solo {
    grid-template-columns: minmax(0, calc((100% - 12px) / 2));
  }

  .mcard {
    border-radius: 16px;
  }

  .mc-info {
    left: 14px;
    right: 14px;
    bottom: 14px;
  }

  .mc-name {
    font-size: 1.15rem;
  }

  .mc-role {
    font-size: 12.5px;
  }
}
