/* The scrubbable radius: one inspector field on white, a shape above it and a ruler that only shows while dragging.
   One ink, one grey, one accent. */
:root {
  --fondo: #ffffff;           /* the background */
  --inchiostro: #111113;      /* the number, the shape outline and the ticks */
  --grigio: #8a8a93;          /* the icon, the unit and the hints */
  --campo: #f4f4f5;           /* the field at rest */
  --bordo: rgba(17, 17, 19, 0.09);
  --forma: #f7f7f8;           /* the inside of the shape */
  --accento: #3b5bfd;         /* the corner being edited, the ruler mark, the focus ring */
}

* { box-sizing: border-box; margin: 0; }

html, body { height: 100%; }

body {
  background: var(--fondo);
  color: var(--inchiostro);
  font-family: "Mona Sans Variable", "Mona Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.stage {
  position: relative;
  height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.inspector {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: min(34px, 6vh);
  padding-bottom: 34px;
}

/* the shape: an SVG square whose corners take the radius; the top-left corner is drawn again in the accent */
.shape {
  width: min(140px, 28vh, 40vw);
  height: min(140px, 28vh, 40vw);
  overflow: visible;
}
.shape__fill {
  fill: var(--forma);
  stroke: var(--inchiostro);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}
.shape__corner {
  fill: none;
  stroke: var(--accento);
  stroke-width: 2;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

/* the field: GSAP moves .field, the face under it carries the colour and the border */
.field {
  position: relative;
  width: min(212px, 64vw);
  height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px 0 12px;
  cursor: ew-resize;
  touch-action: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.field__face {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: var(--campo);
  border: 1px solid transparent;
  transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
}
@media (hover: hover) {
  .field:hover .field__face { border-color: var(--bordo); background: #f1f1f3; }
}
.field.is-active .field__face {
  background: #ffffff;
  border-color: var(--bordo);
  box-shadow: 0 1px 2px rgba(17, 17, 19, 0.04), 0 10px 28px -12px rgba(17, 17, 19, 0.22);
}
.field:focus-visible .field__face { border-color: var(--accento); box-shadow: 0 0 0 3px rgba(59, 91, 253, 0.18); }

.field__icon {
  position: relative;
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: var(--grigio);
  stroke-width: 1.4;
  stroke-linecap: round;
}
.field.is-active .field__icon { stroke: var(--accento); }

.field__num {
  position: relative;
  display: inline-flex;
  font-size: 15px;
  font-weight: 560;
  line-height: 1;
  letter-spacing: -0.01em;
  transform-origin: 0 60%;
}
.slot {
  position: relative;
  display: inline-block;
  overflow: hidden;
  height: 1.08em;
  padding: 0.04em 0;
  margin: -0.04em 0;
}
.slot__c {
  display: block;
}
.slot__c + .slot__c {
  position: absolute;
  left: 0;
  top: 0.04em;
}

.field__unit {
  position: relative;
  font-size: 13px;
  font-weight: 450;
  color: var(--grigio);
  margin-left: -4px;
}

/* the two small chevrons that say "drag sideways": hidden at rest, they slide out on hover */
.field__hint {
  position: absolute;
  top: 50%;
  width: 8px;
  height: 10px;
  margin-top: -5px;
  fill: none;
  stroke: var(--grigio);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}
.field__hint--l { right: 30px; }
.field__hint--r { right: 14px; }

/* the ruler: a tape of thin ticks under the field, faded at both ends, with the accent mark in the middle */
.ruler {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(212px, 64vw);
  height: 20px;
  margin-left: calc(min(212px, 64vw) / -2);
  overflow: hidden;
  opacity: 0;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 28%, #000 72%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 28%, #000 72%, transparent);
}
.ruler__tape {
  position: absolute;
  left: 0;
  top: 0;
  height: 20px;
  overflow: visible;
}
.ruler__ticks, .ruler__major {
  fill: none;
  stroke: var(--inchiostro);
  stroke-width: 1;
}
.ruler__ticks { opacity: 0.22; }
.ruler__major { opacity: 0.55; }
.ruler__mark {
  position: absolute;
  left: 50%;
  top: 0;
  width: 2px;
  height: 14px;
  margin-left: -1px;
  border-radius: 1px;
  background: var(--accento);
  transform-origin: 50% 0;
}

/* the drawn pointer of the preview: an arrow, which turns into the sideways cursor over the field */
.ghost {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  margin: -3px 0 0 -5px;
  opacity: 0;
  pointer-events: none;
  overflow: visible;
  filter: drop-shadow(0 1px 1.5px rgba(17, 17, 19, 0.25));
}
.ghost__arrow {
  fill: var(--inchiostro);
  stroke: #ffffff;
  stroke-width: 1.4;
  stroke-linejoin: round;
}
.ghost__scrub {
  fill: none;
  stroke: var(--inchiostro);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  paint-order: stroke;
}

@media (prefers-reduced-motion: reduce) {
  .field__face { transition: none; }
}
