/* Scoreboard redesign, task T6: the Club rankings and Athlete statistics tabs of a tournament and the athlete history
   (Views/Rankings/Index.cshtml, History.cshtml and their partials). Only what the shared components do not draw: the
   filter form, the scoring rules in plain words, the ranking tables with their row groups and the phone cards. Every
   colour is a token of sb/tokens.css. */

/* The filters: the search and club fields of the statistics, the ranking groups as check boxes, then the order of the
   athlete rows (guide walkthrough round 11, F73: no branch or category filter). */
.ranking-filters { display: flex; flex-direction: column; gap: var(--sp-2); margin: 0; }
.ranking-groups { display: flex; flex-direction: column; gap: var(--sp-1); }
.ranking-groups .help { margin: 0; }
.ranking-groups__items { display: flex; flex-wrap: wrap; gap: 0 var(--sp-2); }
.ranking-groups__items .check { overflow-wrap: anywhere; }
.ranking-groups--active > legend { color: var(--brand-text); }

/* The scoring rules: the mode in one sentence, the points of each item, the four special cases. */
.ranking-rules__lead { margin: 0; font-weight: 600; }
.ranking-rules__points { max-width: 520px; }
.ranking-rules__points dd { font-weight: 700; }
.ranking-rules .eyebrow { margin: var(--sp-2) 0 0; }
.ranking-rules__sexes { margin: 0; }
.ranking-rules__list { display: flex; flex-direction: column; gap: var(--sp-1); margin: 0; padding: 0; list-style: none; }
.ranking-rule { display: flex; align-items: baseline; gap: var(--sp-1); }
.ranking-rule__mark { flex: none; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--st-closed-bg); color: var(--st-closed-fg); font-weight: 800; font-size: var(--fs-xs); }
.ranking-rule--counts .ranking-rule__mark { background: var(--st-ok-bg); color: var(--st-ok-fg); }

/* A panel with a table: its notes and its empty box sit inside the panel padding. */
.ranking-panel__note, .ranking-panel__empty { padding: 0 var(--sp-5) var(--sp-5); }
.ranking-panel > .panel__head { margin-bottom: var(--sp-4); }
/* Guide walkthrough round 12, F79: the line under the title of the overall table (all categories count). */
.ranking-panel > .panel__head:has(+ .ranking-panel__scope) { margin-bottom: var(--sp-1); }
.ranking-panel__scope { margin: 0; padding: 0 var(--sp-5) var(--sp-4); }

/* Guide walkthrough round 14, F83: the state of the table in its head, right after the title: the state badge of the
   Results page draw card, the counted fights (and the percent while in progress) and a thin native bar (the shared
   .progress look; it is aria-hidden, the count beside it says the same). A table that has not started shows its message
   in a dashed box; the note that the percentage is approximate sits under the table. Only a club table head with a state
   puts it beside the title; the athlete table heads keep their row count on the right. */
.ranking-panel > .panel__head:has(> .ranking-panel__state) { justify-content: flex-start; align-items: center; }
.ranking-panel__state { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1); }
.ranking-panel__count { color: var(--muted); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ranking-panel__bar.progress { width: 120px; height: 6px; border-radius: 3px; }
.ranking-panel__waiting { padding: var(--sp-4); }
.ranking-panel__waiting p { margin: 0; color: var(--text-2); }
.ranking-panel__approximate { margin: 0; padding: var(--sp-2) var(--sp-5) var(--sp-4); }

/* The tables: the row header is a name, not a column title; the place holds the medal disc. */
.ranking-table th[scope="row"] { border-top: 1px solid var(--line); background: none; color: var(--text); font: 600 var(--fs-md)/1.3 var(--font-body); letter-spacing: 0; text-transform: none; white-space: normal; overflow-wrap: anywhere; }
.ranking-table__place { width: 1%; white-space: nowrap; }
/* Guide walkthrough round 16, F94: the place column and its head are centered, so the medal discs and the plain numbers
   line up (club tables and the statistics). */
.ranking-table .ranking-table__place { text-align: center; }
/* A link in a ranking table (a club, an athlete, a tournament) is a 24px target, and 44px on touch (FB-97; the
   accessibility sweep measures .ranking-table a). */
.ranking-table a { display: inline-flex; align-items: center; min-height: 24px; }
@media (pointer: coarse) { .ranking-table a { min-height: var(--tap); } }
.ranking-table td { overflow-wrap: anywhere; }
/* The column titles wrap (Croatian titles are long), so a wide screen shows the whole table without scrolling. */
.ranking-table thead th { white-space: normal; vertical-align: bottom; }

/* A row group of the statistics (a club) or of a history (a tournament): its head row. */
.ranking-group__head th { border-top: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); font: 700 var(--fs-md)/1.3 var(--font-body); letter-spacing: 0; text-transform: none; white-space: normal; overflow-wrap: anywhere; }
.ranking-group__count { margin-left: var(--sp-3); color: var(--muted); font-weight: 500; font-size: var(--fs-sm); }
.ranking-table tbody tr.ranking-group__head:hover th { background: var(--surface-2); }

/* Guide walkthrough round 17, F104 (mockup round-17/f104-mockups): the column groups of a club table (Total, Men, Women)
   in a first head row, and the men's and women's columns on a light band. A thin coloured line marks each group head;
   the words say which group it is, the colour only helps the eye. In medal mode the medals of a part sit under its place. */
.ranking-table .ranking-table__groups th, .ranking-table .ranking-table__groups td { padding-bottom: 2px; border-bottom: 0; text-align: center; }
.ranking-table .ranking-table__sex { background: var(--surface-2); }
.ranking-table .ranking-table__groups .ranking-table__sex--men { box-shadow: inset 0 3px 0 var(--tree-lv1-bar); }
.ranking-table .ranking-table__groups .ranking-table__sex--women { box-shadow: inset 0 3px 0 var(--tree-lv3-bar); }
.ranking-table__medals { display: block; color: var(--muted); font-size: var(--fs-sm); font-weight: 500; white-space: nowrap; }

/* Public redesign, task 7 (spec section 6.2): the medals by club panel of the public Statistics page
   (Views/Rankings/_MedalsByClub.cshtml). The line under the heading, fixed columns (so the table of the "Show all" part
   lines up with the first one), the medal counts on their discs in the middle of their cells, the total with a thin
   native bar under it, the "Show all" toggle and the link to the Club rankings tab. The second table repeats its column
   heads for screen readers only. The toggle keeps the house focus ring of base.css (offset 3px; task 8, the accessibility
   sweep): the panel does not clip it. Round 29 combined fix round 1 (accessibility sweep, edge contrast): the toggle is a
   control, so it draws no hairline of its own (a control's edge needs 3:1); the line under the open toggle is the top
   line of the first row of the table behind it (.table td, and the card line of .table--stack on a phone). */
.medals-club > .panel__head { margin-bottom: var(--sp-1); }
.medals-club__note { margin: 0; padding: 0 var(--sp-5) var(--sp-4); }
.medals-club__table { table-layout: fixed; }
.medals-club__table .ranking-table__place { width: 4.5rem; }
.medals-club__table .medals-club__medal { width: 5.5rem; text-align: center; }
.medals-club__table .medals-club__total { width: 8rem; }
.medals-club__sum { display: block; font-weight: 700; font-size: var(--fs-lg); }
.medals-club__bar.progress { width: 100%; max-width: 6rem; height: 5px; margin: 4px 0 0 auto; border-radius: 3px; }
.medals-club__repeat { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.medals-club__more { border-top: 1px solid var(--line); }
.medals-club__toggle { padding: var(--sp-3) var(--sp-5); color: var(--brand-text); font-weight: 600; cursor: pointer; min-height: 24px; }
.medals-club__link { margin: 0; padding: var(--sp-3) var(--sp-5) var(--sp-4); border-top: 1px solid var(--line); }
.medals-club__link a { display: inline-flex; align-items: center; min-height: 24px; }
@media (pointer: coarse) { .medals-club__toggle, .medals-club__link a { min-height: var(--tap); } }

/* Guide walkthrough round 29, F166: the round glossy flag, one shared public class: the flag picture cut to a circle,
   the light spot at the upper left, the dark shade at the bottom, the dark edge, a thin rim and a small drop shadow,
   with the --ball-* tokens of the info screen ball (wall.css .wall-ball keeps its own sizes). 28px here.
   Round 29 combined fix round 1 (accessibility sweep, edge contrast): the ball is decorative (alt empty, the club name
   beside it says the club), so its rim is the decorative hairline --line-strong of every flag picture of the pages
   (club-search.css, registered.css, backoffice.css .flag), not the light wall rim --ball-rim, which almost vanished on
   the light page. The info screen keeps --ball-rim. */
.flag-ball { position: relative; flex: none; display: inline-block; width: 28px; height: 28px; border-radius: 50%; overflow: hidden; box-shadow: 0 1px 3px var(--ball-drop), 0 0 0 1px var(--line-strong); }
.flag-ball img { display: block; width: 100%; height: 100%; object-fit: cover; }
.flag-ball::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background:
  radial-gradient(circle at 34% 24%, var(--ball-spot) 0, var(--ball-spot-2) 14%, var(--ball-spot-0) 38%),
  radial-gradient(circle at 50% 120%, var(--ball-dark) 0, var(--ball-dark-0) 62%),
  radial-gradient(circle at 50% 50%, var(--ball-dark-0) 60%, var(--ball-edge) 100%); }

/* F166: the club cell of the medals by club table is one line, the ball and the club name (700, --fs-lg); a long name
   wraps beside the ball, never under it. */
.medals-club__club { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.medals-club__name { min-width: 0; font: 700 var(--fs-lg)/1.25 var(--font-body); overflow-wrap: anywhere; }

/* F167: the club search in the head of the medals panel and the competitor search in the head of the individual table,
   at the right end of the head (under the title on a phone). The club search works only with script (statistics.js), so
   it shows only on a page that runs script (html.js, set by theme-start.js outside the live regions, so a refresh keeps
   it shown and a focused field keeps its focus); the Search button of the competitor search is for a page without
   script (with script the search is sent after a pause in typing, or by Enter). */
.medals-club > .panel__head { align-items: end; }
.medals-club__search { display: none; flex: 0 1 18rem; min-width: 12rem; margin: 0; }
html.js .medals-club__search { display: flex; }
html.js .ranking-panel__search [data-statistics-search-submit] { display: none; }
.medals-club__none { margin: 0; padding: 0 var(--sp-5); color: var(--text-2); }
.medals-club__none:not(:empty) { padding-bottom: var(--sp-4); }
.ranking-panel > .panel__head:has(> .ranking-panel__search) { justify-content: flex-start; align-items: end; }
.ranking-panel__search { display: flex; flex-wrap: wrap; align-items: end; gap: var(--sp-2); margin: 0 0 0 auto; }
.ranking-panel__search .field { flex: 0 1 18rem; min-width: 12rem; margin: 0; }
/* F167: the heading of a lower table names the chosen club, with the "All clubs" link beside it. */
.ranking-panel__heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-1) var(--sp-3); min-width: 0; }
.ranking-panel__club { overflow-wrap: anywhere; }
.ranking-panel__all { display: inline-flex; align-items: center; min-height: 24px; font-weight: 600; }
@media (pointer: coarse) { .ranking-panel__all { min-height: var(--tap); } }

/* F167: with script the whole row of a club is a click target (statistics.js); the chosen club's row stays marked with
   the light brand tint and a brand bar at its start, also on hover; the rows the club search leaves out are hidden (also
   in the phone cards, which set their own display). The hover rule of the shared tables (components.css,
   .table tbody tr:hover td, and the row header too) would win over a plain chosen rule, so the chosen rule names tbody
   and has its own hover form with a higher weight. */
html.js .medals-club tr[data-medals-row] { cursor: pointer; }
.medals-club__table tbody tr[aria-current="true"] > :is(td, th), .medals-club__table tbody tr[aria-current="true"]:hover > :is(td, th[scope="row"]) { background: var(--brand-tint); }
.medals-club__table tr[aria-current="true"] > :first-child { box-shadow: inset 3px 0 0 var(--brand); }
.medals-club__table tr[hidden], .medals-club__more[hidden] { display: none; }
@media (forced-colors: active) {
  .flag-ball { outline: 1px solid CanvasText; }
  .medals-club__table tr[aria-current="true"] > td, .medals-club__table tr[aria-current="true"] > th { border-block: 2px solid CanvasText; }
}

/* F104: the Club rankings tab of a tournament without club ranking says only that it is not used. */
.ranking-unused { text-align: center; }
.ranking-unused p { margin: 0; color: var(--text-2); }

/* The athlete history head: the photo or the initials beside the name. */
.page-head__row:has(> .avatar) { align-items: center; }

/* Phone cards: every row is a card, its row header the title of the card, and a group head a band above its cards. */
@media (max-width: 760px) {
  .ranking-table.table--stack th[scope="row"] { display: block; width: 100%; padding: 0 0 4px; border-top: 0; font-size: var(--fs-lg); }
  .ranking-table.table--stack .ranking-group__head { padding: 0; }
  .ranking-table.table--stack .ranking-group__head th { display: block; width: 100%; padding: var(--sp-3) var(--sp-4); border-top: 0; }
  .ranking-table__place { width: auto; }
  .ranking-table.table--stack .ranking-table__sex { background: none; }
  .ranking-table.table--stack .ranking-table__medals { display: inline; margin-left: var(--sp-1); }
  .ranking-panel__note, .ranking-panel__empty { padding: 0 var(--sp-4) var(--sp-4); }
  .ranking-panel__scope { padding: 0 var(--sp-4) var(--sp-4); }
  .ranking-panel__approximate { padding: var(--sp-2) var(--sp-4) var(--sp-4); }
  .medals-club__table { table-layout: auto; }
  .medals-club__table .ranking-table__place, .medals-club__table .medals-club__medal, .medals-club__table .medals-club__total { width: auto; text-align: inherit; }
  .medals-club__bar.progress { margin: 4px 0 0; }
  .medals-club__note { padding: 0 var(--sp-4) var(--sp-4); }
  .medals-club__toggle { padding: var(--sp-3) var(--sp-4); }
  .medals-club__link { padding: var(--sp-3) var(--sp-4) var(--sp-4); }
  /* F167: the search fields take the whole width under the title; the chosen card is tinted as a whole. */
  .medals-club__search, .ranking-panel__search, .ranking-panel__search .field { flex: 1 1 100%; min-width: 0; margin-left: 0; }
  .medals-club__none { padding: 0 var(--sp-4); }
  .medals-club__table tr[aria-current="true"] { background: var(--brand-tint); box-shadow: inset 3px 0 0 var(--brand); }
  .medals-club__table tbody tr[aria-current="true"] > :is(td, th), .medals-club__table tbody tr[aria-current="true"]:hover > :is(td, th[scope="row"]) { background: none; }
  .medals-club__table tr[aria-current="true"] > :first-child { box-shadow: none; }
}

/* Guide walkthrough round 11, F75: the ranking group editor of the ranking settings page (Views/Rankings/_GroupEditor.cshtml).
   The category tick tree on the left (the tree table of the back office with a 24px tick box in its first column and the
   "chosen / all" count of a branch on the right; it scrolls inside its own box when the tree is long) and the "In the
   group" list on the right; on a narrow screen the list goes under the tree. */
.rank-editor { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: var(--sp-4); align-items: start; }
@media (max-width: 1100px) { .rank-editor { grid-template-columns: minmax(0, 1fr); } }
.rank-editor__count { margin-left: auto; color: var(--muted); font-size: var(--fs-sm); }
.rank-editor__scroll { max-height: 32rem; overflow: auto; }
.rank-tree td.c > input[type="checkbox"], .rank-tree th.c { width: 24px; }
.rank-tree td.c > input[type="checkbox"] { height: 24px; margin: 0; vertical-align: middle; accent-color: var(--brand); }
.rank-tree td.rank-tree__count { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
.rank-picked { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.rank-picked__title { margin: 0; padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--line); background: var(--surface-2); color: var(--muted); font-size: var(--fs-sm); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.rank-picked__list { margin: 0; padding: 0; list-style: none; }
.rank-picked__row { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); border-top: 1px solid var(--line); }
.rank-picked__row:first-child { border-top: 0; }
.rank-picked__path { min-width: 0; overflow-wrap: anywhere; }
.rank-picked__size { color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; }
.rank-picked__row .btn { margin-left: auto; }
.rank-picked .hint { margin: 0; padding: var(--sp-2) var(--sp-3); }
