/* Tempo: a minimal physics piece. A warm white room, five metronomes drawn with hairlines on a shelf that rests on
   two rollers, and one word underneath. The drawing is an SVG rebuilt by the script on every frame; the word is
   HTML, one span per letter, so its width and weight can move. */
:root {
  --paper: #f3f0e8;     /* the room */
  --ink: #161513;       /* the metronomes and the word */
  --hair: #b9b3a6;      /* the floor and the ticks at rest */
  --muted: #8a8478;     /* the small print */
  --accent: #e8452c;    /* the weights, once they beat together */
  --elastico: cubic-bezier(0.34, 1.9, 0.45, 1);
}

* {
  box-sizing: border-box;
}

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

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

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.scene .line {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.scene .hair {
  fill: none;
  stroke: var(--hair);
  stroke-width: 1;
  stroke-linecap: round;
}

/* ---------------------------------------------------------------- the word */
.word {
  position: absolute;
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  font-size: clamp(2.4rem, 1rem + 6vw, 6.4rem);
  line-height: 1;
  letter-spacing: -0.02em;
  white-space: pre;
  pointer-events: none;
}

.word span {
  display: inline-block;
  will-change: transform;
}

/* ---------------------------------------------------------------- the foot */
.foot {
  position: absolute;
  left: clamp(16px, 4vw, 48px);
  right: clamp(16px, 4vw, 48px);
  bottom: clamp(16px, 4vh, 36px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.note {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 460;
  font-stretch: 92%;
}

/* ---------------------------------------------------------------- the elastic pill */
.pillola {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--paper);
  font: inherit;
  font-size: 15px;
  font-weight: 620;
  cursor: pointer;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
}

.pillola::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--ink);
  transition: inset 0.6s var(--elastico);
}

.pillola__scritta {
  font-stretch: 86%;
  transition: font-stretch 0.6s var(--elastico);
}

.pillola__scritta::before {
  content: attr(data-testo);
  display: block;
  height: 0;
  overflow: hidden;
  visibility: hidden;
  font-stretch: 100%;
}

.pillola__segno {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.6s var(--elastico);
}

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

  .pillola:hover .pillola__scritta {
    font-stretch: 100%;
  }

  .pillola:hover .pillola__segno {
    transform: rotate(-14deg);
  }
}

.pillola:active::before {
  inset: 2px 3px;
}

.pillola:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

@media (max-width: 560px) {
  .note {
    font-size: 13px;
  }
}
