/* This or that: a minimal physics piece. A warm white page, a hairline beam on a slender fulcrum and two words
   standing at its ends. The lines are an SVG redrawn by the script at every frame; each word is HTML, carried by the
   beam as one body, and its weight on the scale is the weight of its type. */
:root {
  --paper: #f3f0e8;     /* the page */
  --ink: #141414;       /* the words, the beam and the fulcrum */
  --accent: #e2462b;    /* the needle of the scale */
  --rule: #b9b3a6;      /* the ticks on the beam and on the dial */
  --muted: #8a857b;     /* the small print */
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter Tight Variable', 'Inter Tight', 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;
}

.balance {
  position: absolute;
  inset: 0;
}

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

.beam,
.stop,
.plinth,
.fulcrum {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.fulcrum {
  fill: var(--paper);
}

.ticks,
.dial {
  fill: none;
  stroke: var(--rule);
  stroke-width: 1;
  stroke-linecap: round;
}

.needle {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linecap: round;
}

.pin {
  fill: var(--paper);
  stroke: var(--ink);
  stroke-width: 1.5;
}

/* the button the script moves and turns: its bottom middle is a point on the beam, the letters stand on it and the
   caption hangs under it (its size is set by the script, from the word at its boldest) */
.word {
  position: absolute;
  left: 0;
  top: 0;
  width: 10px;
  height: 10px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  outline: none;
  will-change: transform;
  transform-origin: 50% 100%;
  -webkit-tap-highlight-color: transparent;
}

.word__box {
  position: absolute;
  left: 50%;
  bottom: 0;
  display: block;
  transform: translateX(-50%);
  font-size: 120px;
  line-height: 1;
  white-space: pre;
}

/* a generous hit area around the letters */
.word__box::before {
  content: '';
  position: absolute;
  inset: -0.18em -0.2em -0.3em;
}

.word__ink {
  display: inline-block;
  letter-spacing: -0.03em;
  font-weight: 530;
  transform-origin: 50% 100%;
}

.word__l {
  display: inline-block;
  transform-origin: 50% 100%;
}

.word__cap {
  position: absolute;
  left: 50%;
  top: calc(100% + 12px);
  transform: translateX(-50%);
  font-size: 11px;
  line-height: 1;
  font-weight: 450;
  letter-spacing: 0.02em;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.word__cap b {
  display: inline-block;
  min-width: 2.2em;
  text-align: left;
  font-weight: 600;
  color: var(--ink);
}

/* keyboard focus: a thin frame drawn in the accent, never on a mouse click */
.word:focus-visible .word__box {
  outline: 1px solid var(--accent);
  outline-offset: 0.08em;
}

.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: calc(100% - 170px);
}

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

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

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

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

  .word__cap {
    font-size: 10px;
  }
}
