/* The weight knob: a type panel's weight control alone on a black page. One word in Fraunces (a variable serif, weight
   100 to 900, its optical size following the font size), two hairline guides under it, and a knob drawn in SVG with
   hairline ticks; the readout in Inter Tight with tabular figures. One accent: the index, and a hundred as it clicks. */
:root {
  --page: #000000;          /* the page */
  --ink: #ece9e2;           /* the word, the hundreds, the figures */
  --muted: #7a7771;         /* the label and a weight between two names */
  --minor: #55534f;         /* the small ticks between the hundreds */
  --body: #0b0b0b;          /* the knob's face */
  --rim: #2e2e2e;           /* the knob's hairline edge */
  --guide: #1f1f1f;         /* the baseline and the x-height */
  --accent: #ff5a2c;        /* the index, and the hundred that clicks */
  --k: 176px;               /* the knob's width */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

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

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Inter Tight Variable', 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 40px 16px;
}

p {
  margin: 0;
}

/* ---------------------------------------------------------------- the whole control */
.weight {
  display: grid;
  justify-items: center;
  gap: 30px;
  width: min(540px, 100%);
}

/* ---------------------------------------------------------------- the word, on its guides */
.specimen {
  position: relative;
  width: 100%;
}

/* the script sets the font size, so that the word fits the width even at 900 */
.specimen__line {
  position: relative;
  font-family: 'Fraunces Variable', Georgia, serif;
  font-size: 84px;
  font-weight: 400;
  font-optical-sizing: auto;
  line-height: 1.22;
  text-align: center;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}

.specimen__word {
  display: inline-block;
  letter-spacing: -0.01em;
}

/* an empty box on the baseline: its bottom edge says where the baseline is */
.specimen__probe {
  display: inline-block;
  width: 0;
  height: 0;
  vertical-align: baseline;
}

/* the baseline and the x-height, two hairlines the width of the control; the script places them */
.guide {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 1px;
  background: var(--guide);
  transform-origin: 50% 50%;
  pointer-events: none;
}

/* ---------------------------------------------------------------- the knob and the readout */
.control {
  display: flex;
  align-items: center;
  gap: 38px;
}

.knob {
  position: relative;
  flex: none;
  width: var(--k);
  height: var(--k);
  border-radius: 50%;
  outline: none;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.knob.is-held {
  cursor: grabbing;
}

.knob__svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.tick {
  stroke: var(--minor);
  stroke-linecap: butt;
}

.tick--major {
  stroke: var(--ink);
}

.face {
  fill: var(--body);
  stroke: var(--rim);
  stroke-width: 1.1;
  transition: stroke 0.25s ease;
}

.index {
  stroke: var(--accent);
  stroke-linecap: round;
}

/* the keys: a hairline ring round the ticks */
.ring {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1;
  opacity: 0;
}

.knob:focus-visible .ring {
  opacity: 1;
}

@media (hover: hover) {
  .knob:hover .face {
    stroke: #4a4a4a;
  }
}

.knob.is-held .face {
  stroke: #5a5a5a;
}

/* the readout: a fixed width, so nothing moves when the name changes */
.read {
  width: 124px;
  display: grid;
  gap: 2px;
}

.read__label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.read__value {
  font-size: 46px;
  font-weight: 300;
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.read__name {
  height: 20px;
  overflow: hidden;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
}

/* the name of the weight: muted between two names, lit once the knob sits on one */
.read__roll {
  display: block;
  color: var(--muted);
  transition: color 0.25s ease;
}

.read__roll.is-on {
  color: var(--ink);
}

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

/* ---------------------------------------------------------------- a phone */
@media (max-width: 560px) {
  :root {
    --k: 150px;
  }

  .weight {
    gap: 26px;
  }

  .control {
    gap: 28px;
  }

  .read {
    width: 112px;
  }

  .read__value {
    font-size: 40px;
  }
}
