/* The merging filters: a row of outlined chips on a white page, and under them the count of the trails left. A lit
   chip is filled with a deep green liquid; the script draws the liquid as one shape, so neighbours run together. */
:root {
  --page: #ffffff;          /* the page */
  --ink: #17201b;           /* the words */
  --muted: #7a837c;         /* the names of the trails, the Clear with nothing to clear */
  --line: #d6dcd6;          /* a chip's outline */
  --line-hover: #9aa59c;    /* a chip's outline under the pointer */
  --liquid: #12634a;        /* the liquid in the lit chips */
  --liquid-top: #2a8a69;    /* the light along the liquid's top */
  --liquid-ink: #ffffff;    /* the words in the liquid */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
}

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

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

.trails {
  width: min(420px, 100%);
}

/* ---------------------------------------------------------------- the chips */
.chips {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  position: relative;
  height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 19px;
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--line);
  color: var(--ink);
  font: 500 15px/1 'Parkinsans Variable', system-ui, sans-serif;
  letter-spacing: -0.005em;
  white-space: nowrap;
  cursor: pointer;
  outline: none;
  transition: box-shadow 0.2s ease, transform 0.16s cubic-bezier(0.23, 1, 0.32, 1);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

@media (hover: hover) {
  .chip:hover {
    box-shadow: inset 0 0 0 1.5px var(--line-hover);
  }
}

/* pressed: an empty chip gives a little; a lit one is squeezed by the script, liquid and all */
.chip[aria-pressed='false']:active,
.chip[aria-pressed='false'].is-down {
  transform: scale(0.96);
}

/* the liquid: one layer over the chips, cut by the script to the shape of the liquid (clip-path: path), with the
   words of the lit chips inside it, in white. It spills a little past the chips, so it is bigger than them */
.flow {
  position: absolute;
  inset: -16px;
  z-index: 1;
  background: var(--liquid);
  pointer-events: none;
  clip-path: path('M0 0Z');
}

/* the light on the liquid, one band for every line of chips */
.flow__light {
  position: absolute;
  left: 0;
  right: 0;
  background: linear-gradient(180deg, var(--liquid-top) 0%, rgba(42, 138, 105, 0) 55%, rgba(0, 0, 0, 0.14) 100%);
}

.flow__word {
  position: absolute;
  display: grid;
  place-items: center;
  color: var(--liquid-ink);
  font: 640 15px/1 'Parkinsans Variable', system-ui, sans-serif;
  letter-spacing: -0.005em;
  white-space: nowrap;
}

/* the keyboard's ring: one ring that goes from chip to chip, over the liquid */
.ring {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  border-radius: 999px;
  box-shadow: 0 0 0 2px var(--page), 0 0 0 4px var(--ink);
  opacity: 0;
  pointer-events: none;
}

/* ---------------------------------------------------------------- the count */
.result {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  column-gap: 16px;
  margin-top: 20px;
  padding: 0 2px;
}

.result__count {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  line-height: 24px;
  letter-spacing: -0.01em;
}

/* the digits roll: every digit is a column of 0 to 9 seen through a slot one digit high */
.odo {
  display: inline-flex;
  vertical-align: top;
}

.odo__slot {
  display: block;
  height: 24px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 22%, #000 78%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0, #000 22%, #000 78%, transparent 100%);
}

.odo__reel {
  display: block;
}

.odo__reel span {
  display: block;
  height: 24px;
  text-align: center;
}

.result__names {
  grid-column: 1 / -1;
  min-height: 21px;
  margin: 4px 0 0;
  font-size: 14px;
  line-height: 21px;
  color: var(--muted);
}

.clear {
  justify-self: end;
  height: 32px;
  margin: -4px -10px -4px 0;
  padding: 0 10px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--ink);
  font: 560 15px/1 'Parkinsans Variable', system-ui, sans-serif;
  cursor: pointer;
  transition: color 0.2s ease, transform 0.16s cubic-bezier(0.23, 1, 0.32, 1);
  -webkit-tap-highlight-color: transparent;
}

.clear[aria-disabled='true'] {
  color: var(--muted);
  cursor: default;
}

@media (hover: hover) {
  .clear:not([aria-disabled='true']):hover {
    color: var(--liquid);
  }
}

.clear:not([aria-disabled='true']):active {
  transform: scale(0.95);
}

.clear:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

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