/**
 * Fiches homepage: one random profile photo per age column.
 *
 * Only enqueued on the "Page fiches Homepage" template.
 */

.fiches-homepage__tile {
  position: relative;
  display: block;
  /* Same ratio as the portrait profile photos (507x760). */
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background: rgba(var(--text-color-rgb), 0.1);
  color: var(--text-color);
  text-decoration: none;

  &:hover {
    color: var(--text-color);
  }
}

.fiches-homepage__image {
  width: 100%;
  height: 100%;
  /* Crop instead of stretch when a photo has another ratio. */
  object-fit: cover;
  object-position: center top;
  transition: transform 0.4s ease;
}

/* Semi-transparent layer between the photo and the label. */
.fiches-homepage__tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(var(--bg-color-rgb), 0.45);
  transition: background-color 0.3s ease;
}

.fiches-homepage__label {
  position: absolute;
  inset: 0;
  /* Above the ::after overlay. */
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  font-size: 1.5rem;
  font-weight: 600;
  text-align: center;
  text-transform: uppercase;
}

/* Underline drawn as a background so it can grow from the center,
   and it follows each line when the label wraps. */
.fiches-homepage__text {
  padding-bottom: 0.25rem;
  background-image: linear-gradient(currentColor, currentColor);
  background-position: center bottom;
  background-repeat: no-repeat;
  background-size: 0% 2px;
  transition: background-size 0.3s ease;
}

.fiches-homepage__tile:hover .fiches-homepage__text,
.fiches-homepage__tile:focus-visible .fiches-homepage__text {
  background-size: 100% 2px;
}

.fiches-homepage__tile:hover::after,
.fiches-homepage__tile:focus-visible::after {
  background: rgba(var(--bg-color-rgb), 0.25);
}

.fiches-homepage__tile:hover .fiches-homepage__image,
.fiches-homepage__tile:focus-visible .fiches-homepage__image {
  transform: scale(1.05);
}

.fiches-homepage__tile:focus-visible {
  outline: 2px solid var(--text-color);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .fiches-homepage__image,
  .fiches-homepage__text {
    transition: none;
  }

  .fiches-homepage__tile:hover .fiches-homepage__image,
  .fiches-homepage__tile:focus-visible .fiches-homepage__image {
    transform: none;
  }
}
