/*
 * Scores ticker. "Night game" palette: navy ink, chalk text, and one accent,
 * scoreboard-bulb amber, which means LIVE and nothing else (plus focus rings).
 * Everything is sized in rem off a root size that scales with the viewport and
 * with the viewer's A-/A+ choice (--scale), so the strip reads across a room.
 */

@font-face {
  font-family: "Big Shoulders Display";
  src: url("fonts/big-shoulders-display-700-900.woff2") format("woff2");
  font-weight: 700 900;
  font-display: swap;
}
@font-face {
  font-family: "Barlow Semi Condensed";
  src: url("fonts/barlow-semi-condensed-500.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Barlow Semi Condensed";
  src: url("fonts/barlow-semi-condensed-600.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Barlow Semi Condensed";
  src: url("fonts/barlow-semi-condensed-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --ink: #0e1b2c;
  --card: #15263b;
  --rule: #26384f;
  --chalk: #f3f6fa;
  --slate: #8da2ba;
  --bulb: #ffb23f;
  --alert: #ff8a7a;

  --display: "Big Shoulders Display", "Arial Narrow", sans-serif;
  --text: "Barlow Semi Condensed", "Arial Narrow", system-ui, sans-serif;

  --scale: 1;
  color-scheme: dark;
  /* ~27px on a 1920px screen, about 2.3x a typical web score strip. */
  font-size: calc(clamp(16px, 0.9vw + 10px, 30px) * var(--scale));
}

/*
 * "Day game": the same roles for a device set to light mode. Amber is darkened
 * because bright amber on white fails contrast (#a65c00 is ~5:1 on the cards).
 */
@media (prefers-color-scheme: light) {
  :root {
    --ink: #eef2f6;
    --card: #ffffff;
    --rule: #d3dbe5;
    --chalk: #0e1b2c;
    --slate: #55687f;
    --bulb: #a65c00;
    --alert: #b3261e;
    color-scheme: light;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--ink);
  color: var(--chalk);
  font-family: var(--text);
  font-weight: 500;
  line-height: 1.2;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

:focus-visible {
  outline: 3px solid var(--bulb);
  outline-offset: 2px;
}

/* ---- masthead ------------------------------------------------------------ */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 1.25rem;
  padding: 0.5rem 1rem 0.6rem;
  font-size: 0.75rem;
  color: var(--slate);
}

.masthead__title {
  margin: 0;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 900;
  line-height: 1;
  color: var(--chalk);
}

.masthead__clock {
  margin: 0;
  color: var(--chalk);
  font-variant-numeric: tabular-nums;
}

.masthead__sync {
  margin: 0;
}

.masthead__sync[data-state="offline"] {
  color: var(--alert);
}

.masthead__controls {
  display: flex;
  gap: 0.4rem;
  margin-left: auto;
}

.masthead__controls button,
.button {
  min-width: 2.6em;
  padding: 0.25em 0.75em;
  border: 1px solid var(--rule);
  border-radius: 0.3em;
  background: var(--card);
  color: var(--chalk);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.masthead__controls button:disabled {
  color: var(--slate);
  cursor: default;
  opacity: 0.6;
}

.icon {
  display: block;
  width: 1.25em;
  height: 1.25em;
  margin: 0 auto;
}

/* ---- settings dialog ------------------------------------------------------- */

.settings {
  width: min(24rem, calc(100vw - 2rem));
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 0.5rem;
  background: var(--card);
  color: var(--chalk);
  font-size: 0.85rem;
}

.settings::backdrop {
  background: rgb(4 10 18 / 0.6);
}

.settings__body {
  padding: 1rem 1.25rem 1.1rem;
}

.settings__title {
  margin: 0 0 0.8rem;
  font-family: var(--display);
  font-size: 1.6rem;
  font-weight: 900;
  line-height: 1;
}

.settings__group {
  margin: 0;
  padding: 0;
  border: 0;
}

.settings__group legend {
  margin-bottom: 0.3rem;
  padding: 0;
  font-weight: 700;
}

.league-option {
  display: flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.45em 0;
  border-top: 1px solid var(--rule);
  cursor: pointer;
}

.league-option:first-child {
  border-top: 0;
}

/* Drawn by hand: native checkboxes stay ~13px however large the text is. */
.league-option input {
  display: grid;
  flex: none;
  place-content: center;
  width: 1.2em;
  height: 1.2em;
  margin: 0;
  border: 2px solid var(--slate);
  border-radius: 0.2em;
  background: transparent;
  /* Form controls don't inherit font-size, so em would size off ~13px. */
  font-size: inherit;
  cursor: pointer;
  appearance: none;
}

.league-option input::before {
  width: 0.65em;
  height: 0.65em;
  background: var(--card);
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0, 43% 62%);
  content: "";
  transform: scale(0);
}

.league-option input:checked {
  border-color: var(--chalk);
  background: var(--chalk);
}

.league-option input:checked::before {
  transform: scale(1);
}

.league-option__name {
  font-weight: 600;
}

.league-option__note {
  margin-left: auto;
  font-size: 0.85em;
  color: var(--slate);
}

.settings__hint {
  margin: 0.8rem 0 0;
  font-size: 0.85em;
  color: var(--slate);
}

.settings__actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
}

/* ---- ticker -------------------------------------------------------------- */

.ticker {
  overflow: hidden;
  overflow: clip;
  border-block: 1px solid var(--rule);
  background: var(--card);
}

/* Paused, focused, or short enough to fit: a plain strip you can scroll yourself. */
.ticker.is-static {
  overflow-x: auto;
  scrollbar-color: var(--rule) transparent;
}

.ticker.is-static .ticker__lane[aria-hidden="true"] {
  display: none;
}

.ticker__track {
  display: flex;
  width: max-content;
  will-change: transform;
}

.ticker__lane {
  display: flex;
  align-items: stretch;
}

.item {
  flex: none;
  margin: 0;
  border-right: 1px solid var(--rule);
}

/* League tile: the section marker that opens each league's run of games. */
.league {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 5rem;
  max-width: 8.5rem;
  padding: 0.6rem 1rem;
  background: var(--ink);
  font-size: 1rem;
  font-weight: inherit;
}

.league__name {
  font-family: var(--display);
  font-size: 1.9rem;
  font-weight: 900;
  line-height: 0.95;
}

.league__meta {
  margin-top: 0.35rem;
  font-family: var(--text);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--slate);
}

.notice {
  display: flex;
  align-items: center;
  padding: 0.6rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--slate);
  white-space: nowrap;
}

/* Game card: status line, away row, home row, one line of context. */
.game {
  display: grid;
  grid-template-rows: auto auto auto auto;
  row-gap: 0.2rem;
  width: 10.5rem;
  padding: 0.55rem 0.9rem 0.6rem;
  color: inherit;
  text-decoration: none;
}

.game__status {
  display: flex;
  justify-content: space-between;
  gap: 0.6em;
  margin-bottom: 0.1rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--slate);
  white-space: nowrap;
}

.game__state {
  display: inline-flex;
  align-items: center;
}

.game__status--live {
  color: var(--bulb);
}

.game__status--final {
  color: var(--chalk);
}

/* The network never takes the status colour: amber marks the game state only. */
.game__network {
  overflow: hidden;
  color: var(--slate);
  text-overflow: ellipsis;
}

.live-dot {
  width: 0.5em;
  height: 0.5em;
  margin-right: 0.4em;
  border-radius: 50%;
  background: var(--bulb);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

.team {
  display: grid;
  grid-template-columns: 1.6rem 1fr auto;
  align-items: center;
  column-gap: 0.5rem;
}

.team__logo {
  display: block;
  width: 1.6rem;
  height: 1.6rem;
  object-fit: contain;
}

.team__name {
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
  min-width: 0;
}

.team__rank {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--slate);
  font-variant-numeric: tabular-nums;
}

.team__abbr {
  font-family: var(--display);
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.02em;
}

/* Football: a small amber ball beside the team that has it. */
.team__possession {
  align-self: center;
  width: 0.6em;
  height: 0.38em;
  border-radius: 50%;
  background: var(--bulb);
}

.team__value {
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.team__value--record {
  font-family: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--slate);
}

.team--loser {
  color: var(--slate);
}

.team--loser .team__value {
  font-weight: 700;
}

.game__extra {
  display: flex;
  align-items: center;
  gap: 0.4em;
  min-height: 1.25em;
  margin-top: 0.15rem;
  overflow: hidden;
  font-size: 0.72rem;
  color: var(--slate);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.bases {
  flex: none;
  width: 1.6em;
  height: 1.1em;
}

.base {
  fill: none;
  stroke: var(--slate);
  stroke-width: 1.2;
}

.base--on {
  fill: var(--bulb);
  stroke: var(--bulb);
}

.noscript {
  padding: 1rem;
  color: var(--slate);
}

@media (prefers-reduced-motion: reduce) {
  .live-dot {
    animation: none;
  }
}
