/* The stepper that gains weight: a minimal type piece. A white page, the word Guests, minus and plus as two thin
   rings and, between them, one big number in a variable grotesque that gets heavier and wider with every guest. Under
   it one hairline with a tick for every seat; the ticks up to the number are vermilion. */
:root {
  --page: #ffffff;      /* the page */
  --ink: #141414;       /* the number, the line and the signs on the buttons */
  --muted: #8b8780;     /* the word Guests and the note under the ticks */
  --seat: #d9d6cf;      /* a tick for a seat nobody takes */
  --accent: #e2401c;    /* the ticks of the guests, the note at a limit, the focus ring */
  --ring: #e7e4dd;      /* the buttons' thin ring at rest */
  --size: 132px;        /* how big the number is */
  --width: 340px;       /* how wide the whole stepper is */
}

* {
  box-sizing: border-box;
}

/* quick taps on the buttons never become a double tap that zooms the page */
html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
}

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

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

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

/* ---------------------------------------------------------------- the stepper */
.party {
  position: relative;
  width: min(var(--width), 100%);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  /* the number never gets so big that the stepper is wider than a phone */
  --fs: min(var(--size), 30vw);
}

/* the script shows it once the typeface is there, so the number never lands in a fallback face */
.party.is-waiting {
  visibility: hidden;
}

.party__label {
  position: relative;
  /* it sits in the empty top of the number's window, to the left of where the figures fall */
  margin: 0 0 calc(var(--fs) * -0.3);
  color: var(--muted);
  font-size: 12px;
  font-variation-settings: 'wght' 520, 'wdth' 108;
  letter-spacing: 0.16em;
  line-height: 16px;
  text-transform: uppercase;
}

.party__row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
}

/* ---------------------------------------------------------------- minus and plus */
.party__btn {
  flex: none;
  position: relative;
  width: 48px;
  height: 48px;
  /* level with the middle of the figures, which stand 6 pixels above the bottom of the window */
  margin-bottom: calc(6px + var(--fs) * 0.36 - 24px);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* a larger target for a finger, without a larger drawing */
.party__btn::before {
  content: '';
  position: absolute;
  inset: -10px;
  border-radius: 50%;
}

.party__btn:focus {
  outline: none;
}

.party__btn-in {
  display: block;
  width: 100%;
  height: 100%;
  transition: transform 0.38s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.party__btn svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.party__ring,
.party__draw {
  fill: none;
  stroke-width: 1;
}

.party__ring {
  stroke: var(--ring);
  transition: stroke 0.3s;
}

/* the ring that draws itself from the top when the button is pointed at, pressed or focused */
.party__draw {
  stroke: var(--ink);
  stroke-dasharray: 1 1;
  stroke-dashoffset: 1;
  opacity: 0;
  transform: rotate(-90deg);
  transform-origin: 24px 24px;
  transition: stroke-dashoffset 0.42s cubic-bezier(0.65, 0, 0.35, 1), stroke 0.2s, opacity 0.1s;
}

.party__icon {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.5;
  stroke-linecap: round;
  transition: stroke-width 0.25s, opacity 0.25s;
}

@media (hover: hover) {
  .party__btn:hover .party__draw {
    stroke-dashoffset: 0;
    opacity: 1;
  }

  .party__btn:hover .party__icon {
    stroke-width: 2;
  }
}

.party__btn.is-pressed .party__draw {
  stroke-dashoffset: 0;
  opacity: 1;
  transition-duration: 0.18s, 0.2s;
}

.party__btn.is-pressed .party__btn-in {
  transform: scale(0.92);
  transition-duration: 0.08s;
}

.party__btn.is-pressed .party__icon {
  stroke-width: 2.4;
}

.party__btn:focus-visible .party__draw {
  stroke: var(--accent);
  stroke-dashoffset: 0;
  opacity: 1;
}

/* at a limit the button is still there to press, but it only says no */
.party__btn[aria-disabled='true'] {
  cursor: default;
}

.party__btn[aria-disabled='true'] .party__icon {
  opacity: 0.28;
}

.party__btn[aria-disabled='true'] .party__draw {
  stroke-dashoffset: 1;
  opacity: 0;
}

/* ---------------------------------------------------------------- the number */
.party__value {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  border-radius: 12px;
}

.party__value:focus {
  outline: none;
}

/* the focus ring hugs the figures and stays clear of the word Guests */
.party__value::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--fs) * 0.34);
  bottom: -1px;
  border: 1.5px solid var(--accent);
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.party__value:focus-visible::after {
  opacity: 1;
}

/* the window the figures fall into: it fades out at the top, and its bottom edge, just above the line, is a slot
   they sink into */
.party__window {
  position: relative;
  display: block;
  height: calc(var(--fs) * 1.2);
  font-size: var(--fs);
  font-kerning: none;
  font-variant-numeric: lining-nums;
  line-height: 1;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(transparent 0, #000 34%, #000 100%);
  mask-image: linear-gradient(transparent 0, #000 34%, #000 100%);
}

/* one number; its baseline stands 6 pixels above the bottom of the window (the script measures where it is) */
.party__num {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(6px - var(--descent, 0.2em));
  display: block;
  text-align: center;
  white-space: nowrap;
}

.party__ch {
  display: inline-block;
  will-change: transform;
}

/* ---------------------------------------------------------------- the line and the ticks */
.party__ruler {
  display: block;
  width: 100%;
  height: 30px;
  overflow: visible;
  cursor: pointer;
  touch-action: pan-y;
}

.party__rule {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.party__tick {
  stroke: var(--seat);
  stroke-width: 1;
  stroke-linecap: round;
}

.party__tick.is-on {
  stroke: var(--accent);
  stroke-width: 1.5;
}

/* ---------------------------------------------------------------- the note */
.party__note {
  position: relative;
  display: grid;
  height: 18px;
  margin: 8px 0 0;
  overflow: hidden;
}

.party__note > span {
  grid-area: 1 / 1;
  color: var(--muted);
  font-size: 13px;
  font-variation-settings: 'wght' 420, 'wdth' 100;
  line-height: 18px;
  white-space: nowrap;
}

.party__note > .is-limit {
  color: var(--accent);
  font-variation-settings: 'wght' 540, 'wdth' 100;
}
