/* product finder: search box, filter chips and result cards */

.finder {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 5vh 24px 72px;
}

.finder-head {
  text-align: center;
}

.finder-head h1 {
  margin: 0;
  font-size: clamp(34px, 5.4vw, 60px);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.lede {
  margin: 14px 0 0;
  font-family: var(--mono);
  font-size: clamp(13px, 1.7vw, 15px);
  color: var(--muted);
}

.search {
  max-width: 560px;
  margin: 32px auto 0;
}

.search input {
  width: 100%;
  height: 52px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  font: 400 15px/1 var(--mono);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.search input::placeholder {
  color: var(--faint);
}

.search input:focus {
  border-color: #b8b8bf;
  box-shadow: 0 0 0 4px rgba(17, 17, 17, 0.05);
}

/* category row: single choice, and it decides which filters appear below */
.cats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 30px;
}

.cat {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: #52525b;
  font: 400 13px/1 var(--mono);
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease;
}

.cat:hover {
  background: rgba(17, 17, 17, 0.05);
}

.cat.is-on {
  background: var(--ink);
  color: #fff;
}

.cat-n {
  color: var(--faint);
  font-size: 11px;
}

.cat.is-on .cat-n {
  color: rgba(255, 255, 255, 0.7);
}

/* one button per filter; the options live in a panel it drops down */
.filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}

/* a category with nothing to filter leaves the row out of the rhythm */
.filters:empty {
  display: none;
}

.pick {
  position: relative;
}

.pick-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: #52525b;
  font: 400 13px/1 var(--mono);
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease;
}

.pick-btn:hover,
.pick.is-open .pick-btn {
  border-color: var(--edge);
}

/* a filter that is doing something reads darker than the idle ones */
.pick.has-pick .pick-btn {
  border-color: var(--ink);
  color: var(--ink);
}

/* these two carry a display of their own, which would outrank [hidden] */
.pick-menu[hidden],
.num[hidden] {
  display: none;
}

.num {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 11px;
}

.caret {
  width: 9px;
  height: 6px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 180ms ease;
}

.pick.is-open .caret {
  transform: rotate(180deg);
}

.pick-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
  gap: 6px;
  width: max-content;
  max-width: min(340px, calc(100vw - 36px));
  /* long lists scroll inside the panel instead of stretching the page */
  max-height: 306px;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 14px 34px rgba(17, 17, 17, 0.1);
  /* find.js sets --shift to nudge a panel back inside the viewport */
  transform: translateX(var(--shift, 0px));
}

.opt {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--card);
  color: #52525b;
  font: 400 12px/1 var(--mono);
  white-space: nowrap;
  text-align: center;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}

.opt:hover {
  border-color: var(--edge);
}

.opt.is-on {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.tally {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 30px 0 14px;
  font: 400 13px/1 var(--mono);
  color: var(--faint);
}

.reset {
  appearance: none;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--faint);
  text-decoration: underline;
  cursor: pointer;
}

.reset:hover {
  color: var(--ink);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  gap: 14px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: inherit;
  text-decoration: none;
  transition: border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.card:hover {
  border-color: var(--edge);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(17, 17, 17, 0.06);
}

.card-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.size {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

/* boards, panels, cameras and sensors lead with a model number, not a size */
.model {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.tag {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  font: 400 11px/1 var(--mono);
  letter-spacing: 0.06em;
  color: #52525b;
}

.specs {
  display: grid;
  gap: 3px;
  font: 400 13px/1.5 var(--mono);
  color: #52525b;
}

/* one-line pitch from the repository description */
.blurb {
  font: 400 13px/1.5 var(--mono);
  color: var(--muted);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.repo {
  /* cards in a row vary in copy, so the repo name sits on the floor of each */
  margin-top: auto;
  /* long repo names read badly when broken mid-word: clip them instead */
  font: 400 12px/1.4 var(--mono);
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 48px 0;
  text-align: center;
  font: 400 14px/1.6 var(--mono);
  color: var(--faint);
}

.foot {
  border-top: 1px solid var(--line);
  padding: 26px 24px 44px;
}

.foot-in {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  justify-content: center;
  font: 400 13px/1.6 var(--mono);
}

.foot a {
  color: #52525b;
  text-decoration: none;
}

.foot a:hover {
  color: var(--ink);
  text-decoration: underline;
}

.foot .note {
  width: 100%;
  margin: 12px 0 0;
  text-align: center;
  color: var(--faint);
}

@media (max-width: 640px) {
  .finder { padding: 4vh 18px 56px; }
  .cards { grid-template-columns: 1fr; }
}
