/* The thermostat: a metal dial on a black page, its scale warm when heating and cold when cooling. */
:root {
  --page: #000000;          /* the page */
  --ink: #f2f3f5;
  --muted: #7f838d;
  --warm: #ff7a2f;          /* heating */
  --cool: #45a8ff;          /* cooling */
  --on: var(--warm);        /* the colour of the moment: the script changes it with the mode */
  --d: min(320px, calc(100vw - 48px));   /* the dial's width */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Saira 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: 28px 16px;
}

.thermo {
  display: grid;
  justify-items: center;
  gap: 26px;
}

/* ---------------------------------------------------------------- the dial */
.dial {
  position: relative;
  width: var(--d);
  height: var(--d);
  border-radius: 50%;
  outline: none;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

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

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

.tick {
  stroke: #3a3d45;
  stroke-width: 2.2;
  stroke-linecap: round;
  transition: stroke 0.3s;
}

.tick.is-on {
  stroke: var(--on);
}

.dial__read {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  pointer-events: none;
}

.dial__mode {
  margin: 0;
  color: var(--on);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  transition: color 0.4s;
}

.dial__temp {
  display: flex;
  align-items: flex-start;
  margin: 0;
  font-size: calc(var(--d) * 0.24);
  font-weight: 300;
  line-height: 1;
  letter-spacing: -0.02em;
  /* proportional figures: a tabular 1 is as wide as a 2 and leaves a hole before the degree sign */
  font-variant-numeric: proportional-nums;
}

.dial__deg {
  margin-left: 2px;
  font-size: 0.42em;
  line-height: 1.3;
  color: var(--muted);
}

.dial__now {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* a figure or a word that rolls */
.roll {
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
}

.roll > span {
  display: inline-block;
}

.thermo.is-off .dial__temp {
  color: var(--muted);
}

.dial:focus-visible {
  box-shadow: 0 0 0 3px #000000, 0 0 0 5px var(--ink);
}

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

/* ---------------------------------------------------------------- the controls */
.controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #262930;
  border-radius: 50%;
  background: #121317;
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.step svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
}

@media (hover: hover) {
  .step:hover {
    background: #1b1d22;
  }
}

.modes {
  position: relative;
  display: flex;
  padding: 4px;
  border: 1px solid #262930;
  border-radius: 999px;
  background: #121317;
}

.modes__pill {
  position: absolute;
  top: 4px;
  left: 0;
  height: calc(100% - 8px);
  border-radius: 999px;
  background: #24262d;
  pointer-events: none;
}

.mode {
  position: relative;
  padding: 9px 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: 600 14px 'Saira Variable', system-ui, sans-serif;
  cursor: pointer;
  transition: color 0.3s;
  -webkit-tap-highlight-color: transparent;
}

.mode[aria-checked='true'] {
  color: var(--ink);
}

.step:focus-visible,
.mode:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

html[data-using='pointer'] .step:focus-visible,
html[data-using='pointer'] .mode:focus-visible {
  outline: none;
}

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