/* The lamp dimmer: a wall plate on a black page. The colours below are what things would look like in plain white
   light: on the page they are lit by the lamp, warm and as bright as the knob says, and by a faint cool light. */
:root {
  --page: #000000;          /* the page */
  --plate: #1e1d1c;         /* the plate's paint */
  --metal: #d8d4cc;         /* the knob's nickel */
  --ink: #ece6da;           /* the printing on the plate */
  --window: #94a6cc;        /* the cool light from a window, always there */
  --focus: #f6f1e7;         /* the keyboard's ring */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Jost Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

/* the plate: 300 by 356, drawn on the canvas; the knob and the words sit on it in the same proportions */
.dimmer {
  position: relative;
  width: min(300px, 100%);
  aspect-ratio: 300 / 356;
  border-radius: 26px;
  user-select: none;
  -webkit-user-select: none;
}

.dimmer__plate {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* the knob's hand: a round, invisible area over the drawn knob. The finger turns it without scrolling the page */
.dimmer__knob {
  position: absolute;
  left: calc(100% * 56 / 300);
  top: calc(100% * 52 / 356);
  width: calc(100% * 188 / 300);
  aspect-ratio: 1;
  border-radius: 50%;
  outline: none;
  touch-action: none;
  cursor: grab;
  -webkit-tap-highlight-color: transparent;
}

.dimmer__knob.is-middle {
  cursor: ns-resize;
}

.dimmer.is-held .dimmer__knob {
  cursor: grabbing;
}

.dimmer.is-held .dimmer__knob.is-middle {
  cursor: ns-resize;
}

.dimmer__knob:focus-visible {
  box-shadow: 0 0 0 2px var(--focus);
}

html[data-using='pointer'] .dimmer__knob:focus-visible {
  box-shadow: none;
}

/* ---------------------------------------------------------------- the words printed on the plate */
/* their colour is the light that falls on them: the script works it out */
.dimmer__read {
  position: absolute;
  left: calc(100% * 26 / 300);
  right: calc(100% * 24 / 300);
  bottom: calc(100% * 22 / 356);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-items: end;
  pointer-events: none;
}

.dimmer__read p {
  margin: 0;
}

.dimmer__name {
  grid-column: 1;
  grid-row: 1;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.25;
}

.dimmer__read .dimmer__warmth {
  grid-column: 1;
  grid-row: 2;
  margin-top: 3px;
  font-size: 13px;
  font-weight: 450;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  line-height: 1.25;
}

/* the level: the brighter the lamp, the heavier the figure */
.dimmer__level {
  grid-column: 2;
  grid-row: 1 / 3;
  display: flex;
  align-items: baseline;
  font-size: 44px;
  font-weight: 380;
  line-height: 0.86;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.dimmer__pct {
  margin-left: 2px;
  font-size: 0.46em;
  font-weight: 450;
  letter-spacing: 0;
}

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