/* Homepage (Market Finder) layout. Shared chrome/components are in
   site.css, tokens in tokens.css. Layout follows traders-trove-handoff/
   design/index-desktop.dc.html; at <= 640px it switches to
   index-mobile.dc.html's layout (see the mobile block at the bottom, and
   isMobile() in index.js). */

/* --- Hero ---------------------------------------------------------------- */

.hero { background: var(--surface-tint); border-bottom: 1px solid var(--border); }
.hero__inner { padding-top: 56px; padding-bottom: 40px; display: flex; flex-direction: column; gap: 24px; }
.hero__copy { display: flex; flex-direction: column; gap: 12px; max-width: 760px; }
.hero h1 {
  font-family: var(--font-display); font-weight: 700; font-size: 52px; line-height: 1.05; letter-spacing: -0.02em;
}
.hero__sub { font-size: 19px; color: var(--text-soft); max-width: 640px; }

.search { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; max-width: 860px; }
.search__field { flex: 1 1 360px; display: flex; flex-direction: column; gap: 6px; }
.search__field label { font-weight: 600; font-size: 15px; color: var(--ink); }
.search__row { display: flex; gap: 12px; }
.search input {
  flex: 1 1 auto; min-width: 0; height: 52px; padding: 0 16px; font-size: 17px; color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--border-input); border-radius: var(--radius-control);
}
.search input::placeholder { color: #66746C; }
.search__submit { height: 52px; padding: 0 28px; font-size: 17px; }
.locate-button { height: 52px; padding: 0 18px; }
.search-message:empty { display: none; }
.search-message { color: var(--eyebrow); font-weight: 600; }

.trust {
  list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 12px 32px;
  color: #2E3D35; font-size: 15px;
}
.trust li { display: flex; align-items: center; gap: 8px; }
.trust svg { color: var(--brand); flex: 0 0 auto; }

/* --- Results header + filters ------------------------------------------ */

.results { padding-top: 32px; padding-bottom: 64px; display: flex; flex-direction: column; gap: 20px; }
.results:focus { outline: none; }
.results__head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; }
.results__title { display: flex; flex-direction: column; gap: 4px; }
.results__title h2 { font-family: var(--font-display); font-weight: 700; font-size: 30px; letter-spacing: -0.01em; }
.results__count { color: var(--text-muted); }
.results__controls { display: flex; flex-wrap: wrap; gap: 12px; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 14px; font-weight: 600; color: var(--ink); }
.field select {
  height: var(--target-min); padding: 0 12px; color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--border-input); border-radius: 8px;
}
#category { min-width: 190px; }
#sort { min-width: 160px; }

.filter-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; padding: 14px 16px;
  background: var(--surface-muted); border: 1px solid var(--border); border-radius: var(--radius-card);
}
.filter-bar__divider { width: 1px; height: 28px; background: var(--divider); }

.check { display: inline-flex; align-items: center; gap: 8px; min-height: var(--target-min); font-weight: 500; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--brand); }

/* --- Results list + map -------------------------------------------------- */

.results__body { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.results__list { flex: 1 1 360px; max-width: 460px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.results__aside { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }

@media (max-width: 960px) {
  .results__list { max-width: none; }
}

.market-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
/* More than six results: the list scrolls in place (height set by index.js).
   Side padding keeps the cards' focus ring and selected border unclipped. */
.market-list--scroll { position: relative; overflow-y: auto; overscroll-behavior: contain; padding: 2px 6px 2px 2px; margin: -2px -6px -2px -2px; }

.card {
  width: 100%; text-align: left; display: flex; gap: 14px; padding: 16px;
  color: var(--text); background: var(--surface); border: 2px solid var(--border);
  border-radius: var(--radius-card); cursor: pointer;
}
.card:hover { border-color: var(--border-input); }
.card[aria-pressed="true"] { background: var(--surface-tint); border-color: var(--brand); }
.card__num {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; background: var(--brand); color: var(--on-brand);
}
.card[aria-pressed="true"] .card__num { background: var(--accent); }
.card__main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.card__top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.card__name { font-family: var(--font-display); font-weight: 700; font-size: 19px; color: var(--ink); line-height: 1.2; }
.card__distance { flex: 0 0 auto; font-size: 14px; color: var(--text-muted); }
.card__meta { font-size: 15px; color: var(--text-muted); }
.card__tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.map-hint {
  position: absolute; left: 12px; bottom: 12px; z-index: 500; pointer-events: none;
  padding: 6px 10px; border-radius: 8px; background: var(--surface);
  font-size: 13px; color: var(--text-soft); border: 1px solid var(--border);
}

/* --- Quick view (desktop) ------------------------------------------------ */

.quick-view {
  border: 1px solid var(--border); border-radius: var(--radius-panel); background: var(--surface);
  box-shadow: var(--shadow-card); overflow: hidden;
}
.qv__head {
  padding: 24px 24px 18px; display: flex; flex-wrap: wrap; justify-content: space-between;
  gap: 12px 24px; border-bottom: 1px solid var(--border-soft);
}
.qv__titles { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.qv__eyebrow { font-size: 13px; }
.qv__title { font-family: var(--font-display); font-weight: 700; font-size: 28px; line-height: 1.15; }
.qv__title a { color: inherit; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; text-decoration-color: var(--brand); }
.qv__title a:hover { color: var(--brand); }
.qv__sub { color: var(--text-muted); }

.quick-view .facts { padding: 20px 24px; }

.qv__amenities { padding: 0 24px 20px; display: flex; flex-direction: column; gap: 10px; }
.amenities { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.amenities li { padding: 6px 12px; border-radius: 8px; background: var(--surface-tint); font-size: 15px; color: var(--text); }

.qv__vendors {
  padding: 20px 24px; background: var(--surface-muted); border-top: 1px solid var(--border-soft);
  display: flex; flex-direction: column; gap: 12px;
}
.qv__vendors-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.qv__vendors-title { font-family: var(--font-display); font-size: 19px; font-weight: 700; }
.qv__vendors-head a { font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; min-height: var(--target-min); }

.qv__foot {
  padding: 18px 24px 22px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 14px 24px; border-top: 1px solid var(--border-soft);
}

/* --- Bottom sheet (mobile) ------------------------------------------------- */

.sheet {
  /* The <dialog> is the full-viewport hit area: a click whose target is the
     dialog itself (not .sheet__panel) is a scrim click -- see index.js. */
  margin: 0; padding: 0; border: 0; background: transparent;
  width: 100%; max-width: 100%; height: 100%; max-height: 100%;
  inset: 0;
}
.sheet::backdrop { background: var(--scrim); }
.sheet[open] { display: flex; align-items: flex-end; }
.sheet__panel {
  width: 100%; max-height: 78%; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 20px 20px 0 0; box-shadow: var(--shadow-sheet);
  animation: sheet-in 220ms ease-out;
}
.sheet__handle { flex: 0 0 auto; width: 40px; height: 5px; border-radius: 3px; background: var(--divider); margin: 10px auto 0; }
.sheet__body { flex: 1 1 auto; overflow-y: auto; padding: 8px 20px 16px; display: flex; flex-direction: column; gap: 16px; }
.sheet__head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.sheet__title { font-family: var(--font-display); font-weight: 700; font-size: 24px; line-height: 1.15; }
.sheet__sub { font-size: 15px; color: var(--text-muted); }
.sheet__close {
  flex: 0 0 auto; width: var(--target-min); height: var(--target-min);
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-chip); border: 0; border-radius: 50%; color: var(--ink); cursor: pointer;
}
.sheet .facts { display: flex; flex-direction: column; gap: 12px; }
.sheet .pill { align-self: flex-start; }
.sheet__vendors { display: flex; flex-direction: column; gap: 8px; }
.sheet__vendors h3 { font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.sheet__vendors ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sheet__vendors .vendor { background: var(--surface-muted); border: 0; padding: 8px 10px; }
.sheet__vendors .vendor__avatar { width: 34px; height: 34px; }
.sheet__vendors > a { font-weight: 600; font-size: 15px; min-height: var(--target-min); display: inline-flex; align-items: center; }
.sheet__actions {
  flex: 0 0 auto; padding: 12px 16px 20px; display: flex; gap: 10px; border-top: 1px solid var(--border-soft);
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}
.sheet__actions .button { flex: 1 1 0; min-height: 48px; }

@keyframes sheet-in { from { transform: translateY(100%); } to { transform: translateY(0); } }

@media (prefers-reduced-motion: reduce) {
  .sheet__panel { animation: none; }
}

html.sheet-open { overflow: hidden; }

/* --- Mobile (index-mobile.dc.html) ------------------------------------------ */

@media (max-width: 640px) {
  .chip-scroller.mobile-only, .segmented.mobile-only { display: flex !important; }

  .hero__inner { padding-top: 22px; padding-bottom: 18px; gap: 14px; }
  .hero__eyebrow, .hero__sub, .trust { display: none; }
  .hero h1 { font-size: 32px; line-height: 1.08; }
  .search { flex-direction: column; align-items: stretch; gap: 6px; }
  .search__field { flex: 0 0 auto; }
  .search__row { gap: 8px; }
  .search input { height: 48px; padding: 0 14px; }
  .search__submit { height: 48px; padding: 0 18px; font-size: 16px; }
  .locate-button {
    align-self: flex-start; height: auto; min-height: var(--target-min); padding: 0; margin-top: 8px;
    background: transparent; border: 0; color: var(--link); text-decoration: underline;
  }
  .locate-button:hover { background: transparent; color: var(--link-hover); }

  .results { padding: 16px 0 24px; gap: 14px; }
  .results__head { padding: 0 16px; align-items: center; flex-wrap: nowrap; order: 2; }
  .results__title h2 { font-size: 22px; }
  .results__count { font-size: 15px; }
  .chip-scroller { order: 1; display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px 4px; }
  .chip-scroller .chip { flex: 0 0 auto; padding: 0 14px; }
  .results__body { order: 3; padding: 0 16px; display: block; }
  .results__list { gap: 10px; }

  .segmented { flex: 0 0 auto; padding: 3px; background: var(--surface-chip); border-radius: var(--radius-control); }
  .segmented button {
    min-height: var(--target-min); min-width: 56px; padding: 0 12px; font-size: 15px; font-weight: 600;
    border: 0; border-radius: 8px; cursor: pointer; background: transparent; color: var(--ink);
  }
  .segmented button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 2px rgba(23, 37, 30, 0.12); }

  /* One view at a time (List / Map toggle). */
  .results__body[data-view="list"] .results__aside { display: none; }
  .results__body[data-view="map"] .market-list { display: none; }
  .map-region { height: 420px; }

  .market-list { gap: 10px; }
  .card { padding: 14px; gap: 12px; border-width: 1.5px; }
  .card__num { width: 28px; height: 28px; }
  .card[aria-pressed="true"] { background: var(--surface); border-color: var(--border); }
  .card[aria-pressed="true"] .card__num { background: var(--brand); }
  .card__main { gap: 4px; }
  .card__top { gap: 8px; }
  .card__name { font-size: 18px; }
  .card__meta { font-size: 14px; }
  .card .pill { padding: 2px 10px; }

  .empty { padding: 20px; gap: 10px; }
}
