/* Cosmetics — the appearance of every catalogue id, and the player info card.
 *
 * ⚠️ THIS FILE IS THE ART. Every nameplate, profile picture and medal in
 * `shared/cosmetics/catalog.js` is drawn here, by id, with gradients. No PNG, no SVG file,
 * no data URI, no new origin — so `img-src 'self'` on all 16 published pages is untouched
 * and nothing that arrives off the wire can ever become a URL. A hostile id resolves to no
 * catalogue entry at all, so it never reaches a selector.
 *
 * The gradients are PLACEHOLDERS, exactly as the emote sprite sheets are placeholders. They
 * exist so the geometry, the layout and the pickers are real. Replacing one is an edit to a
 * rule below; the id does not change, because the id is what an entitlement row will point at.
 *
 * ⚠️ EVERY ID NEEDS A RULE AND EVERY RULE NEEDS TO DO SOMETHING. Two gates, because those are
 * two different failures:
 *   · `tests/cosmetics-catalog.test.js` derives every id from the catalogue and fails on one
 *     this file has no rule for — a missing rule renders an invisible cosmetic, silently.
 *   · `tests/cosmetics-smoke.mjs` renders all of them in a real browser and fails if any two
 *     paint identically — because a rule that exists but does nothing looks, in a diff and in
 *     every string assertion, exactly like a rule that works.
 *
 * Self-contained on purpose: it borrows no token from `site.css`, because GAMES DO NOT LOAD
 * site.css. That gap is what let a `hidden` D Coin balance render on every game (CLAUDE.md),
 * and a player card is destined for the lobby and the end-game screen.
 */

/* ── the four appearances ═══════════════════════════════════════════════════════════════ */

/* Profile picture. A disc; the id decides what is in it. */
.gg-pfp {
  --gg-pfp-size: 56px;
  width: var(--gg-pfp-size);
  height: var(--gg-pfp-size);
  flex: none;
  border-radius: 50%;
  border: 1px solid rgb(255 255 255 / .14);
  background: linear-gradient(150deg, #4a5347, #2b332a);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .1);
}

.gg-pfp[data-gg-pfp="pfp-pebble"]     { background: linear-gradient(150deg, #8d8f88, #4c4f49); }
.gg-pfp[data-gg-pfp="pfp-moss"]       { background: linear-gradient(150deg, #6f9a5c, #24391d); }
.gg-pfp[data-gg-pfp="pfp-solar"]      { background: radial-gradient(circle at 32% 28%, #ffe08a, #e5871f 58%, #7a3c05); }
.gg-pfp[data-gg-pfp="pfp-void"]       { background: radial-gradient(circle at 68% 30%, #4b3f7a, #140f24 62%, #05040a); }
.gg-pfp[data-gg-pfp="pfp-firstlight"] { background: conic-gradient(from 210deg, #fff3d0, #ffb545, #b95c12, #fff3d0); }
.gg-pfp[data-gg-pfp="pfp-postmark"]   { background: repeating-linear-gradient(45deg, #d9d3c8 0 6px, #b04a3a 6px 12px); }

/* Nameplate. The banner the name sits on. `plate-plain` is deliberately bare — "no plate"
   is a choice a player can make, not the absence of one. */
.gg-plate {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: none;
}

.gg-plate[data-gg-plate="plate-plain"]      { background: none; border-color: transparent; }
.gg-plate[data-gg-plate="plate-slate"]      { background: linear-gradient(90deg, rgb(120 128 118 / .30), rgb(120 128 118 / .06)); border-color: rgb(200 208 198 / .22); }
.gg-plate[data-gg-plate="plate-ember"]      { background: linear-gradient(90deg, rgb(214 106 40 / .48), rgb(214 106 40 / .04)); border-color: rgb(240 150 80 / .45); }
.gg-plate[data-gg-plate="plate-frost"]      { background: linear-gradient(90deg, rgb(74 150 214 / .45), rgb(74 150 214 / .04)); border-color: rgb(140 200 245 / .45); }
.gg-plate[data-gg-plate="plate-laurel"]     { background: linear-gradient(90deg, rgb(120 168 74 / .45), rgb(214 196 96 / .10)); border-color: rgb(190 210 120 / .48); }
.gg-plate[data-gg-plate="plate-season-one"] { background: linear-gradient(90deg, rgb(126 76 190 / .50), rgb(52 168 178 / .12)); border-color: rgb(178 140 235 / .5); }

/* Medal. A small badge beside the name. */
.gg-medal {
  --gg-medal-size: 22px;
  width: var(--gg-medal-size);
  height: var(--gg-medal-size);
  flex: none;
  border-radius: 6px;
  border: 1px solid rgb(255 255 255 / .16);
  background: linear-gradient(160deg, #6b7266, #333a30);
}

.gg-medal[data-gg-medal="medal-rookie"]     { background: linear-gradient(160deg, #a9b0a3, #545c4f); }
.gg-medal[data-gg-medal="medal-first-win"]  { background: linear-gradient(160deg, #ffd873, #a97a15); }
.gg-medal[data-gg-medal="medal-marathon"]   { background: linear-gradient(160deg, #7fc4e8, #1f5f8d); }
.gg-medal[data-gg-medal="medal-founder"]    { background: linear-gradient(160deg, #e79ad0, #6d2159); }
.gg-medal[data-gg-medal="medal-season-one"] { background: linear-gradient(160deg, #b28cec, #3a2a6b); }

/* ── the player info card ═══════════════════════════════════════════════════════════════
 *
 * What a player sees when they inspect another player: the picture, the name on its plate,
 * the title, the medal. Built by `./card.js` with `createElement` and `textContent` only —
 * there is no `innerHTML` anywhere on this path, which is the whole reason a peer-supplied
 * name is safe to render.
 */

.gg-player-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgb(245 241 232 / .14);
  background: rgb(17 22 15 / .94);
  box-shadow: 0 18px 40px -20px rgb(0 0 0 / .85);
  color: #f5f1e8;
  font: 400 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  max-width: 340px;
}

.gg-player-card-body { min-width: 0; display: grid; gap: 4px; }

.gg-player-card-name {
  font-weight: 700;
  font-size: 15px;
  /* A peer chose this string. It cannot be markup — it arrives through `textContent` — but an
     unbroken 24-character run still decides how wide somebody else's card is, so the box
     clips rather than the layout stretching. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

.gg-player-card-title {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #b4bdaf;
}

.gg-player-card-row { display: flex; align-items: center; gap: 8px; }

/* `hidden` is a USER-AGENT style and ANY author `display` beats it — CLAUDE.md's standing
   example, which shipped a D Coin balance under "Not signed in" on every game. Every element
   in this file that can be hidden is also a flex or grid item, so the pairing is mandatory
   rather than defensive. Scoped, not global: games do not load site.css and a blanket
   `[hidden] !important` from a shared stylesheet is not this component's call to make. */
.gg-player-card [hidden],
.gg-cos-option[hidden],
.gg-cos-grid[hidden] { display: none !important; }

/* ── the overlay placement ══════════════════════════════════════════════════════════════
 *
 * ⚠️ THE TOP-RIGHT CORNER OF EVERY GAME IS RESERVED FOR THE EMOTE DECK. There is no
 * allowlist and no exception (CLAUDE.md; `tests/emote-corner.mjs` enforces it over a
 * population derived from `games/`).
 *
 * A card shown over a game is a floating layer, and a full-width layer's BOX reaches the
 * corner even where it looks empty there — which is exactly the failure that rule names. So
 * this layer insets itself with `--gg-emote-corner`, the token published by
 * `shared/emotes/emotes.css` and the ONLY place that width is written down. Do not restate
 * the number: `reservedCornerRect()` measures the deck's real button, so a second copy would
 * be a rectangle the gate guards while the deck sits somewhere else.
 *
 * Mounted by `mountInspector()` in `./roster.js` since phase 2 of #132 — Blackout and Stick to
 * Your Guns both use it for tap-to-inspect. The inset was written here in phase 1, before
 * anything used it, so the first game to mount it started correct rather than discovering the
 * rule from a red gate; that is why this paragraph reads as a prediction that came true.
 */
.gg-player-card-layer {
  position: fixed;
  inset: 0;
  /* The corner, kept clear, from the one token. The extra top inset clears the deck's own
     height as well, so a card can never sit under it either. */
  padding: calc(var(--gg-emote-corner, 0px) + 12px) var(--gg-emote-corner, 0px) 24px 12px;
  display: grid;
  place-items: center;
  z-index: 460;              /* under the emote deck (470) and the drawer backdrop (498) */
  background: rgb(6 9 5 / .55);
}

.gg-player-card-layer[hidden] { display: none !important; }

/* The card sits in a holder rather than being the layer's only child, so `replaceChildren()`
   on a re-open cannot take the layer's own listeners with it. */
.gg-player-card-holder { display: grid; place-items: center; max-width: 100%; }

/* ── the roster strip ═══════════════════════════════════════════════════════════════════
 *
 * The lobby and the end-game screen. One row per player: their profile picture, their name on
 * their nameplate, their medal, and a note the local surface owns ("host", "survived").
 *
 * A row is a real `<button>` (see `./roster.js`) because tapping it opens the inspect card —
 * so it has to be keyboard-reachable and it has to announce itself. Self-contained, borrowing
 * no token from `site.css`: GAMES DO NOT LOAD site.css, and this strip's first two homes are
 * both games.
 */

.gg-roster {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.gg-roster > li { display: flex; min-width: 0; }

.gg-roster-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  padding: 3px 11px 3px 3px;
  border-radius: 999px;
  border: 1px solid rgb(245 241 232 / .16);
  background: rgb(17 22 15 / .55);
  color: #f5f1e8;
  font: 600 12px/1.25 system-ui, -apple-system, "Segoe UI", sans-serif;
  text-align: left;
  cursor: pointer;
}

.gg-roster-row:hover:not([disabled]) { border-color: rgb(245 241 232 / .42); background: rgb(30 38 26 / .72); }
.gg-roster-row:focus-visible { outline: 2px solid #8fd06a; outline-offset: 2px; }
/* Inert rows are still rows — they are not controls, so they must not look like one. */
.gg-roster-row[disabled] { cursor: default; }
/* "You". A border, not a label: a word here would be one more peer-adjacent string to render. */
.gg-roster-row[data-gg-self] { border-color: rgb(143 208 106 / .55); }

.gg-roster-row .gg-pfp { --gg-pfp-size: 26px; }
.gg-roster-row .gg-medal { --gg-medal-size: 15px; }
.gg-roster-row .gg-plate { padding: 2px 9px; gap: 6px; min-width: 0; }

.gg-roster-name {
  /* A peer chose this string. It cannot be markup — it arrives through `textContent` — but an
     unbroken run still decides how wide somebody else's lobby is, so the box clips. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 132px;
}

.gg-roster-note {
  flex: none;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: #8f9a8a;
}

.gg-roster [hidden] { display: none !important; }

/* ── the customiser ═════════════════════════════════════════════════════════════════════
 * The picker on /profile/. One grid per slot; one control per catalogue entry.
 */

.gg-cos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.gg-cos-option {
  display: grid;
  justify-items: center;
  gap: 6px;
  width: 100%;
  padding: 10px 8px 9px;
  border-radius: 10px;
  border: 1px solid rgb(255 255 255 / .10);
  background: rgb(255 255 255 / .03);
  color: #cfd6cb;
  font: 600 11px/1.25 system-ui, -apple-system, "Segoe UI", sans-serif;
  cursor: pointer;
  text-align: center;
}

.gg-cos-option:hover:not([disabled]) { border-color: rgb(255 255 255 / .28); background: rgb(255 255 255 / .07); }
.gg-cos-option[aria-pressed="true"] { border-color: #8fd06a; background: rgb(143 208 106 / .14); color: #f5f1e8; }

/* A control that cannot be used must LOOK like one. `disabled` alone still renders as an
   ordinary button on some engines, and a live-looking control that does nothing is worse
   than no control — the same reasoning as the shop's coming-soon buttons. */
.gg-cos-option[disabled] { opacity: .45; cursor: not-allowed; }

.gg-cos-swatch { display: grid; place-items: center; min-height: 40px; }
.gg-cos-label { display: block; }
.gg-cos-source {
  display: block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: #8f9a8a;
}

/* A title has no art, so its swatch IS its text. */
.gg-cos-swatch .gg-cos-title-sample {
  font: 600 11px/1.2 system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #b4bdaf;
}
