/* Chess players (chess-players.js): names as links, the card on hover, the player's page */

a.chp-a { color: inherit; text-decoration: none; }
a.chp-a:hover { text-decoration: underline; text-underline-offset: 3px; }
a.chp-a:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; border-radius: 2px; }

.chp-t { font: 700 11px/1 var(--body); color: var(--muted); vertical-align: .18em; }

/* The portrait, or the player's initials on a plain square where there is none */
.chp-pic, .chp-ph {
  display: block;
  flex: none;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}
.chp-pic img { display: block; width: 100%; height: 100%; object-fit: cover; }
.chp-ph {
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 600;
  color: var(--muted);
  user-select: none;
}

/* ─── The card ─────────────────────────────────────────── */

.chpk {
  position: fixed;
  z-index: 61;
  top: 0;
  left: 0;
  width: 304px;
  max-width: calc(100vw - 16px);
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink);
  font-size: 13px;
  text-align: left;
  white-space: normal;
  cursor: pointer;
}
.chpk-top { display: flex; align-items: center; gap: 12px; }
.chpk-pic { width: 60px; height: 60px; font-size: 22px; }
.chpk-id { min-width: 0; }
.chpk-n { margin: 0; font: 600 20px/1.15 var(--display); }
.chpk-c { margin: 3px 0 0; color: var(--muted); }
.chpk .sp-flag, .chp-hc .sp-flag {
  display: inline-block;
  height: .85em;
  aspect-ratio: 4 / 3;
  margin-right: .4em;
  vertical-align: -.06em;
  outline: 1px solid var(--line);
}
/* Three ratings, and the world rank as a fourth field for a top-100 player. Equal columns, except
   that Classical's label keeps its width when there are four */
.chpk-rt { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(max-content, 1fr); gap: 8px; margin: 12px 0 0; }
.chpk-rt dt, .chp-rt dt {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.chpk-rt dd { margin: 1px 0 0; font: 600 21px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.chp-wait { color: var(--faint); }
.chpk-w { margin: 10px 0 0; line-height: 1.35; }
/* A headline's years link their events */
.chpk-w a { color: inherit; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.chpk-w a:hover { text-decoration-color: currentColor; }
.chpk-e { margin: 8px 0 0; color: var(--muted); }
.chpk-e span { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }

/* ─── The player's page ────────────────────────────────── */

.chp-head { display: flex; align-items: center; gap: 20px; padding: 18px; }
.chp-hpic { width: 132px; height: 132px; font-size: 44px; }
.chp-hid { min-width: 0; }
.chp-hn { margin: 0; font: 600 32px/1.1 var(--display); }
.chp-hn .chp-t { font-size: 13px; }
.chp-hc { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.chp-hc a { color: inherit; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.chp-hc a:hover { color: var(--ink); text-decoration-color: currentColor; }
.chp-rt { display: flex; flex-wrap: wrap; gap: 6px 28px; margin: 14px 0 0; }
.chp-rt dd { margin: 0; font: 600 30px/1.05 var(--display); font-variant-numeric: tabular-nums; }

/* The world rank after the classical rating on the page: a button that shows the ranking around
   the player */
.chp-rk {
  padding: 0;
  border: 0;
  background: none;
  font: 600 17px/1 var(--display);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  vertical-align: .35em;
  text-decoration: underline dotted;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
  cursor: help;
}
.chp-rk:hover, .chp-rk[aria-expanded="true"] { color: var(--ink); text-decoration-color: currentColor; }
.chp-rk:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 2px; }
/* Under the player card (.chpk), which a name in it opens beside it */
.chp-rkp {
  position: fixed;
  z-index: 60;
  top: 0;
  left: 0;
  width: 300px;
  max-width: calc(100vw - 16px);
  padding: 10px 12px 8px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink);
  font-size: 13px;
  text-align: left;
}
.chp-rkp-h { margin: 0 0 6px; font-weight: 700; }
.chp-rkp-h span { margin-left: 6px; font-weight: 400; color: var(--muted); }
.chp-rkp-l { list-style: none; margin: 0; padding: 0; }
.chp-rkp-r { display: grid; grid-template-columns: 4ch minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 3px 6px; margin: 0 -6px; border-radius: 4px; }
.chp-rkp-n, .chp-rkp-v { font-variant-numeric: tabular-nums; color: var(--muted); }
.chp-rkp-v { text-align: right; }
.chp-rkp-p { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chp-rkp-p a { color: inherit; text-decoration: none; }
.chp-rkp-p a:hover { text-decoration: underline; text-underline-offset: 3px; }
/* Where there's hover, the whole row is its name's link: the player's card opens from anywhere on
   it, and the pointer stays on it on the way across to that card */
@media (any-hover: hover) {
  .chp-rkp-r { position: relative; }
  .chp-rkp-p a::after { content: ''; position: absolute; inset: 0; }
}
/* A focused name rings its row, the name's own ring being cut off by its clipped box */
.chp-rkp-p a:focus-visible { outline: none; }
.chp-rkp-r:has(a:focus-visible) { outline: 2px solid var(--ink); outline-offset: -2px; }
.chp-rkp .sp-flag {
  display: inline-block;
  height: .85em;
  aspect-ratio: 4 / 3;
  margin-right: .45em;
  vertical-align: -.06em;
  outline: 1px solid var(--line);
}
.chp-rkp .chp-rkp-nf { visibility: hidden; } /* no flag (FIDE's own): the name stays in line */
.chp-rkp-me { background: var(--surface-2); }
.chp-rkp-me .chp-rkp-n, .chp-rkp-me .chp-rkp-v { color: var(--ink); font-weight: 700; }
.chp-rkp-gap { padding: 0 0 2px calc(4ch + 8px); color: var(--faint); line-height: 1; }

/* The capsule: the career in a few lines, a grid of them; on phones one line runs into its detail */
.chp-cap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px 28px;
  margin: 0;
  padding: 16px 18px;
  list-style: none;
}
.chp-cap li { min-width: 0; }
.chp-cap b { display: block; font: 600 19px/1.2 var(--display); }
.chp-cap span { display: block; margin-top: 2px; font-size: 13px; line-height: 1.35; color: var(--muted); }
/* Each year of a line of events links its event */
.chp-cap a { color: inherit; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.chp-cap a:hover { color: var(--ink); text-decoration-color: currentColor; }
.chp-cap a:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; border-radius: 2px; }

/* Tier badges: the bigger the event, the heavier */
.chp-tier {
  display: inline-block;
  padding: 1px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .05em;
  line-height: 1.45;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--muted);
}
/* World Championship and Candidates: the tennis profiles' Slam badge */
.chp-k1, .chp-k2 { background: #1f5130; border-color: #1f5130; color: #fff; }
.chp-c-world-cup, .chp-c-elite { border-color: var(--ink); color: var(--ink); }

/* Best results: a list, newest first */
.chp-best { margin: 0; padding: 0; list-style: none; }
.chp-b { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 12px; align-items: baseline; padding: 11px 14px; }
.chp-b + .chp-b { border-top: 1px solid var(--line); }
.chp-place { font: 700 16px/1.2 var(--display); text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.chp-place.chp-p1 { color: var(--win); }
.chp-b-main { min-width: 0; }
.chp-ev { color: var(--ink); font-weight: 600; text-decoration: none; }
a.chp-ev:hover { text-decoration: underline; text-underline-offset: 3px; }
a.chp-ev:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; border-radius: 2px; }
.chp-b-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 4px; font-size: 13px; color: var(--muted); }
.chp-sc { font-variant-numeric: tabular-nums; }

/* Every event */
.chp-evs .chp-d { width: 92px; }
.chp-evs .chp-k { width: 150px; }
.chp-evs .chp-pl { width: 92px; }
.chp-evs .chp-pts { width: 52px; }
.chp-evs .chp-g { width: 46px; }
.chp-evs .chp-r { width: 60px; }
.chp-evs td.chp-d, .chp-evs td.chp-g, .chp-evs td.chp-r { color: var(--muted); }
.chp-evs td.chp-e { white-space: normal; }
.chp-evs td.chp-pts { font-weight: 700; }
.chp-sec { display: block; margin-top: 1px; font-size: 12.5px; color: var(--muted); }
.chp-of { color: var(--muted); font-size: 12.5px; }
.chp-muted { color: var(--faint); }
.chp-sts { display: none; }
/* A knockout stage's name wraps in its narrow column rather than losing its end ("3rd-4th") */
@media (min-width: 601px) {
  .chp-evs .chp-stl { display: block; white-space: normal; font-size: 12.5px; line-height: 1.3; }
}

@media (max-width: 600px) {
  .chp-head { gap: 14px; padding: 14px; }
  .chp-hpic { width: 88px; height: 88px; font-size: 30px; }
  .chp-hn { font-size: 25px; }
  .chp-hc { font-size: 13px; gap: 2px 12px; }
  .chp-rt { gap: 4px 18px; margin-top: 10px; }
  .chp-rt dd { font-size: 23px; }
  .chp-cap { grid-template-columns: 1fr; gap: 9px; padding: 12px 14px; }
  .chp-cap b { display: inline; font-size: 17px; }
  .chp-cap span { display: inline; margin: 0 0 0 4px; }
  .chp-b { grid-template-columns: 60px minmax(0, 1fr); gap: 8px; padding: 10px 10px; }
  .chp-place { font-size: 14px; }
  /* Phones: date, event, place and points */
  .chp-evs .chp-d { width: 66px; }
  .chp-evs td.chp-d { white-space: normal; font-size: 12.5px; }
  .chp-evs .chp-pl { width: 52px; }
  .chp-evs .chp-pts { width: 40px; }
  .chp-evs .chp-k, .chp-evs .chp-g, .chp-evs .chp-r { width: 0; padding: 0; font-size: 0; }
  .chp-evs .chp-k > *, .chp-of, .chp-stl { display: none; }
  .chp-sts { display: inline; }
}
