/* Shared listing page, served by the `listingPage` function.
   Its own stylesheet rather than inline rules: the site's CSP is
   `style-src 'self'`, which blocks both <style> blocks and style attributes. */

:root {
  --navy: #0b192c;
  --coral: #ff4c4c;
  --ink: #0f172a;
  --muted: #6b7280;
  --line: rgba(15, 23, 42, 0.1);
  --bg: #f7f8fa;
  --card: #fff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.brand img { display: block; height: 38px; width: auto; }

.btn {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

/* In the bar, the button matches the burger beside it. */
.bar .btn {
  height: 42px;
  padding-top: 0;
  padding-bottom: 0;
  display: inline-flex;
  align-items: center;
}

.btn-coral { background: var(--coral); }

main { max-width: 960px; margin: 0 auto; padding: 28px 24px 56px; }

.listing {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 36px;
  align-items: start;
}

.shots {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}

.shots img {
  width: 100%;
  height: auto;
  border-radius: 14px;
  display: block;
  background: #e9edf2;
}

/* Extra photos ride along underneath the cover, two up. */
.shots img:not(:first-child) { grid-column: auto; }

.detail h1 { font-size: 1.9rem; line-height: 1.2; margin: 0 0 8px; }

.price {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--coral);
  margin: 0 0 18px;
}

.sold {
  display: inline-block;
  margin: 0 0 10px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.facts { list-style: none; margin: 0 0 18px; padding: 0; }

.facts li {
  display: flex;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.facts span { min-width: 110px; color: var(--muted); }

.desc { white-space: pre-wrap; margin: 0 0 20px; }

.specs { width: 100%; border-collapse: collapse; margin: 0 0 22px; }

.specs th,
.specs td {
  text-align: left;
  font-weight: 400;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.specs th { color: var(--muted); width: 45%; padding-right: 14px; }

.cta { margin-top: 8px; }

.note { color: var(--muted); font-size: 0.9rem; margin: 12px 0 0; }

.gone { text-align: center; padding: 60px 0; }
.gone h1 { font-size: 1.8rem; margin: 0 0 10px; }
.gone p { color: var(--muted); margin: 0 0 24px; }

.foot {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
  padding: 26px 24px 44px;
  border-top: 1px solid var(--line);
  background: var(--card);
}

.foot a { color: var(--muted); text-decoration: none; font-size: 0.9rem; }
.foot a:hover { color: var(--coral); }

/* ---- Browse pages (/parts, /parts/{category}) and shop pages (/seller/…),
   rendered by the partsPage and sellerPage functions. ---- */

.bar-links { margin-left: auto; display: flex; gap: 18px; }
.bar-links a { color: var(--ink); text-decoration: none; font-weight: 600; }
.bar-links a:hover, .bar-links a[aria-current] { color: var(--coral); }

/* Burger menu — a <details>, so it works without JavaScript and under the
   /map CSP, which allows no inline scripts. Hidden on wide screens, where
   the bar carries the links itself. */
.burger { display: none; position: relative; }

.burger > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  cursor: pointer;
}

.burger > summary::-webkit-details-marker { display: none; }

.burger-lines {
  display: block;
  position: relative;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--ink);
}

.burger-lines::before,
.burger-lines::after {
  content: '';
  position: absolute;
  left: 0;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--ink);
}

.burger-lines::before { top: -6px; }
.burger-lines::after { top: 6px; }

.burger-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 220px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
  padding: 8px;
  display: flex;
  flex-direction: column;
  z-index: 1200; /* above Leaflet's controls (max ~1000) */
}

.burger-panel a {
  padding: 11px 14px;
  border-radius: 9px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
}

.burger-panel a:hover { background: var(--bg); color: var(--ink); }
.burger-panel .burger-cta { color: var(--coral); }

.crumbs { color: var(--muted); font-size: 0.9rem; margin: 0 0 18px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--coral); }

.browse h1, .shop h1 { font-size: 1.9rem; line-height: 1.2; margin: 0 0 8px; }

.intro { color: var(--muted); max-width: 64ch; margin: 0 0 20px; }

/* Filter bar on /parts, search bar on /map — shared control styles. */
.filterbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 0 0 12px;
}

.filterbar input[type="search"] {
  flex: 1;
  min-width: 190px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font: inherit;
  background: var(--card);
}

.filterbar .btn { border: 0; cursor: pointer; font: inherit; font-weight: 700; }

.mapopt {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.92rem;
  white-space: nowrap;
}

.mapopt select {
  font: inherit;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
}

.filternote { margin: 0 0 14px; }
.filternote a { color: var(--coral); }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 26px;
}

.chip {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 0.88rem;
  text-decoration: none;
  white-space: nowrap;
}

.chip:hover { border-color: var(--coral); color: var(--coral); }

.chip.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 18px;
  margin: 0 0 30px;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  text-decoration: none;
  color: var(--ink);
}

.card:hover { border-color: var(--coral); }

.thumb {
  display: block;
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #e9edf2;
}

/* Absolutely positioned: a percentage height against an aspect-ratio box is
   not reliably definite, and a tall photo would stretch its card out of the
   row. */
.thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-body { display: block; padding: 12px 14px 14px; }
.card-price { display: block; font-weight: 800; color: var(--coral); }
.card-title {
  display: block;
  font-weight: 600;
  line-height: 1.35;
  margin: 2px 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.card-sub { display: block; color: var(--muted); font-size: 0.85rem; }

.empty { text-align: center; padding: 48px 0; }
.empty h2 { margin: 0 0 8px; }
.empty p { color: var(--muted); margin: 0 0 20px; }

.shop-head {
  display: flex;
  gap: 18px;
  align-items: center;
  margin: 0 0 16px;
}

.shop-photo {
  width: 88px;
  height: 88px;
  border-radius: 18px;
  object-fit: cover;
  background: #e9edf2;
}

.shop-place { color: var(--muted); margin: 2px 0 0; }

.rating { margin: 6px 0 0; font-weight: 700; color: var(--ink); }
.rating span { color: var(--muted); font-weight: 400; font-size: 0.9rem; }

.hours { margin: 0 0 18px; }
.hours summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.hours ul { list-style: none; margin: 8px 0 0; padding: 0; }
.hours li {
  display: flex;
  gap: 12px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}
.hours li span { min-width: 110px; color: var(--muted); }

.claim {
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0 0 22px;
}

.shop-sub { font-size: 1.2rem; margin: 26px 0 14px; }

@media (max-width: 760px) {
  .listing { grid-template-columns: 1fr; gap: 24px; }
  .detail h1 { font-size: 1.5rem; }
  .browse h1, .shop h1 { font-size: 1.5rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  main { padding: 20px 18px 44px; }
  .bar-links { display: none; }
  .burger { display: block; }
  /* With the links gone, space-between would centre the button. */
  .bar .btn { margin-left: auto; }
}
