/* The home thermostat with the arc of light that follows the finger: the dial of a made-up smart home app (Calora)
   on an almost black page. A wide ring with the ticks of the degrees, an arc of light from cold blue to warm amber,
   a rolling figure in the middle and an Eco pill under it. */
:root {
  --page: #0a0b0d;          /* the page, almost black */
  --page-light: #15171b;    /* the soft light at the top of the page */
  --ink: #f3f1ec;           /* the figure and the words */
  --muted: #7d8089;         /* the small words */
  --line: rgba(255, 255, 255, 0.08); /* the thin lines */
  --groove: #121418;        /* the groove the arc of light runs in */
  --tick: rgba(255, 255, 255, 0.2); /* the ticks far from the knob */
  --cold: #4f86ff;          /* cold blue, at 10 degrees */
  --cool: #8cc4ff;          /* the light blue past the middle of the cold side */
  --mild: #f2e4c4;          /* the pale middle of the scale */
  --warm: #ffb54a;          /* warm amber */
  --hot: #ff7a2e;           /* the deep amber at 30 degrees */
  --eco: #9fd8b0;           /* sage: the leaf of Eco when it is on */
  --knob: #f6f4ef;          /* the knob */
  --temp: #ffb54a;          /* the colour of the temperature, set by the script */
}

* {
  box-sizing: border-box;
}

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

body {
  background:
    radial-gradient(80% 55% at 50% 0%, var(--page-light), transparent 70%),
    var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', 'Mona Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  --size: min(78vw, 56vh, 430px);
  position: relative;
  height: 100vh;
  display: grid;
  place-items: center;
  padding: min(4vw, 3vh);
  overflow: hidden;
}

.unit {
  width: var(--size);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(8px, 2.4vh, 22px);
}

.unit__head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: clamp(11px, 1.7vh, 13px);
  color: var(--muted);
  letter-spacing: 0.01em;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  color: var(--ink);
  font-weight: 560;
  font-variation-settings: 'wdth' 108;
}

.brand__mark {
  width: 1.45em;
  height: 1.45em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.room {
  font-family: 'Geist Mono Variable', ui-monospace, monospace;
  font-size: 0.92em;
  letter-spacing: 0.02em;
}

/* ---- the dial ---- */

.dial {
  position: relative;
  width: var(--size);
  aspect-ratio: 1;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.dial__glow {
  position: absolute;
  inset: -2%;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--temp), transparent 74%);
  filter: blur(calc(var(--size) * 0.09));
  opacity: 0.22;
  pointer-events: none;
}

.dial__base,
.dial__top,
.dial__arc {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.dial__face {
  filter: drop-shadow(0 14px 22px rgba(0, 0, 0, 0.55));
}

.dial__facerim {
  fill: none;
  stroke-width: 1;
}

.dial__groove {
  fill: none;
  stroke: var(--groove);
  stroke-width: 18;
  stroke-linecap: round;
}

.dial__groove-edge {
  fill: none;
  stroke: rgba(255, 255, 255, 0.05);
  stroke-width: 1;
}

.dial__ticks line {
  stroke: var(--tick);
  stroke-width: 1.15;
  stroke-linecap: round;
}

.dial__ticks line.is-whole {
  stroke-width: 1.5;
}

.dial__ends text {
  fill: var(--muted);
  font-family: 'Geist Mono Variable', ui-monospace, monospace;
  font-size: 9px;
  text-anchor: middle;
  dominant-baseline: middle;
}

/* the arc of light: a conic gradient cut to the groove (radial mask) and to the angle (conic mask) */
.dial__arc {
  --a: 0deg;
  background: conic-gradient(from 225deg, var(--cold) 0deg, var(--cool) 70deg, var(--mild) 135deg, var(--warm) 200deg, var(--hot) 270deg, var(--hot) 360deg);
  -webkit-mask:
    radial-gradient(closest-side, transparent 73.1%, #000 73.5%, #000 84.1%, transparent 84.5%),
    conic-gradient(from 225deg, #000 0deg, #000 var(--a), transparent var(--a));
  -webkit-mask-composite: source-in;
  mask:
    radial-gradient(closest-side, transparent 73.1%, #000 73.5%, #000 84.1%, transparent 84.5%),
    conic-gradient(from 225deg, #000 0deg, #000 var(--a), transparent var(--a));
  mask-composite: intersect;
  opacity: 0.9;
  pointer-events: none;
}

/* a thin sheen that runs along the inner edge of the arc */
.dial__sheen {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(closest-side, transparent 73%, rgba(255, 255, 255, 0.55) 74.2%, transparent 77%);
  opacity: 0.5;
}

.dial__cap {
  fill: var(--cold);
}

.knob__shadow {
  fill: rgba(0, 0, 0, 0.5);
  filter: blur(3px);
}

.knob__disc {
  fill: var(--knob);
}

.knob__ring {
  fill: none;
  stroke: rgba(0, 0, 0, 0.12);
  stroke-width: 0.8;
}

.knob__dimple {
  fill: var(--temp);
  opacity: 0.9;
}

.dial__hit {
  fill: transparent;
  cursor: grab;
  outline: none;
}

.dial.is-dragging .dial__hit {
  cursor: grabbing;
}

.dial__hit:focus-visible {
  stroke: rgba(255, 255, 255, 0.35);
  stroke-width: 1;
}

/* ---- the figure ---- */

.readout {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.readout__mode {
  font-size: calc(var(--size) * 0.042);
  font-weight: 560;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--temp);
  margin-bottom: calc(var(--size) * 0.01);
}

.readout__num {
  display: flex;
  align-items: flex-start;
  font-size: calc(var(--size) * 0.2);
  line-height: 1;
  font-weight: 330;
  font-variation-settings: 'wdth' 92;
  letter-spacing: -0.035em;
  color: var(--ink);
}

.reel {
  position: relative;
  height: 1em;
  width: 0.6em;
  overflow: hidden;
  display: inline-block;
  text-align: center;
}

.reel__col {
  display: flex;
  flex-direction: column;
}

.reel__col span {
  height: 1em;
  line-height: 1;
  text-align: center;
}

.readout__dot {
  height: 1em;
  line-height: 1;
}

.readout__deg {
  font-size: 0.42em;
  line-height: 1;
  margin-top: 0.12em;
  margin-left: 0.04em;
  font-weight: 380;
  color: var(--muted);
}

.readout__room {
  margin-top: calc(var(--size) * 0.028);
  font-family: 'Geist Mono Variable', ui-monospace, monospace;
  font-size: calc(var(--size) * 0.036);
  color: var(--muted);
}

.readout__room b {
  font-weight: 500;
  color: var(--ink);
}

/* ---- the time to get there ---- */

.status {
  margin: 0;
  height: 1.4em;
  font-size: clamp(12px, 2vh, 15px);
  color: var(--muted);
  font-variation-settings: 'wdth' 100;
  white-space: nowrap;
}

.status span {
  display: inline-block;
}

.status b {
  color: var(--ink);
  font-weight: 520;
}

/* ---- Eco ---- */

.eco {
  appearance: none;
  border: 0;
  padding: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  -webkit-tap-highlight-color: transparent;
}

.eco__body {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  height: clamp(32px, 5.6vh, 42px);
  padding: 0 1.1em 0 0.9em;
  border-radius: 999px;
  font-size: clamp(12px, 1.9vh, 14px);
  font-weight: 540;
  font-variation-settings: 'wdth' 100;
  background: linear-gradient(#1a1c21, #121418);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 8px 18px rgba(0, 0, 0, 0.45);
  transition: box-shadow 0.4s;
}

.eco__leaf {
  width: 1.25em;
  height: 1.25em;
  overflow: visible;
}

.eco__leaf-fill {
  fill: transparent;
  stroke: var(--muted);
  stroke-width: 1.4;
  stroke-linejoin: round;
  transition: fill 0.4s, stroke 0.4s;
}

.eco__vein {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.3;
  stroke-linecap: round;
  transition: stroke 0.4s;
}

.eco__val {
  font-family: 'Geist Mono Variable', ui-monospace, monospace;
  font-weight: 400;
  color: var(--muted);
  font-size: 0.92em;
}

.eco[aria-pressed='true'] .eco__body {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 0 0 1px rgba(159, 216, 176, 0.35),
    0 8px 22px rgba(0, 0, 0, 0.45);
}

.eco[aria-pressed='true'] .eco__leaf-fill {
  fill: rgba(159, 216, 176, 0.22);
  stroke: var(--eco);
}

.eco[aria-pressed='true'] .eco__vein {
  stroke: var(--eco);
}

.eco:focus-visible {
  outline: 1px solid rgba(255, 255, 255, 0.4);
  outline-offset: 3px;
}

@media (hover: hover) {
  .eco:hover .eco__body {
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.12),
      inset 0 0 0 1px rgba(255, 255, 255, 0.12),
      0 10px 22px rgba(0, 0, 0, 0.5);
  }
}

/* ---- the pointer that plays by itself ---- */

.cursor {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  fill: #fff;
  stroke: #0a0b0d;
  stroke-width: 1.2;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}

@media (prefers-reduced-motion: reduce) {
  .dial__glow {
    filter: blur(calc(var(--size) * 0.09));
  }
}
