/* The button under stress: a slab of clear plastic between crossed polarising filters. The bands of colour are drawn
   on a canvas by script.js (they are interference colours, worked out from the light, not picked); from here come the
   page, the gloss on the plastic, its polished edge and the words. */
:root {
  --page: #000000;          /* the page: the crossed filters let no light through where there is no plastic */
  --text: #f5f5f7;          /* the words and the icons */
  --halo: rgba(0, 0, 0, 0.85); /* the dark halo round the words, so they read over the bands */
  --edge: rgba(255, 255, 255, 0.16); /* the polished edge of the slab */
  --gloss: rgba(255, 255, 255, 0.07); /* the light of the room on the top of the slab */
  --done: #8ff0b4;          /* the tick once the test has passed */
  --focus: #f5f5f7;         /* the ring of the keyboard's focus */
}

* {
  box-sizing: border-box;
}

/* a tap is a click at once: no wait for a double tap */
html {
  touch-action: manipulation;
}

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

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

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

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 72px 16px;
}

.stress {
  display: grid;
  justify-items: center;
}

/* ---------------------------------------------------------------- the slab */
.stress__btn {
  position: relative;
  display: grid;
  place-items: center;
  width: min(300px, calc(100vw - 48px));
  height: 60px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #000000;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
  /* a finger dragged across moves the load; up and down it still scrolls the page */
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 160ms cubic-bezier(0.23, 1, 0.32, 1);
}

/* pressed, the slab gives a little under the load */
.stress__btn.is-down {
  transform: scale(0.975);
}

.stress__btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 5px;
}

html[data-using='pointer'] .stress__btn:focus-visible {
  outline: none;
}

.stress__btn[aria-disabled='true'] {
  cursor: progress;
}

.stress__fringes {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  pointer-events: none;
}

/* the bands at the peak of the test, worked out once, that fade in when the motion is reduced */
.stress__ghost {
  opacity: 0;
}

/* the gloss of the plastic: the room's light on the top of the slab, and the light box a shade weaker at the ends */
.stress__btn::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  background:
    linear-gradient(180deg, var(--gloss) 0%, rgba(255, 255, 255, 0.02) 38%, rgba(255, 255, 255, 0) 52%),
    radial-gradient(120% 160% at 50% 50%, rgba(0, 0, 0, 0) 58%, rgba(0, 0, 0, 0.32) 100%);
  pointer-events: none;
}

/* the polished edge, drawn over the bands so it stays crisp */
.stress__btn::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px var(--edge), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  pointer-events: none;
}

/* ---------------------------------------------------------------- the words */
.stress__label {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 4px;
  font-size: 16px;
  font-weight: 520;
  line-height: 1;
  letter-spacing: -0.003em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-shadow: 0 0 2px var(--halo), 0 0 7px var(--halo), 0 0 14px var(--halo);
  pointer-events: none;
}

.stress__words {
  display: block;
  text-align: left;
}

.stress__icons {
  position: relative;
  display: block;
  width: 20px;
  height: 20px;
  flex: none;
  filter: drop-shadow(0 0 3px var(--halo)) drop-shadow(0 0 6px var(--halo));
}

.stress__icon {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.stress__icon [data-supports] {
  fill: currentColor;
  stroke-width: 1.2;
}

.stress__icon--done {
  opacity: 0;
  color: var(--done);
}

@media (max-width: 380px) {
  .stress__label {
    gap: 8px;
    font-size: 15.5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stress__btn,
  .stress__btn.is-down {
    transform: none;
  }

  .stress__btn.is-down {
    filter: brightness(0.92);
  }
}
