/* The Run tests button with the cells that light up. A brushed graphite pill (.tb__body, moved only by GSAP) holds
   three still layers: the metal with its hairlines and its 1px edges (.tb__metal), a light that follows the pointer
   (.tb__shine) and the reflection that crosses it at the end (.tb__sweep). On top the icon, the two lines of words
   and the matrix of cells, drawn on a canvas that reads its colours from here. */
:root {
  --page: #0a0b0d;            /* the page */
  --page-light: #1a1d22;      /* the soft light on the page behind the button */
  --metal-top: #2b2e34;       /* the metal, top */
  --metal-bottom: #121418;    /* the metal, bottom */
  --ink: #eef0f3;             /* the words */
  --muted: rgba(238, 240, 243, 0.56); /* the small line */
  --cell: #ffffff;            /* the cells at rest (drawn very faint) */
  --run: #ffc46b;             /* a test file that is running */
  --pass: #6ff0b0;            /* a test file that passed */
  --fail: #ff7a6b;            /* a test file that failed before its retry */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

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

body {
  min-height: 100svh;
  background:
    radial-gradient(60% 50% at 50% 46%, var(--page-light), transparent 70%),
    var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* a fine grain on the page */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.06 0'/%3E%3C/filter%3E%3Crect width='140' height='140' 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;
  z-index: 1;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
}

.tb {
  position: relative;
  display: grid;
  place-items: center;
}

/* the light the button throws on the floor: grey at rest, mint as the tests pass */
.tb__spill {
  position: absolute;
  left: 50%;
  top: 100%;
  width: 110%;
  height: 44px;
  margin: -16px 0 0 -55%;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--pass) 55%, transparent), transparent);
  filter: blur(16px);
  opacity: 0;
  pointer-events: none;
}

.tb__btn {
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  -webkit-tap-highlight-color: transparent;
}

.tb__btn:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--pass) 70%, white);
  outline-offset: 5px;
}

.tb__body {
  --mx: 30%;
  --my: 0%;
  position: relative;
  display: block;
  width: min(88vw, 318px);
  height: 60px;
  border-radius: 999px;
  isolation: isolate;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.8),
    0 1px 1px rgba(0, 0, 0, 0.6),
    0 6px 12px -6px rgba(0, 0, 0, 0.8),
    0 22px 44px -18px rgba(0, 0, 0, 0.95);
}

.tb__metal,
.tb__shine,
.tb__sweep {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
}

/* brushed graphite: horizontal hairlines, a soft band of light across the upper third, edges that catch the light */
.tb__metal {
  background:
    repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.022) 0 1px, rgba(0, 0, 0, 0.03) 1px 2px, transparent 2px 3px),
    linear-gradient(100deg, transparent 8%, rgba(255, 255, 255, 0.05) 30%, transparent 46%, transparent 64%, rgba(255, 255, 255, 0.035) 80%, transparent 94%),
    linear-gradient(180deg, var(--metal-top) 0%, color-mix(in srgb, var(--metal-top) 50%, var(--metal-bottom)) 46%, var(--metal-bottom) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.07),
    inset 0 1px 0 rgba(255, 255, 255, 0.26),
    inset 0 -1px 0 rgba(0, 0, 0, 0.5),
    inset 0 -12px 18px -14px rgba(0, 0, 0, 0.8);
}

/* the top highlight, a little wet */
.tb__metal::after {
  content: '';
  position: absolute;
  left: 7%;
  right: 7%;
  top: 1px;
  height: 42%;
  border-radius: 999px 999px 40% 40%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0));
}

/* the light under the pointer, stretched like light on brushed metal */
.tb__shine {
  background: radial-gradient(120px 34px at var(--mx) var(--my), rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.03) 55%, transparent 75%);
  opacity: 0;
}

/* the reflection that crosses the metal at the end */
.tb__sweep-band {
  position: absolute;
  top: -30%;
  left: 0;
  width: 34%;
  height: 160%;
  background: linear-gradient(100deg, transparent 0%, rgba(255, 255, 255, 0.04) 30%, rgba(255, 255, 255, 0.24) 50%, rgba(255, 255, 255, 0.04) 70%, transparent 100%);
}

.tb__row {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 22px 0 16px;
  gap: 10px;
}

.tb__icon {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
}

.tb__icon svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.tb__ring {
  fill: rgba(255, 255, 255, 0.05);
  stroke: rgba(255, 255, 255, 0.16);
  stroke-width: 1;
}

.tb__play {
  fill: var(--ink);
}

.tb__spin {
  fill: none;
  stroke: var(--run);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-dasharray: 0.22 0.78;
  opacity: 0;
}

.tb__check {
  fill: none;
  stroke: var(--pass);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  opacity: 0;
}

.tb__text {
  flex: none;
  display: grid;
  gap: 2px;
  text-align: left;
  width: 96px;
}

.tb__labels,
.tb__subs {
  display: grid;
}

.tb__label {
  grid-area: 1 / 1;
  font-size: 15px;
  line-height: 1.15;
  font-weight: 580;
  font-variation-settings: 'wdth' 100;
  letter-spacing: 0.002em;
  white-space: nowrap;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
}

/* Running shimmers: a band of light slides through the letters (GSAP moves background-position) */
.tb__label--busy {
  background: linear-gradient(90deg, var(--ink) 0%, var(--ink) 38%, #ffffff 46%, var(--run) 50%, #ffffff 54%, var(--ink) 62%, var(--ink) 100%);
  background-size: 260% 100%;
  background-position: 100% 0;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
}

.tb__sub {
  grid-area: 1 / 1;
  font-size: 11px;
  line-height: 1.2;
  font-weight: 480;
  font-variant-numeric: tabular-nums;
  font-variation-settings: 'wdth' 92;
  color: var(--muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.tb__sub--ok {
  color: color-mix(in srgb, var(--pass) 72%, var(--ink));
}

.tb__retry {
  color: color-mix(in srgb, var(--fail) 80%, var(--ink));
  opacity: 0;
}

/* a hairline between the words and the cells, light on the left, dark on the right like a cut in the metal */
.tb__rule {
  flex: none;
  align-self: center;
  width: 2px;
  height: 26px;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.55) 0 1px, rgba(255, 255, 255, 0.09) 1px 2px);
  -webkit-mask: linear-gradient(180deg, transparent, #000 25%, #000 75%, transparent);
  mask: linear-gradient(180deg, transparent, #000 25%, #000 75%, transparent);
}

.tb__matrix {
  flex: 1;
  min-width: 0;
  height: 26px;
  position: relative;
}

.tb__matrix canvas {
  position: absolute;
  left: -8px;
  top: -8px;
  width: calc(100% + 16px);
  height: calc(100% + 16px);
}

/* before the script runs, only the rest state shows */
.tb__label + .tb__label,
.tb__sub + .tb__sub {
  opacity: 0;
}
