/* Guide walkthrough round 31, F179 (mockup round-31/mockups/f179.html, layout V1 charts on top, path P1): the athlete page
   (Views/Rankings/History.cshtml and Views/Rankings/Athlete). The head meta line, the summary strip, the four chart cards
   (inline SVG, every size an SVG attribute), the tabs, the Borbe tab with the fight lists and the paths through the
   draw, the Turniri table and the Medalje cards. Every colour is a token of sb/tokens.css. The page works at 390 px with
   no sideways scroll; touch targets are 44 px on a touch screen. Without script (no html.js) every panel shows under its
   heading, the tab row is hidden and every path is open; with script (js/sb/athlete.js) one panel shows and the paths
   open with their buttons. */

.athlete-page {
  --athlete-win: var(--st-ok-fg);
  --athlete-win-bg: var(--st-ok-bg);
  --athlete-loss: var(--st-bad-fg);
  --athlete-loss-bg: var(--st-bad-bg);
  --athlete-draw: var(--st-neutral-fg);
  --athlete-draw-bg: var(--st-neutral-bg);
}

/* The head meta line: the country with its flag, the club, the first appearance. */
.athlete-meta { display: inline-flex; align-items: center; gap: var(--sp-1); }
.athlete-meta + .athlete-meta { margin-left: var(--sp-3); }

/* The summary strip: a number above its word, five columns, three on a phone. */
.athlete-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.athlete-strip__item { display: flex; flex-direction: column-reverse; padding: var(--sp-3) var(--sp-4); border-right: 1px solid var(--line); min-width: 0; }
.athlete-strip__item:last-child { border-right: 0; }
.athlete-strip dt { color: var(--muted); font-size: var(--fs-sm); }
.athlete-strip dd { margin: 0; font: 800 1.75rem/1 var(--font-display); }
.athlete-strip__share { color: var(--athlete-win); font: 700 var(--fs-md)/1 var(--font-display); }

/* The chart cards: four columns, two from 761 to 1100 px, one on a phone. */
.athlete-charts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-3); }
.athlete-chart { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); min-width: 0; }
.athlete-chart__title { margin: 0; font: 700 var(--fs-md)/1.2 var(--font-display); text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); }
.athlete-chart__body { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.athlete-chart__foot, .athlete-chart__empty { margin: 0; color: var(--muted); font-size: var(--fs-sm); }
.athlete-chart__foot { margin-top: auto; }

.athlete-donut { flex: none; width: 112px; height: 112px; }
.athlete-donut circle { fill: none; stroke-width: 14; }
.athlete-donut__ring { stroke: var(--surface-3); }
.athlete-donut__big { fill: var(--text); font: 800 1.5rem var(--font-display); }
.athlete-donut__small { fill: var(--muted); font: 500 .6875rem var(--font-body); }

/* The colours of the chart parts and their legend keys. */
.athlete-c-win { stroke: var(--athlete-win); background: var(--athlete-win); }
.athlete-c-loss { stroke: var(--athlete-loss); background: var(--athlete-loss); }
.athlete-c-draw { stroke: var(--athlete-draw); background: var(--athlete-draw); }
.athlete-c-1 { stroke: var(--brand); background: var(--brand); }
.athlete-c-2 { stroke: var(--st-done-fg); background: var(--st-done-fg); }
.athlete-c-3 { stroke: var(--st-ok-fg); background: var(--st-ok-fg); }
.athlete-c-4 { stroke: var(--st-info-fg); background: var(--st-info-fg); }
.athlete-c-5 { stroke: var(--faint); background: var(--faint); }

.athlete-legend { display: grid; gap: var(--sp-1); margin: 0; padding: 0; list-style: none; font-size: var(--fs-md); min-width: 0; flex: 1; }
.athlete-legend li { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; overflow-wrap: anywhere; }
.athlete-legend b { margin-left: auto; padding-left: var(--sp-2); }
.athlete-key { flex: none; width: 10px; height: 10px; border-radius: 2px; }

.athlete-bars { display: grid; gap: var(--sp-2); }
.athlete-bar { display: grid; grid-template-columns: minmax(0, 7rem) minmax(0, 1fr) 2rem; align-items: center; gap: var(--sp-2); font-size: var(--fs-md); }
.athlete-bar__label { overflow-wrap: anywhere; }
.athlete-bar__track { display: block; width: 100%; height: 10px; border-radius: 5px; overflow: hidden; background: var(--surface-3); }
.athlete-bar__fill { fill: var(--athlete-win); }
.athlete-bar b { text-align: right; }

.athlete-medals { display: flex; gap: var(--sp-3); align-items: flex-end; }
.athlete-medals__item { flex: 1; display: grid; justify-items: center; gap: var(--sp-1); }
.athlete-medals__item .medal { width: 46px; height: 46px; font-size: 1.375rem; }
.athlete-medals__item small { color: var(--muted); font-size: var(--fs-sm); }

/* The tabs: hidden without script; with script one panel shows. A tab keeps the house focus ring (base.css, 3px with a
   3px offset), as the .tabs links do: the tab row scrolls sideways, so it has 8px of padding on every side for the ring,
   and the negative top and bottom margins keep the tabs where they were. The rule under the tabs is a 1px --line
   drawn at the bottom of the content box (as .tabs--ruled), so it stays under the tabs. */
.athlete-tabs { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); min-width: 0; }
.athlete-tabs__list { display: none; gap: 2px; margin: calc(var(--sp-2) * -1) 0; padding: var(--sp-2); background: linear-gradient(var(--line), var(--line)) left 0 bottom var(--sp-2) / 100% 1px no-repeat; overflow-x: auto; }
html.js .athlete-tabs__list { display: flex; }
.athlete-tabs__tab { display: inline-flex; align-items: center; gap: var(--sp-1); min-height: var(--tap); padding: var(--sp-3) var(--sp-3) var(--sp-2); border: 0; border-bottom: 3px solid transparent; background: none; color: var(--muted); font: 700 var(--fs-md)/1 var(--font-display); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; cursor: pointer; }
.athlete-tabs__tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--brand); }
.athlete-tabs__count { color: var(--faint); font: 600 var(--fs-xs) var(--font-body); }
.athlete-panel { padding: var(--sp-3) var(--sp-4); min-width: 0; }
.athlete-panel + .athlete-panel { border-top: 1px solid var(--line); }
.athlete-panel__title { margin: 0 0 var(--sp-3); font: 700 var(--fs-lg)/1.2 var(--font-display); text-transform: uppercase; letter-spacing: .03em; }
html.js .athlete-panel { border-top: 0; }
html.js .athlete-panel:not(.is-active) { display: none; }
html.js .athlete-panel__title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.athlete-empty { margin: 0; padding: var(--sp-4) 0; color: var(--muted); }

/* The Borbe tab: years, tournaments, categories. */
.athlete-year { margin: var(--sp-4) 0 var(--sp-2); font: 800 var(--fs-xl)/1 var(--font-display); color: var(--text-2); }
.athlete-year:first-of-type { margin-top: 0; }
.athlete-tour { margin-bottom: var(--sp-3); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.athlete-tour__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-3); padding: var(--sp-2) var(--sp-3); background: var(--surface-2); border-bottom: 1px solid var(--line); }
.athlete-tour__name { margin: 0; font-size: var(--fs-md); font-weight: 700; overflow-wrap: anywhere; }
/* The tournament name link stands alone in its heading, so it is a 24px target (44px on touch), as .solo-link. */
.athlete-tour__name a { display: inline-flex; align-items: center; min-height: 24px; max-width: 100%; }
.athlete-tour__meta { display: inline-flex; align-items: center; gap: var(--sp-1); color: var(--muted); font-size: var(--fs-sm); }

.athlete-cat { border-bottom: 1px solid var(--line); }
.athlete-cat:last-child { border-bottom: 0; }
.athlete-cat__head { display: flex; align-items: center; gap: var(--sp-2) var(--sp-3); padding: var(--sp-2) var(--sp-3); }
.athlete-cat__place { flex: none; display: inline-grid; place-items: center; width: 28px; }
.athlete-cat__none { color: var(--faint); }
.athlete-cat__name { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.athlete-cat__rec { color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; }
.athlete-cat__empty { margin: 0; padding: 0 var(--sp-3) var(--sp-2); color: var(--muted); font-size: var(--fs-sm); }

/* The button frame is --control-border, the 3:1 edge of every button (the mockup's --line-strong is a hairline). */
.athlete-path-toggle { display: none; align-items: center; gap: var(--sp-1); min-height: 30px; padding: var(--sp-1) var(--sp-2); border: 1px solid var(--control-border); border-radius: var(--r-md); background: var(--surface); color: var(--text); font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; cursor: pointer; }
html.js .athlete-path-toggle { display: inline-flex; }
.athlete-path-toggle[aria-expanded="true"] { border-color: var(--brand-line); background: var(--brand-tint); }

.athlete-fights { margin: 0; padding: 0 var(--sp-3) var(--sp-2); list-style: none; }
.athlete-fight { display: grid; grid-template-columns: 8rem minmax(0, 1fr) 6rem 6rem; align-items: center; gap: var(--sp-2) var(--sp-3); padding: var(--sp-2) 0; border-top: 1px dashed var(--line); font-size: var(--fs-md); }
.athlete-fight__round { color: var(--muted); font-size: var(--fs-sm); }
.athlete-fight__opp { min-width: 0; overflow-wrap: anywhere; }
.athlete-fight__opp small, .athlete-fight__kind small { display: flex; align-items: center; gap: var(--sp-1); color: var(--muted); font-size: var(--fs-xs); }
.athlete-fight__kind { text-align: right; font-size: var(--fs-sm); }
.athlete-fight__kind small { justify-content: flex-end; }
.athlete-res { justify-self: start; display: inline-block; padding: var(--sp-1) 7px; border-radius: var(--r-sm); font: 700 var(--fs-sm)/1 var(--font-display); text-transform: uppercase; letter-spacing: .03em; }
.athlete-res--win { color: var(--athlete-win); background: var(--athlete-win-bg); }
.athlete-res--loss { color: var(--athlete-loss); background: var(--athlete-loss-bg); }
.athlete-res--draw { color: var(--athlete-draw); background: var(--athlete-draw-bg); }

/* The path through the draw: open without script; with script open only while its category is open (the fight list
   then hides). One row with arrows on a wide screen, stacked on a phone. */
.athlete-path { padding: var(--sp-1) var(--sp-3) var(--sp-3); }
html.js .athlete-cat:not(.is-open) .athlete-path { display: none; }
html.js .athlete-cat.is-open .athlete-fights { display: none; }
.athlete-path__steps { display: flex; align-items: stretch; gap: 22px; margin: 0; padding: 0 0 var(--sp-1); list-style: none; overflow-x: auto; }
.athlete-step { position: relative; flex: none; display: grid; align-content: start; gap: var(--sp-1); min-width: 150px; max-width: 220px; padding: var(--sp-2) var(--sp-3); border: 1px solid var(--line); border-left: 3px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface-2); }
.athlete-step--win { border-left-color: var(--athlete-win); }
.athlete-step--loss { border-left-color: var(--athlete-loss); }
.athlete-step--place { min-width: 96px; place-items: center; text-align: center; border-left-width: 1px; border-style: dashed; }
.athlete-step + .athlete-step::before { content: ""; position: absolute; left: -20px; top: 50%; width: 16px; height: 2px; background: var(--connector, var(--line-strong)); }
.athlete-step + .athlete-step::after { content: ""; position: absolute; left: -9px; top: calc(50% - 4px); border: 5px solid transparent; border-left-color: var(--connector, var(--line-strong)); border-right: 0; }
.athlete-step__round { color: var(--muted); font: 700 var(--fs-xs)/1 var(--font-display); text-transform: uppercase; letter-spacing: .05em; }
.athlete-step__opp { font-weight: 600; overflow-wrap: anywhere; }
.athlete-step__res { font-size: var(--fs-sm); }
.athlete-path__foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--sp-2); margin-top: var(--sp-2); color: var(--muted); font-size: var(--fs-sm); }
.athlete-path__foot a { display: inline-flex; align-items: center; }

/* The Turniri table and the Medalje cards. */
.athlete-table { width: 100%; }
.athlete-table th[scope="row"] { font-weight: 600; overflow-wrap: anywhere; }
.athlete-table__place { text-align: center; }
.athlete-table td .flag { margin-right: var(--sp-1); vertical-align: -2px; }
.athlete-medal-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: var(--sp-2); margin: 0; padding: 0; list-style: none; }
.athlete-medal-card { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.athlete-medal-card b { display: block; overflow-wrap: anywhere; }
.athlete-medal-card small { color: var(--muted); font-size: var(--fs-sm); }

@media (max-width: 1100px) {
  .athlete-charts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .athlete-meta + .athlete-meta { margin-left: 0; }
  .athlete-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .athlete-strip__item:nth-child(3) { border-right: 0; }
  .athlete-strip__item:nth-child(n + 4) { border-top: 1px solid var(--line); }
  .athlete-charts { grid-template-columns: minmax(0, 1fr); }
  .athlete-panel { padding: var(--sp-3); }
  .athlete-cat__head { flex-wrap: wrap; }
  .athlete-path-toggle { min-width: var(--tap); min-height: var(--tap); justify-content: center; }
  .athlete-path-toggle__text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .athlete-fight { grid-template-columns: minmax(0, 1fr) auto; }
  .athlete-fight__round { grid-column: 1 / -1; }
  .athlete-fight__kind { grid-column: 1 / -1; text-align: left; }
  .athlete-fight__kind small { display: inline; margin-left: var(--sp-2); }
  .athlete-path__steps { flex-direction: column; gap: 14px; overflow-x: visible; }
  .athlete-step, .athlete-step--place { min-width: 0; max-width: none; }
  .athlete-step--place { justify-items: start; text-align: left; }
  .athlete-step + .athlete-step::before { left: 20px; top: -13px; width: 2px; height: 10px; }
  .athlete-step + .athlete-step::after { left: 16px; top: -5px; border: 5px solid transparent; border-top-color: var(--connector, var(--line-strong)); border-bottom: 0; }
  .athlete-table__wide { display: none; }
  .athlete-path__foot a { min-height: var(--tap); }
}

@media (pointer: coarse) {
  .athlete-path-toggle { min-height: var(--tap); }
  .athlete-tour__name a { min-height: var(--tap); }
  .athlete-path__foot a { min-height: var(--tap); }
}

@media (forced-colors: active) {
  .athlete-donut__ring { stroke: GrayText; }
  .athlete-bar__fill { fill: CanvasText; }
  .athlete-key { forced-color-adjust: none; }
  .athlete-tabs__tab[aria-selected="true"] { border-bottom-color: Highlight; }
}
