/* WVIZ-850: the league Table tab (block `league-table`).

   Full width with no scroll wrapper: on a phone the stat columns hide
   instead, and the points cell's "N played" line carries the matches
   played. Number sizes are the shared --fs-num* tokens in base.css
   (WVIZ-1060); other literal sizes live here as custom properties. */

.league-table-panel {
  --league-table-stat-w: 54px;
  --league-table-row-h: 56px;
  --league-table-rule: 2px;
}

@media (width >= 1100px) {
  .league-table-panel {
    --league-table-stat-w: 64px;
  }
}

.league-table__section {
  margin-top: var(--space-4);
}

.league-table__heading {
  margin: 0 0 var(--space-2);
  font-family: var(--font-display);
  font-size: var(--fs-h3);
}

.league-table__no-data {
  padding: var(--space-12) var(--space-4);
  color: var(--color-text-muted);
  font-size: var(--fs-body);
  text-align: center;
}

.league-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.league-table__caption {
  padding-bottom: var(--space-2);
  color: var(--color-text-muted);
  font-size: var(--fs-caption);
  text-align: left;
  caption-side: top;
}

.league-table__th {
  padding: var(--space-2) var(--space-1);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: var(--fs-caption);
  font-weight: var(--fw-semibold);
  text-align: right;
}

.league-table__th--pos {
  width: 48px;
  text-align: center;
}

.league-table__th--club {
  text-align: left;
}

.league-table__th--stat {
  width: var(--league-table-stat-w);
}

.league-table__th--points {
  width: 88px;
}

.league-table__row {
  height: var(--league-table-row-h);
  border-bottom: 1px solid var(--color-border);
}

.league-table__club--focus .league-table__row {
  background: color-mix(in srgb, var(--color-home) 14%, transparent);
  box-shadow: inset 3px 0 0 var(--color-home);
}

.league-table__pos {
  padding: var(--space-1);
  text-align: center;
}

.league-table__big {
  display: block;
  font-family: var(--font-display);
  font-size: var(--fs-num-focus);
  font-weight: var(--fw-bold);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.league-table__club-cell {
  padding: var(--space-2) var(--space-1);
  font-weight: normal;
  text-align: left;
}

.league-table__club-line {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.league-table__crest {
  flex: none;
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.league-table__club-link {
  display: inline-flex;
  align-items: center;
  min-height: var(--hit-min);
  font-size: var(--fs-body);
  font-weight: var(--fw-semibold);
}

.league-table__form {
  display: flex;
  gap: var(--space-1);
  margin-top: var(--space-1);
}

.league-table__chip {
  font-size: var(--fs-micro);
}

.league-table__stat {
  width: var(--league-table-stat-w);
  padding: var(--space-1);
  font-family: var(--font-display);
  font-size: var(--fs-num);
  font-weight: var(--fw-bold);
  text-align: right;
}

.league-table__points {
  padding: var(--space-1) var(--space-2) var(--space-1) var(--space-1);
  text-align: right;
}

.league-table__secondary {
  display: block;
  margin-top: var(--space-1);
  color: var(--color-text-muted);
  font-size: var(--fs-caption);
  white-space: nowrap;
}

/* A race line: the label above a 2px rule, across the whole table. */
.league-table__cutoff td {
  padding: var(--space-2) var(--space-1) var(--space-1);
  border-bottom: var(--league-table-rule) solid var(--color-text-muted);
  color: var(--color-text-muted);
  font-size: var(--fs-caption);
  text-align: left;
}

/* Lenses (Points / PPG / In hand / Goals). The table's data-lens picks which
   [data-lens-value] elements show; the rest are display:none, so a screen
   reader hears the visible lens only. */
.league-table__lenses {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.league-table__lens {
  min-height: var(--hit-touch);
  padding: var(--space-1) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: none;
  color: var(--color-text-muted);
  font-size: var(--fs-body-sm);
  font-weight: var(--fw-semibold);
  cursor: pointer;
}

.league-table__lens[aria-pressed="true"] {
  border-color: var(--color-text);
  background: var(--color-surface-raised);
  color: var(--color-text);
}

.league-table[data-lens="points"] [data-lens-value]:not([data-lens-value="points"]),
.league-table[data-lens="ppg"] [data-lens-value]:not([data-lens-value="ppg"]),
.league-table[data-lens="in-hand"] [data-lens-value]:not([data-lens-value="in-hand"]),
.league-table[data-lens="goals"] [data-lens-value]:not([data-lens-value="goals"]) {
  display: none;
}

.league-table:not([data-lens="points"]) .league-table__cutoff {
  display: none;
}

.league-table__vs {
  display: block;
  color: var(--color-text-muted);
  font-size: var(--fs-caption);
  white-space: nowrap;
}

.league-table__note td {
  padding: var(--space-2) var(--space-1);
  color: var(--color-text-muted);
  font-size: var(--fs-caption);
}

/* The drill-down. A tap anywhere on a club's row opens its detail row; the
   toggle is the keyboard path. */
.league-table[data-drilldown] .league-table__row {
  cursor: pointer;
}

.league-table__th--toggle {
  width: var(--hit-touch);
}

.league-table__toggle-cell {
  padding: 0;
  text-align: center;
}

.league-table__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--hit-touch);
  min-height: var(--hit-touch);
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
}

.league-table__toggle:focus-visible {
  outline: 2px solid var(--color-link);
  outline-offset: -2px;
}

.league-table__chevron {
  transition: transform 0.15s ease;
}

.league-table__toggle[aria-expanded="true"] .league-table__chevron {
  transform: rotate(180deg);
}

/* Before league-table.js has run, show only the page's own club's detail
   row, so the others do not flash open. Without JavaScript the class is
   never set and every detail row shows. */
html.js-site-menu [data-league-table]:not([data-league-table-init]) .league-table__club:not(.league-table__club--focus) .league-table__detail {
  display: none;
}

/* No raised fill: the status colours of the tiles and badges keep 4.5:1
   only on the page's own background. */
.league-table__detail td {
  padding: var(--space-3) var(--space-2) var(--space-4) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.league-table__detail-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  font-size: var(--fs-body-sm);
}

.league-table__scenario {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  margin: 0;
}

.league-table__place,
.league-table__scenario-text {
  font-weight: var(--fw-semibold);
}

.league-table__badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  font-size: var(--fs-micro);
  font-weight: var(--fw-semibold);
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.league-table__badge--shield {
  background: color-mix(in srgb, var(--color-status-highlight) 15%, transparent);
  color: var(--color-status-highlight);
}

.league-table__badge--line-1 {
  background: color-mix(in srgb, var(--color-status-positive) 15%, transparent);
  color: var(--color-status-positive);
}

.league-table__badge--line-2 {
  background: color-mix(in srgb, var(--color-status-info) 15%, transparent);
  color: var(--color-status-info);
}

.league-table__badge--eliminated {
  background: color-mix(in srgb, var(--color-status-negative) 15%, transparent);
  color: var(--color-status-negative);
}

/* WVIZ-540 / WVIZ-775: out of that line only, struck through and neutral. */
.league-table__badge--eliminated-partial {
  background: color-mix(in srgb, var(--color-text-muted) 15%, transparent);
  color: var(--color-text-muted);
  text-decoration-line: line-through;
  text-decoration-thickness: 1.5px;
  text-decoration-skip-ink: none;
}

.league-table__tiles {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.league-table__tile {
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* The sign is in the text, so colour is not the only cue. */
.league-table__tile--positive {
  color: var(--color-status-positive);
}

.league-table__tile--negative {
  color: var(--color-status-negative);
}

.league-table__tile--zero {
  color: var(--color-text-muted);
}

.league-table__odds-line {
  margin: 0;
}

.league-table__odds-line + .league-table__odds-line {
  margin-top: var(--space-1);
}

.league-table__odds-line--stale {
  color: var(--color-text-muted);
  font-size: var(--fs-caption);
}

.league-table__detail-label {
  margin: 0 0 var(--space-1);
  color: var(--color-text-muted);
  font-size: var(--fs-caption);
  font-weight: var(--fw-semibold);
}

.league-table__matches {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.league-table__match {
  font-variant-numeric: tabular-nums;
}

.league-table__match-crest {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
  object-fit: contain;
}

.league-table__match .watch {
  display: block;
  color: var(--color-text-muted);
  font-size: var(--fs-caption);
}

.league-table__detail-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin: 0;
}

.league-table__detail-link {
  display: inline-flex;
  align-items: center;
  min-height: var(--hit-min);
  font-weight: var(--fw-semibold);
}

.league-table__terms {
  margin: var(--space-2) 0 0;
  color: var(--color-text-muted);
  font-size: var(--fs-caption);
}

@media (width <= 640px) {
  .league-table__th--stat,
  .league-table__stat {
    display: none;
  }
}

.league-table__subtitle {
  margin: 0 0 var(--space-3);
  color: var(--color-text-muted);
  font-size: var(--fs-caption);
}

/* WVIZ-857: the Odds path, one club's Sankey in its drill-down. odds-path.js
   sets --odds-path-win to the club's colour, on the block, through `style`.

   Width 0 then min-width 100% keeps the chart out of the table's column
   sizing, so a wide chart scrolls in its own box instead of widening the
   table. */
.odds-path {
  --odds-path-win-opacity: 0.85;
  --odds-path-draw-opacity: 0.6;
  --odds-path-loss-opacity: 0.25;
  --odds-path-swatch: 12px;

  position: relative;
  width: 0;
  min-width: 100%;
}

/* WVIZ-889: above a tablet the block runs past the drill-down cell's padding
   (.league-table__detail td) to the table's full width. */
@media (width > 768px) {
  .odds-path {
    margin-inline: calc(-1 * var(--space-4)) calc(-1 * var(--space-2));
    min-width: calc(100% + var(--space-4) + var(--space-2));
  }
}

/* High contrast: the win, draw and loss bands stand 3:1 off the page in dark
   and light (the standard 0.85 leaves some club colours under it, and 0.6 and
   0.25 read 1.5:1 for loss), still apart from each other. The key swatches
   share the rule, so they follow. */
html[data-contrast="high"] .odds-path {
  --odds-path-win-opacity: 1;
  --odds-path-draw-opacity: 0.95;
  --odds-path-loss-opacity: 0.65;
}

/* WVIZ-869: the switch between Rest of season and Whole season. */
.odds-path__views {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-block-end: var(--space-2);
}

.odds-path__view {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: var(--fs-body-sm);
  font-weight: var(--fw-semibold);
  min-height: var(--hit-touch);
  padding: var(--space-1) var(--space-4);
}

.odds-path__view[aria-pressed="true"] {
  background: var(--color-surface-raised);
  border-color: var(--color-text);
  color: var(--color-text);
}

.odds-path__summary {
  margin-block: 0 var(--space-2);
  color: var(--color-text);
  font-size: var(--fs-body-sm);
}

/* The fade is decoration on the frame around the scroller: it says there is
   more to the right, in the page background so every theme and contrast mode
   is right. It takes no pointer events and adds no size. */
.odds-path__frame {
  position: relative;
}

.odds-path__frame::after {
  content: "";
  position: absolute;

  /* Inside the scroller's 2px focus ring, which it must not cover. */
  inset: 2px 2px 2px auto;
  width: 48px;
  background: linear-gradient(to right, transparent, var(--color-bg));
  opacity: 0;
  pointer-events: none;
}

.odds-path__frame--more::after {
  opacity: 1;
}

.odds-path__scroller {
  overflow-x: auto;
}

.odds-path__scroller:focus-visible {
  outline: 2px solid var(--color-link);
  outline-offset: -2px;
}

.odds-path__chart {
  display: block;
  color: var(--color-text);
}

/* A band and its key swatch share one rule, so the key cannot drift from the
   chart in any theme or contrast mode. */
.odds-path__band--win,
.odds-path__swatch--win {
  background-color: var(--odds-path-win);
  opacity: var(--odds-path-win-opacity);
  fill: var(--odds-path-win);
}

.odds-path__band--draw,
.odds-path__swatch--draw {
  background-color: var(--color-text-muted);
  opacity: var(--odds-path-draw-opacity);
  fill: var(--color-text-muted);
}

.odds-path__band--loss,
.odds-path__swatch--loss {
  background-color: var(--color-text-muted);
  opacity: var(--odds-path-loss-opacity);
  fill: var(--color-text-muted);
}

.odds-path__node {
  fill: var(--color-text);
}

/* WVIZ-869: columns not played yet show the opening-day forecast, not today's.
   Marks only: their labels stay at full contrast. */
.odds-path__ahead {
  opacity: 0.45;
}

html[data-contrast="high"] .odds-path__ahead {
  opacity: 0.8;
}

/* What happened: set apart by weight and rings, the halo lifting it off the
   bands in every theme. */
.odds-path__settled,
.odds-path__settled-halo {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.odds-path__settled {
  stroke: var(--color-text);
  stroke-width: 3;
}

.odds-path__settled-halo {
  stroke: var(--color-bg);
  stroke-width: 7;
}

.odds-path__ring {
  fill: var(--color-bg);
  stroke: var(--color-text);
  stroke-width: 2;
}

.odds-path__now {
  stroke: var(--color-text);
  stroke-dasharray: 4 4;
  stroke-width: 1;
}

.odds-path__now-word {
  fill: currentcolor;
  font-family: var(--font-display);
  font-size: var(--fs-micro);
  font-weight: var(--fw-bold);
}

.odds-path__node--final {
  fill: var(--odds-path-win);
}

.odds-path__total,
.odds-path__head,
.odds-path__odds {
  fill: currentcolor;
  font-family: var(--font-display);
  font-size: var(--fs-micro);
}

.odds-path__total,
.odds-path__head {
  font-weight: var(--fw-bold);
}

.odds-path__swatch-line {
  display: inline-block;
  width: var(--odds-path-swatch);
  height: 3px;
  background-color: var(--color-text);
}

.odds-path__total--final {
  font-size: var(--fs-caption);
}

/* A node total sits on the bands that feed it, so any club colour can be
   behind it. The halo in the page background keeps it readable; the final
   labels sit clear of the bands, to the right of the last node. */
.odds-path__total:not(.odds-path__total--final) {
  paint-order: stroke;
  stroke: var(--color-bg);
  stroke-width: 3px;
  stroke-linejoin: round;
}

.odds-path__head {
  font-size: var(--fs-body-sm);
}

.odds-path__head--tight {
  font-size: var(--fs-micro);
}

.odds-path__foot {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  align-items: center;
  margin-top: var(--space-1);
}

.odds-path__key {
  display: flex;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.odds-path__key-item {
  display: inline-flex;
  gap: var(--space-1);
  align-items: center;
  color: var(--color-text-muted);
  font-size: var(--fs-caption);
}

.odds-path__swatch {
  width: var(--odds-path-swatch);
  height: var(--odds-path-swatch);
  border-radius: 2px;
}

.odds-path__note {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--fs-caption);
}
