/* 540 frame, 30 margin. Field 30-126 with a 4 px rule. Under it, from y 156, a 66 px row
   grid, five rows deep: the list at x 30-290 (its frame on the margin, with the rule above)
   and a 198 column at 312-510, so a shape is three rows tall and ends where the rule ends. */
.wb,
.wb-pop {
  --white: #fff;
  --black: #0c0c0c;
  --blue: #1a3fd8;
  --yellow: #ffd000;
  --red: #e62a17;
  --row: 66px;
  --move: cubic-bezier(0.6, 0, 0.2, 1);
  font-family: "Jost Variable", sans-serif;
  color: var(--black);
  text-transform: uppercase;
  -webkit-font-smoothing: antialiased;
}

.wb {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--white);
  user-select: none;
  cursor: default;
}

.wb *,
.wb-pop *,
.wb-pop {
  box-sizing: border-box;
}

.wb svg,
.wb-pop svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
[data-bin="paper"] {
  fill: var(--blue);
}
[data-bin="plastics"] {
  fill: var(--yellow);
}
[data-bin="glass"] {
  fill: var(--red);
}
[data-bin="general"] {
  fill: var(--black);
}
[data-bin="centre"] {
  stroke: var(--black);
}

/* the field */
.wb-field {
  position: absolute;
  inset: 30px 30px auto 30px;
  height: 96px;
  border-bottom: 4px solid var(--black);
  transition: box-shadow 120ms var(--move);
}

.wb-input,
.wb-ruler {
  font: inherit;
  font-size: 53px;
  font-weight: 700;
  line-height: 64px;
  letter-spacing: -0.012em;
  text-transform: uppercase;
}

.wb-input {
  display: block;
  /* 3 px out, so the first letter's stem stands on the margin with the rule and the shapes */
  width: calc(100% + 3px);
  height: 92px;
  margin: 0 0 0 -3px;
  padding: 14px 0;
  border: 0;
  border-radius: 0;
  outline: 0;
  background: none;
  color: var(--black);
  caret-color: transparent;
  user-select: text;
  cursor: text;
}
/* at rest the question is the page's headline, at full strength */
.wb-input::placeholder {
  color: var(--black);
  opacity: 1;
}
/* and it steps aside for the caret */
.wb-input:focus::placeholder {
  color: transparent;
}
.wb-input::selection {
  background: var(--black);
  color: var(--white);
}

.wb-ruler {
  position: absolute;
  left: 0;
  top: 0;
  visibility: hidden;
  white-space: pre;
  pointer-events: none;
}

.wb-caret {
  position: absolute;
  top: 22px;
  width: 4px;
  height: 48px;
  margin-left: -3px;
  background: var(--red);
  pointer-events: none;
  animation: wb-blink 1.2s steps(1) infinite;
}
@keyframes wb-blink {
  58% {
    opacity: 0;
  }
}

/* focus on the field: the rule under it doubles in weight */
.wb-field:has(.wb-input:focus) {
  box-shadow: 0 4px 0 var(--black);
}

/* the suggestions */
.wb-pop {
  width: 273px;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: var(--white);
  overflow: visible;
  transition: clip-path 200ms var(--move);
  clip-path: inset(0 0 0 0);
}
.wb-pop[data-starting-style],
.wb-pop[data-ending-style] {
  clip-path: inset(0 0 100% 0);
}

.wb-list {
  position: relative;
  max-height: calc(var(--row) * 5);
  overflow-x: hidden;
  overflow-y: auto;
  outline: 0;
  overscroll-behavior: contain;
}
/* the thumb: a 4 px bar midway between the list and the column beside it */
.wb-list::-webkit-scrollbar {
  width: 13px;
}
.wb-list::-webkit-scrollbar-track {
  background: none;
}
.wb-list::-webkit-scrollbar-thumb {
  border-left: 9px solid transparent;
  background: var(--black) padding-box;
}
@supports not selector(::-webkit-scrollbar) {
  .wb-list {
    scrollbar-width: thin;
    scrollbar-color: var(--black) transparent;
  }
}

/* a row is 260 wide whether or not the list scrolls */
.wb-row {
  position: relative;
  display: grid;
  grid-template-columns: 22px 1fr;
  grid-template-rows: 31px 18px;
  align-content: start;
  column-gap: 12px;
  width: 260px;
  height: var(--row);
  padding: 8px 12px 0;
  outline: 0;
  cursor: default;
}
.wb-row[hidden] {
  display: none;
}

.wb-glyph {
  grid-area: 1 / 1 / 3 / 2;
  /* centred on the row: 8 + 14 + 11 = 33 */
  margin-top: 14px;
  width: 22px;
  height: 22px;
}

.wb-name {
  grid-area: 1 / 2;
  font-size: 23px;
  font-weight: 500;
  line-height: 31px;
  letter-spacing: 0.01em;
  white-space: pre;
}
/* the letters that matched: heavier, standing on a bar */
.wb-name [data-match] {
  display: inline-block;
  font-weight: 700;
  background: linear-gradient(var(--black), var(--black)) no-repeat 0 27px / 100% 3px;
}

.wb-bin {
  grid-area: 2 / 2;
  font-size: 14px;
  font-weight: 600;
  line-height: 18px;
  letter-spacing: 0.09em;
  white-space: nowrap;
}

/* the highlight: one frame that travels from row to row */
.wb-frame {
  position: absolute;
  inset: 0 auto auto 0;
  width: 260px;
  height: var(--row);
  border: 3px solid var(--black);
  opacity: 0;
  pointer-events: none;
  transition: translate 150ms var(--move);
}
.wb-frame[data-on] {
  opacity: 1;
}

.wb-none:not([data-empty]) {
  display: none;
}
/* no frame and no shape, so it stands on the margin, under the question */
.wb-none {
  display: grid;
  grid-template-rows: 31px 18px;
  height: var(--row);
  padding-top: 8px;
  font-size: 14px;
  font-weight: 600;
  line-height: 18px;
  letter-spacing: 0.09em;
  white-space: nowrap;
}
.wb-none b {
  font-size: 23px;
  font-weight: 500;
  line-height: 31px;
  letter-spacing: 0.01em;
}

/* the stage: everything under the field */
.wb-stage {
  position: absolute;
  left: 30px;
  top: 156px;
  width: 480px;
  height: 354px;
}

/* A shape is drawn once, 198 px, at the head of the right-hand column, and is moved and
   scaled from there:
   strip   144 px, three over two, filling the page under the rule (the bar two columns wide)
   key     30 px, down the column, one to a row
   big     as drawn
   answer  216 px, at the left margin, centred in the space under the rule
   away    gone, turned a quarter, from its place in the key */
.wb-shape {
  position: absolute;
  left: 282px;
  top: 0;
  width: 198px;
  height: 198px;
  transition:
    translate 340ms var(--move),
    scale 340ms var(--move),
    rotate 340ms var(--move);
}
.wb-shape[data-state="strip"] {
  translate: var(--rx) var(--ry);
  scale: var(--rs);
}
.wb-shape[data-state="key"],
.wb-shape[data-state="away"] {
  translate: -84px calc(var(--i) * var(--row) - 66px);
  scale: 0.1515;
}
.wb-shape[data-state="away"] {
  scale: 0;
  rotate: -90deg;
  transition-duration: 200ms;
}
.wb-shape[data-state="answer"] {
  translate: -273px 72px;
  scale: 1.0909;
}

/* the names under the shapes at rest */
.wb-strip {
  position: absolute;
  inset: 0 0 auto 0;
  margin: 0;
  padding: 0;
  list-style: none;
}
.wb-strip li {
  position: absolute;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 17px;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* the names down the column */
.wb-key {
  position: absolute;
  inset: 0 0 auto 330px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.wb-key li {
  display: grid;
  align-content: center;
  height: var(--row);
  font-size: 15px;
  font-weight: 700;
  line-height: 18px;
  letter-spacing: 0.08em;
}

/* the answer's words: under the shape beside the list; once chosen, to the right of the
   shape and centred on it, so shape and words are one sign */
.wb-answer {
  position: absolute;
  left: 282px;
  top: 216px;
  width: 198px;
  display: grid;
  margin: 0;
}
.wb[data-mode="answer"] .wb-answer {
  left: 240px;
  top: 171px;
  width: 240px;
  translate: 0 -50%;
}
.wb[data-mode="answer"] .wb-into {
  margin-left: -3px;
  font-size: 40px;
  line-height: 40px;
}
.wb[data-mode="answer"] .wb-rule {
  margin-top: 16px;
  padding-top: 12px;
  font-size: 18px;
  line-height: 24px;
}
.wb-into {
  display: grid;
  margin-left: -2px;
  font-size: 31px;
  font-weight: 800;
  line-height: 31px;
  letter-spacing: -0.005em;
}
.wb-rule {
  margin-top: 12px;
  padding-top: 9px;
  border-top: 4px solid var(--black);
  font-size: 15px;
  font-weight: 700;
  line-height: 19px;
  letter-spacing: 0.08em;
  text-wrap: balance;
}

/* words leave at once and arrive after the shapes have started moving */
.wb-strip,
.wb-key,
.wb-answer {
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 60ms linear,
    visibility 0s linear 60ms;
}
.wb[data-mode="strip"] .wb-strip,
.wb[data-mode="key"] .wb-key,
.wb[data-mode="big"] .wb-answer,
.wb[data-mode="answer"] .wb-answer {
  opacity: 1;
  visibility: visible;
  transition:
    opacity 140ms linear 200ms,
    visibility 0s linear 200ms;
}
/* the answer's words are remade when they change sides: they wait for the shape to land */
.wb-answer {
  animation: wb-arrive 380ms linear;
}
@keyframes wb-arrive {
  0%,
  60% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wb-pop,
  .wb-field,
  .wb-frame,
  .wb-shape,
  .wb-strip,
  .wb-key,
  .wb-answer,
  .wb[data-mode] .wb-strip,
  .wb[data-mode] .wb-key,
  .wb[data-mode] .wb-answer {
    transition: none;
  }
  .wb-caret,
  .wb-answer {
    animation: none;
  }
}
