/*
 * Sportradar blocks: brackets and the series popover. Loaded after sportradar.css (the base) by the blocks that need it.
 */

/* Bracket: horizontal scroll with snap; arrows are added by the script. */

.sr-block .sr-bracket {
  position: relative;
  padding-block-start: 0.75em;
}

/* Scroll buttons float in the bracket's top corner (over the column headings if need be). */
.sr-block .sr-bracket__nav {
  position: absolute;
  inset-block-start: 0.5em;
  inset-inline-end: 0.5em;
  z-index: 2;
  display: flex;
  gap: 4px;

  &[hidden] {
    display: none;
  }
}

/* The bracket's lists are layout, not lists: no inline padding either. */
.sr-block .sr-bracket :is(.sr-bracket__stages, .sr-bracket__ties, .sr-bracket__games) {
  padding-inline: 0;

  & > li {
    padding-inline-start: 0;
  }

  & > li::before {
    content: none;
  }
}

.sr-block .sr-bracket__lines {
  position: absolute;
  inset-block-start: 0;
  inset-inline-start: 0;
  z-index: 0;
  overflow: visible;
  pointer-events: none;
  fill: none;
  stroke: var(--sr-bracket-line, color-mix(in srgb, currentcolor 30%, transparent));
  stroke-width: 1.5;
}

.sr-block .sr-bracket__stages {
  position: relative;
  display: grid;
  grid-auto-columns: minmax(13em, 1fr);
  grid-auto-flow: column;
  gap: 1em;
  padding: 0 0 0.5em;
  margin: 0;
  overflow-x: auto;
  list-style: none;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}

.sr-block .sr-bracket__stage {
  display: flex;
  flex-direction: column;
  scroll-snap-align: start;
}

.sr-block .sr-bracket__name {
  margin: 0 0 0.5em;
  font-size: 0.9em;
  text-transform: uppercase;
}

.sr-block .sr-bracket__ties {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 1em;
  justify-content: space-around;
  padding: 0;
  margin: 0;
  list-style: none;
}

.sr-block .sr-bracket__tie {
  position: relative;
  z-index: 1;
  background: var(--sr-bracket-bg, Canvas);
  border: 1px solid var(--sr-border);
  border-radius: var(--sr-radius);

  & summary {
    display: grid;
    gap: 0.35em;
    padding: 0.6em 0.75em;
    line-height: 1.35;
    cursor: pointer;
    list-style: none;
  }

  & summary::-webkit-details-marker {
    display: none;
  }

  & details[open] summary {
    border-block-end: 1px solid var(--sr-border);
  }
}

/* The bronze match sits under the final, captioned, with space above. */
.sr-block .sr-bracket__tie.is-bronze {
  margin-block-start: 1.5em;
}

.sr-block .sr-bracket__caption {
  position: absolute;
  inset-block-end: 100%;
  inset-inline-start: 0;
  margin-block-end: 0.2em;
  font-size: 0.75em;
  color: var(--sr-muted);
  text-transform: uppercase;
}

.sr-block .sr-bracket__team {
  display: flex;
  gap: 0.5em;
  justify-content: space-between;

  /* A long name (full names on a narrow screen) is cut short; the series popover shows it in full. */
  & .sr-team {
    min-inline-size: 0;
  }

  & .sr-team > :is(.sr-name, a) {
    min-inline-size: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  &.is-winner {
    font-weight: 700;
  }
}

.sr-block .sr-bracket__tbd {
  display: block;
  padding: 0.4em 0.6em;
  color: var(--sr-muted);
}

/* A series' games: date, teams and score on one line each. */
.sr-block .sr-bracket__games {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.5em 0.9em;
  padding: 0.7em 0.75em 0.8em;
  margin: 0;
  font-size: 0.85em;
  line-height: 1.35;
  white-space: nowrap;
  list-style: none;

  & li {
    display: contents;
  }

  & .sr-date {
    color: var(--sr-muted);
  }

  & .sr-score {
    font-variant-numeric: tabular-nums;
    text-align: end;
  }

  & .sr-vs {
    margin-inline: 0.3em;
  }

  /* Full names wrap rather than widen the popover. */
  & .sr-teams {
    min-inline-size: 0;
    white-space: normal;
  }

  & .sr-teams__team.is-winner {
    font-weight: 700;
  }
}

/* A bracket series' games, opened by the script (the shared native popover). */
.sr-block.sr-popover {
  position: fixed;
  inset: auto;
  inline-size: 280px;
  max-inline-size: calc(100vw - 16px);
  padding: 14px 16px;
  margin: 0;

  /* Not a size container: at 280px the narrow rules would abbreviate the team names. */
  container-type: normal;
  font-size: 14px;
  color: var(--sr-popover-color, #1d2327);
  background: var(--sr-popover-bg, #fff);
  border: 1px solid var(--sr-border);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.12);

  & .sr-popover__title {
    margin: 0 0 10px;
    font-weight: 600;
  }

  & .sr-bracket__games {
    padding: 0;
    font-size: 13px;
  }
}
