/* WVIZ-853: the Stakes tab. Its sections' spacing and headings, then the club
   tiles and sheet, which a mixed root's Scenarios tab draws too. */
.stakes__section {
  margin-top: var(--space-4);
}

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

/* The tiles and the club sheet. --tile-fill and --tile-ink are set per club
   in the element's style (var(--tc-<slug>), var(--tci-<slug>)), so a theme or
   contrast switch repaints with no script. Text sits straight on the fill,
   never on a tint of it: ink only reaches 4.5:1 on the pure colour. */
.stakes-cards {
  --stakes-crest-head: 40px;
  --stakes-crest-row: 26px;
  --stakes-crest-game: 20px;
  --stakes-badge-clinch: #166534;
  --stakes-badge-out: #991b1b;
  --stakes-badge-ink: #fff;

  align-items: start;
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr));
  margin-block: var(--space-4);
}

.stakes-crest {
  align-items: center;
  display: inline-flex;
  flex: none;
  font-size: var(--fs-micro);
  font-weight: 700;
  height: var(--stakes-crest-row, 26px);
  justify-content: center;
  width: var(--stakes-crest-row, 26px);
}

.stakes-crest img {
  height: 100%;
  object-fit: contain;
  width: 100%;
}

/* A club with a crest for each theme: on a club-colour surface the crest
   follows the surface's ink (--tcod / --tcol, set per theme beside --tci),
   not the page theme, so a navy crest never lands on a navy tile. The
   selector outranks chrome.css's per-theme hiding; high contrast sets the
   same variables from its series slot. */
html:root :is(.stakes-tile, .stakes-pill, .stakes-sheet__head) .team-logo--dark {
  display: var(--crest-on-dark);
}

html:root :is(.stakes-tile, .stakes-pill, .stakes-sheet__head) .team-logo--light {
  display: var(--crest-on-light);
}

.stakes-crest--head {
  height: var(--stakes-crest-head, 40px);
  width: var(--stakes-crest-head, 40px);
}

.stakes-crest--game {
  height: var(--stakes-crest-game, 20px);
  vertical-align: middle;
  width: var(--stakes-crest-game, 20px);
}

.stakes-card {
  background: var(--color-surface);
  border-radius: var(--radius-2xl);
  min-width: 0;
  padding: var(--space-3);
}

.stakes-card__header {
  margin-block-end: var(--space-2);
}

.stakes-card__title {
  font-family: var(--font-display);
  font-size: var(--fs-h3);
  margin: 0;
}

.stakes-card__settled {
  color: var(--color-text-muted);
  font-size: var(--fs-caption);
  margin: var(--space-1) 0 0;
}

.stakes-card__crests {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.stakes-card__crest {
  align-items: center;
  display: inline-flex;
  gap: 2px;
}

.stakes-card__tiles,
.stakes-tile__rows {
  list-style: none;
  margin: 0;
  padding: 0;
}

.stakes-card__tiles {
  display: grid;
  gap: var(--space-2);
}

.stakes-tile {
  background: var(--tile-fill);
  border-radius: var(--radius-2xl);
  color: var(--tile-ink);
  min-width: 0;
  padding: var(--space-3);
  position: relative;
}

.stakes-tile__heading {
  font: inherit;
  margin: 0;
}

.stakes-tile__open {
  align-items: center;
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  display: flex;
  font: inherit;
  gap: var(--space-2);
  min-height: var(--hit-touch);
  padding: 0;
  text-align: start;
  width: 100%;
}

/* The whole tile is the target; the button stays the real control, so the
   rows below stay a list rather than the button's name. */
.stakes-tile__open::after {
  border-radius: var(--radius-2xl);
  content: "";
  inset: 0;
  position: absolute;
}

.stakes-tile__open:focus-visible {
  border-radius: var(--radius-sm);
  outline: 2px solid currentcolor;
  outline-offset: 2px;
}

.stakes-tile__who {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stakes-tile__name {
  font-family: var(--font-display);
  font-size: var(--fs-h3);
  font-weight: 700;
}

.stakes-tile__facts,
.stakes-tile__small,
.stakes-tile__closing,
.stakes-tile__more,
.stakes-tile__rivals {
  font-size: var(--fs-micro);
  font-weight: 600;
}

.stakes-tile__small {
  margin: var(--space-2) 0 0;
}

/* WVIZ-943: the count of conditions the cap left off, in the closing's slot. */
.stakes-tile__closing,
.stakes-tile__more {
  border-block-start: 1px solid currentcolor;
  margin: 0;
  padding-block-start: var(--space-2);
}

.stakes-tile__rows {
  margin-block-start: var(--space-2);
}

.stakes-tile__row {
  border-block-start: 1px solid currentcolor;
  padding-block: var(--space-2);
}

.stakes-tile__drawing {
  display: block;
}

.stakes-tile__line,
.stakes-tile__chips {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.stakes-tile__line {
  justify-content: space-between;
}

.stakes-tile__plus {
  font-weight: 700;
}

.stakes-tile__rivals {
  display: block;
  margin-block-start: var(--space-1);
}

.stakes-chip {
  align-items: center;
  display: inline-flex;
  gap: 2px;
}

.stakes-chip--any {
  font-size: var(--fs-caption);
  font-weight: 600;
}

.stakes-chip__result {
  background: var(--tile-ink);
  border-radius: var(--radius-md);
  color: var(--tile-fill);
  font-size: var(--fs-caption);
  font-weight: 700;
  padding: 2px var(--space-2);
  white-space: nowrap;
}

/* WVIZ-953: the other club, when this one has two games this round. */
.stakes-chip__versus {
  align-items: center;
  display: inline-flex;
  font-size: var(--fs-caption);
  gap: 2px;
  margin-inline-start: 2px;
  white-space: nowrap;
}

.stakes-chip__result--struck,
.stakes-chip--missed .stakes-chip__result {
  text-decoration: line-through;
}

.stakes-badge {
  border-radius: var(--radius-full);
  font-size: var(--fs-micro);
  font-weight: 700;
  margin-inline-start: auto;
  padding: 2px var(--space-2);
  white-space: nowrap;
}

.stakes-badge--clinch {
  background: var(--stakes-badge-clinch);
  color: var(--stakes-badge-ink);
}

.stakes-badge--out {
  background: var(--stakes-badge-out);
  color: var(--stakes-badge-ink);
}

.stakes-badge--clinch-unless,
.stakes-badge--out-unless,
.stakes-badge--level {
  background: var(--tile-ink);
  color: var(--tile-fill);
  outline: 1px dashed var(--tile-fill);
  outline-offset: -3px;
}

/* The sheet: a card beside the tile, or base.css's bottom sheet on a phone. */
.stakes-sheet {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-tooltip);
  color: var(--color-text);
  font-size: var(--fs-body-sm);
  max-height: calc(100dvh - 2 * var(--space-3));
  overflow-wrap: anywhere;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-3);
  position: fixed;
  width: min(30rem, calc(100vw - 2 * var(--space-3)));
  z-index: 1000;
}

.stakes-sheet abbr {
  text-decoration: none;
}

.stakes-sheet__head {
  align-items: center;
  background: var(--tile-fill);
  border-radius: var(--radius-lg);
  color: var(--tile-ink);
  display: flex;
  gap: var(--space-2);
  margin-block-end: var(--space-2);
  padding: var(--space-2);
}

.stakes-sheet__head .stakes-tile__who {
  flex: 1;
}

.stakes-sheet__title {
  font-family: var(--font-display);
  font-size: var(--fs-h3);
  margin: 0;
}

.stakes-sheet__facts {
  font-size: var(--fs-micro);
  font-weight: 600;
  margin: 0;
}

.stakes-sheet__close {
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  flex: none;
  font: inherit;
  font-weight: 700;
  height: var(--hit-touch);
  width: var(--hit-touch);
}

.stakes-sheet__close:focus-visible {
  outline: 2px solid currentcolor;
  outline-offset: -4px;
}

/* The Cut-offs: a pill per open club, filled in the club's colour like a tile,
   its whole face the button. */
.stakes-cards--cutoffs {
  --stakes-pill-icon: 16px;
}

.stakes-pills {
  display: grid;
  gap: var(--space-2);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 11rem), 1fr));
  list-style: none;
  margin: 0;
  padding: 0;
}

.stakes-pill {
  background: var(--tile-fill);
  border-radius: var(--radius-2xl);
  color: var(--tile-ink);
  min-width: 0;
  padding: var(--space-2);
  position: relative;
}

.stakes-pill__open {
  align-items: center;
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  display: flex;
  font: inherit;
  gap: var(--space-2);
  min-height: var(--hit-touch);
  padding: 0;
  text-align: start;
  width: 100%;
}

.stakes-pill__open::after {
  border-radius: var(--radius-2xl);
  content: "";
  inset: 0;
  position: absolute;
}

.stakes-pill__open:focus-visible {
  border-radius: var(--radius-sm);
  outline: 2px solid currentcolor;
  outline-offset: 2px;
}

.stakes-pill__who {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.stakes-pill__name {
  font-size: var(--fs-caption);
  font-weight: 700;
}

.stakes-pill__big {
  font-family: var(--font-display);
  font-size: var(--fs-body-sm);
  font-weight: 700;
}

/* The hand and link are ink, like the pill's text, not data marks: a mask of
   the shape over the current colour, so they follow the pill's --tci ink. */
.stakes-pill__icon {
  background: currentcolor;
  flex: none;
  height: var(--stakes-pill-icon, 16px);
  mask: var(--stakes-icon-shape) center / contain no-repeat;
  width: var(--stakes-pill-icon, 16px);
}

/* Forced colours repaint a background to the canvas, which would hide a mask
   painted with one. CanvasText is the colour the pill's text gets there. */
@media (forced-colors: active) {
  .stakes-pill__icon {
    background: CanvasText;
    forced-color-adjust: none;
  }
}

.stakes-pill__icon--own {
  --stakes-icon-shape: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 11V6a2 2 0 0 0-2-2 2 2 0 0 0-2 2'/%3E%3Cpath d='M14 10V4a2 2 0 0 0-2-2 2 2 0 0 0-2 2v2'/%3E%3Cpath d='M10 10.5V6a2 2 0 0 0-2-2 2 2 0 0 0-2 2v8'/%3E%3Cpath d='M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15'/%3E%3C/svg%3E");
}

.stakes-pill__icon--help {
  --stakes-icon-shape: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71'/%3E%3Cpath d='M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71'/%3E%3C/svg%3E");
}

.stakes-pill__level {
  border-block-start: 1px solid currentcolor;
  font-size: var(--fs-micro);
  font-weight: 600;
  margin: var(--space-1) 0 0;
  padding-block-start: var(--space-1);
}

.stakes-cutoffs__last-place {
  color: var(--color-text-muted);
  font-size: var(--fs-body-sm);
  margin-block: 0 var(--space-3);
}

/* The Range: a row per club, a pill across a shared axis. Text and CSS, not
   SVG, so the names wrap and zoom. --from, --to, --min, --span and --unit
   place a pill (and --at a line) as a share of the track; the club's colour
   comes in as --pill, set from var(--tc-<slug>), so a theme or contrast switch
   repaints with no script. */
.range {
  --range-pill: 16px;
  --range-pill-min: 12px;
  --range-gutter: 2.75rem;
  --range-name: 11rem;
  --range-tier: 1.25rem;
}

/* The switch looks and works like the Table's lenses. */
.range__modes {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

/* display: flex above defeats the hidden attribute; without this the switch
   would show, dead, until the script reveals it. */
.range__modes[hidden] {
  display: none;
}

.range__mode {
  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);
}

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

.range__caption {
  color: var(--color-text);
  font-weight: 700;
}

/* Without the script both views show, each with its own caption; with it only
   the chosen one does, and the switch names it. */
.range[data-range-showing="place"] [data-range-view="points"],
.range[data-range-showing="points"] [data-range-view="place"] {
  display: none;
}

.range[data-range-showing] .range__caption {
  display: none;
}

.range__view + .range__view {
  margin-top: var(--space-4);
}

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

.range__rows {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* The labels above the tracks, on the same columns as a row. */
.range__axis {
  height: calc(var(--tiers, 1) * var(--range-tier));
  margin-inline-start: 0;
  position: relative;
}

.range__row {
  min-width: 0;
}

.range__open {
  align-items: center;
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  display: grid;
  font: inherit;
  gap: 2px var(--space-2);
  grid-template-columns: minmax(0, 1fr);
  min-height: var(--hit-touch);
  padding: var(--space-1) 0;
  text-align: start;
  width: 100%;
}

.range__open:hover {
  background: var(--color-surface);
}

.range__who {
  align-items: center;
  display: flex;
  gap: var(--space-2);
  min-width: 0;
}

.range__crest {
  flex: none;
  height: 20px;
  object-fit: contain;
  width: 20px;
}

.range__name {
  font-size: var(--fs-body-sm);
  min-width: 0;
  overflow-wrap: anywhere;
}

/* The club's own row on its team page: a heavier name and a marker, so the
   cue is not colour alone. */
.range__row--own .range__name {
  font-weight: 800;
}

.range__row--own .range__name::before {
  content: "\25B8\00a0";
}

.range__track {
  height: var(--range-pill);
  position: relative;
}

.range__track--points {
  margin-inline-end: var(--range-gutter);
}

.range__pill {
  background: var(--pill);
  border-radius: var(--radius-full);
  height: 100%;
  inset-inline-start: calc((var(--from) - var(--min)) / var(--span) * 100%);
  min-width: var(--range-pill-min);
  position: absolute;
  width: calc((var(--to) - var(--from) + var(--unit)) / var(--span) * 100%);
}

/* The most points a club can reach, printed past the pill's right end. The
   track leaves a gutter for it, so it cannot reach the edge. */
.range__max {
  color: var(--color-text);
  font-size: var(--fs-micro);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  inset-block-start: 50%;
  inset-inline-start: 100%;
  line-height: 1;
  margin-inline-start: var(--space-1);
  position: absolute;
  transform: translateY(-50%);
}

/* A dashed line down every track, which reads as one line through the rows. */
.range__line {
  border-inline-start: 2px dashed var(--color-text-muted);
  inset-block: calc(-1 * var(--space-1));
  inset-inline-start: calc((var(--at) - var(--min) + var(--unit)) / var(--span) * 100%);
  position: absolute;
}

.range__cut {
  color: var(--color-text-muted);
  font-size: var(--fs-micro);
  font-weight: 700;
  inset-block-start: calc(var(--tier) * var(--range-tier));
  inset-inline-start: calc((var(--at) - var(--min) + var(--unit)) / var(--span) * 100%);
  line-height: var(--range-tier);
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}

.range__cut--starts {
  padding-inline-start: 4px;
  transform: none;
}

.range__cut--ends {
  padding-inline-end: 4px;
  transform: translateX(-100%);
}

.range__axis--points {
  margin-inline-end: var(--range-gutter);
}

@media (width >= 640px) {
  .range__open {
    grid-template-columns: var(--range-name) minmax(0, 1fr);
  }

  .range__axis {
    margin-inline-start: calc(var(--range-name) + var(--space-2));
  }
}

/* The sheet's figures and badges. */
.range-sheet__facts {
  display: grid;
  gap: var(--space-2);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0 0 var(--space-2);
}

.range-sheet__facts div {
  min-width: 0;
}

.range-sheet__facts dt {
  color: var(--color-text-muted);
  font-size: var(--fs-micro);
}

.range-sheet__facts dd {
  font-family: var(--font-display);
  font-size: var(--fs-h3);
  font-weight: 700;
  margin: 0;
}

.range-sheet__badges {
  margin: 0;
}

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

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

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

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

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

.stakes-range__badge--eliminated-partial {
  background: color-mix(in srgb, var(--color-text-muted) 15%, transparent);
  color: var(--color-text-muted);
  text-decoration: line-through 1.5px;
}

/* The link to the league's odds, on a page that has none of its own. */
.stakes__league-odds-line {
  margin: 0 0 var(--space-4);
}

.stakes__league-odds {
  align-items: center;
  display: inline-flex;
  font-weight: 600;
  min-height: 44px;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}
