/* The price range slider with the glass lens: the price filter of Northvale, an invented shop of trail running
   shoes, alone on white. A white card with a layered shadow and a 1px edge; the histogram of the prices; over the
   chosen range a lens of glass that can be grabbed and slid as a whole, with the two handles at its lower corners. */
:root {
  --page: #ffffff;          /* the page */
  --card: #ffffff;          /* the card */
  --ink: #141414;           /* the words */
  --muted: #8b8984;         /* the small words */
  --line: #ecebe8;          /* thin lines and the bars outside the range */
  --accent: #ff5a1f;        /* the bars inside the range, the fill, the live field */
  --accent-deep: #e8430c;   /* the foot of the bars inside the range */
  --button: #141414;        /* the Show button */
  --button-ink: #ffffff;    /* the words on the button */
}

* {
  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 {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
}

/* ---------------------------------------------------------------- the card */
.filter {
  position: relative;
  width: min(352px, 90vw);
  padding: clamp(14px, 3.6vh, 20px) 18px clamp(14px, 3.6vh, 18px);
  border-radius: 22px;
  background: var(--card);
  box-shadow:
    0 0 0 1px rgba(20, 20, 20, 0.06),
    0 1px 1px rgba(20, 20, 20, 0.04),
    0 4px 8px -2px rgba(20, 20, 20, 0.05),
    0 18px 36px -14px rgba(20, 20, 20, 0.14),
    0 40px 70px -40px rgba(255, 90, 31, 0.22);
  opacity: 0;
  user-select: none;
  -webkit-user-select: none;
}

/* the 1px edge that catches the light at the top */
.filter::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0) 40%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* a very fine grain on the card */
.filter::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
  opacity: 0.035;
  mix-blend-mode: multiply;
  pointer-events: none;
}

.filter__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.filter__title {
  margin: 0;
  font-size: 17px;
  font-weight: 640;
  font-stretch: 104%;
  letter-spacing: -0.01em;
}

.filter__sub {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  font-stretch: 96%;
}

.reset {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 10px 0 8px;
  border: 0;
  border-radius: 999px;
  background: #f5f4f2;
  box-shadow: inset 0 0 0 1px rgba(20, 20, 20, 0.05);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  font-weight: 560;
  cursor: pointer;
  transition: background-color 0.25s;
}

.reset svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.reset:focus-visible,
.show:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

@media (hover: hover) {
  .reset:hover {
    background: #efedea;
  }
}

/* ---------------------------------------------------------------- the range: chart, lens, track, handles */
.range {
  --pad: 12px;
  --chart: clamp(58px, 17vh, 100px);
  position: relative;
  height: calc(var(--chart) + 34px);
  margin-top: clamp(10px, 3vh, 18px);
  padding: 0 var(--pad);
  touch-action: none;
  cursor: pointer;
}

.bars {
  position: absolute;
  left: var(--pad);
  right: var(--pad);
  top: 8px;
  height: var(--chart);
  display: flex;
  align-items: flex-end;
  gap: 2px;
}

.bar {
  flex: 1 1 0;
  min-width: 0;
  border-radius: 2px 2px 1px 1px;
  background: var(--line);
  transform-origin: 50% 100%;
  transition: background-color 0.35s ease;
}

.bar.is-on {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 78%, #fff) 0%, var(--accent) 22%, var(--accent-deep) 100%);
}

.track {
  position: absolute;
  left: var(--pad);
  right: var(--pad);
  top: calc(var(--chart) + 21px);
  height: 3px;
  margin-top: -1.5px;
  border-radius: 3px;
  background: var(--line);
}

.track__fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
}

/* the glass lens over the chosen range, from the top of the chart to the track */
.lens {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: calc(var(--chart) + 21px);
  outline: none;
  cursor: grab;
}

.lens.is-grab {
  cursor: grabbing;
}

.lens__glass {
  position: absolute;
  inset: 0;
  border-radius: 12px 12px 4px 4px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.08) 55%, rgba(255, 255, 255, 0.22) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(20, 20, 20, 0.07),
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 1px 2px rgba(20, 20, 20, 0.05),
    0 10px 22px -12px rgba(255, 90, 31, 0.45);
  -webkit-backdrop-filter: saturate(1.25) brightness(1.04);
  backdrop-filter: saturate(1.25) brightness(1.04);
  transition: box-shadow 0.35s ease;
}

.lens.is-grab .lens__glass,
.lens:focus-visible .lens__glass {
  box-shadow:
    inset 0 0 0 1px rgba(255, 90, 31, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 2px 4px rgba(20, 20, 20, 0.06),
    0 18px 30px -14px rgba(255, 90, 31, 0.6);
}

.lens__tint {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 90, 31, 0.07), rgba(255, 90, 31, 0) 70%);
}

/* the sheen: a soft slanted band that leans the way the lens is going */
.lens__sheen {
  position: absolute;
  top: -20%;
  bottom: -20%;
  left: 50%;
  width: 34px;
  margin-left: -17px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.62) 50%, rgba(255, 255, 255, 0));
  filter: blur(2px);
  opacity: 0.55;
}

.lens__grip {
  position: absolute;
  top: 6px;
  left: 50%;
  display: flex;
  gap: 2px;
  transform: translateX(-50%);
}

.lens__grip i {
  display: block;
  width: 2px;
  height: 8px;
  border-radius: 2px;
  background: rgba(20, 20, 20, 0.2);
}

.thumb {
  position: absolute;
  top: calc(var(--chart) + 21px);
  left: 0;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border-radius: 50%;
  outline: none;
  cursor: grab;
  z-index: 2;
}

.thumb__body {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffffff, #f4f3f1);
  box-shadow:
    0 0 0 1px rgba(20, 20, 20, 0.09),
    0 1px 2px rgba(20, 20, 20, 0.12),
    0 4px 10px -2px rgba(20, 20, 20, 0.16),
    inset 0 1px 0 #fff;
  transition: box-shadow 0.3s ease;
}

.thumb__core {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15), 0 0 0 3px rgba(255, 90, 31, 0.12);
}

.thumb.is-grab .thumb__body,
.thumb:focus-visible .thumb__body {
  box-shadow:
    0 0 0 1px rgba(255, 90, 31, 0.45),
    0 2px 4px rgba(20, 20, 20, 0.12),
    0 10px 20px -4px rgba(255, 90, 31, 0.38),
    0 0 0 6px rgba(255, 90, 31, 0.1),
    inset 0 1px 0 #fff;
}

/* ---------------------------------------------------------------- the two fields */
.fields {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: clamp(8px, 2.4vh, 14px);
}

.fields__line {
  flex: 0 0 10px;
  height: 1px;
  background: #d7d5d1;
}

.field {
  flex: 1 1 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  height: clamp(40px, 10.5vh, 46px);
  padding: 0 12px;
  align-items: center;
  border-radius: 12px;
  background: #faf9f8;
  box-shadow: inset 0 0 0 1px rgba(20, 20, 20, 0.07);
  transition: box-shadow 0.3s ease, background-color 0.3s ease;
}

.field.is-live {
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 90, 31, 0.55), 0 0 0 4px rgba(255, 90, 31, 0.09);
}

.field__key {
  font-size: 11.5px;
  color: var(--muted);
  font-stretch: 92%;
}

.field__val {
  display: inline-flex;
  align-items: center;
  line-height: 1.2;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.field__plus {
  display: inline-block;
  width: 0;
  overflow: hidden;
  opacity: 0;
  transition: width 0.3s ease, opacity 0.3s ease;
}

.field__plus.is-on {
  width: 0.62em;
  opacity: 1;
}

/* ---------------------------------------------------------------- the rolling digits */
.roll {
  display: inline-flex;
  height: 1.2em;
  line-height: 1.2em;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
  vertical-align: bottom;
}

.roll__slot {
  display: inline-block;
  width: 1ch;
  height: 1.2em;
  overflow: hidden;
  transition: width 0.32s cubic-bezier(0.3, 0.7, 0.2, 1), opacity 0.25s ease;
}

.roll__slot.is-off {
  width: 0;
  opacity: 0;
}

.roll__col {
  display: block;
}

.roll__col span {
  display: block;
  height: 1.2em;
  text-align: center;
}

/* ---------------------------------------------------------------- the Show button */
.show {
  display: block;
  width: 100%;
  margin-top: clamp(10px, 2.6vh, 14px);
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.show__face {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: clamp(42px, 11vh, 48px);
  border-radius: 999px;
  overflow: hidden;
  background: linear-gradient(180deg, #2a2a2a, var(--button) 60%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 1px 2px rgba(20, 20, 20, 0.2),
    0 10px 20px -10px rgba(20, 20, 20, 0.5);
  color: var(--button-ink);
  font-size: 14px;
  font-weight: 580;
  font-stretch: 102%;
}

.show__words {
  position: relative;
  display: inline-flex;
  align-items: center;
  line-height: 1.2;
  white-space: nowrap;
}

.show__chev {
  position: relative;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.show__sweep {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 46%;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0), rgba(255, 140, 90, 0.38) 50%, rgba(255, 255, 255, 0));
  transform: translateX(-120%);
}

@media (hover: hover) {
  .show:hover .show__chev {
    transform: translateX(2px);
  }
}

/* ---------------------------------------------------------------- the drawn pointer of the autopilot */
.pointer {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  margin: -3px 0 0 -4px;
  opacity: 0;
  pointer-events: none;
  z-index: 5;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25));
}

.pointer path {
  fill: #141414;
  stroke: #fff;
  stroke-width: 1.4;
  stroke-linejoin: round;
}

@media (max-width: 380px) {
  .filter {
    padding-left: 14px;
    padding-right: 14px;
  }
  .field {
    padding: 0 10px;
  }
}
