/* v20261127: .pick-grid removed from the count rules below (9 picks were forced into 9 ~135px columns, Abdus #170868,
   Codex #170871); pick grids get their own capped rules at the end. */
/* No half-empty rows (Abdus, Nov 24 2026): on desktop, each card grid picks a column count that divides its number of
   cards, so the last row is full. Loaded on every page after the theme by pages/site-nav/build.py. Phones unchanged. */

/* Laptops (1001-1439px): mostly 3-5 per row */
@media (min-width: 1001px) and (max-width: 1439px) {
  html body :is(.gcard-grid, .lcard-grid, .pcard-grid, .dcard-grid):has(> :nth-child(3):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  html body :is(.gcard-grid, .lcard-grid, .pcard-grid, .dcard-grid):has(> :nth-child(5):last-child) { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  html body :is(.gcard-grid, .lcard-grid, .pcard-grid, .dcard-grid):has(> :nth-child(6):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  html body :is(.gcard-grid, .lcard-grid, .pcard-grid, .dcard-grid):has(> :nth-child(7):last-child) { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  html body :is(.gcard-grid, .lcard-grid, .pcard-grid, .dcard-grid):has(> :nth-child(9):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  html body :is(.gcard-grid, .lcard-grid, .pcard-grid, .dcard-grid):has(> :nth-child(10):last-child) { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  html body :is(.gcard-grid, .lcard-grid, .pcard-grid, .dcard-grid):has(> :nth-child(12):last-child) { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

/* Wide screens (1440px+): one row for up to 7 cards, 6 per row for 12 */
@media (min-width: 1440px) {
  html body :is(.gcard-grid, .lcard-grid, .pcard-grid, .dcard-grid):has(> :nth-child(3):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  html body :is(.gcard-grid, .lcard-grid, .pcard-grid, .dcard-grid):has(> :nth-child(4):last-child) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  html body :is(.gcard-grid, .lcard-grid, .pcard-grid, .dcard-grid):has(> :nth-child(5):last-child) { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  html body :is(.gcard-grid, .lcard-grid, .pcard-grid, .dcard-grid):has(> :nth-child(6):last-child) { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  html body :is(.gcard-grid, .lcard-grid, .pcard-grid, .dcard-grid):has(> :nth-child(7):last-child) { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  html body :is(.gcard-grid, .lcard-grid, .pcard-grid, .dcard-grid):has(> :nth-child(12):last-child) { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (min-width: 1440px) and (max-width: 1699px) {
  html body :is(.gcard-grid, .lcard-grid, .pcard-grid, .dcard-grid):has(> :nth-child(8):last-child) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  html body :is(.gcard-grid, .lcard-grid, .pcard-grid, .dcard-grid):has(> :nth-child(9):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  html body :is(.gcard-grid, .lcard-grid, .pcard-grid, .dcard-grid):has(> :nth-child(10):last-child) { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
/* 1700px+: rows of 8, 9 or 10 cards fit on one line */
@media (min-width: 1700px) {
  html body :is(.gcard-grid, .lcard-grid, .pcard-grid, .dcard-grid):has(> :nth-child(8):last-child) { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  html body :is(.gcard-grid, .lcard-grid, .pcard-grid, .dcard-grid):has(> :nth-child(9):last-child) { grid-template-columns: repeat(9, minmax(0, 1fr)); }
  html body :is(.gcard-grid, .lcard-grid, .pcard-grid, .dcard-grid):has(> :nth-child(10):last-child) { grid-template-columns: repeat(10, minmax(0, 1fr)); }
}

/* Pick cards (gift/sale pages) carry a price line, verdict and two buttons, so they need ~300px+.
   Cap at 3 columns on laptops and 4 on wide screens, choosing counts that fill rows where possible. */
@media (min-width: 1001px) {
  html body .pick-grid:has(> :nth-child(4):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  html body .pick-grid:has(> :nth-child(n+5)) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  html body .pick-grid:has(> :nth-child(8):last-child) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 1440px) {
  html body .pick-grid:has(> :nth-child(4):last-child) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  html body .pick-grid:has(> :nth-child(7):last-child),
  html body .pick-grid:has(> :nth-child(12):last-child) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
/* Never let a button's label spill into the next card. */
html body .pick-actions .button, html body .pick-alt a { white-space: normal; overflow-wrap: anywhere; }
