/* The syllable metronome: a minimal piece. A warm white page, a metronome drawn in hairlines and one line of type.
   The lines are an SVG redrawn by the script at every frame; the syllables and the tempo are plain HTML in a variable
   face, so their weight and width can change while they move. */
:root {
  --paper: #f3f0e8;   /* the page */
  --ink: #141414;     /* the lines and the syllables */
  --accent: #e2442a;  /* the accented beat: the last syllable of every bar */
  --faint: #cfc8ba;   /* the arc of the swing and the marks at its ends */
  --muted: #8a8478;   /* the scale on the metronome, the small print */
}

* {
  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;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

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

.scene path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.rule,
.floor {
  stroke: var(--ink);
  stroke-width: 1;
}

.tick {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1;
  stroke-linecap: butt;
}

.tick--accent {
  stroke: var(--accent);
}

.body {
  stroke: var(--ink);
  stroke-width: 1.25;
}

.scale {
  stroke: var(--muted);
  stroke-width: 1;
}

.arc,
.mark {
  stroke: var(--faint);
  stroke-width: 1;
}

.flash {
  stroke: var(--ink);
  stroke-width: 1.5;
  opacity: 0;
}

.flash--accent {
  stroke: var(--accent);
}

.rod {
  stroke: var(--ink);
  stroke-width: 1.25;
}

.scene .weight {
  fill: var(--paper);
  stroke: var(--ink);
  stroke-width: 1.25;
  transition: stroke-width 0.25s ease;
}

.scene .pivot {
  fill: var(--paper);
  stroke: var(--ink);
  stroke-width: 1.25;
}

.words {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* one syllable: the outer span is placed and squashed, the inner one carries the type axes */
.syl {
  position: absolute;
  left: 0;
  top: 0;
  line-height: 1;
  white-space: nowrap;
  text-align: center;
  visibility: hidden;
  will-change: transform, opacity;
}

.syl__in {
  display: inline-block;
  font-variation-settings: 'wght' 160, 'wdth' 100;
}

.probe {
  position: absolute;
  left: -9999px;
  top: 0;
  font-size: 100px;
  line-height: 1;
  white-space: nowrap;
  visibility: hidden;
}

.probe i {
  display: inline-block;
  width: 0;
  height: 0;
  vertical-align: baseline;
}

/* the handle over the metronome */
.grip {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  cursor: grab;
  touch-action: none;
  outline: none;
  border-radius: 6px;
}

.grip:focus-visible {
  box-shadow: 0 0 0 1px var(--muted);
}

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

.stage.is-grabbing .scene .weight {
  stroke-width: 2;
}

@media (hover: hover) {
  .stage.is-over .scene .weight {
    stroke-width: 2;
  }
}

.tempo {
  position: absolute;
  left: 0;
  top: 0;
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 0.7em;
  pointer-events: none;
  opacity: 0;
}

.tempo__num {
  font-size: clamp(34px, 7.4vmin, 72px);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  font-variation-settings: 'wght' 300, 'wdth' 100;
  letter-spacing: -0.01em;
}

.tempo__meta {
  display: flex;
  flex-direction: column;
  gap: 0.3em;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-variation-settings: 'wght' 480, 'wdth' 100;
}

.tempo__unit {
  color: var(--muted);
}

.tempo__window {
  display: block;
  overflow: hidden;
  height: 1.3em;
  line-height: 1.3em;
}

.tempo__name {
  display: block;
  white-space: nowrap;
}

.hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(20px, 4.5vh);
  margin: 0;
  text-align: center;
  pointer-events: none;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-variation-settings: 'wght' 440, 'wdth' 100;
  opacity: 0;
}
