/* Sprung: a minimal physics piece. A warm white page, one hairline for the ceiling, a thin coiled spring and a big
   number hanging from it on a rail as thin as a hair. Lines and the spring are an SVG redrawn by the script at every
   frame; the number is HTML, moved and turned as one body. */
:root {
  --paper: #f3f0e8;     /* the page */
  --ink: #141414;       /* the number and the spring */
  --accent: #e5432b;    /* the digit that has just changed */
  --line: #cfc9bc;      /* the ceiling, the back of the coils, the dimension line */
  --muted: #8a857a;     /* the small print */
  --weight: 560;        /* how heavy the number is (100 to 1000) */
  --stretch: 88;        /* how wide the number is at rest (40 to 140) */
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Roboto Flex Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: grab;
  outline: none;
}

.stage.is-grabbing {
  cursor: grabbing;
}

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

.rule,
.dim {
  fill: none;
  stroke: var(--line);
  stroke-width: 1;
}

.coil {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.coil--back {
  stroke: var(--line);
  stroke-width: 1.1;
}

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

/* the element the script moves and turns: the children are left free for the squash and the type axes */
.body {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  will-change: transform;
  pointer-events: none;
}

.rail {
  display: block;
  align-self: stretch;
  height: 1.5px;
  margin: 0 -0.04em;
  background: var(--ink);
  transform-origin: 50% 50%;
}

.count {
  --dw: 0;
  --ds: 0;
  margin-top: 0.1em;
  font-size: clamp(76px, min(30vw, 25vh), 236px);
  line-height: 0.86;
  white-space: pre;
  letter-spacing: 0.012em;
  font-variant-numeric: tabular-nums lining-nums;
  font-weight: clamp(100, calc(var(--weight) + var(--dw)), 1000);
  font-stretch: clamp(25%, calc((var(--stretch) + var(--ds)) * 1%), 151%);
  transform-origin: 50% 0;
}

.slot {
  position: relative;
  display: inline-block;
  clip-path: inset(-0.02em -0.12em);
}

.g {
  --gw: 0;
  display: inline-block;
  font-weight: clamp(100, calc(var(--weight) + var(--dw) + var(--gw)), 1000);
}

.g--out {
  position: absolute;
  left: 0;
  top: 0;
}

.sep {
  display: inline-block;
  margin: 0 0.02em 0 0;
}

.label {
  margin: 0.95em 0 0;
  font-size: 13px;
  line-height: 1.2;
  font-weight: 480;
  font-stretch: 100%;
  letter-spacing: 0.02em;
  color: var(--muted);
  text-align: center;
  max-width: calc(100vw - 48px);
}

.hint,
.read {
  position: absolute;
  bottom: 22px;
  margin: 0;
  font-size: 12px;
  line-height: 1.3;
  font-weight: 450;
  letter-spacing: 0.01em;
  color: var(--muted);
  pointer-events: none;
}

.hint {
  left: 24px;
  max-width: min(360px, calc(100% - 150px));
}

.read {
  right: 24px;
  display: flex;
  gap: 10px;
  font-variant-numeric: tabular-nums;
}

.read__value {
  display: inline-block;
  min-width: 2.6em;
  text-align: right;
  font-weight: 640;
  color: var(--ink);
}

.stage:focus-visible .read__label {
  color: var(--ink);
}

@media (max-width: 560px) {
  .hint {
    left: 16px;
    bottom: 18px;
  }

  .read {
    right: 16px;
    bottom: 18px;
  }
}
