/* The humidity slider with the mist that thickens: the bedroom card of a smart home app on pure black. The card body
   is the element itself; the canvas with the mist sits just above its background; the sheen (the light on the 1px
   edge that follows the pointer) and the grain over it; the words and the ruler on top. */
:root {
  --page: #000000;           /* the page */
  --card-top: #17191c;       /* the card, at the top */
  --card-bottom: #0d0f11;    /* the card, at the bottom */
  --edge: rgba(255, 255, 255, 0.075); /* its 1px edge at rest */
  --ink: #eef1f2;            /* the words */
  --muted: #7d858b;          /* the small words */
  --faint: rgba(255, 255, 255, 0.16); /* the ticks */
  --accent: #7fe3dc;         /* the mist and the comfortable range */
  --warn: #f2b56b;           /* dry or damp air */
}

* {
  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: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
}

.humid {
  --mx: 50%;
  --my: 0%;
  --lit: 0;
  --tone: var(--accent);
  position: relative;
  width: min(86vw, 330px);
  padding: clamp(14px, 4vh, 22px) clamp(16px, 5.4vw, 22px) clamp(12px, 3.4vh, 18px);
  border-radius: 26px;
  background: linear-gradient(180deg, var(--card-top), var(--card-bottom));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    inset 0 0 0 1px var(--edge),
    0 1px 1px rgba(0, 0, 0, 0.6),
    0 18px 40px -18px rgba(0, 0, 0, 0.9),
    0 40px 90px -40px color-mix(in srgb, var(--accent) 22%, transparent);
  overflow: hidden;
  isolation: isolate;
  opacity: 0;
}

/* the grain, very thin, over the mist and under the words */
.humid::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0.09;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.humid__mist {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* the 1px edge catching a light that follows the pointer */
.humid__sheen {
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: inherit;
  padding: 1px;
  pointer-events: none;
  background: radial-gradient(180px 140px at var(--mx) var(--my), rgba(255, 255, 255, 0.55), transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  opacity: calc(0.35 + var(--lit) * 0.65);
}

.humid > :not(canvas):not(.humid__sheen) {
  position: relative;
  z-index: 4;
}

.humid__head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.humid__icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  flex: none;
}

.humid__icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.humid__who {
  display: grid;
  gap: 1px;
  min-width: 0;
  flex: 1;
}

.humid__room {
  font-size: 14.5px;
  font-weight: 600;
  font-variation-settings: 'wdth' 106;
}

.humid__device {
  font-size: 11.5px;
  color: var(--muted);
}

.humid__chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 520;
  color: #c6cdd1;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.09);
}

.humid__chip svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
  opacity: 0.8;
}

.humid__read {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-top: clamp(10px, 3.2vh, 20px);
}

.humid__value {
  margin: 0;
  display: flex;
  align-items: flex-start;
  font-size: clamp(50px, min(17vw, 15vh), 68px);
  line-height: 1;
  font-weight: 560;
  font-variation-settings: 'wdth' 92;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
}

.humid__digits {
  display: inline-flex;
  align-items: flex-start;
  height: 1em;
  overflow: hidden;
  /* the digits fade a little at their top and bottom while they roll */
  -webkit-mask: linear-gradient(180deg, transparent 0, #000 12%, #000 88%, transparent 100%);
  mask: linear-gradient(180deg, transparent 0, #000 12%, #000 88%, transparent 100%);
}

.humid__col {
  display: block;
  flex: none;
  height: 10em;
  width: 0.6em;
  text-align: center;
}

.humid__col span {
  display: block;
  height: 1em;
}

.humid__pct {
  font-size: 0.4em;
  margin: 0.2em 0 0 0.08em;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
}

.humid__side {
  display: grid;
  justify-items: end;
  gap: 4px;
  padding-bottom: 6px;
}

.humid__state {
  font-size: 13px;
  font-weight: 600;
  font-variation-settings: 'wdth' 104;
  color: var(--tone);
  transition: color 0.5s ease;
}

.humid__now {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

.humid__now b {
  font-weight: 560;
  color: #c6cdd1;
}

/* the ruler: the slider itself */
.humid__slider {
  display: block;
  height: 64px;
  margin: clamp(8px, 2.4vh, 16px) 0 0;
  cursor: grab;
  touch-action: none;
  outline: none;
  border-radius: 12px;
  -webkit-tap-highlight-color: transparent;
}

.humid__slider:active {
  cursor: grabbing;
}

.humid__slider:focus-visible {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 70%, transparent);
}

.humid__ticks {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 22px;
  height: 30px;
}

.humid__tick {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 1px;
  height: 30px;
  margin-left: -0.5px;
  border-radius: 1px;
  background: var(--faint);
  transform-origin: 50% 100%;
}

.humid__tick.is-major {
  background: rgba(255, 255, 255, 0.3);
}

.humid__tick.is-comfort {
  background: color-mix(in srgb, var(--accent) 34%, transparent);
}

.humid__tick.is-comfort.is-major {
  background: color-mix(in srgb, var(--accent) 60%, transparent);
}

/* the comfortable range, a thin lit line under the ticks with its word */
.humid__band {
  position: absolute;
  bottom: 18px;
  height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 70%, transparent) 14%, color-mix(in srgb, var(--accent) 70%, transparent) 86%, transparent);
}

.humid__band span {
  position: absolute;
  left: 50%;
  top: 4px;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 540;
  letter-spacing: 0.04em;
  color: color-mix(in srgb, var(--accent) 80%, #fff);
  opacity: 0.75;
}

.humid__ends {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2px;
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.humid__thumb {
  position: absolute;
  left: 8px;
  bottom: 18px;
  width: 0;
  height: 44px;
  pointer-events: none;
}

.humid__thumb-core {
  position: absolute;
  left: -1.5px;
  bottom: 0;
  width: 3px;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(180deg, #ffffff, color-mix(in srgb, var(--tone) 70%, #fff));
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 0 14px 1px color-mix(in srgb, var(--tone) 55%, transparent);
  transform-origin: 50% 100%;
  transition: background 0.5s ease, box-shadow 0.5s ease;
}

.humid__foot {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: clamp(10px, 2.6vh, 16px);
  padding-top: clamp(10px, 2.6vh, 14px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.humid__stat {
  display: grid;
  gap: 2px;
}

.humid__stat:last-child {
  text-align: right;
}

.humid__label {
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.humid__stat b {
  font-size: 13.5px;
  font-weight: 580;
  font-variation-settings: 'wdth' 100;
  font-variant-numeric: tabular-nums;
}
