/* ===========================================================================
   Categories
   =========================================================================== */

.cats { padding-top: 18px; padding-bottom: 70px; }

/* --- Head ---------------------------------------------------------------- */

.cats-head {
  padding: 22px 0 24px; border-bottom: 2px solid var(--ink);
  display: flex; flex-wrap: wrap; gap: 28px;
  align-items: flex-end; justify-content: space-between;
}
.cats-head > div { flex: 1 1 400px; min-width: 0; }
.cats-head h1 { margin: 0 0 10px; font-size: 48px; }
.cats-head .lede { margin: 0; max-width: 56ch; }

.cats-jump { flex: 0 1 300px; min-width: 0; }
.cats-jump label {
  display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-55); margin-bottom: 8px;
}
.cats-jump input {
  width: 100%; border: 2px solid var(--ink); background: var(--card);
  padding: 12px 14px; font-family: var(--font-body); font-size: 15px; color: var(--ink);
}
.cats-jump input:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.cats-count {
  margin: 7px 0 0; font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.04em; color: var(--ink-40);
}
.cats-go { margin-top: 10px; }
/* Removed once categories.js has taken over the filtering. Until then it is
   the only way to narrow. */
.cats-js .cats-go { display: none; }

/* --- Families ------------------------------------------------------------ */

.fam { padding-top: 34px; }
.fam h2 {
  margin: 0 0 16px; font-size: 28px;
  display: flex; flex-wrap: wrap; gap: 12px; align-items: baseline;
}
.fam-n {
  font-family: var(--font-mono); font-size: 13px; font-weight: 400;
  letter-spacing: 0.04em; color: var(--ink-55); text-transform: none;
}

/* THREE WIDE, NOT FOUR, AND THE CHIPS ARE WHY.

   At four columns the card was 274px, 238px inside its padding, and the
   Games / Consoles / Accessories row needs about 250px. Twelve pixels
   short, so Accessories dropped to a second line on 30 of the 40 cards.

   Three columns makes the card 369px — but a photograph beside the chips
   would have taken that back and more, leaving them about 210px and
   wrapping every card instead of most. So the plate sits beside the NAME,
   and the chip row keeps the full width underneath it. Both things wanted
   from this change only arrive together. */
.fam-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px;
}

/* --- Platform card -------------------------------------------------------- */

.plat {
  background: var(--card); border: 1px solid var(--line);
  padding: 18px; display: flex; flex-direction: column; gap: 9px;
}
/* align-items: flex-start, so a one-line card does not stretch its plate:
   the machine keeps the same footprint whether the name wrapped or not. */
.plat-main { display: flex; gap: 12px; align-items: flex-start; }
.plat-text { flex: 1 1 auto; min-width: 0; }
/* A SHARE OF THE CARD, CAPPED. The name column is whatever this leaves, and
   the cap is what the widest card can spare: at 104px "Gameboy Advance" plus
   its boost chip stops fitting on one line. 80px would also clear "Sega
   Master System", the longest name here at 236px, but that is one card in
   forty and not worth shrinking every photograph for.

   The percentage only bites in the band where the grid still shows three
   columns but each one has given up 30px — around 1100px wide, where a fixed
   96px wrapped seven names and this wraps five. Above 1180px and below 1000
   it is capped at 96 and behaves as a fixed width. Measured at 1440, 1280,
   1180, 1100, 1000 and 960. */
.plat-art {
  flex: 0 0 auto; width: 29%; max-width: 96px; height: 62px;
  background-repeat: no-repeat; background-size: contain;
  background-position: right center;
  mix-blend-mode: multiply;
}

.plat-top { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; }
.plat-name {
  text-decoration: none; color: var(--ink);
  font-family: var(--font-display); font-weight: 900; font-size: 18px;
  line-height: 1.1; letter-spacing: -0.012em; text-transform: uppercase;
}
.plat-name:hover { color: var(--red); }
.plat-name:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

.plat-boost {
  flex: 0 0 auto; background: var(--red); color: #FFFFFF;
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  letter-spacing: 0.03em; padding: 2px 7px; white-space: nowrap;
}
.plat-n { margin: 0; font-size: 13px; color: var(--ink-55); }

.plat-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
/* .chip-sub itself now lives in counter.css: /browse draws the same chips
   under its heading, and browse.css is loaded without this file. */

.cats-empty {
  margin: 34px 0 0; padding: 22px;
  background: var(--card); border: 1px solid var(--line);
  font-size: 15px; color: var(--ink-70); text-align: center;
}

/* ===========================================================================
   Phone
   ---------------------------------------------------------------------------
   One column of rows rather than forty stacked cards, which would be a very
   long scroll for the same information.
   =========================================================================== */

@media (max-width: 900px) {

  .cats { padding-top: 14px; }
  .cats-head { padding: 12px 0 0; border-bottom: 0; display: block; }
  .cats-head h1 { font-size: 28px; margin-bottom: 8px; }
  .cats-head .lede { margin-bottom: 14px; }
  .cats-jump { margin-bottom: 4px; }
  .cats-jump input { padding: 0 14px; min-height: 48px; }

  .fam { padding-top: 20px; }
  .fam h2 { font-size: 18px; margin-bottom: 9px; gap: 10px; }
  .fam-n { font-size: 11px; color: var(--ink-40); }

  /* The grid becomes one bordered list per family, with hairlines between
     rows instead of a gap and a border around each. */
  .fam-grid {
    display: block; background: var(--card); border: 1px solid var(--line);
  }
  .plat {
    border: 0; border-bottom: 1px solid var(--line-4);
    padding: 12px 14px; gap: 2px;
  }
  .plat:last-child { border-bottom: 0; }
  /* :not([hidden]) so the hairline follows the filter rather than sitting
     under whichever card happens to be last in the markup. */
  .fam-grid .plat:not([hidden]) ~ .plat[hidden] { border-bottom: 0; }

  .plat-name { font-family: var(--font-body); font-size: 15px; font-weight: 600;
               text-transform: none; letter-spacing: 0; }
  .plat-boost { font-size: 10px; }
  .plat-n { font-size: 11px; color: var(--ink-40); }
  .plat-chips { margin-top: 5px; }
  /* The phone list is a compact row per platform and a plate would double
     its height — forty times. Hidden as a background, so none of the forty
     files is requested here. */
  .plat-art { display: none; }

  .cats-empty { margin-top: 22px; padding: 20px; }
}
