/* The waitlist with the queue: the waitlist of a calendar app on a white page. The queue is a field of thin grey
   marks, one for every person waiting; the only colour is the green of your own mark once you are in it. */
:root {
  --page: #ffffff;          /* the page */
  --ink: #151515;           /* the words */
  --muted: #8a8780;         /* the smaller words */
  --mark: #a9a69f;          /* a person waiting */
  --edge: #dcd9d2;          /* the edge of the field */
  --accent: #14955f;        /* your mark in the queue, and a field that needs a word */
  --join: #151515;          /* the button */
  --join-ink: #ffffff;      /* the button's words */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

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

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: 40px 16px;
}

.wait {
  position: relative;
  width: min(460px, 100%);
}

.wait__title {
  margin: 0;
  font-size: 24px;
  font-weight: 620;
  font-stretch: 100%;
  letter-spacing: -0.015em;
  line-height: 1.15;
}

.wait__sub {
  margin: 6px 0 22px;
  font-size: 15px;
  font-weight: 420;
  line-height: 21px;
  color: var(--muted);
}

/* ---------------------------------------------------------------- the queue */
.queue {
  position: relative;
  height: 124px;
  margin: -14px 0;
}

.queue__canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* the word over your own mark */
.queue__you {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  opacity: 0;
}

.queue__you span {
  position: absolute;
  left: 0;
  bottom: 6px;
  transform: translateX(-50%);
  padding: 3px 8px 4px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--page);
  color: #ffffff;
  font-size: 12px;
  font-weight: 620;
  font-stretch: 108%;
  line-height: 1;
  white-space: nowrap;
}

.wait__count {
  position: relative;
  min-height: 22px;
  margin: 12px 0 0;
  font-size: 14px;
  font-weight: 460;
  line-height: 22px;
  color: var(--muted);
}

.wait__count b {
  font-weight: 640;
  color: var(--ink);
}

/* the number of your place, which rolls digit by digit */
.place {
  display: inline-flex;
  font-variant-numeric: tabular-nums;
  font-weight: 680;
  color: var(--accent);
  vertical-align: bottom;
}

.place__d {
  position: relative;
  display: inline-block;
  height: 22px;
  overflow: hidden;
}

.place__d span {
  display: block;
}

/* ---------------------------------------------------------------- the form */
.wait__form {
  margin: 18px 0 0;
}

.wait__row {
  display: flex;
  gap: 8px;
  height: 52px;
}

.wait__field {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  border: 1px solid var(--edge);
  border-radius: 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.wait__field.is-focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}

.wait__field.is-wrong {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.wait__field.is-in {
  border-color: var(--edge);
  box-shadow: none;
  background: #f7f6f3;
}

.wait__input {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0 16px;
  border: 0;
  border-radius: inherit;
  outline: none;
  background: transparent;
  color: var(--ink);
  caret-color: var(--accent);
  font: 460 16px/50px 'Instrument Sans Variable', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.wait__input::placeholder {
  color: #b2afa8;
  opacity: 1;
}

.wait__input:-webkit-autofill {
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: 0 0 0 60px var(--page) inset;
}

.wait__caret {
  position: absolute;
  left: 16px;
  top: 15px;
  width: 1.5px;
  height: 20px;
  background: var(--accent);
  opacity: 0;
  pointer-events: none;
}

.wait__caret.is-on {
  animation: blink 1.06s steps(1) infinite;
}

@keyframes blink {
  0%,
  50% {
    opacity: 1;
  }

  50.01%,
  100% {
    opacity: 0;
  }
}

/* the elastic pill */
.join {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  height: 52px;
  margin: 0;
  padding: 0 22px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--join-ink);
  font: 600 15px/1 'Instrument Sans Variable', system-ui, sans-serif;
  cursor: pointer;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
}

.join__bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--join);
  transition: inset 0.6s cubic-bezier(0.3, 1.7, 0.45, 1), transform 0.16s ease-out;
}

.join__label {
  display: block;
  font-stretch: 100%;
  white-space: nowrap;
  transition: font-stretch 0.6s cubic-bezier(0.3, 1.7, 0.45, 1);
}

@media (hover: hover) and (pointer: fine) {
  .join:not([aria-disabled='true']):hover .join__bg {
    inset: -2px -4px;
  }

  .join:not([aria-disabled='true']):hover .join__label {
    font-stretch: 116%;
  }
}

.join:not([aria-disabled='true']):active .join__bg,
.join.is-pressed .join__bg {
  transform: scale(0.95);
}

.join[aria-disabled='true'] {
  cursor: default;
}

.join:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.wait__status {
  position: relative;
  min-height: 40px;
  margin: 10px 2px 0;
  font-size: 14px;
  font-weight: 440;
  line-height: 20px;
  color: var(--muted);
}

.status__line {
  display: block;
}

.status__line.is-going {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  pointer-events: none;
}

.status__line.is-wrong {
  color: var(--ink);
}

.status__line b {
  font-weight: 640;
  color: var(--ink);
}

.status__btn {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-weight: 640;
  font-stretch: 100%;
  cursor: pointer;
  transition: font-stretch 0.5s cubic-bezier(0.3, 1.7, 0.45, 1), color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) and (pointer: fine) {
  .status__btn:hover {
    font-stretch: 118%;
    color: var(--accent);
  }
}

.status__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

/* for screen readers only */
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 440px) {
  .wait__row {
    flex-direction: column;
    height: auto;
  }

  .wait__field {
    height: 52px;
  }

  .join {
    width: 100%;
  }
}
