/* The tape pagination: a pale tray alone on a white page, with two white keys at its ends and, in the middle, the
   pages on a tape. The dark carriage marks the current page; the numbers that run through it are lit white. */
:root {
  --page: #ffffff;          /* the page */
  --tray: #f0f0ed;          /* the tray the tape runs in */
  --key: #ffffff;           /* the Previous and Next keys, and the plate under a page you point at */
  --num: #2a2b2f;           /* the page numbers on the tape */
  --ink: #141518;           /* the arrows, and the numbers of the range under the bar */
  --dots: #9c9ea4;          /* the dots, the reels the tape winds into */
  --off: #b9bbbf;           /* an arrow with no page to go to */
  --carriage: #141518;      /* the carriage on the current page */
  --carriage-top: #2c2d33;  /* the light on its top edge */
  --lit: #ffffff;           /* a number inside the carriage */
  --caption: #7b7e85;       /* the words of the range under the bar */
}

* {
  box-sizing: border-box;
}

/* a tap is a click at once: no wait for a double tap */
html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

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

.stage {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 40px 16px;
}

.pager {
  display: grid;
  justify-items: center;
  gap: 14px;
  max-width: 100%;
}

/* ---------------------------------------------------------------- the tray */
.bar {
  --pitch: 48px;            /* the room of a page on the tape (less on a narrow screen) */
  --key-size: 44px;
  --car-h: 42px;            /* the carriage's height */
  --car-r: 14px;            /* the rounding of its corners */
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  height: 60px;
  padding: 0 8px;
  border-radius: 30px;
  background: var(--tray);
  box-shadow:
    inset 0 1px 2px rgba(20, 21, 24, 0.07),
    inset 0 0 0 1px rgba(20, 21, 24, 0.045),
    0 1px 0 rgba(255, 255, 255, 0.9);
  -webkit-tap-highlight-color: transparent;
}

/* ---------------------------------------------------------------- Previous and Next */
.key {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: var(--key-size);
  height: var(--key-size);
  border-radius: 50%;
  background: var(--key);
  color: var(--ink);
  box-shadow:
    0 0 0 1px rgba(20, 21, 24, 0.05),
    0 1px 2px rgba(20, 21, 24, 0.12),
    0 4px 10px -3px rgba(20, 21, 24, 0.14);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  transition:
    transform 0.16s cubic-bezier(0.23, 1, 0.32, 1),
    background-color 0.24s ease,
    box-shadow 0.24s ease,
    color 0.24s ease;
}

.key__arrow {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.28s cubic-bezier(0.3, 1.5, 0.5, 1);
}

.key:active {
  transform: scale(0.93);
  transition-duration: 0.08s;
}

/* at the first or the last page the key sinks into the tray */
.key[aria-disabled='true'] {
  background: transparent;
  box-shadow: 0 0 0 1px rgba(20, 21, 24, 0);
  color: var(--off);
  cursor: default;
}

.key[aria-disabled='true']:active {
  transform: none;
}

@media (hover: hover) and (pointer: fine) {
  .key--prev:not([aria-disabled='true']):hover .key__arrow {
    transform: translateX(-2px);
  }

  .key--next:not([aria-disabled='true']):hover .key__arrow {
    transform: translateX(2px);
  }
}

/* ---------------------------------------------------------------- the pages */
.track {
  position: relative;
  flex: 0 1 auto;
  width: calc(7 * var(--pitch));
  min-width: 0;
  height: 44px;
}

.slots {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--slots, 7), minmax(0, 1fr));
  margin: 0;
  padding: 0;
  list-style: none;
}

.slot {
  position: relative;
  display: grid;
  min-width: 0;
}

/* a page link: it holds its number for screen readers and for the page without the script; with the script the
   number you see is the one on the tape, over it */
.slot__page,
.slot__skip,
.slot__gap {
  display: grid;
  place-items: center;
  margin: 0 2px;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: var(--num);
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  transition:
    background-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.16s cubic-bezier(0.23, 1, 0.32, 1);
}

.slot__gap {
  color: var(--dots);
  cursor: default;
}

.slot__page[aria-current='page'] {
  background: var(--carriage);
  color: var(--lit);
  font-weight: 650;
}

.slot__page[hidden],
.slot__skip[hidden] {
  display: none;
}

.is-live .slot__page,
.is-live .slot__skip {
  color: transparent;
}

.is-live .slot__page[aria-current='page'] {
  background: transparent;
  cursor: default;
}

/* the plate under a page you point at, or press with a finger */
@media (hover: hover) and (pointer: fine) {
  .slot__page:not([aria-current='page']):hover,
  .slot__skip:hover {
    background: var(--key);
    box-shadow: 0 0 0 1px rgba(20, 21, 24, 0.04), 0 1px 3px rgba(20, 21, 24, 0.1);
  }
}

.slot__page:not([aria-current='page']):active,
.slot__skip:active {
  background: var(--key);
  transform: scale(0.92);
  transition-duration: 0.08s;
}

/* the carriage: moved by the script, on a spring */
.carriage {
  position: absolute;
  top: 50%;
  left: 0;
  width: var(--car-w, 42px);
  height: var(--car-h);
  margin: calc(var(--car-h) / -2) 0 0 calc(var(--car-w, 42px) / -2);
  border-radius: var(--car-r);
  background: linear-gradient(180deg, var(--carriage-top), var(--carriage) 58%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 1px 2px rgba(20, 21, 24, 0.22),
    0 6px 14px -6px rgba(20, 21, 24, 0.5);
  pointer-events: none;
  will-change: transform;
}

/* the dots: three of them on a little wheel the tape winds round */
.reel {
  position: absolute;
  top: 50%;
  left: 0;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
}

.reel i {
  position: absolute;
  top: -2px;
  left: -2px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--dots);
}

/* the tape: the numbers, placed by the script one by one */
.tape {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.num {
  position: absolute;
  top: 0;
  left: calc(var(--pitch-now, 48px) / -2);
  width: var(--pitch-now, 48px);
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--num);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  white-space: nowrap;
  will-change: transform, opacity;
}

.tape--lit .num {
  color: var(--lit);
}

/* the first and the last page never move: they leave no trail */
.num.is-pinned {
  text-shadow: none;
}

/* without the script the tape stays empty */
.track:not(.is-live) .carriage,
.track:not(.is-live) .reel,
.track:not(.is-live) .tape {
  display: none;
}

/* ---------------------------------------------------------------- the keyboard */
.key:focus-visible,
.slot__page:focus-visible,
.slot__skip:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

html[data-using='pointer'] .key:focus-visible,
html[data-using='pointer'] .slot__page:focus-visible,
html[data-using='pointer'] .slot__skip:focus-visible {
  outline: none;
}

/* ---------------------------------------------------------------- the range under the bar */
.range {
  margin: 0;
  color: var(--caption);
  font-size: 13px;
  font-weight: 450;
  line-height: 20px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.range__shown {
  display: inline;
}

.range__dash {
  margin: 0 0.12em;
}

.range [data-total] {
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.odo {
  position: relative;
  display: inline-flex;
  vertical-align: top;
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* one digit: a column of figures behind a little window, faded at the top and the bottom */
.odo__cell {
  position: relative;
  display: block;
  height: 20px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(transparent, #000 22%, #000 78%, transparent);
  mask-image: linear-gradient(transparent, #000 22%, #000 78%, transparent);
}

.odo__probe {
  position: absolute;
  visibility: hidden;
}

.odo__col {
  display: block;
  will-change: transform;
}

.odo__col span {
  display: block;
  height: 20px;
  text-align: center;
}

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

/* ---------------------------------------------------------------- a phone */
@media (max-width: 480px) {
  .bar {
    --pitch: 40px;
    --key-size: 40px;
    --car-h: 40px;
    --car-r: 13px;
    gap: 4px;
    height: 56px;
    padding: 0 8px;
    border-radius: 28px;
  }

  .slot__page,
  .slot__skip,
  .slot__gap,
  .num {
    font-size: 15px;
  }

  .slot__page,
  .slot__skip,
  .slot__gap {
    margin: 0 1px;
    border-radius: 12px;
  }
}
