/* The live cricket scoreboard: the match card of a sports app, in smoked glass over two soft team lights. The card is
   a stack of layers: the glass body (.score), the light under the pointer, the rim that catches it, a red tint for the
   wickets and the diagonal sweep for the boundaries; the words sit on top in .score__body. The stats open with a grid
   row that goes from 0fr to 1fr, the ball by ball list gives up one row to make room: no height is ever measured. */
:root {
  --page: #06080c;            /* the page */
  --glass: rgba(16, 19, 26, 0.6); /* the glass of the card */
  --ink: #eef1f6;             /* the words */
  --muted: #8a93a3;           /* the small words */
  --line: rgba(255, 255, 255, 0.07); /* hairlines and empty slots */
  --bat: #5ef0c4;             /* the team batting: mint */
  --bat-ink: #04241b;         /* the letter on its crest */
  --bowl: #ffb547;            /* the team bowling: amber */
  --bowl-ink: #2b1700;        /* the letter on its crest */
  --out: #ff6b5e;             /* a wicket */
  --row: clamp(24px, 6.6vh, 34px); /* the height of a line in the ball by ball list */
}

* {
  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.07;
  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 two team lights behind the glass (GSAP drifts them; nothing else transforms them) */
.aura {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(70vw, 62vh, 420px);
  aspect-ratio: 1;
  margin: calc(min(70vw, 62vh, 420px) / -2) 0 0 calc(min(70vw, 62vh, 420px) / -2);
  border-radius: 50%;
  filter: blur(min(14vw, 12vh, 70px));
  opacity: 0.42;
  z-index: -1;
  pointer-events: none;
}

.aura--bat {
  background: radial-gradient(circle, var(--bat), transparent 68%);
}

.aura--bowl {
  background: radial-gradient(circle, var(--bowl), transparent 68%);
  opacity: 0.3;
}

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

.score {
  position: relative;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.02) 46%, rgba(255, 255, 255, 0.035)),
    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.14),
    inset 0 0 0 1px rgba(255, 255, 255, 0.07),
    inset 0 -1px 0 rgba(0, 0, 0, 0.35),
    0 1px 1px rgba(0, 0, 0, 0.45),
    0 10px 22px -10px rgba(0, 0, 0, 0.6),
    0 40px 80px -36px rgba(0, 0, 0, 0.85);
  overflow: hidden;
}

/* the light under the pointer and the rim that catches it */
.score__light,
.score__rim,
.score__tint,
.score__sweep {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

.score__light {
  background: radial-gradient(260px circle at var(--mx, 30%) var(--my, -10%), rgba(255, 255, 255, calc(0.06 * var(--mo, 1))), transparent 70%);
}

.score__rim {
  padding: 1px;
  background: radial-gradient(200px circle at var(--mx, 30%) var(--my, -10%), rgba(190, 255, 236, calc(0.5 * 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);
}

.score__tint {
  background: radial-gradient(120% 80% at 50% 0%, color-mix(in srgb, var(--out) 30%, transparent), transparent 70%);
  opacity: 0;
}

.score__sweep {
  overflow: hidden;
}

.score__sweep-band {
  position: absolute;
  top: -30%;
  bottom: -30%;
  left: 0;
  width: 46%;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.1) 46%, rgba(200, 255, 238, 0.16) 50%, rgba(255, 255, 255, 0.08) 54%, transparent 80%);
  mix-blend-mode: screen;
}

.score__body {
  position: relative;
  padding: clamp(10px, 3vh, 20px) clamp(14px, 4.6vw, 20px) clamp(4px, 1.4vh, 12px);
}

/* ------------------------------------------------------------------ the head */
.score__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: clamp(6px, 2vh, 16px);
  min-width: 0;
}

.live {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px 3px 6px;
  border-radius: 999px;
  color: var(--bat);
  background: color-mix(in srgb, var(--bat) 10%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bat) 24%, transparent);
  font-size: 10.5px;
  font-weight: 640;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  flex: none;
}

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

.live__icon {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.live__word {
  display: inline-block;
}

.score__match {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* ------------------------------------------------------------------ the teams */
.team {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
}

.team--bowl {
  margin-top: clamp(6px, 1.8vh, 10px);
  padding-top: clamp(6px, 1.8vh, 10px);
  border-top: 1px solid var(--line);
}

.crest {
  display: grid;
  place-items: center;
  width: clamp(28px, 8vh, 34px);
  height: clamp(28px, 8vh, 34px);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 760;
  font-variation-settings: 'wdth' 112;
  position: relative;
}

.crest--bat {
  color: var(--bat-ink);
  background: linear-gradient(160deg, color-mix(in srgb, var(--bat) 70%, #ffffff), var(--bat) 45%, color-mix(in srgb, var(--bat) 70%, #000000));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), inset 0 -2px 4px rgba(0, 0, 0, 0.18), 0 6px 14px -6px color-mix(in srgb, var(--bat) 70%, transparent);
}

.crest--bat::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 13px;
  box-shadow: 0 0 0 1.5px var(--bat);
  opacity: 0;
  transition: opacity 0.5s ease;
}

.is-won .crest--bat::after {
  opacity: 0.55;
}

.crest--bowl {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  font-size: 11px;
  color: var(--bowl-ink);
  background: linear-gradient(160deg, color-mix(in srgb, var(--bowl) 70%, #ffffff), var(--bowl) 50%, color-mix(in srgb, var(--bowl) 72%, #000000));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
  margin-left: calc((clamp(28px, 8vh, 34px) - 22px) / 2);
  margin-right: calc((clamp(28px, 8vh, 34px) - 22px) / 2);
}

.team__names {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.team__name {
  font-size: 15px;
  font-weight: 620;
  font-variation-settings: 'wdth' 106;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.team__name--small {
  font-size: 13px;
  font-weight: 540;
  color: color-mix(in srgb, var(--ink) 80%, var(--muted));
}

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

.team__figures {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

.team__score {
  font-size: clamp(28px, min(10.4vw, 8.8vh), 42px);
  line-height: 1;
  font-weight: 660;
  font-variation-settings: 'wdth' 94;
  letter-spacing: -0.035em;
  transition: color 0.6s ease, text-shadow 0.6s ease;
}

.is-won .team__score {
  color: color-mix(in srgb, var(--bat) 70%, #ffffff);
  text-shadow: 0 0 22px color-mix(in srgb, var(--bat) 40%, transparent);
}

.team__overs {
  font-size: 11.5px;
  color: var(--muted);
}

.team__line {
  font-size: 12.5px;
  color: color-mix(in srgb, var(--ink) 74%, var(--muted));
  white-space: nowrap;
}

/* ------------------------------------------------------------------ the rolling digits */
.roll {
  display: inline-flex;
  white-space: pre;
}

.roll .dg {
  display: inline-block;
  height: 1.1em;
  line-height: 1.1em;
  overflow: hidden;
  vertical-align: top;
  -webkit-mask: linear-gradient(180deg, transparent, #000 22%, #000 78%, transparent);
  mask: linear-gradient(180deg, transparent, #000 22%, #000 78%, transparent);
  text-align: center;
}

.roll .strip {
  display: block;
}

.roll .strip > span {
  display: block;
  height: 1.1em;
}

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

.team__score.roll .dg,
.team__score.roll .ch {
  height: 1.06em;
  line-height: 1.06em;
}

.team__score.roll .strip > span {
  height: 1.06em;
}

/* ------------------------------------------------------------------ what is needed */
.need {
  margin: clamp(8px, 2.4vh, 14px) 0 0;
  font-size: 13px;
  font-weight: 560;
  color: color-mix(in srgb, var(--ink) 88%, var(--muted));
  min-height: 1.3em;
}

.need__words {
  display: inline-block;
}

.is-won .need__words {
  color: var(--bat);
}

/* ------------------------------------------------------------------ this over */
.over {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: clamp(8px, 2.2vh, 12px);
}

.over__label {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.over__balls {
  display: flex;
  gap: clamp(4px, 1.4vw, 6px);
}

.ball {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(22px, 6.6vh, 26px);
  height: clamp(22px, 6.6vh, 26px);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px var(--line);
  background: rgba(255, 255, 255, 0.015);
}

.ball__chip {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 660;
  opacity: 0;
  color: var(--ink);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.06));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.ball__chip.is-dot {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
}

.ball__chip.is-four,
.ball__chip.is-six {
  color: var(--bat-ink);
  background: linear-gradient(180deg, color-mix(in srgb, var(--bat) 75%, #ffffff), var(--bat));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 4px 12px -4px color-mix(in srgb, var(--bat) 80%, transparent);
}

.ball__chip.is-out {
  color: #2a0603;
  background: linear-gradient(180deg, color-mix(in srgb, var(--out) 70%, #ffffff), var(--out));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 4px 12px -4px color-mix(in srgb, var(--out) 80%, transparent);
}

/* ------------------------------------------------------------------ the ball by ball list */
.feed {
  list-style: none;
  margin: clamp(8px, 2.4vh, 14px) 0 0;
  padding: 0;
  height: calc(var(--row) * 2);
  overflow: hidden;
  transition: height 0.6s cubic-bezier(0.2, 0.9, 0.25, 1.04);
  -webkit-mask: linear-gradient(180deg, #000 calc(100% - 10px), transparent);
  mask: linear-gradient(180deg, #000 calc(100% - 10px), transparent);
}

.is-open .feed {
  height: var(--row);
}

.feed li {
  height: var(--row);
  overflow: hidden;
}

.ev {
  display: flex;
  align-items: center;
  gap: 9px;
  height: var(--row);
  border-top: 1px solid var(--line);
  font-size: 12.5px;
}

.ev__over {
  width: 2.4em;
  flex: none;
  color: var(--muted);
  font-size: 11.5px;
}

.ev__tag {
  flex: none;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 640;
  letter-spacing: 0.02em;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.ev__tag.is-four,
.ev__tag.is-six {
  color: var(--bat);
  background: color-mix(in srgb, var(--bat) 12%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bat) 26%, transparent);
}

.ev__tag.is-out {
  color: var(--out);
  background: color-mix(in srgb, var(--out) 12%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--out) 28%, transparent);
}

.ev__txt {
  color: color-mix(in srgb, var(--ink) 80%, var(--muted));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* ------------------------------------------------------------------ the stats */
.stats {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.6s cubic-bezier(0.2, 0.9, 0.25, 1.04);
}

.is-open .stats {
  grid-template-rows: 1fr;
}

.stats__inner {
  overflow: hidden;
  min-height: 0;
}

.prob {
  padding-top: clamp(8px, 2.2vh, 12px);
  border-top: 1px solid var(--line);
}

.prob__labels {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  color: var(--muted);
}

.prob__labels b {
  color: var(--ink);
  font-weight: 640;
}

.prob__title {
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.8;
  white-space: nowrap;
}

.prob__bar {
  position: relative;
  height: 6px;
  margin-top: 7px;
  border-radius: 99px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--bowl) 60%, #000000), var(--bowl));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
  overflow: hidden;
}

.prob__fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 62%;
  border-radius: 99px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--bat) 60%, #000000), var(--bat));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 2px 0 0 0 var(--page);
}

.tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: clamp(8px, 2.2vh, 12px) 0 clamp(4px, 1.4vh, 8px);
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: clamp(5px, 1.4vh, 9px) 9px;
  border-radius: 11px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.02));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  min-width: 0;
}

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

.tile__value {
  font-size: clamp(13px, 4vh, 17px);
  font-weight: 640;
  font-variation-settings: 'wdth' 96;
  letter-spacing: -0.01em;
}

/* ------------------------------------------------------------------ the toggle */
.toggle {
  display: block;
  width: 100%;
  margin-top: clamp(4px, 1.4vh, 8px);
  padding: 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: none;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.toggle:focus-visible {
  outline: 2px solid var(--bat);
  outline-offset: 2px;
  border-radius: 10px;
}

.toggle__face {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: clamp(30px, 8vh, 40px);
}

.toggle__words {
  font-size: 12.5px;
  font-weight: 560;
  font-variation-settings: 'wdth' 100;
  transition: font-variation-settings 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toggle__knob {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  transition: background 0.3s ease;
}

.toggle__chev {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (hover: hover) {
  .toggle:hover .toggle__words {
    font-variation-settings: 'wdth' 112;
  }

  .toggle:hover .toggle__knob {
    background: rgba(255, 255, 255, 0.11);
  }
}

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