/* Tennis players (sports/tennis-players.js): a name's card on hover, and a player's page. */

/* ─── Names ─── */

.tp-name, .tp-a { color: inherit; text-decoration: none; }
.tp-on, a.tp-name { cursor: pointer; }
.tp-on:hover, a.tp-name:hover, .tp-a:hover, .tp-a:focus-visible { text-decoration: underline; text-underline-offset: 3px; }

.tp-flag {
  display: inline-block;
  width: auto;
  height: .8em;
  aspect-ratio: 4 / 3;
  margin-right: .4em;
  vertical-align: -.06em;
  outline: 1px solid var(--line);
}

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

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

.tpk {
  position: fixed;
  z-index: 60;
  top: 0;
  left: 0;
  width: 290px;
  padding: 10px 12px 11px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.tpk-top { display: flex; align-items: center; gap: 10px; }
.tpk-pic { width: 56px; height: 56px; font-size: 22px; }
.tpk-id { min-width: 0; }
.tpk-n { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 20px/1.1 var(--display); }
.tpk-c { margin: 2px 0 0; color: var(--muted); font-size: 12px; font-weight: 600; }
.tpk-d { display: grid; gap: 3px; margin: 9px 0 0; }
.tpk-r { display: grid; grid-template-columns: 50px minmax(0, 1fr); gap: 8px; }
.tpk-r dt { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .06em; line-height: 1.75; text-transform: uppercase; }
/* A value wraps rather than lose its numbers to an ellipsis */
.tpk-r dd { margin: 0; overflow-wrap: anywhere; font-weight: 500; line-height: 1.45; }
.tpk-when { margin-left: 4px; color: var(--muted); font-size: 12px; font-weight: 500; }
/* The Slams' lines: the titles, then the finals lost under them */
.tpk-l { display: block; }
.tpk-sub { color: var(--muted); }
.tpk-y { white-space: nowrap; }
.tpk-x { color: var(--muted); font-size: 12px; }

/* ─── The page ─── */

.tp-head {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px;
}
.tp-hpic { width: 132px; height: 132px; font-size: 48px; }
.tp-hid { min-width: 0; }
.tp-hn { margin: 0; font: 700 34px/1.05 var(--display); }
.tp-hc { display: flex; flex-wrap: wrap; gap: 2px 16px; margin: 4px 0 0; color: var(--muted); font-size: 15px; font-weight: 500; }
.tp-stats { display: flex; flex-wrap: wrap; gap: 4px 22px; margin: 12px 0 0; }
.tp-stats dt { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.tp-stats dd { margin: 0; font: 600 20px/1.2 var(--display); white-space: nowrap; }

/* The ATP rank, first among the numbers: a button that shows the ranking around the player. Its
   date beside its label, as "since 2007" is beside a count */
.tp-rkd { margin-left: 4px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0; text-transform: none; white-space: nowrap; }
.tp-rk {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-variant-numeric: tabular-nums;
  color: inherit;
  text-decoration: underline dotted;
  text-decoration-color: var(--line-strong);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  cursor: pointer;
}
:root[data-hover] .tp-rk:hover, .tp-rk[aria-expanded="true"] { text-decoration-color: currentColor; }
.tp-rk:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 2px; }
/* Under the player card (.tpk), which a name in it opens beside it */
.tp-rkp {
  position: fixed;
  z-index: 59;
  top: 0;
  left: 0;
  width: 320px;
  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;
}
.tp-rkp-h { margin: 0 0 6px; font-weight: 700; }
.tp-rkp-h span { margin-left: 6px; font-weight: 400; color: var(--muted); }
/* One grid for every row, so the ranks and the points line up at their widest, never cut */
.tp-rkp-l { display: grid; grid-template-columns: max-content minmax(0, 1fr) max-content; column-gap: 8px; list-style: none; margin: 0; padding: 0; }
.tp-rkp-r {
  position: relative;
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
  align-items: center;
  padding: 3px 6px;
  margin: 0 -6px;
  border-radius: 4px;
}
.tp-rkp-n, .tp-rkp-v { font-variant-numeric: tabular-nums; color: var(--muted); text-align: right; white-space: nowrap; }
.tp-rkp-p { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The whole row is its name's link: a tap anywhere on it opens the player, the card opens from
   anywhere on it, and the pointer stays on it on the way across to that card */
.tp-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 */
.tp-rkp-p a:focus-visible { outline: none; }
.tp-rkp-r:has(a:focus-visible) { outline: 2px solid var(--ink); outline-offset: -2px; }
.tp-rkp .tp-flag { height: .85em; margin-right: .45em; }
.tp-rkp .tp-rkp-nf { visibility: hidden; } /* no flag: the name stays in line */
.tp-rkp-x { color: var(--faint); }
.tp-rkp-me { background: var(--surface-2); }
.tp-rkp-me .tp-rkp-n, .tp-rkp-me .tp-rkp-v { color: var(--ink); font-weight: 700; }
.tp-rkp-gap { grid-column: 2 / -1; padding: 0 0 2px; color: var(--faint); line-height: 1; }
/* Win–loss, season by season */
.tp-wls { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; padding: 4px 14px 14px; color: var(--muted); font-size: 13px; }
.tp-wl { white-space: nowrap; font-variant-numeric: tabular-nums; }
.tp-wl b { color: var(--ink); font-weight: 600; }

.tp-sec { margin-top: 12px; }
.tp-x { color: var(--muted); font-weight: 500; }
/* "since 2007": a count the archive alone makes, for a career that may be longer */
.tp-since { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0; text-transform: none; white-space: nowrap; }
.tp-stats .tp-since { margin-left: 4px; }

/* A finish: Won, Final, Semifinal, Quarterfinal. The Slam green for a title. */
.tp-f {
  display: inline-block;
  padding: 0 6px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  font: 700 11px/1.6 var(--body);
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.tp-f-W { background: #1f5130; border-color: #1f5130; color: #fff; }
.tp-f-F { border-color: #1f5130; color: #1f5130; }

/* Slam finishes, best first */
.tp-fins { margin: 0; padding: 0 14px; list-style: none; }
.tp-fin {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 4px 12px;
  align-items: baseline;
  padding: 10px 0;
}
.tp-fin + .tp-fin { border-top: 1px solid var(--line); }
.tp-fin-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; }
.tp-fin-b { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.tp-sl { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; }
.tp-sl-n { font-weight: 600; }
.tp-sl a, .tp-sl span[title] { color: var(--muted); text-decoration: none; }
.tp-sl a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

/* Every Slam by year */
/* The left inset is the sticky column's own padding, so a scrolled grid shows nothing beside it */
.tp-grid-w { --tp-inset: 14px; overflow-x: auto; padding: 4px var(--tp-inset) 14px 0; border-top: 1px solid var(--line); }
.tp-grid-h { position: sticky; left: 0; margin: 8px 0 0; padding-left: var(--tp-inset); color: var(--muted); font-size: 12px; font-weight: 600; }
.tp-grid { border-collapse: collapse; font-size: 13px; }
.tp-grid th, .tp-grid td { padding: 3px 2px; text-align: center; white-space: nowrap; }
.tp-grid thead th { padding-top: 8px; color: var(--muted); font-size: 12px; font-weight: 600; }
.tp-grid tbody th, .tp-grid thead th:first-child {
  position: sticky;
  left: 0;
  padding-left: var(--tp-inset);
  padding-right: 10px;
  background: var(--surface);
  font-weight: 600;
  text-align: left;
}
.tp-g {
  display: block;
  min-width: 38px;
  padding: 1px 4px;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}
.tp-g.tp-f { padding: 1px 4px; font: 600 13px/1.4 var(--body); letter-spacing: 0; text-transform: none; color: var(--ink); }
.tp-g.tp-f-W { color: #fff; }
.tp-g.tp-f-F { color: #1f5130; }
a.tp-g:hover { background: var(--surface-2); }
a.tp-g.tp-f-W:hover { background: #2b6a40; }
.tp-g-none { color: var(--faint); }
.tp-grid a:focus-visible, .tp-sl a:focus-visible, .tp-ws a:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }

/* Titles and finals, newest first */
.tp-ws { margin: 0; padding: 0 14px; list-style: none; }
.tp-w {
  display: grid;
  grid-template-columns: 40px 104px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  padding: 8px 0;
}
.tp-w + .tp-w { border-top: 1px solid var(--line); }
.tp-w-y { color: var(--muted); font-size: 14px; }
.tp-tier {
  display: block;
  padding: 0 6px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  color: var(--muted);
  font: 700 11px/1.6 var(--body);
  letter-spacing: .04em;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
}
.tp-tier-GS { background: #1f5130; border-color: #1f5130; color: #fff; }
.tp-tier-F { background: var(--ink); border-color: var(--ink); color: #fff; }
.tp-tier-M { border-color: var(--ink); color: var(--ink); }
/* A Slam final: won (the Slam green) or runner-up */
.tp-res-W { background: #1f5130; border-color: #1f5130; color: #fff; }
.tp-res-F { border-color: #1f5130; color: #1f5130; }
.tp-w-e > b { font-weight: 600; }
.tp-sc { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tp-src { margin: 0; padding: 2px 14px 12px; color: var(--muted); font-size: 12px; }
.tp-src a { color: inherit; text-underline-offset: 2px; }
.tp-w-e { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; min-width: 0; }
.tp-w-e > a { font-weight: 600; text-decoration: none; }
.tp-w-e > a:hover, .tp-w-m:hover { text-decoration: underline; text-underline-offset: 3px; }
.tp-w-o { color: var(--muted); font-size: 14px; }
.tp-w-m { color: inherit; text-decoration: none; }
.tp-w-o .tp-name { color: var(--ink); }

@media (max-width: 600px) {
  .tp-head { align-items: flex-start; gap: 14px; padding: 14px 12px; }
  .tp-hpic { width: 96px; height: 96px; font-size: 36px; }
  .tp-hn { font-size: 28px; }
  .tp-hc { gap: 2px 12px; font-size: 14px; }
  .tp-stats { gap: 4px 16px; }
  .tp-fins, .tp-ws { padding: 0 12px; }
  .tp-grid-w { --tp-inset: 12px; padding: 4px 12px 12px 0; }
  .tp-fin { grid-template-columns: minmax(0, 1fr); }
  .tp-w { grid-template-columns: 34px 104px minmax(0, 1fr); gap: 8px; }
  .tp-w-e { display: block; }
  .tp-w-o { display: block; }
  .tp-sc { display: block; }
  .tp-wls, .tp-src { padding-left: 12px; padding-right: 12px; }
}

/* ─── Doubles ─── */

/* The card: his doubles under his singles, under their own small heading */
.tpk-d:empty { display: none; }
.tpk-dh { margin: 9px 0 0; color: var(--ink); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.tpk-dh + .tpk-dd { margin-top: 3px; }

/* A final: his partner after the two they played, the tier after the event */
.tp-with { color: var(--muted); font-size: 14px; }
.tp-with .tp-name { color: var(--ink); }
.tp-tier-t { margin-left: 8px; color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }

/* Season by season: each a disclosure, its events a table */
.tp-dys { padding: 4px 14px 6px; }
.tp-dy > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 14px;
  padding: 7px 8px;
  margin: 0 -8px;
  border-radius: 4px;
  cursor: pointer;
  list-style: none;
  font-variant-numeric: tabular-nums;
}
.tp-dy > summary::-webkit-details-marker { display: none; }
.tp-dy > summary::after { content: "▸"; margin-left: auto; color: var(--muted); font-size: 12px; }
.tp-dy[open] > summary::after { content: "▾"; }
.tp-dy > summary:hover { background: var(--surface-2); }
.tp-dy > summary:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.tp-dy > summary b { font-weight: 700; }
.tp-dy-s { display: inline-flex; flex-wrap: wrap; gap: 2px 14px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.tp-dt { width: 100%; margin: 2px 0 10px; border-collapse: collapse; font-size: 14px; }
.tp-dt th { padding: 4px 8px 4px 0; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-align: left; text-transform: uppercase; }
.tp-dt td { padding: 4px 8px 4px 0; vertical-align: baseline; }
.tp-dt tbody tr:nth-child(odd) td { background: var(--surface-2); }
.tp-dt td:first-child, .tp-dt th:first-child { padding-left: 6px; }
.tp-dt-e { width: 48%; }
.tp-dt-e a { color: inherit; font-weight: 600; text-decoration: none; }
.tp-dt-e a:hover { text-decoration: underline; text-underline-offset: 3px; }
.tp-dt-e a:focus-visible, .tp-dt-p a:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
/* A finish never wraps or loses a letter */
.tp-dt-f { white-space: nowrap; }
.tp-df { color: var(--muted); font-weight: 600; white-space: nowrap; }
.tp-df.tp-f { font: 600 12px/1.5 var(--body); letter-spacing: 0; text-transform: none; }
.tp-df.tp-f-W { color: #fff; }
.tp-dt-p .tp-name { color: var(--ink); }

@media (max-width: 600px) {
  .tp-dys { padding: 4px 12px 6px; }
  .tp-dt { font-size: 13px; }
  .tp-dt-e { width: auto; }
}
