/* ===========================================================================
   The faction picker — tiles first, one card open at a time
   ===========================================================================

   A separate file rather than more of `styles.css`, following `market.css`
   next to it in `index.html`. It loads after `styles.css` and overrides it, and
   it keeps a self-contained screen's rules in one readable place instead of
   scattered through four thousand lines.

   **The measurement that prompted it.** `.faction-grid` is
   `repeat(auto-fit, minmax(210px, 1fr))`, which on a 412px phone resolves to a
   single column; each of the eighteen cards carries a perk, an identity, a
   weakness, the old quarrels and a protector. Choosing the eighteenth faction
   meant scrolling past seventeen essays. The player's words for it: "we need to
   scroll down to see them".

   The split is by *job*. Finding a faction needs a crest, a name and whether the
   seat is free. Choosing it needs everything else. So the grid is tiles, and the
   card you tap opens in place across the full row — `lobby.js` decides which,
   this file only dresses it. -------------------------------------------------- */

.faction-grid {
  /* 104px lets a 412px phone hold three across with the grid's 10px gaps, and a
     desktop as many as it has room for, instead of the 210px that forced one. */
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  align-items: start;
}

.faction-card.is-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  padding: 8px 6px;
  min-height: 0;
}

.faction-card.is-tile .faction-name {
  font-size: 12px;
  line-height: 1.2;
  /* Two lines and then an ellipsis: a long name must not make its tile taller
     than its neighbours, or the grid rows stop lining up. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.faction-card.is-tile .faction-occupant {
  font-size: 10px;
  opacity: 0.75;
}

/* The open card takes the whole row, so the tiles below it keep their grid and
   the reading measure does not become one narrow column. */
.faction-card.is-open {
  grid-column: 1 / -1;
}

/* What a second tap does. Said on the card because the first tap not seating is
   the one thing about this screen a player has to be told once. */
.faction-take {
  font-size: 11px;
  opacity: 0.8;
  font-style: italic;
}

@media (pointer: coarse) {
  /* The tile is the target, so it carries the 44px floor the rest of the
     interface uses. At 104px wide it is already over it on the other axis. */
  .faction-card.is-tile {
    min-height: 76px;
  }
}
