/* The live league standings: the table of a football league in a card of dark smoked glass, over a pitch green light.
   The positions are a column of their own (.ranks) that never moves; the rows of the teams (.rows) are real list
   items that change order in the DOM, and GSAP plays the FLIP: every row starts from where it was and springs to its
   new place. Each row is a stack: the accent light (.row__glow), the band that crosses it (.row__sweep) and on top
   the crest, the name window (name and goal message, one under the other), the figures and the arrows. */
:root {
  --page: #050607;            /* the page */
  --glass: rgba(14, 17, 19, 0.66); /* the glass of the card */
  --ink: #eef1ee;             /* the words */
  --muted: #7f8985;           /* the small words */
  --faint: #4b5450;           /* the column heads and the positions */
  --line: rgba(255, 255, 255, 0.06); /* hairlines */
  --accent: #c8f560;          /* the accent: the goal, the row that climbs, the arrow up */
  --accent-ink: #172200;      /* words on the accent */
  --down: #ff7a66;            /* the arrow down */
  --pitch: #1d6b45;           /* the green light behind */
  --row: clamp(27px, 6.9vh, 40px); /* the height of a row */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* a very fine grain over everything */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.08;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

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

.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
  isolation: isolate;
}

/* the lights behind the glass (GSAP drifts them; nothing else transforms them) */
.aura {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(74vw, 64vh, 440px);
  aspect-ratio: 1;
  margin: calc(min(74vw, 64vh, 440px) / -2) 0 0 calc(min(74vw, 64vh, 440px) / -2);
  border-radius: 50%;
  filter: blur(min(14vw, 12vh, 72px));
  z-index: -1;
  pointer-events: none;
}

.aura--a {
  background: radial-gradient(circle, var(--pitch), transparent 68%);
  opacity: 0.62;
}

.aura--b {
  background: radial-gradient(circle, #3a4a66, transparent 68%);
  opacity: 0.34;
}

.wrap {
  position: relative;
  width: min(90vw, 384px);
  opacity: 0;
}

.board {
  position: relative;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.015) 40%, rgba(255, 255, 255, 0.03)),
    var(--glass);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  backdrop-filter: blur(24px) saturate(150%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.13),
    inset 0 0 0 1px rgba(255, 255, 255, 0.065),
    inset 0 -1px 0 rgba(0, 0, 0, 0.4),
    0 1px 1px rgba(0, 0, 0, 0.5),
    0 12px 24px -12px rgba(0, 0, 0, 0.7),
    0 44px 80px -36px rgba(0, 0, 0, 0.9);
  overflow: hidden;
}

/* the mowing stripes of a pitch, barely there, and the light that follows the pointer with the rim that catches it */
.board__pitch,
.board__light,
.board__rim {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

.board__pitch {
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.012) 0 28px, transparent 28px 56px);
  -webkit-mask: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent);
  mask: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent);
}

.board__light {
  background: radial-gradient(280px circle at var(--mx, 24%) var(--my, -12%), rgba(255, 255, 255, calc(0.055 * var(--mo, 1))), transparent 70%);
}

.board__rim {
  padding: 1px;
  background: radial-gradient(220px circle at var(--mx, 24%) var(--my, -12%), rgba(214, 255, 160, calc(0.45 * var(--mo, 1))), transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}

.board__body {
  position: relative;
  padding: clamp(10px, 2.8vh, 18px) clamp(12px, 4vw, 18px) clamp(8px, 2.2vh, 14px);
}

/* ------------------------------------------------------------------ the head */
.head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.head__title {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.head__league {
  font-size: clamp(14px, 3.6vh, 16px);
  font-weight: 640;
  font-stretch: 108%;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.head__day {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* the live state is a word, never a dot */
.state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 3px 4px 3px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.state__min {
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  color: var(--ink);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.is-full .state {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

/* the bar of the minute: a 1px track with a half time notch, the fill grows with the match */
.clock {
  position: relative;
  height: 3px;
  margin: clamp(8px, 2vh, 12px) 0 clamp(6px, 1.6vh, 10px);
}

.clock__track,
.clock__fill {
  position: absolute;
  left: 0;
  right: 0;
  top: 1px;
  height: 1px;
  border-radius: 1px;
}

.clock__track {
  background: var(--line);
}

.clock__fill {
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 20%, transparent), var(--accent));
  transform-origin: left center;
  transform: scaleX(0.744);
  box-shadow: 0 0 6px color-mix(in srgb, var(--accent) 40%, transparent);
}

.clock__half {
  position: absolute;
  left: 50%;
  top: 0;
  width: 1px;
  height: 3px;
  background: rgba(255, 255, 255, 0.18);
}

/* ------------------------------------------------------------------ the columns */
.cols,
.row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 24px 34px 32px 14px;
  align-items: center;
  column-gap: clamp(6px, 2vw, 9px);
}

.cols {
  padding: 0 8px 0 calc(18px + 8px);
  height: 18px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}

.cols__team {
  grid-column: 2;
}

.cols__n {
  text-align: right;
}

.cols__pts {
  color: var(--muted);
}

.table {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  border-top: 1px solid var(--line);
}

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

.ranks li {
  height: var(--row);
  display: grid;
  place-items: center start;
  padding-left: 2px;
  font-size: 11px;
  font-weight: 560;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  border-bottom: 1px solid transparent;
}

.ranks li:first-child {
  color: var(--accent);
}

.rows {
  list-style: none;
  margin: 0 0 0 8px;
  padding: 0;
  position: relative;
}

.row {
  position: relative;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  height: var(--row);
  padding: 0 8px;
  border-bottom: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  isolation: isolate;
}

.row__under {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(255, 255, 255, 0);
  transition: background-color 0.25s;
  z-index: -2;
  pointer-events: none;
}

@media (hover: hover) {
  .row:hover .row__under {
    background: rgba(255, 255, 255, 0.035);
  }
}

.row.is-moving .row__under {
  background: linear-gradient(180deg, #1b2120, #141817);
  box-shadow: 0 14px 28px -10px rgba(0, 0, 0, 0.8), 0 2px 6px rgba(0, 0, 0, 0.5);
  transition: none;
}

.row.is-pinned .row__under {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015));
  box-shadow: inset 1px 0 0 var(--accent);
}

.row.is-pinned .row__team {
  color: var(--accent);
}

.row:focus-visible .row__under {
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 60%, transparent);
}

/* the light of the row that climbs: a wash from the left, a 1px edge, and a band that crosses it */
.row__glow {
  position: absolute;
  inset: -1px 0 0;
  border-radius: inherit;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--accent) 22%, transparent), color-mix(in srgb, var(--accent) 6%, transparent) 55%, transparent),
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--accent) 34%, transparent),
    0 10px 24px -12px color-mix(in srgb, var(--accent) 50%, transparent);
  opacity: 0;
  z-index: -1;
  pointer-events: none;
}

.row__sweep {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  z-index: -1;
  pointer-events: none;
}

.row__band {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 40%;
  background: linear-gradient(100deg, transparent 15%, color-mix(in srgb, var(--accent) 22%, transparent) 50%, transparent 85%);
  mix-blend-mode: screen;
}

.crest {
  width: 20px;
  height: 22px;
  display: grid;
  place-items: center;
  color: var(--crest-ink, #fff);
  font-size: 9.5px;
  font-weight: 720;
  font-stretch: 112%;
  letter-spacing: 0.02em;
}

.crest svg {
  grid-area: 1 / 1;
  width: 20px;
  height: 22px;
  overflow: visible;
}

.crest__letter {
  grid-area: 1 / 1;
  position: relative;
  top: -1px;
}

/* the name window: the team name and, under it, the goal message; one slides up to make room for the other */
.row__name {
  position: relative;
  height: 18px;
  overflow: hidden;
  min-width: 0;
}

.row__slide {
  display: grid;
}

.row__team,
.row__goal {
  height: 18px;
  display: flex;
  align-items: center;
  min-width: 0;
  white-space: nowrap;
  font-size: 13px;
}

.row__team span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.row__team {
  font-weight: 540;
}

.row__goal {
  gap: 5px;
  color: var(--accent);
  font-weight: 620;
}

.row__goal svg {
  width: 13px;
  height: 13px;
  flex: none;
}

.row__goal b {
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 10.5px;
}

.row__goal i {
  font-style: normal;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
}

.num {
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--muted);
  display: flex;
  justify-content: flex-end;
}

.num--pts {
  font-variant-numeric: normal;
  color: var(--ink);
  font-weight: 680;
  font-size: 13.5px;
}

/* the odometer: every digit is a window one digit tall over a strip 0 to 9 */
.dg {
  display: inline-block;
  height: 1.25em;
  line-height: 1.25em;
  overflow: hidden;
  width: 0.62em;
  text-align: center;
}

.strip {
  display: flex;
  flex-direction: column;
}

.strip span {
  height: 1.25em;
}

.ch {
  display: inline-block;
  line-height: 1.25em;
}

/* the arrows: two drawn chevrons, dim at rest; the one of the last move lights up */
.mv {
  position: relative;
  width: 14px;
  height: 14px;
}

.mv svg {
  position: absolute;
  inset: 0;
  width: 14px;
  height: 14px;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mv__up {
  stroke: var(--accent);
  opacity: 0;
}

.mv__down {
  stroke: var(--down);
  opacity: 0;
}

.mv__rest {
  stroke: var(--faint);
  opacity: 0.7;
}

/* ------------------------------------------------------------------ the matches in play */
.fixtures {
  display: flex;
  gap: 6px;
  margin-top: clamp(8px, 2vh, 12px);
  min-width: 0;
}

.fx {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: clamp(22px, 5.4vh, 28px);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.025);
  box-shadow: inset 0 0 0 1px var(--line), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  position: relative;
}

.fx__flash {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent);
  opacity: 0;
}

.fx__score {
  position: relative;
  color: var(--ink);
  display: inline-flex;
}

.fx__team {
  position: relative;
}

@media (max-width: 360px) {
  .cols,
  .row {
    grid-template-columns: 22px minmax(0, 1fr) 32px 30px 14px;
  }
  .cols__p,
  .num--p {
    display: none;
  }
  .fx {
    font-size: 9.5px;
    letter-spacing: 0.02em;
    gap: 3px;
  }
  .row__team,
  .row__goal {
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .row__under {
    transition: none;
  }
}
