/* Garage Sale engine styles — generic, reusable. */
:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --ink: #1c1c1e;
  --muted: #6b6b70;
  --line: #e6e6e2;
  --accent: #2f6d4f;
  --accent-ink: #ffffff;
  --sold: #c0392b;
  --reserved: #8a6d3b;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 6px 20px rgba(0,0,0,.05);
  --maxw: 1120px;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding-left: 20px; padding-right: 20px; }

/* Header */
.site-header {
  background: linear-gradient(160deg, var(--accent), #244f3a);
  color: var(--accent-ink);
  padding: 32px 0 24px;
}
.site-header h1 { margin: 0; font-size: clamp(1.65rem, 2.8vw, 2.2rem); line-height: 1.15; letter-spacing: -.02em; }
.site-header .subtitle { margin: 8px 0 0; max-width: 60ch; font-size: 1rem; line-height: 1.5; opacity: .9; }
.site-header .contact { margin: 8px 0 0; font-size: .9rem; opacity: .82; }
.site-header .contact:empty, .site-header .subtitle:empty { display: none; }

/* Controls */
.controls-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(247,247,245,.9);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
}
.search {
  flex: 1;
  min-width: 0;
  font-size: 1rem;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
}
.search:focus, .sort:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Custom select caret so the arrow has proper breathing room */
.sort {
  font: inherit;
  font-size: .95rem;
  padding: 12px 40px 12px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background-color: var(--surface);
  color: var(--ink);
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2.5 4.5l3.5 3.5 3.5-3.5' fill='none' stroke='%236b6b70' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px;
  cursor: pointer;
}
.sort::-ms-expand { display: none; }

/* Single-row toolbar: search + category multiselect + sort + toggle */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.toolbar .search { flex: 1 1 240px; }
.toolbar .sort { flex: 0 0 auto; }

/* Category multiselect button */
.cat-select { position: relative; flex: 0 0 auto; }
.cat-btn {
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-size: .95rem;
  padding: 12px 16px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  cursor: pointer; white-space: nowrap;
}
.cat-btn:hover { border-color: var(--accent); }
.cat-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cat-btn.has-selection { border-color: var(--accent); color: var(--accent); }
.cat-btn-count {
  min-width: 18px; padding: 0 5px; line-height: 18px; text-align: center;
  background: var(--accent); color: #fff; border-radius: 999px;
  font-size: .72rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.cat-btn-count[hidden] { display: none; }
.cat-caret {
  width: 0; height: 0; margin-left: 1px;
  border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-top: 5px solid currentColor; opacity: .55;
}

/* Category dropdown menu */
.cat-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40;
  width: 260px; max-height: 340px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.15);
  padding: 8px;
}
.cat-menu[hidden] { display: none; }
.cat-menu-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 2px 6px 8px; margin-bottom: 4px; border-bottom: 1px solid var(--line);
}
.cat-menu-title { font-weight: 600; font-size: .9rem; }
.cat-menu-clear { font: inherit; font-size: .82rem; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px 4px; }
.cat-menu-clear:hover { color: var(--accent); }
.cat-list { display: flex; flex-direction: column; }
.cat-opt { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 7px; cursor: pointer; font-size: .92rem; }
.cat-opt[hidden] { display: none; }
.cat-opt:hover { background: rgba(0,0,0,.04); }
.cat-check { width: 16px; height: 16px; flex: none; accent-color: var(--accent); cursor: pointer; }
.cat-opt-name { flex: 1; }
.cat-opt-count { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.cat-opt.cat-opt-empty { opacity: .5; }

/* Backdrop — only used for the mobile bottom sheet */
.cat-backdrop { display: none; }

/* Active filter chips (surface current selections) */
.active-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.active-filters[hidden] { display: none; }
.afilter {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: .82rem; font-weight: 600;
  padding: 4px 8px 4px 12px;
  border: 1px solid var(--accent); border-radius: 999px;
  background: rgba(47,109,79,.08); color: var(--accent); cursor: pointer;
}
.afilter:hover { background: rgba(47,109,79,.16); }
.afilter-x { font-size: 1.05rem; line-height: 1; }
.afilter-clear { font: inherit; font-size: .82rem; background: none; border: 0; color: var(--muted); cursor: pointer; text-decoration: underline; padding: 4px; }
.afilter-clear:hover { color: var(--ink); }

/* Reserved & sold toggle */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: .9rem;
  color: var(--ink);
  user-select: none;
}
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: #cfcfca;
  transition: background .15s;
  flex: none;
}
.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.3);
  transition: transform .15s;
}
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(16px); }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Result count */
.result-count { color: var(--muted); font-size: .88rem; margin: 12px auto 0; }

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 20px;
  padding-top: 8px;
  padding-bottom: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  transition: transform .12s ease, box-shadow .12s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 2px 6px rgba(0,0,0,.08), 0 12px 28px rgba(0,0,0,.08); }
.card.status-is-sold { opacity: .68; }

/* card-media is a <button> when the item has photos */
.card-media {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #ececea;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  overflow: hidden;
}
button.card-media { cursor: zoom-in; }
button.card-media.is-empty { cursor: pointer; }
button.card-media.is-empty:hover { background: #e4e4e2; }
button.card-media:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s ease; }
button.card-media:hover img { transform: scale(1.03); }
.placeholder { color: #a6a6a6; font-size: .85rem; letter-spacing: .03em; text-transform: uppercase; }

/* photo-count pill on cards with multiple photos */
.photo-count {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,.62);
  color: #fff;
  font-size: .78rem;
  font-weight: 600;
  line-height: 1;
  pointer-events: none;
}
.photo-count svg { display: block; }

.status {
  position: absolute;
  top: 10px;
  left: 10px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  padding: 5px 9px;
  border-radius: 6px;
  color: #fff;
  text-transform: uppercase;
}
.status-sold { background: var(--sold); }
.status-reserved { background: var(--reserved); }

.card-body { padding: 16px; display: flex; flex-direction: column; flex: 1; }
.card-content { display: flex; flex-direction: column; gap: 12px; flex: 1; }
/* tight "identity" group: title -> price sit close together */
.card-head { display: flex; flex-direction: column; gap: 4px; }
.card-name {
  margin: 0; font-size: 16px; font-weight: 600; line-height: 1.25; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-price { font-size: 18px; font-weight: 700; color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; }
.card-full { font-weight: 400; font-size: .78em; color: var(--muted); text-decoration: line-through; margin-left: 10px; }
.card-unit { font-weight: 400; font-size: .7em; color: var(--muted); margin-left: 3px; }
/* price + condition share a row: price anchors left, condition chip sits right */
.card-priceline { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
/* quantity = plain muted text (self-describing via the "available" unit) */
.card-qty { font-size: 13px; line-height: 1.4; color: var(--muted); }

/* condition = color-coded status chip */
.card-condition {
  flex: none;
  display: inline-flex; align-items: center;
  font-size: 12px; font-weight: 500; line-height: 1.4;
  padding: 2px 9px; border-radius: 999px; white-space: nowrap;
  background: #f1f5f9; color: #334155; /* default / unknown = neutral */
}
.card-condition.cond-new,
.card-condition.cond-likenew { background: #e0f2fe; color: #0c4a6e; } /* positive = sky */
.card-condition.cond-good     { background: #f1f5f9; color: #334155; } /* fine = neutral */
.card-condition.cond-fair     { background: #fef3c7; color: #92400e; } /* caution = amber */
.card-condition.cond-forparts { background: #fee2e2; color: #991b1b; } /* defect = red */
.card-descwrap { display: flex; flex-direction: column; gap: 8px; }
.card-desc {
  margin: 0; font-size: 14px; line-height: 1.5; color: #52555c;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-more {
  display: none;
  align-self: flex-start;
  align-items: center;
  gap: 3px;
  margin: 0; padding: 0; border: 0; background: none;
  color: var(--accent);
  font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.card-more::after { content: "›"; font-size: 1.15em; line-height: 0; }
.card-more:hover { text-decoration: underline; }
.card.is-clamped .card-more { display: inline-flex; }

/* Add-to-reserve-list button on cards */
.cart-add {
  margin-top: 16px;
  width: 100%;
  font: inherit;
  font-size: .86rem;
  font-weight: 600;
  padding: 9px 12px;
  border: 1px solid var(--accent);
  border-radius: 9px;
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.cart-add:hover { background: rgba(47,109,79,.08); }
.cart-add.in-cart { background: var(--accent); color: var(--accent-ink); }

/* Pagination */
.pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding-bottom: 48px;
}
.pager:empty { display: none; }
.pager-btn {
  font: inherit;
  font-size: .9rem;
  min-width: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: border-color .12s, background .12s, color .12s;
}
.pager-btn:hover:not(:disabled):not(.is-current) { border-color: var(--accent); }
.pager-btn.is-current { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); cursor: default; }
.pager-btn:disabled { opacity: .4; cursor: default; }
.pager-gap { padding: 0 4px; color: var(--muted); }

/* States */
.empty, .error { grid-column: 1 / -1; color: var(--muted); text-align: center; padding: 48px 12px; }
.error { text-align: left; background: #fff4f2; border: 1px solid #f3c9c1; color: #7a271a; border-radius: 10px; padding: 20px; }
.error code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 4px; }
.retry-btn {
  font: inherit; font-size: .92rem; font-weight: 600;
  margin-top: 4px; padding: 9px 16px; border-radius: 8px; cursor: pointer;
  border: 1px solid #c0392b; background: #fff; color: #7a271a;
}
.retry-btn:hover { background: #7a271a; color: #fff; border-color: #7a271a; }

/* Loading state */
.loading {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 64px 12px;
  color: var(--muted);
  font-size: .95rem;
}
.spinner {
  width: 38px; height: 38px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

/* Detail overlay — card-styled modal */
body.lb-open { overflow: hidden; }
.lb {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.lb[hidden] { display: none; }
.lb-backdrop { position: absolute; inset: 0; background: rgba(15,18,20,.55); }
.lb-card {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0,0,0,.28);
  overflow: hidden;
}
.lb--media .lb-card { max-width: 1100px; }
.lb-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}
.lb-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: rgba(0,0,0,.5);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: background .12s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lb-close:hover { background: rgba(0,0,0,.7); }
.lb-media {
  position: relative;
  flex: none;
  background: #eef1f4;
  overflow: hidden;
  touch-action: none;
}
.lb-media[hidden] { display: none; }
.lb-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; cursor: zoom-in; }
.lb-img.is-zoomed { cursor: zoom-out; }
.lb-media.is-panning, .lb-media.is-panning .lb-img { cursor: grabbing; }
.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: rgba(0,0,0,.45);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  transition: background .12s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lb-nav:hover { background: rgba(0,0,0,.65); }
.lb-nav[hidden] { display: none; }
.lb-prev { left: 10px; }
.lb-next { right: 10px; }
.lb-counter {
  position: absolute;
  bottom: 10px;
  right: 10px;
  z-index: 2;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: .78rem;
  font-variant-numeric: tabular-nums;
}
.lb-counter[hidden] { display: none; }
.lb-zoomhint {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: rgba(0,0,0,.45);
  color: #fff;
  pointer-events: none;
}
.lb-img.is-zoomed ~ .lb-zoomhint { display: none; }
.lb-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 18px 18px;
  flex: none;
}
.lb-caption { margin: 0; font-size: 18px; font-weight: 600; line-height: 1.3; color: var(--ink); padding-right: 34px; }
.lb-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lb-desc {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: #52555c;
  white-space: pre-wrap;
}
.lb-desc[hidden] { display: none; }

/* Reserve list — floating pill */
.cart-pill {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,.22);
}
.cart-pill[hidden] { display: none; }
.cart-pill svg { display: block; }
.cart-pill-count {
  min-width: 20px;
  text-align: center;
  background: rgba(255,255,255,.25);
  border-radius: 999px;
  padding: 1px 6px;
  font-variant-numeric: tabular-nums;
}

/* Reserve list — panel */
.cartp { position: fixed; inset: 0; z-index: 90; }
.cartp[hidden] { display: none; }
body.cartp-open { overflow: hidden; }
.cartp-backdrop { position: absolute; inset: 0; background: rgba(12,12,14,.5); }
.cartp-panel {
  position: absolute;
  top: 0; right: 0;
  height: 100%;
  width: min(420px, 100%);
  background: var(--bg);
  box-shadow: -8px 0 30px rgba(0,0,0,.18);
  display: flex;
  flex-direction: column;
  animation: cartp-in .18s ease;
}
@keyframes cartp-in { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.cartp-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.cartp-head h2 { margin: 0; font-size: 1.15rem; }
.cartp-close {
  width: 36px; height: 36px; border: 0; border-radius: 8px;
  background: none; color: var(--muted); font-size: 1.1rem; cursor: pointer;
}
.cartp-close:hover { background: var(--line); color: var(--ink); }
.cartp-items { flex: 1; overflow-y: auto; padding: 8px 12px; }
.cartp-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px; border-radius: 10px;
}
.cartp-row:hover { background: rgba(0,0,0,.03); }
.cartp-thumb {
  flex: 0 0 auto; width: 52px; height: 52px; border-radius: 8px;
  object-fit: cover; background: #e4e4e0; display: block;
}
.cartp-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.cartp-name { font-weight: 600; font-size: .95rem; }
.cartp-cat { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.cartp-remove {
  flex: 0 0 auto; width: 30px; height: 30px; border: 0; border-radius: 7px;
  background: none; color: var(--muted); cursor: pointer;
}
.cartp-remove:hover { background: var(--line); color: var(--sold); }
.cartp-empty { padding: 40px 24px; color: var(--muted); text-align: center; font-size: .95rem; }
.cartp-empty[hidden] { display: none; }
.cartp-foot { border-top: 1px solid var(--line); padding: 16px 20px 20px; }
.cartp-foot[hidden] { display: none; }
.cartp-note { margin: 0 0 12px; font-size: .85rem; color: var(--muted); }
.cartp-actions { display: flex; flex-direction: column; gap: 8px; }
.btn, .btn-primary, .btn-ghost {
  font: inherit; font-size: .92rem; font-weight: 600; text-align: center;
  padding: 11px 14px; border-radius: 9px; cursor: pointer; text-decoration: none;
  border: 1px solid var(--line); transition: background .12s, border-color .12s, color .12s;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #275c42; }
.btn-primary[hidden] { display: none; }
.btn { background: var(--surface); color: var(--ink); }
.btn:hover { border-color: var(--accent); }
.btn.copied { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: none; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--sold); }

@media (max-width: 560px) {
  .toolbar .search { flex-basis: 100%; }
  .controls-bar { backdrop-filter: none; }
  /* category dropdown becomes a bottom sheet */
  .cat-select { position: static; }
  .cat-menu {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    width: auto; max-height: 70vh;
    border-radius: 16px 16px 0 0;
    z-index: 120;
  }
  .cat-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 110; }
  .cat-backdrop[hidden] { display: none; }
  .cart-pill { right: 14px; bottom: 14px; }
  .cart-pill-label { display: none; }
}
@media (max-width: 480px) {
  .grid { grid-template-columns: 1fr; gap: 14px; }
  .site-header { padding: 24px 0 20px; }
}
