/* The active filters in pills that gather in the count: the filter bar of Larchway, a made-up camping gear shop, on a
   white page. Every pill is placed by GSAP (x, y, scale, rotation on .pill); its look and its hover live on the child
   .pill__in, so GSAP's inline transform never wipes the CSS one. */
:root {
  --page: #ffffff;           /* the page */
  --panel: #fbfaf7;          /* the panel, a warm off white */
  --edge: rgba(28, 26, 18, 0.09); /* the hairline edges */
  --ink: #18191b;            /* the words */
  --muted: #74767c;          /* the small words */
  --pill: #ffffff;           /* the pills */
  --accent: #2f6a4f;         /* pine green: the +3 pill and the x on hover */
  --accent-ink: #f3f7f2;     /* the words on the accent */
  --sand: #d9c7a3;           /* the sand swatch */
  --slate: #8d97a1;          /* the slate swatch */
}

* {
  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: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

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

.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 12px;
  overflow: hidden;
}

/* ---- the panel ---- */
.panel {
  position: relative;
  width: min(94vw, 620px);
  padding: clamp(14px, 3.6vh, 22px) clamp(14px, 4vw, 22px) clamp(14px, 3.4vh, 22px);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 38%),
    var(--panel);
  box-shadow:
    inset 0 0 0 1px var(--edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 1px 2px rgba(30, 28, 20, 0.05),
    0 10px 24px -12px rgba(30, 28, 20, 0.14),
    0 34px 60px -34px rgba(30, 28, 20, 0.22);
  opacity: 0;
}

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

.panel__crumb {
  display: block;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.panel__sep {
  opacity: 0.5;
  padding: 0 2px;
}

.panel__count {
  margin: 5px 0 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: clamp(20px, min(6vw, 5.4vh), 26px);
  line-height: 1;
  font-weight: 640;
  font-variation-settings: 'wdth' 96;
  letter-spacing: -0.025em;
}

.panel__word {
  font-weight: 460;
  color: var(--muted);
  font-variation-settings: 'wdth' 100;
  letter-spacing: -0.01em;
}

/* ---- the rolling digits: each figure is a drum of 0 to 9 ---- */
.roll {
  display: inline-flex;
  height: 1em;
  line-height: 1;
  align-items: flex-start;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 18%, #000 82%, transparent);
  mask-image: linear-gradient(180deg, transparent, #000 18%, #000 82%, transparent);
}

.roll__col {
  display: flex;
  flex-direction: column;
  will-change: transform;
}

.roll__col > span {
  display: block;
  text-align: center;
  height: 1em;
}

/* ---- Clear all and Restore ---- */
.clear {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 560;
  color: var(--ink);
  transition: background-color 0.25s, box-shadow 0.25s;
}

.clear[hidden] {
  display: none;
}

.clear__face {
  display: inline-block;
  font-variation-settings: 'wdth' 100;
  transition: font-variation-settings 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.clear__icon {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.clear.is-hover,
.clear:focus-visible {
  background: rgba(28, 26, 18, 0.05);
  box-shadow: inset 0 0 0 1px var(--edge);
}

.clear.is-hover .clear__face {
  font-variation-settings: 'wdth' 112;
}

@media (hover: hover) {
  .clear:hover {
    background: rgba(28, 26, 18, 0.05);
    box-shadow: inset 0 0 0 1px var(--edge);
  }
  .clear:hover .clear__face {
    font-variation-settings: 'wdth' 112;
  }
}

.clear:focus-visible,
.pill__x:focus-visible,
.more__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.clear:disabled {
  color: var(--muted);
  cursor: default;
  opacity: 0.55;
}

.clear--restore {
  color: var(--accent);
}

/* ---- the row of pills ---- */
.row {
  position: relative;
  height: 36px;
  margin-top: clamp(14px, 3.4vh, 20px);
  z-index: 3;
}

.row__empty {
  position: absolute;
  left: 2px;
  top: 0;
  margin: 0;
  height: 36px;
  display: flex;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  opacity: 0;
  pointer-events: none;
}

.pill {
  position: absolute;
  left: 0;
  top: 0;
  height: 36px;
  transform-origin: 50% 50%;
  will-change: transform;
  z-index: 2;
}

.pill.is-fan {
  z-index: 6;
}

.pill__in {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 36px;
  padding: 0 6px 0 13px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, #fcfbf8);
  box-shadow:
    inset 0 0 0 1px rgba(28, 26, 18, 0.11),
    inset 0 1px 0 #ffffff,
    0 1px 1px rgba(30, 28, 20, 0.05),
    0 3px 8px -4px rgba(30, 28, 20, 0.12);
  white-space: nowrap;
  font-size: 13px;
  font-weight: 540;
  letter-spacing: -0.005em;
  transition: box-shadow 0.3s, background 0.3s;
}

.pill.is-fan .pill__in {
  box-shadow:
    inset 0 0 0 1px rgba(28, 26, 18, 0.1),
    inset 0 1px 0 #ffffff,
    0 2px 3px rgba(30, 28, 20, 0.06),
    0 14px 26px -12px rgba(30, 28, 20, 0.28);
}

.pill__key {
  color: var(--muted);
  font-weight: 460;
}

.pill__key:empty {
  display: none;
}

.pill__x {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: var(--muted);
  transition: background-color 0.25s, color 0.25s, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pill__x svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

/* hovering the x: the circle fills with pine and the two strokes draw themselves again, one after the other */
.pill__x path {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}

.pill.is-hover .pill__in {
  box-shadow:
    inset 0 0 0 1px rgba(47, 106, 79, 0.35),
    inset 0 1px 0 #ffffff,
    0 1px 1px rgba(30, 28, 20, 0.05),
    0 6px 12px -6px rgba(47, 106, 79, 0.3);
}

.pill.is-hover .pill__x {
  background: var(--accent);
  color: var(--accent-ink);
  transform: rotate(90deg);
}

.pill.is-hover .pill__x-a {
  animation: draw 0.32s cubic-bezier(0.65, 0, 0.35, 1) both;
}

.pill.is-hover .pill__x-b {
  animation: draw 0.32s 0.08s cubic-bezier(0.65, 0, 0.35, 1) both;
}

.pill.is-press .pill__x {
  transform: rotate(90deg) scale(0.84);
}

@media (hover: hover) {
  .pill:hover .pill__in {
    box-shadow:
      inset 0 0 0 1px rgba(47, 106, 79, 0.35),
      inset 0 1px 0 #ffffff,
      0 1px 1px rgba(30, 28, 20, 0.05),
      0 6px 12px -6px rgba(47, 106, 79, 0.3);
  }
  .pill__x:hover {
    background: var(--accent);
    color: var(--accent-ink);
    transform: rotate(90deg);
  }
  .pill__x:hover .pill__x-a {
    animation: draw 0.32s cubic-bezier(0.65, 0, 0.35, 1) both;
  }
  .pill__x:hover .pill__x-b {
    animation: draw 0.32s 0.08s cubic-bezier(0.65, 0, 0.35, 1) both;
  }
}

.pill__x:active {
  transform: rotate(90deg) scale(0.84);
}

@keyframes draw {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}

/* ---- the +3 pill and the pile behind it ---- */
.more {
  position: absolute;
  left: 0;
  top: 0;
  height: 36px;
  z-index: 4;
  opacity: 0;
  pointer-events: none;
  will-change: transform;
}

.more.is-on {
  pointer-events: auto;
}

.more__btn {
  position: relative;
  display: block;
  height: 36px;
}

/* two thinner pills peek out behind, like a little stack */
.more__pile {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.more__pile::before,
.more__pile::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 999px;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s;
}

.more__pile::before {
  left: 6px;
  right: -6px;
  background: color-mix(in srgb, var(--accent) 22%, #ffffff);
  transform: scale(0.84);
  box-shadow: inset 0 0 0 1px rgba(47, 106, 79, 0.18);
}

.more__pile::after {
  left: 3px;
  right: -3px;
  background: color-mix(in srgb, var(--accent) 48%, #ffffff);
  transform: scale(0.92);
}

.more.is-open .more__pile::before,
.more.is-open .more__pile::after {
  transform: scale(0.8) translateY(4px);
  opacity: 0;
}

.more__face {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  min-width: 46px;
  padding: 0 13px 0 11px;
  border-radius: 999px;
  overflow: hidden;
  color: var(--accent-ink);
  font-size: 13.5px;
  font-weight: 620;
  font-variation-settings: 'wdth' 100;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 55%),
    var(--accent);
  box-shadow:
    inset 0 0 0 1px rgba(10, 30, 20, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    0 1px 2px rgba(20, 50, 35, 0.2),
    0 8px 16px -8px rgba(20, 60, 40, 0.5);
  transition: font-variation-settings 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.more.is-open .more__face,
.more.is-hover .more__face {
  font-variation-settings: 'wdth' 116;
}

@media (hover: hover) {
  .more__btn:hover .more__face {
    font-variation-settings: 'wdth' 116;
  }
}

.more__plus {
  margin-right: 1px;
  opacity: 0.8;
}

.more__sheen {
  position: absolute;
  top: -10px;
  bottom: -10px;
  left: 0;
  width: 26px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  transform: translateX(-40px) skewX(-18deg);
  pointer-events: none;
}

/* ---- the results the bar acts on: three quiet tiles, no photos ---- */
.results {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: clamp(14px, 3.4vh, 20px);
  padding-top: clamp(14px, 3.4vh, 20px);
  border-top: 1px solid var(--edge);
  z-index: 1;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.tile__swatch {
  display: grid;
  place-items: center;
  height: clamp(58px, 17vh, 104px);
  border-radius: 12px;
  margin-bottom: 4px;
  box-shadow: inset 0 0 0 1px rgba(28, 26, 18, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  overflow: hidden;
}

.tile__swatch svg {
  width: 58%;
  max-height: 70%;
  fill: none;
  stroke: rgba(255, 255, 255, 0.85);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tile__swatch--pine {
  background: radial-gradient(120% 90% at 30% 10%, #5f9479, var(--accent) 60%, #22503b);
}

.tile__swatch--sand {
  background: radial-gradient(120% 90% at 30% 10%, #eadcbf, var(--sand) 60%, #bfa57a);
}

.tile__swatch--slate {
  background: radial-gradient(120% 90% at 30% 10%, #b5bdc5, var(--slate) 60%, #6c7580);
}

.tile__name {
  font-size: 12.5px;
  font-weight: 560;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile__meta {
  display: flex;
  gap: 8px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.tile__dim {
  color: var(--muted);
}

@media (max-width: 420px) {
  .results {
    grid-template-columns: repeat(2, 1fr);
  }
  .tile--third {
    display: none;
  }
}

/* ---- the drawn pointer of the demo ---- */
.cursor {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  fill: var(--ink);
  stroke: #ffffff;
  stroke-width: 1.4;
  stroke-linejoin: round;
  pointer-events: none;
  opacity: 0;
  z-index: 10;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.18));
}

@media (prefers-reduced-motion: reduce) {
  .clear__face,
  .more__face,
  .pill__x,
  .more__pile::before,
  .more__pile::after {
    transition: none;
  }
  .pill.is-hover .pill__x-a,
  .pill.is-hover .pill__x-b,
  .pill__x:hover .pill__x-a,
  .pill__x:hover .pill__x-b {
    animation: none;
  }
}
