:root {
  --paper: #f2f0eb;
  --cell: #f8f7f3;
  --cell-hover: #ffffff;
  --well: #ffffff;
  --ink: #161513;
  --muted: #6d6a63;
  --line: #d6d2c8;
  --signal: #d7261e;
  --focus: #1f4fd1;

  --sans: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --gutter: clamp(16px, 3vw, 40px);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121211;
    --cell: #181816;
    --cell-hover: #1f1f1c;
    --well: #ecebe6;
    --ink: #ebe8e1;
    --muted: #96928a;
    --line: #2c2b28;
    --signal: #ff5145;
    --focus: #7d9cff;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #121211;
  --cell: #181816;
  --cell-hover: #1f1f1c;
  --well: #ecebe6;
  --ink: #ebe8e1;
  --muted: #96928a;
  --line: #2c2b28;
  --signal: #ff5145;
  --focus: #7d9cff;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

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

.label {
  display: block;
  margin-bottom: 6px;
  padding: 0;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---- masthead ---------------------------------------------------------- */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 40px;
  padding: 28px var(--gutter) 20px;
  border-bottom: 2px solid var(--ink);
}

.title {
  margin: 0;
  font-size: clamp(44px, 8vw, 88px);
  font-weight: 850;
  font-stretch: 68%;
  line-height: 0.85;
  letter-spacing: -0.01em;
  text-transform: uppercase;
}

.title span {
  margin-left: 0.18em;
  font-weight: 400;
  color: var(--signal);
}

.facts {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 4px 28px;
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
}

.facts div {
  display: contents;
}

.facts dt {
  grid-row: 1;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11px;
}

.facts dd {
  grid-row: 2;
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---- controls ---------------------------------------------------------- */

.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px 24px;
  padding: 14px var(--gutter);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.search {
  flex: 1 1 180px;
  max-width: 340px;
}

.search input,
.sort select,
.tier select,
.category select,
.avail-filter select {
  width: 100%;
  height: 36px;
  padding: 0 2px;
  border: 0;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}

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

.sort select,
.tier select,
.category select,
.avail-filter select {
  appearance: none;
  padding-right: 22px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(-45deg, transparent 50%, currentColor 50%);
  background-position: right 7px center, right 2px center;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.sort select option,
.tier select option,
.category select option,
.avail-filter select option {
  background: var(--paper);
  color: var(--ink);
}

.steps {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.steps-row {
  display: flex;
  border: 1px solid var(--ink);
}

.steps label {
  position: relative;
  cursor: pointer;
}

.steps label + label {
  border-left: 1px solid var(--ink);
}

.steps input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.steps span {
  display: block;
  padding: 0 11px;
  line-height: 34px;
  font-family: var(--mono);
  font-size: 13px;
  white-space: nowrap;
}

.steps input:checked + span {
  background: var(--ink);
  color: var(--paper);
}

.steps input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: -4px;
}

/* ---- product grid ------------------------------------------------------ */

main {
  padding: 0 var(--gutter) 48px;
}

.notice {
  margin: 18px 0 0;
  padding: 10px 14px;
  border-left: 3px solid var(--signal);
  background: var(--cell);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
}

.result-count {
  margin: 18px 0 10px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.grid > li {
  display: flex;
  min-width: 0;
  background: var(--cell);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.item {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 14px 14px 16px;
  color: inherit;
  text-decoration: none;
}

.item:hover {
  background: var(--cell-hover);
}

.item:hover .name {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.item:focus-visible {
  outline-offset: -2px;
}

.off {
  margin: 0 0 10px;
  font-size: 34px;
  font-weight: 800;
  font-stretch: 70%;
  line-height: 1;
  color: var(--signal);
  font-variant-numeric: tabular-nums;
}

.well {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  margin-bottom: 14px;
  padding: 8%;
  overflow: hidden;
  background: var(--well);
}

.well img {
  position: absolute;
  inset: 8%;
  width: 84%;
  height: 84%;
  object-fit: contain;
  mix-blend-mode: multiply;
}

.well .noimg {
  max-width: 100%;
  overflow: hidden;
  font-size: clamp(22px, 2.6vw, 32px);
  font-weight: 800;
  font-stretch: 62%;
  line-height: 1;
  text-transform: uppercase;
  text-align: center;
  overflow-wrap: anywhere;
  color: #cfcbc1;
}

.well .noimg.long {
  font-size: clamp(16px, 1.8vw, 22px);
}

.name {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 450;
  line-height: 1.35;
}

.prices {
  margin-top: auto;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.now {
  display: block;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.was {
  font-size: 13px;
  color: var(--muted);
}

.was s {
  text-decoration-thickness: 1px;
}

.was em {
  font-style: normal;
  margin-left: 6px;
}

/* in stock: ink with a filled square; at the supplier: muted with an outline */
.avail {
  margin: 6px 0 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.avail::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border: 1px solid currentColor;
  vertical-align: 1px;
}

.avail.stock {
  color: var(--ink);
}

.avail.stock::before {
  background: currentColor;
}

.tiers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 12px;
  margin: 10px 0 0;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tiers div {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.tiers dt,
.tiers dd {
  margin: 0;
  white-space: nowrap;
}

.tiers .best {
  color: var(--ink);
  font-weight: 600;
}

.promos {
  margin: 10px 0 0;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.promos b {
  font-weight: 600;
  color: var(--ink);
}

.empty {
  grid-column: 1 / -1;
  padding: 48px 16px;
  background: var(--cell);
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
}

#sentinel {
  height: 1px;
}

/* ---- footer ------------------------------------------------------------ */

.colophon {
  padding: 20px var(--gutter) 40px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.colophon p {
  max-width: 70ch;
  margin: 0;
}

/* ---- mobile ------------------------------------------------------------ */

@media (max-width: 640px) {
  .masthead {
    padding-top: 20px;
  }

  .facts {
    gap: 2px 20px;
  }

  .toolbar {
    position: static;
    gap: 14px 20px;
  }

  .search {
    flex-basis: 100%;
    max-width: none;
  }

  .steps span {
    padding: 0 8px;
    font-size: 12px;
  }

  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .item {
    padding: 10px 10px 12px;
  }

  .off {
    font-size: 26px;
  }

  .name {
    font-size: 13px;
  }

  .now {
    font-size: 16px;
  }

  .was em {
    display: block;
    margin-left: 0;
  }

  .promos {
    display: none;
  }

  .tiers {
    grid-template-columns: minmax(0, 1fr);
  }
}
