/* Character tile component (templates/partials/character_tile.html) and the
   grid used by the homepage "Popular Characters" row and /browse/characters. */

.character-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

@media (min-width: 640px) {
  .character-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 900px) {
  .character-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-5);
  }
}

@media (min-width: 1120px) {
  .character-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

.character-tile {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
  color: var(--color-text);
  text-decoration: none;
}

.character-tile-art {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border-radius: var(--radius-ui);
  background: var(--color-bg-elevated);
  transition: transform var(--duration-base), box-shadow var(--duration-base);
}

.character-tile-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Wiki art mixes portraits and wide shots; faces sit near the top. */
  object-position: top center;
}

/* Initials are a square avatar: keep them small and centred, not cropped. */
.character-tile-art .character-tile-initials {
  position: absolute;
  inset: 0;
  width: var(--space-20);
  height: var(--space-20);
  margin: auto;
  border-radius: var(--radius-ui);
}

.character-tile:hover .character-tile-art {
  transform: scale(var(--home-card-hover-scale, 1.03));
  box-shadow: var(--shadow-md);
}

.character-tile:focus-visible {
  outline: none;
}

.character-tile:focus-visible .character-tile-art {
  box-shadow: var(--shadow-focus-brand);
}

.character-tile-meta {
  min-width: 0;
}

.character-tile-name {
  margin: 0;
  overflow: hidden;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-snug);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.character-tile-alias,
.character-tile-stats {
  margin: 0;
  overflow: hidden;
  font-size: var(--font-size-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.character-tile-alias {
  color: var(--color-text-secondary);
}

.character-tile-stats {
  color: var(--color-text-muted);
}

.browse-wrap--characters .site-pagination {
  margin-top: var(--space-10);
}
