/* The yarn ball download: a warm charcoal panel on a black page, a coral yarn ball and a pale pill.
   The yarn is painted by script.js with these colours; the panel, the words and the button are plain CSS. */
:root {
  --page: #000000;          /* the page */
  --panel: #151312;         /* the download panel */
  --ink: #f4efe8;           /* the words */
  --muted: #8f877e;         /* the quieter words */
  --yarn: #ff6a3d;          /* the yarn */
  --yarn-deep: #5c1a0b;     /* the yarn in its own shadow */
  --yarn-light: #ffd8bd;    /* the light on the yarn */
  --floor: #000000;         /* the ball's shadow on the panel */
  --error: #ff7b6b;         /* the words that say what went wrong */
  --button: #f4efe8;        /* the button */
  --button-ink: #151312;    /* its words */
  --focus: #ffb08f;         /* the ring round the focused button */
}

* {
  box-sizing: border-box;
}

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

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

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

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

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

/* ---------------------------------------------------------------- the panel */
.kit {
  position: relative;
  width: min(380px, 100%);
  padding: 18px 20px 16px;
  overflow: hidden;
  border-radius: 22px;
  background: var(--panel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  color: var(--ink);
}

.kit__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.kit__words {
  min-width: 0;
}

.kit__title {
  margin: 0;
  font-size: 16px;
  font-weight: 640;
  font-stretch: 92%;
  line-height: 1.25;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.kit__meta {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 440;
  font-stretch: 96%;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
}

/* the words that change slide by themselves */
.kit__swap {
  display: inline-block;
}

.kit__swap .is-error {
  color: var(--error);
}

/* the figure on the right: the percentage, then the tick */
.kit__figure {
  position: relative;
  flex: none;
  min-width: 52px;
  height: 20px;
  margin: 0;
  font-size: 16px;
  font-weight: 640;
  font-stretch: 92%;
  line-height: 20px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.kit__pct {
  display: inline-block;
}

.kit__pct.is-quiet {
  color: var(--muted);
  font-weight: 480;
  font-size: 13px;
}

.kit__tick {
  position: absolute;
  right: -2px;
  top: -2px;
  width: 24px;
  height: 24px;
  fill: none;
  stroke: var(--yarn);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  visibility: hidden;
}

/* ---------------------------------------------------------------- the ball */
/* it runs to the panel's edges, so the yarn comes in from the left edge itself */
.kit__ball {
  position: relative;
  height: 158px;
  margin: 6px -20px 4px;
}

.kit__paint {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------------------------------------------------------------- the foot */
.kit__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.kit__note {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  font-stretch: 96%;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* the pill: its words widen on the width axis under the pointer, its fill swells with a bounce; pressed, it squashes */
.pill {
  position: relative;
  flex: none;
  display: inline-grid;
  place-items: center;
  height: 36px;
  padding: 0 17px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--button-ink);
  font: inherit;
  font-size: 13.5px;
  font-weight: 640;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  transition: color 0.25s ease;
}

.pill::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--button);
  transition: inset 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.25s ease, box-shadow 0.25s ease;
}

.pill__label {
  display: inline-block;
  font-stretch: 86%;
  transition: font-stretch 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* while the download runs the button only pauses it: it steps back */
.pill.is-quiet {
  color: var(--ink);
}

.pill.is-quiet::before {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ink) 18%, transparent);
}

@media (hover: hover) and (pointer: fine) {
  .pill:hover::before {
    inset: -2px -5px;
  }

  .pill:hover .pill__label {
    font-stretch: 100%;
  }

  .pill.is-quiet:hover::before {
    background: color-mix(in srgb, var(--ink) 7%, transparent);
  }
}

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

@media (prefers-reduced-motion: reduce) {
  .pill::before,
  .pill__label {
    transition: none;
  }
}
