/* Shared ranking parts (rank_ui.py): one implementation for the games, studio and trends pages. */

/* A filter as one row of chips that scrolls in its own box, so 8 or 70 options take one line. */
.rk-chips { margin:0 0 var(--sp-3); }
.rk-chips ul { display:flex; gap:var(--sp-2); margin:0; padding:var(--sp-1) 0; list-style:none; overflow-x:auto;
  scroll-snap-type:x proximity; scrollbar-width:thin; }
.rk-chips li { flex:none; scroll-snap-align:start; }
.rk-chips a { display:inline-flex; align-items:center; min-height:44px; padding:0 var(--sp-4); border:1px solid var(--rule);
  border-radius:999px; background:var(--surface); color:var(--ink); font:500 var(--fs-note)/1 var(--sans); text-decoration:none; white-space:nowrap; }
.rk-chips a:hover { border-color:var(--accent); color:var(--accent); }
.rk-chips a[aria-current] { border-color:var(--ink); background:var(--ink); color:var(--bg); font-weight:600; }
.rk-chips a:focus-visible { outline:2px solid var(--accent); outline-offset:-2px; }
/* The same chips as a choice in a form (radio buttons): the input is kept for keyboard and screen readers. */
.rk-choice label { position:relative; display:inline-flex; }
.rk-choice input { position:absolute; inset:0; opacity:0; margin:0; cursor:pointer; }
.rk-choice span { display:inline-flex; align-items:center; min-height:44px; padding:0 var(--sp-4); border:1px solid var(--rule);
  border-radius:999px; background:var(--surface); color:var(--ink); font:500 var(--fs-note)/1 var(--sans); white-space:nowrap; }
.rk-choice input:hover + span { border-color:var(--accent); color:var(--accent); }
.rk-choice input:checked + span { border-color:var(--ink); background:var(--ink); color:var(--bg); font-weight:600; }
.rk-choice input:focus-visible + span { outline:2px solid var(--accent); outline-offset:-2px; }

/* A change: an arrow and the figure, green up and red down; the words are for assistive technology. */
.rk-delta { display:inline-block; min-width:2.5em; font:600 var(--fs-note)/1.4 var(--sans); font-variant-numeric:tabular-nums; white-space:nowrap; }
.rk-delta.is-up { color:var(--up); }
.rk-delta.is-down { color:var(--down); }
.rk-delta.is-same { color:var(--muted); font-weight:500; }
.rk-delta.is-new { color:var(--accent); }
/* Parts a page's filter hides (a figure or mover whose topic is filtered out) leave the layout. */
.rk-kpis[hidden], .rk-kpis > div[hidden], .rk-movers li[hidden] { display:none; }

/* A band of headline figures, each read from the table below it. */
.rk-kpis { display:grid; grid-template-columns:repeat(4, minmax(0, 1fr)); gap:0; margin:0 0 var(--sp-5); border-top:2px solid var(--ink);
  border-bottom:1px solid var(--rule); }
.rk-kpis > div { min-width:0; padding:var(--sp-3) var(--sp-4) var(--sp-3) 0; }
.rk-kpis > div + div { padding-left:var(--sp-4); border-left:1px solid var(--rule); }
.rk-kpis dt { color:var(--muted); font:500 var(--fs-note)/1.4 var(--sans); }
.rk-kpis dd { margin:var(--sp-1) 0 0; }
.rk-kpi { display:block; color:var(--ink); font:600 var(--fs-rail)/1.25 var(--serif); overflow-wrap:break-word; }
.rk-kpi a { color:inherit; text-decoration:none; }
.rk-kpi a:hover { color:var(--accent); text-decoration:underline; }
.rk-kpi .rk-delta { font:600 var(--fs-rail)/1.25 var(--sans); }
.rk-kpi-note { display:block; margin-top:var(--sp-1); color:var(--muted); font:400 var(--fs-note)/1.4 var(--sans); }
.rk-kpi-note .rk-delta { min-width:0; margin-right:0.2em; }
.rk-kpi-note a, .rk-sub a { display:inline-block; padding:3px 0; }
@media (max-width: 700px) {
  .rk-kpis { grid-template-columns:repeat(2, minmax(0, 1fr)); }
  .rk-kpis > div, .rk-kpis > div + div { padding:var(--sp-3) var(--sp-3) var(--sp-3) 0; border-left:0; }
  .rk-kpis > div:nth-child(even) { padding-left:var(--sp-3); border-left:1px solid var(--rule); }
  .rk-kpis > div:nth-child(n+3) { border-top:1px solid var(--rule); }
  .rk-kpi, .rk-kpi .rk-delta { font-size:var(--fs-copy); }
}

/* The ranking table: dense, tabular columns on a wide screen. The site's own first and last cells do not wrap; these do. */
.rk table { width:100%; border-collapse:collapse; font:400 var(--fs-tool)/1.35 var(--sans); }
.rk th { padding:var(--sp-2) var(--sp-3) var(--sp-2) 0; border-bottom:1px solid var(--ink); background:none; color:var(--muted);
  font:500 var(--fs-note)/1.3 var(--sans); text-align:left; white-space:nowrap; vertical-align:bottom; }
.rk td { padding:var(--sp-2) var(--sp-3) var(--sp-2) 0; border-bottom:1px solid var(--rule); vertical-align:middle;
  font:400 var(--fs-tool)/1.35 var(--sans); white-space:normal; }
.rk tbody tr:hover { background:var(--s2); }
.rk th:last-child, .rk td:last-child { padding-right:0; }
.rk td.rk-place { width:3.5rem; color:var(--ink); font-weight:700; font-size:var(--fs-copy); font-variant-numeric:tabular-nums; white-space:nowrap; }
.rk td.rk-change { width:3.5rem; }
.rk td.rk-meta, .rk td.rk-prev { color:var(--muted); font-size:var(--fs-note); }
.rk td.rk-meta a { color:var(--muted); }
.rk td.rk-prev, .rk td.rk-figure { font-variant-numeric:tabular-nums; white-space:nowrap; }
.rk td.rk-share { width:30%; white-space:nowrap; }
.rk td.rk-spark, .rk td.rk-strip { width:1%; white-space:nowrap; }
.rk td.rk-spark svg, .rk td.rk-strip svg { display:block; }
.rk-sub { display:block; margin-left:calc(1.75rem + var(--sp-2)); color:var(--muted); font:400 var(--fs-note)/1.35 var(--sans); }
.rk-sub a { color:var(--muted); }

/* Sparkline and strip: one muted line with the end dot in the change's colour; cells in one aqua ramp. */
.rk-spark-line { fill:none; stroke:var(--muted); stroke-width:1.5; stroke-linejoin:round; stroke-linecap:round; }
.rk-spark-end { fill:var(--ink); }
.rk-spark.is-up .rk-spark-end { fill:var(--up); }
.rk-spark.is-down .rk-spark-end { fill:var(--down); }
.rk-heat-0 { fill:none; stroke:var(--iv-line); stroke-width:1; background:none; box-shadow:inset 0 0 0 1px var(--iv-line); }
.rk-heat-1 { fill:var(--iv-aqua-tint); background:var(--iv-aqua-tint); }
.rk-heat-2 { fill:color-mix(in srgb, var(--accent) 55%, var(--iv-aqua-tint)); background:color-mix(in srgb, var(--accent) 55%, var(--iv-aqua-tint)); }
.rk-heat-3 { fill:var(--accent); background:var(--accent); }
.rk-key { display:flex; flex-wrap:wrap; gap:var(--sp-1) var(--sp-4); margin:var(--sp-2) 0 0; color:var(--muted); font:400 var(--fs-note)/1.4 var(--sans); }
.rk-key span { display:inline-flex; align-items:center; gap:var(--sp-1); }
.rk-key i { display:inline-block; width:10px; height:10px; border-radius:1px; }

/* A share as a bar with its figure. */
.rk-bar { display:inline-block; width:calc(100% - 5.5em); max-width:12rem; height:8px; margin-right:var(--sp-2); border-radius:0 4px 4px 0;
  background:var(--s2); vertical-align:middle; overflow:hidden; }
.rk-bar > span { display:block; height:100%; border-radius:0 4px 4px 0; background:var(--accent); }
.rk-bar-figure { font:500 var(--fs-note)/1 var(--sans); font-variant-numeric:tabular-nums; }

/* On a phone a row is two lines: place, name and change; then meta, spark and strip. The header stays for screen readers. */
@media (max-width: 700px) {
  .rk thead { position:absolute; width:1px; height:1px; margin:-1px; overflow:hidden; clip-path:inset(50%); }
  .rk table, .rk tbody { display:block; }
  .rk tr { display:grid; grid-template-columns:2.25rem minmax(0, 1fr) auto auto; grid-template-areas:'place name name change' 'place meta spark strip';
    align-items:center; column-gap:var(--sp-2); row-gap:2px; padding:var(--sp-3) 0; border-bottom:1px solid var(--rule); }
  .rk td { display:block; width:auto; padding:0; border:0; }
  .rk td.rk-place { grid-area:place; align-self:start; width:auto; }
  .rk td.rk-name { grid-area:name; }
  .rk td.rk-change { grid-area:change; width:auto; text-align:right; }
  .rk td.rk-meta, .rk td.rk-share { grid-area:meta; width:auto; padding-left:calc(1.75rem + var(--sp-2)); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .rk td.rk-share { display:flex; align-items:center; }
  .rk td.rk-share .rk-bar { flex:1; width:auto; max-width:6rem; }
  .rk td.rk-spark { grid-area:spark; width:auto; }
  .rk td.rk-strip { grid-area:strip; width:auto; }
  .rk td.rk-prev, .rk td.rk-figure, .rk .rk-sub { display:none; }
  .rk td.rk-meta:empty + td.rk-share { grid-area:meta; }
  .rk .rk-delta { min-width:0; }
}

/* Movers: a short list each of climbers, fallers and new entries. */
.rk-movers { margin:0; padding:0; list-style:none; }
.rk-movers li { display:grid; grid-template-columns:2rem minmax(0, 1fr) auto; align-items:center; gap:var(--sp-2);
  min-height:44px; border-bottom:1px solid var(--rule); font:400 var(--fs-tool)/1.3 var(--sans); }
.rk-movers .rk-delta { min-width:0; text-align:right; }
.rk-pos { color:var(--muted); font:600 var(--fs-note)/1 var(--sans); font-variant-numeric:tabular-nums; }
.rk-mover { min-width:0; }

/* One series over a few dates: one line, each point labelled in HTML so labels keep their size. */
.rk-chart { margin:0 0 var(--sp-5); max-width:44rem; }
.rk-plot { position:relative; height:160px; margin:var(--sp-5) 2.5rem 0; }
.rk-plot svg { position:absolute; inset:0; width:100%; height:100%; overflow:visible; }
.rk-plot-base { fill:none; stroke:var(--rule); stroke-width:1; }
.rk-plot-line { fill:none; stroke:var(--accent); stroke-width:2; stroke-linejoin:round; stroke-linecap:round; }
.rk-plot-point { position:absolute; width:10px; height:10px; margin:-5px 0 0 -5px; border:2px solid var(--bg); border-radius:50%;
  background:var(--accent); box-sizing:content-box; }
.rk-plot-point.is-now { background:var(--ink); }
.rk-plot-point > span { position:absolute; bottom:14px; left:50%; transform:translateX(-50%); color:var(--ink);
  font:600 var(--fs-note)/1 var(--sans); font-variant-numeric:tabular-nums; white-space:nowrap; }
.rk-plot-axis { position:relative; height:1.5em; margin:var(--sp-2) 2.5rem 0; color:var(--muted); font:400 var(--fs-note)/1.4 var(--sans); }
.rk-plot-axis span { position:absolute; transform:translateX(-50%); white-space:nowrap; }
