/* The bellows zoom: a camera's zoom on a white page. The bellows is oxblood leather between two graphite plates;
   the script reads the four bellows colours from here. */
:root {
  --page: #ffffff;          /* the page */
  --ink: #17161a;           /* text, the focus ring */
  --muted: #8e8b93;
  --rail: #eeece8;          /* the rail the knob runs on */
  --tick: #cdc9c2;          /* the marks on the rail, one for each whole zoom */
  --plate: #222126;         /* the two plates */
  --plate-edge: #55545c;    /* the plates' lit edge */
  --bellows-deep: #170403;  /* a face of the bellows in the dark */
  --bellows: #6c1d18;       /* a face half lit */
  --bellows-light: #ad4537; /* a face in full light */
  --bellows-shine: #e48e78; /* the sheen on the leather */
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Instrument Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.zoom {
  width: min(460px, 100%);
  user-select: none;
  -webkit-user-select: none;
}

/* ---------------------------------------------------------------- the name and the zoom */
.zoom__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.zoom__label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.zoom__icon {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.9;
  stroke-linecap: round;
}

/* the figures widen with the zoom (the script moves the width axis); the box is as wide as the widest, so nothing
   beside it moves */
.zoom__value {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  min-width: 70px;
  font-variant-numeric: tabular-nums;
}

.zoom__number {
  font-size: 25px;
  font-weight: 620;
  letter-spacing: -0.02em;
  font-stretch: 85%;
}

.zoom__times {
  margin-left: 1px;
  color: var(--muted);
  font-size: 19px;
  font-weight: 500;
}

/* ---------------------------------------------------------------- the rail, the bellows and the plates */
.zoom__track {
  position: relative;
  height: 60px;
  touch-action: pan-y;
  outline: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.zoom__rail {
  position: absolute;
  left: 6px;
  right: 0;
  top: 27px;
  height: 6px;
  border-radius: 3px;
  background: var(--rail);
  box-shadow: inset 0 1px 1px rgba(23, 22, 26, 0.07);
}

.zoom__tick {
  position: absolute;
  top: 1px;
  width: 1.5px;
  height: 4px;
  margin-left: -0.75px;
  border-radius: 1px;
  background: var(--tick);
}

/* the canvas runs past the track above and below, for the folds that swell and the shadow */
.zoom__bellows {
  position: absolute;
  left: 0;
  top: -12px;
  width: 100%;
  height: calc(100% + 24px);
  pointer-events: none;
}

.zoom__rear,
.zoom__plate {
  position: absolute;
  top: 2px;
  height: 56px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--plate-edge) 0%, var(--plate) 38%, #141317 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 9px 14px -9px rgba(23, 22, 26, 0.6);
}

.zoom__rear {
  left: 0;
  width: 12px;
}

/* the knob: the front plate and the lens. The script moves it along */
.zoom__knob {
  position: absolute;
  left: 0;
  top: 0;
  width: 24px;
  height: 60px;
  cursor: grab;
}

.zoom__plate {
  left: 0;
  width: 14px;
  transition: filter 0.2s, transform 0.16s ease-out;
}

/* three grooves to hold it by */
.zoom__plate::after {
  content: '';
  position: absolute;
  left: 4px;
  right: 4px;
  top: 22px;
  height: 12px;
  background: repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.16) 0 1px, transparent 1px 5px);
}

/* the lens seen from the side: a short barrel, lit from above, with a bright ring at its front */
.zoom__lens {
  position: absolute;
  left: 13px;
  top: 17px;
  width: 10px;
  height: 26px;
  border-radius: 1px 4px 4px 1px;
  background: linear-gradient(180deg, #6a6971 0%, #2b2a30 34%, #131216 72%, #3a3940 100%);
}

.zoom__lens::after {
  content: '';
  position: absolute;
  right: 0;
  top: 1px;
  bottom: 1px;
  width: 2px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, #a9a8b0, #44434a 60%, #77767e);
}

@media (hover: hover) {
  .zoom__knob:hover .zoom__plate {
    filter: brightness(1.7);
  }
}

/* held, the plate lights up and gives a little under the fingers */
.is-held .zoom__plate {
  filter: brightness(1.9);
  transform: scaleY(0.965);
}

.is-held .zoom__track,
.is-held .zoom__knob {
  cursor: grabbing;
}

/* the keys' ring goes round the knob */
.zoom__knob::after {
  content: '';
  position: absolute;
  left: -5px;
  right: -4px;
  top: -3px;
  bottom: -3px;
  border-radius: 8px;
  box-shadow: 0 0 0 2px var(--ink);
  opacity: 0;
  transition: opacity 0.15s;
}

.zoom__track:focus-visible .zoom__knob::after {
  opacity: 1;
}
