/* The text size slider of Leaflet, a made-up reading app: one small card alone on white, a single ink-blue accent. */
:root {
  --fondo: #ffffff;
  --carta: #ffffff;
  --bordo: #ebeae6;
  --binario: #ecebe7;       /* the empty track */
  --tacca: #cfccc5;         /* the notches past the knob */
  --testo: #16151a;
  --testo-2: #5d5a63;
  --testo-3: #9d99a3;
  --accento: #3346d3;       /* the single accent: the filled track, the knob ring, the bubble */
  --accento-chiaro: #eef0fd;
  --ombra: 22, 21, 30;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
html { font-size: clamp(9px, min(4.2vw, 3.2vh), 19px); }
body {
  background: var(--fondo);
  color: var(--testo);
  font-family: "Mona Sans Variable", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

.stage { height: 100vh; display: grid; place-items: center; padding: 2vh 4vw; }

/* the card */
.card {
  position: relative;
  width: min(20em, 92vw);
  padding: 1.15em 1.2em 1.2em;
  border-radius: 1.4em;
  background: var(--carta);
  box-shadow:
    0 0 0 1px var(--bordo),
    0 1px 2px rgba(var(--ombra), .05),
    0 .6em 1.6em -.4em rgba(var(--ombra), .12),
    0 1.8em 3.2em -1.6em rgba(var(--ombra), .16);
}

.head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: .8em; }
.brand { font-size: .66em; letter-spacing: .02em; color: var(--testo-3); font-weight: 500; }
.title { font-size: 1.12em; font-weight: 650; letter-spacing: -.01em; margin-top: .15em; font-variation-settings: "wdth" 100; }

/* the Default pill: label in its own centred layer, the ground for GSAP */
.reset {
  position: relative;
  height: 2em; padding: 0 .95em;
  border-radius: 99em;
  display: grid; place-items: center;
  font-size: .72em; font-weight: 600;
  color: var(--testo-2);
  transition: color .25s;
}
.reset__bg { position: absolute; inset: 0; border-radius: inherit; background: #f4f3f0; box-shadow: inset 0 0 0 1px var(--bordo); }
.reset__txt { position: relative; font-variation-settings: "wdth" 100; transition: font-variation-settings .35s cubic-bezier(.3, 1.4, .5, 1); white-space: nowrap; }
.reset.is-off { color: var(--testo-3); cursor: default; }
@media (hover: hover) {
  .reset:not(.is-off):hover .reset__txt { font-variation-settings: "wdth" 112; }
  .reset:not(.is-off):hover { color: var(--testo); }
}

/* the slider: small A, the rail, big A */
.slider {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 1.3em;
  margin-top: 2.15em;
}
.glyph { font-family: "Newsreader Variable", Georgia, serif; color: var(--testo-2); line-height: 1; width: 1.1em; text-align: center; }
.glyph--s { font-size: .78em; }
.glyph--l { font-size: 1.45em; }

.rail { position: relative; height: 2em; touch-action: none; cursor: pointer; outline: none; }
.rail:focus-visible .knob { box-shadow: 0 0 0 .2em var(--accento-chiaro), 0 0 0 .32em var(--accento), 0 .2em .5em rgba(var(--ombra), .22); }
.track, .fill {
  position: absolute; left: 0; top: 50%; height: .3em; margin-top: -.15em; border-radius: 99em;
}
.track { right: 0; background: var(--binario); box-shadow: inset 0 1px 1px rgba(var(--ombra), .06); }
.fill { width: 0; background: var(--accento); }

/* the six notches, placed in pixels by the script */
.ticks { position: absolute; inset: 0; pointer-events: none; }
.tick {
  position: absolute; top: 50%; width: .3em; height: .3em; margin: -.15em 0 0 -.15em; border-radius: 50%;
  background: var(--tacca);
}
.tick.is-on { background: rgba(255, 255, 255, .75); }

/* the knob: a positioner for the x, the knob itself for the grab */
.knob-pos { position: absolute; left: 0; top: 50%; width: 0; height: 0; }
.knob {
  position: absolute; left: -.8em; top: -.8em; width: 1.6em; height: 1.6em; border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(var(--ombra), .08), 0 .15em .4em rgba(var(--ombra), .2), 0 .05em .1em rgba(var(--ombra), .12);
  display: grid; place-items: center;
  cursor: grab;
}
.knob__dot { width: .44em; height: .44em; border-radius: 50%; background: var(--accento); }
.is-grabbed .knob { cursor: grabbing; }

/* the bubble above the knob: centred by its positioner, moved by GSAP on the inner element */
.bubble-pos { position: absolute; left: 0; bottom: 1.05em; width: 0; display: flex; justify-content: center; }
.bubble {
  position: relative;
  display: inline-flex; align-items: baseline; gap: .18em;
  padding: .28em .55em .3em;
  border-radius: .55em;
  background: var(--testo); color: #fff;
  font-size: .7em; font-weight: 650; white-space: nowrap;
  transform-origin: 50% 120%;
  box-shadow: 0 .35em .8em -.3em rgba(var(--ombra), .45);
}
.bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -.28em; width: .56em; height: .56em; margin-left: -.28em;
  background: inherit; border-radius: .1em; transform: rotate(45deg);
}
.bubble .unit { font-weight: 500; color: rgba(255, 255, 255, .62); }

/* the rolling digits: each digit is a window over a column 0-9 */
.roll { display: inline-flex; font-variant-numeric: tabular-nums; }
.roll .ch { display: inline-block; height: 1.2em; line-height: 1.2em; overflow: hidden; vertical-align: bottom;
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 20%, #000 80%, transparent); mask-image: linear-gradient(180deg, transparent, #000 20%, #000 80%, transparent); }
.roll .col { display: block; will-change: transform; }
.roll .col span { display: block; height: 1.2em; text-align: center; }

/* the preview: a fixed window, the paragraph really reflows inside it */
.preview {
  position: relative;
  margin-top: 1.25em;
  height: 7.6em;
  padding: .85em .95em;
  border-radius: .9em;
  background: #faf9f6;
  box-shadow: inset 0 0 0 1px var(--bordo);
  overflow: hidden;
}
.preview::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1.6em;
  background: linear-gradient(180deg, rgba(250, 249, 246, 0), #faf9f6 85%);
  pointer-events: none;
}
.preview__txt {
  font-family: "Newsreader Variable", Georgia, serif;
  font-size: calc(var(--pt, 17) / 17 * .9em);
  line-height: 1.45;
  color: var(--testo);
  text-wrap: pretty;
}

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
