/* Scoreboard redesign, task T5: the read-only draw of one category (Views/Shared/Sb/Draw). It builds on the bracket,
   match, side, legend, round tabs and round-robin rules of sb/components.css (hand-off components.html #fights) and adds
   what every draw format needs: the column heights as classes (rows-N, never a style attribute), the boxes whose lines
   js/sb/draw.js draws in an <svg> (losers bracket, repechage, finals, a graph without a diagram), the source line of a
   side, the seed, the dropout mark, the head states of StateBadges.For(MatchStatus), the jump bar, the pool cards and the
   score rounds tables. Every colour is a token of sb/tokens.css. */

.draw { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }
.draw__legend { align-items: center; }
.draw__hint { margin: 0; }
.draw .side__dot { box-shadow: 0 0 0 1px var(--line-strong); }

/* ---------- One part of a draw: a bracket box with its heading ---------- */
.draw-part { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; scroll-margin-top: calc(var(--app-header-bottom, 0px) + var(--sp-4)); }
.draw-part__title { margin: 0; font: 800 var(--fs-xl)/1.1 var(--font-display); letter-spacing: .03em; text-transform: uppercase; }
.draw-part > .help { margin: 0; }

/* The number of fight places of the tallest round. */
.bracket.rows-1 { --rows: 1; }
.bracket.rows-2 { --rows: 2; }
.bracket.rows-4 { --rows: 4; }
.bracket.rows-8 { --rows: 8; }
.bracket.rows-16 { --rows: 16; }
.bracket.rows-32 { --rows: 32; }
.bracket.rows-64 { --rows: 64; }
.bracket.rows-128 { --rows: 128; }
.bracket.rows-256 { --rows: 256; }

.round__title { margin: 0; }
.round__note { margin: 0 0 var(--sp-2); }

/* A box of lines: the cards keep their places (space-around, as the pairs of a tree) and the top padding of each round
   holds one 6px lane per line that skips a round (--draw-lanes, written by js/sb/draw.js). The <svg> sits under the cards. */
.bracket--lines { position: relative; }
/* A tree with a third-place fight: its <svg> holds only the dashed loser lines from the semifinals to that fight. */
.bracket--bronze-lines { position: relative; }
.bracket--lines .round__body { justify-content: space-around; padding-top: calc(8px + var(--draw-lanes, 3) * 6px); }
.bracket__lines { position: absolute; top: 0; left: 0; overflow: visible; pointer-events: none; z-index: 0; }
.bracket__lines path { fill: none; stroke: var(--connector-strong); stroke-width: 2; }
.bracket__lines path.is-loser { stroke-dasharray: 6 4; }
.bracket .match { position: relative; z-index: 1; }
/* Guide walkthrough F53 (option A): the compact card is about 96px (a 24px head, two 34px sides with their 1px lines,
   the card border), so it fits its fight place of 86 + 18 = 104px. On a fine pointer a card never grows taller than its
   place: every long text (state, club, source, score) is cut with "...". The cards keep their own height. In a tree
   each card sits in the middle of its half of the pair (grid rows), so the CSS connectors at a quarter and three
   quarters of the pair meet the middle of each card whatever its height. The one column is the whole width of the
   round: without it the justify-content of the hand-off .pair (space-around) would size the column to its cards and
   centre it, so a card would not reach the connector at the edge of the round. */
.draw .bracket { --match-h: 86px; }
/* A touch screen keeps the 44px tap floor of the fight number, the result button and the source links, so it keeps the
   taller place of 176 + 18px. The phone rules below (no fixed round height) stay as they are. */
@media (pointer: coarse) and (min-width: 761px) {
  .draw .bracket { --match-h: 176px; }
}
.draw .bracket .match { height: auto; }
.draw .bracket--tree .pair { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(2, minmax(0, 1fr)); align-items: center; }
.draw .bracket--tree .pair--single { grid-template-rows: minmax(0, 1fr); }

/* The scroll boxes are tab stops (keyboard scrolling), so their edge is a control edge. */
.draw .bracket-box, .draw .table-wrap { border-color: var(--control-border); }

/* ---------- The fight card ---------- */
.draw .match { overflow: visible; }
/* F53 option A: one 24px head line holds the number, the planned time, the state and the result button; no foot. */
.draw .match__head { height: 24px; gap: 6px; padding: 0 8px; min-width: 0; border-radius: var(--r-md) var(--r-md) 0 0; }
.match__number { display: inline-flex; align-items: center; min-width: 24px; min-height: 24px; font: 700 14px/1 var(--font-display); letter-spacing: .03em; }
/* The number and the time keep their full width; only the state text is cut. */
.draw .match__head .match__number, .draw .match__head time { flex: none; }
/* Guide walkthrough F149: a draw bye of a tournament without fight numbers has no number. Its link keeps the 24px target
   and shows a short muted line in place of the number, so the box still reads as the fight's link. */
.match__number--none { justify-content: center; }
.match__number--none::before { content: ""; width: 10px; border-top: 2px solid var(--muted); }
/* Region: match time. Guide walkthrough F147 (mockup round-25/mockups/f147.html, style A): the public time of a fight
   stands right after its number behind a thin divider ("Tatami 1-003 | 10:58"), in tabular figures; no plan time or
   delay next to it. */
.draw .match__head .match__time { padding-left: 6px; border-left: 1px solid var(--line-strong); color: var(--text-2); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* The same time after the number of a card on the public Fights page and in the Time column of By fight number. */
.fight__start { margin-left: 6px; padding-left: 6px; border-left: 1px solid var(--line-strong); color: var(--text-2); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dft__time { font-weight: 700; white-space: nowrap; }
/* End region: match time. */
.match.is-target, .match:target { box-shadow: 0 0 0 3px var(--brand-line); }
/* The state of the fight at the right of the head (StateBadges.For(MatchStatus)); its title holds the full text. */
.match__status { margin-left: auto; min-width: 0; display: inline-flex; align-items: center; gap: 3px; color: var(--muted); font: 700 var(--fs-xs)/1 var(--font-body); letter-spacing: .05em; text-transform: uppercase; }
.match__state { min-width: 0; padding: 0; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.match__btn { margin-left: auto; display: inline-flex; align-items: center; min-height: 24px; color: var(--brand-text); font-weight: 700; text-decoration: none; }
.match__head .match__btn { flex: none; margin-left: 0; }
.match__btn:hover { text-decoration: underline; }
/* On a touch screen the head grows to the 44px tap floor of the number and the result button. */
@media (pointer: coarse) {
  .draw .match__head { height: auto; min-height: var(--tap); }
  .draw .match__number, .draw .match__btn { min-height: var(--tap); }
}
.draw .side { gap: var(--sp-1); }
/* F53 option A: a side has two lines: the name in row 1; the club (with the flag) or the source in row 2 left, a score
   in row 2 right. */
.draw .match .side { height: auto; min-height: 34px; padding: 0 8px; }
.draw .match .side__text { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, auto); column-gap: 4px; align-content: center; }
.draw .match .side__name { grid-column: 1 / -1; line-height: 1.2; }
.draw .match .side__club, .draw .match .side__src, .draw .match .side__score { line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* A source link keeps its 24px target but takes only one text line of the card: the target reaches 4px into the name
   above and the side padding below. A touch screen keeps the full 44px link, and the phone rules below keep theirs. */
@media (pointer: fine) and (min-width: 761px) {
  .draw .match a.side__src { display: block; min-height: 24px; margin-block: -4px; padding-block: 4px; line-height: 16px; }
}
/* F51: the flag of the competitor's country before the club name, drawn 16x12 (the img attributes keep 20x15 as on the
   Registered tab). base.css draws every img as a block, which put the flag on a line of its own above the club and made
   a side about 10px taller than its 34px, so the card no longer fit its 104px place. The flag is an inline block in the
   club line. */
.side__flag { display: inline-block; width: 16px; height: 12px; margin-right: 4px; vertical-align: -1px; }
/* In the compact card the flag hangs from the top of the club line (1px down), so its 13px never makes the 14.4px line
   (12px at line-height 1.2) taller, whatever the font. */
.draw .match .side__flag { margin-top: 1px; vertical-align: top; }
/* F50: the line number of a first-round side at the right edge (organizer and administrator draws page). order: 1
   keeps it at the right edge even after a swap appends the moved nodes after it (js/sb/backoffice.js). */
.side__line { order: 1; flex: none; min-width: 16px; text-align: right; color: var(--muted); font: 600 var(--fs-xs)/1 var(--font-body); font-variant-numeric: tabular-nums; }
/* F109 (mockup round-18/f109-mockups/seed-lines.html, option A) and F113: the seed place badge of every first-round side
   at its left, an empty side too, the same colours in both themes (tokens.css, --seed-place-*): 1-4 strong, 5-8 light,
   9 and up neutral. In forced colours it keeps a 1px border in the text colour, as the badges of components.css do. */
.seed-place { flex: none; display: inline-grid; place-items: center; min-width: 26px; height: 18px; padding: 0 4px; border-radius: var(--r-sm); font: 800 var(--fs-xs)/1 var(--font-body); font-variant-numeric: tabular-nums; }
.seed-place--strong { background: var(--seed-place-strong-bg); color: var(--seed-place-strong-ink); }
.seed-place--light { background: var(--seed-place-light-bg); color: var(--seed-place-light-ink); }
.seed-place--grey { background: var(--seed-place-grey-bg); color: var(--seed-place-grey-ink); }
/* F113: on an editable draft a side with a competitor starts with its 24px grip (backoffice.css .grip); an empty side
   (a bye) has none, so it keeps that room here and its badge stands in the same column. A swap moves the grip to the
   empty side (js/sb/backoffice.js), and the room follows it. */
.draw .side[data-pos]:has(> [data-side-seed-place]):not(:has(> .grip))::before { content: ""; flex: none; width: 24px; }
@media (forced-colors: active) {
  .seed-place { border: 1px solid CanvasText; }
}
/* The competitor highlight: hover or tap (is-hl, js/sb/portal.js), the competitor of the address (is-chosen, guide
   walkthrough F175) and the two competitors of a fight number with focus (is-focus-hl, js/sb/draw.js). */
.draw .side.is-hl, .draw .side.is-chosen, .draw .side.is-focus-hl { outline: 2px solid var(--brand-line); outline-offset: -2px; background: var(--brand-tint); }
/* Region: winner look. Guide walkthrough F177 (Marko, 2026-10-27, mockup round-31/mockups/f177.html V4 + Z5): the winner
   side of a fight card has a green fill (--win-bg), a 4px green bar on the left and a bold name; the crown at its right
   edge is the winner sign (components.css, region "Winner crown and draw icon"). The loser name is muted at normal
   weight. A club's own winner keeps its club tint under the green. The chosen or highlighted competitor keeps its orange
   frame and tint; when it won, the green lies over the orange tint and the green bar is 6px, inside the orange frame
   (the outline is drawn over the inset bar). In forced colours the fills go; the crown stays. */
.draw .match .side--win { background: var(--win-bg); box-shadow: inset 4px 0 0 var(--win-line); }
.draw .match .side--win .side__name { font-weight: 700; }
.draw .match .side--lose .side__name { color: var(--muted); font-weight: 500; }
.draw .match .side--win.is-mine { background: linear-gradient(var(--win-bg), var(--win-bg)), var(--brand-tint-2); }
.draw .match .side--win:is(.is-hl, .is-chosen, .is-focus-hl) { background: linear-gradient(var(--win-bg), var(--win-bg)), var(--brand-tint); box-shadow: inset 6px 0 0 var(--win-line); }
/* End region: winner look. */
.side__score { font-size: var(--fs-xs); color: var(--text-2); overflow-wrap: anywhere; }
.side__src { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
a.side__src { display: inline-flex; align-items: center; min-height: 24px; color: var(--brand-text); text-decoration: none; }
a.side__src:hover { text-decoration: underline; }
/* On every touch screen a source link is a 44px target; the phone rule below sets the same floor. */
@media (pointer: coarse) { a.side__src { min-height: var(--tap); } }
.side__photo { flex: none; width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: var(--surface-3); }
.seed { flex: none; display: inline-grid; place-items: center; min-width: 24px; height: 20px; padding: 0 4px; border: 1px solid var(--line); border-radius: var(--r-sm); color: var(--text-2); font: 700 var(--fs-xs)/1 var(--font-body); }
.side__out { flex: none; padding: 2px 6px; border-radius: var(--r-sm); background: var(--st-bad-bg); color: var(--st-bad-fg); font: 700 var(--fs-xs)/1.2 var(--font-body); }
/* Forced colours (final round A9): the "out of the draw" chip keeps a 1px border in the text colour, as the badges of
   components.css do; inside a link it takes the link's forced colour. Normal mode does not change. */
@media (forced-colors: active) {
  .side__out { border: 1px solid CanvasText; }
  :any-link .side__out { border-color: currentColor; color: inherit; }
}
.side--out .side__name { text-decoration: line-through; }
.side--bye .side__name { color: var(--muted); font-style: italic; }

/* A side that takes a loser from another part of the draw: a dashed line comes in from the left. */
.side--enter { position: relative; }
.side--enter::before { content: ""; position: absolute; left: -22px; top: 50%; width: 20px; border-top: 2px dashed var(--connector-strong); }

/* The state in the head: the tone and the symbol of StateBadges.For(MatchStatus). */
.match__status--ok { color: var(--st-ok-fg); }
.match__status--warn { color: var(--st-warn-fg); }
.match__status--bad { color: var(--st-bad-fg); }
.match__status--live { color: var(--st-live-fg); }
.match__status--neutral, .match__status--closed { color: var(--muted); }
.match__status--sym-check::before { content: "\2713"; content: "\2713" / ""; }
.match__status--sym-circle::before { content: "\25CB"; content: "\25CB" / ""; }
.match__status--sym-clock::before { content: "\25F7"; content: "\25F7" / ""; }
.match__status--sym-barred::before { content: "\2298"; content: "\2298" / ""; }
.match__status--sym-equal::before { content: "="; content: "=" / ""; }
.match__status--sym-cross::before { content: "\2715"; content: "\2715" / ""; }
.match__status--sym-pulse::before { content: "\25CF"; content: "\25CF" / ""; }

/* ---------- The jump bar of a draw with three or more parts ---------- */
.jump-bar { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.jump-bar a { display: inline-flex; align-items: center; min-height: 36px; padding: 0 var(--sp-3); border: 1px solid var(--control-border); border-radius: var(--r-pill); background: var(--surface); color: var(--text); font-weight: 600; text-decoration: none; }
.jump-bar a:hover { background: var(--surface-2); }

/* ---------- Round-robin pools ---------- */
.draw__pools { display: grid; gap: var(--sp-2); }
.pool { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; padding: var(--sp-5); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--bg-sunken); scroll-margin-top: calc(var(--app-header-bottom, 0px) + var(--sp-4)); }
.pool__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1); }
.pool__title { margin: 0; font: 800 var(--fs-xl)/1.1 var(--font-display); letter-spacing: .03em; text-transform: uppercase; }
.pool__tables { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: var(--sp-2); }
.pool .help { margin: 0; }
.pool__fights-title { margin: var(--sp-2) 0 0; }
.pool__fights { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: var(--sp-1); }
.pool__fights .match { height: auto; min-height: 0; }
.pool__tie-form .fieldset { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--sp-1); }
/* The screen-reader words inside a table that scrolls stay inside its box, so they never widen the page. */
.draw .table-wrap { position: relative; }
.rr__bout { display: block; }
.rr__score { display: block; font-size: var(--fs-xs); font-weight: 500; color: var(--muted); }
.rr__name { font-weight: 600; }
.rr__reasons { display: block; font-size: var(--fs-xs); color: var(--muted); }
.draw .table tr.is-hl th, .draw .table tr.is-hl td, .draw .table tr.is-chosen th, .draw .table tr.is-chosen td { background: var(--brand-tint); }
.draw .table tr.is-out .rr__name { text-decoration: line-through; }
.draw .table th[scope="row"] { color: var(--text); font: 500 var(--fs-md)/1.3 var(--font-body); letter-spacing: 0; text-transform: none; white-space: normal; background: transparent; }

/* ---------- Score rounds ---------- */
.score-round { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }
.score-round__title { margin: 0; font: 800 var(--fs-xl)/1.1 var(--font-display); letter-spacing: .03em; text-transform: uppercase; }
.score-round .help { margin: 0; }
.score-round__cut td { padding: var(--sp-2) var(--cell-px); background: var(--surface-2); color: var(--muted); font-size: var(--fs-sm); font-weight: 600; text-align: center; border-top: 2px dashed var(--connector-strong); }
.score-round__extra { display: block; margin-top: 4px; font-size: var(--fs-xs); color: var(--muted); }
.score-round__marks { display: none; }
.score-round__marks summary { min-height: 24px; cursor: pointer; color: var(--brand-text); font-size: var(--fs-sm); }

/* ---------- The fight dialog ---------- */
.draw-dialog .side { min-height: 44px; padding: 0 var(--sp-2); border-top: 1px solid var(--line); }
.draw-dialog .side__text { display: flex; flex-direction: column; }
.draw-dialog .eyebrow, .draw-dialog .muted { margin: 0; }

/* ---------- Phone: each round is a page of its box ---------- */
@media (max-width: 760px) {
  /* One round is exactly one page of its box: 100% of the box, not 100vw, which counts a classic scrollbar too. */
  .draw .bracket { width: 100%; min-width: 0; }
  /* The box stays inside the page padding, so its focus ring is never cut by the screen edge. Its room above and below
     keeps the focus ring of a fight number or a result button in the head of the first card, and of a source link on
     the last side of the last card, inside the box that scrolls (it clips what leaves it). No room at the sides: each
     round is exactly one page of the box. */
  .draw .bracket-box { margin-inline: 0; padding-block: var(--sp-2); }
  /* A pair is a flex column again; its cards fill the pair up to the connector on the right. */
  .draw .bracket--tree .pair { display: flex; align-items: stretch; }
  .draw .round { flex: 0 0 100%; width: 100%; }
  .bracket__lines { display: none; }
  .bracket--lines .round__body { padding-top: 0; }
  .side--enter::before { display: none; }
  .bracket > .round:only-of-type > .round__title { display: block; margin-bottom: var(--sp-2); }
  .jump-bar a { min-height: var(--tap); }
  .draw .match__head { height: auto; min-height: var(--tap); }
  .match__number, a.side__src, .match__btn { min-height: var(--tap); }
  /* A fight label with a long area name ("Area of the hall 1-012") wraps inside its card instead of running past it: the
     number may shrink down to its 24px target width and break, and the state moves under it, so the number's focus ring
     stays inside the round (the box that scrolls clips what leaves it). */
  .draw .match__head { flex-wrap: wrap; }
  .draw .match__head .match__number { flex: 0 1 auto; min-width: 24px; overflow-wrap: anywhere; }
  .pool { padding: var(--sp-4); margin-inline: calc(var(--page-pad) * -1); border-radius: 0; border-inline: 0; }
}

@media (max-width: 600px) {
  .score-round__judge { display: none; }
  .score-round__marks { display: block; }
  .score-round__marks summary { display: flex; align-items: center; min-height: var(--tap); }
}

/* Guide walkthrough F153: the green notice at the top of the organizer draws page that names the category a single lock or
   generation from the category head has just locked or generated (Views/Draws/Index.cshtml). */
.draws-done { margin-bottom: var(--sp-4); }
