/* ============================================================================
   Map page styles
   ============================================================================ */

body.map-body {
  height: 100vh;
  overflow: hidden;
}

/* The nav stays from base.html (56px). The action bar sits below it. */
:root {
  --map-nav-h: 56px;
  --map-bar-h: 48px;
  --map-chrome: calc(var(--map-nav-h) + var(--map-bar-h));
  --ph: 42dvh;
  --phx: 88dvh;
}

/* Hide footer on map page (also blocked in template) */
body.map-body .footer { display: none; }

/* ── Action bar ────────────────────────────────────────────────────────────── */
.action-bar {
  position: fixed;
  top: var(--map-nav-h);
  left: 0; right: 0;
  height: var(--map-bar-h);
  background: var(--paper);
  border-bottom: 1px solid var(--border);
  z-index: 200;
  overflow: visible;
}
.action-bar-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  height: 100%;
  padding: 0 var(--gutter);
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.action-bar-inner::-webkit-scrollbar { display: none; }

.search-compact {
  flex: 0 1 280px;
  min-width: 180px;
  padding: 0 14px;
  height: 34px;
}
.search-compact input { padding: 8px 0; font-size: 0.88rem; }

.map-action-btn {
  flex-shrink: 0;
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--paper);
  border: 1px solid var(--border);
  color: var(--ink-2);
  font-size: 0.85rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: all 0.15s;
}
.map-action-btn:hover { border-color: var(--forest); color: var(--forest); }
.map-action-btn.active {
  background: var(--forest);
  color: var(--cream);
  border-color: var(--forest);
}

.count-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-left: auto;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Search results dropdown ──────────────────────────────────────────────── */
.search-results {
  position: fixed;
  top: calc(var(--map-chrome) + 4px);
  left: 50%;
  transform: translateX(-50%);
  width: min(540px, calc(100% - 32px));
  max-height: 60vh;
  overflow-y: auto;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 250;
  display: none;
}
.search-results.show { display: block; }
.sr-section { padding: 8px 0; }
.sr-section + .sr-section { border-top: 1px solid var(--border); }
.sr-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 4px 16px 6px;
}
.sr-item {
  display: block;
  padding: 10px 16px;
  font-size: 0.92rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.sr-item:last-child { border-bottom: none; }
.sr-item:hover { background: var(--sand); }
.sr-item-name { font-weight: 500; color: var(--ink); }
.sr-item-meta { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
.sr-empty { padding: 20px 16px; color: var(--muted); font-size: 0.88rem; text-align: center; }

@media (max-width: 720px) {
  .search-compact { flex: 1 1 auto; min-width: 140px; }
  .map-action-btn span { display: none; }
  .map-action-btn { padding: 0 11px; }
  #btnOpen, #btnWeek { padding: 0 11px; }
}

/* ── Map container ─────────────────────────────────────────────────────────── */
#map {
  position: fixed;
  top: var(--map-chrome);
  left: 0; right: 0; bottom: 0;
  z-index: 0;
  background: var(--cream);
}
#map .leaflet-bottom {
  bottom: calc(var(--ph) + 8px);
  transition: bottom 0.35s;
}
body.vendor-open #map .leaflet-bottom { bottom: 8px; }
body.panel-peeked #map .leaflet-bottom { bottom: 64px; }
body.panel-hidden #map .leaflet-bottom { bottom: 8px; }

/* No sepia filter — using CartoDB Voyager which has a warm tone built in */
.leaflet-control-attribution { font-size: 9px !important; }

/* ── Legend ────────────────────────────────────────────────────────────────── */
.map-legend {
  position: fixed;
  bottom: calc(var(--ph) + 14px);
  right: 14px;
  background: var(--paper);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.74rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  z-index: 90;
  pointer-events: none;
  transition: bottom 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}
body.vendor-open .map-legend { bottom: 14px; }
body.panel-peeked .map-legend { bottom: 70px; }
body.panel-hidden .map-legend { bottom: 14px; }
.li { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.li:last-child { margin-bottom: 0; }
.legend-pin {
  width: 14px; height: 14px;
  border-radius: 50%;
  display: inline-block;
}
.pin-open {
  background: var(--forest);
  border: 2px solid var(--paper);
  box-shadow: 0 0 0 1px var(--forest);
}
.pin-closed {
  background: var(--paper);
  border: 2px solid var(--moss);
}

.empty-msg {
  display: none;
  position: fixed;
  top: calc(var(--map-chrome) + 28%);
  left: 50%;
  transform: translateX(-50%);
  background: var(--paper);
  border-radius: var(--radius);
  padding: 22px 30px;
  text-align: center;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  z-index: 80;
  pointer-events: none;
  min-width: 240px;
}
.em-text { font-weight: 500; font-size: 0.98rem; color: var(--ink); }
.em-sub { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }

/* ── Vendor panel (bottom drawer) ──────────────────────────────────────────── */
#vendorPanel {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--ph);
  background: var(--cream);
  border-top: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -2px 16px rgba(31, 61, 42, 0.08);
  transition: height 0.32s cubic-bezier(0.32, 0.72, 0, 1),
              transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}
#vendorPanel.expanded { height: var(--phx); }
#vendorPanel.slide-down { transform: translateY(100%); }
#vendorPanel.peeked { height: 56px; overflow: hidden; }
#vendorPanel.no-transition { transition: none; }

.vp-peek-hint { display: none; font-size: 0.74rem; color: var(--muted); margin-top: 2px; }
#vendorPanel.peeked .vp-peek-hint { display: block; text-align: center; }
#vendorPanel.peeked .vp-handle-row { padding: 8px 0 4px; flex-direction: column; gap: 4px; }

.vp-handle-row {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px 0 10px;
  flex-shrink: 0;
  touch-action: none;
  cursor: grab;
}
.vp-handle {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 2px;
}
.vp-header {
  padding: 2px 18px 12px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.vp-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.vp-count {
  font-size: 0.74rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
}

.vp-filter-row { display: flex; gap: 8px; }
.vp-select {
  flex: 1; min-width: 0;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--paper);
  color: var(--ink);
  font-size: 0.85rem;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236B6B6B'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.vp-select:focus { outline: none; border-color: var(--forest); }

/* ── Vendor list (improved card) ───────────────────────────────────────────── */
#vendorList {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.vendor-card {
  display: flex;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  background: var(--cream);
  transition: background 0.1s;
}
.vendor-card:active { background: var(--sand); }

.vc-photo {
  width: 72px; height: 72px;
  flex-shrink: 0;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--sage) 0%, #B5C9A8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}
.vc-photo img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.vc-placeholder {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 500;
  color: rgba(31, 61, 42, 0.32);
}

.vc-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.vc-name {
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vc-meta {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vc-tags {
  display: flex;
  gap: 5px;
  margin-top: 6px;
  flex-wrap: wrap;
  overflow: hidden;
  max-height: 22px;
}
.vc-tag {
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 8px;
  background: rgba(31, 61, 42, 0.07);
  color: var(--forest);
  white-space: nowrap;
}

.vl-empty {
  text-align: center;
  padding: 36px 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ── Sheets (market detail / vendor detail) ────────────────────────────────── */
#vOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: transparent;
  z-index: 500;
  pointer-events: none;
}
#vOverlay.on { display: block; }

#vSheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--paper);
  border-radius: 20px 20px 0 0;
  z-index: 600;
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 75dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 -8px 32px rgba(31, 61, 42, 0.18);
}
#vSheet.open { transform: translateY(0); }

/* Vendor sheet has photos at the top, so the close X must live in a
   sticky handle row that stays pinned while content scrolls. */
#vSheet .sheet-handle-row {
  position: sticky;
  top: 0;
  background: var(--paper);
  z-index: 5;
  border-radius: 20px 20px 0 0;
}
.vsheet-x {
  position: absolute;
  right: 14px;
  top: 9px;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; color: var(--muted);
  cursor: pointer;
}
/* Hide the duplicate xbtn that the JS still inserts inside .sh-row */
#vSheet .sh-row .xbtn { display: none; }

#overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 26, 0.32);
  z-index: 650;
}
#overlay.on { display: block; }

#sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--paper);
  border-radius: 20px 20px 0 0;
  z-index: 700;
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 88dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 -8px 32px rgba(31, 61, 42, 0.22);
}
#sheet.open { transform: translateY(0); }

.sheet-handle-row {
  padding: 14px 0 10px;
  display: flex;
  justify-content: center;
  touch-action: none;
  cursor: grab;
}
.handle {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 2px;
}
.sc { padding: 8px 22px 56px; }

/* ── Sheet content ─────────────────────────────────────────────────────────── */
.sh-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}
.mname, .vname {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1.18;
  color: var(--ink);
  flex: 1;
}
.xbtn {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--sand);
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.permalink {
  display: inline-block;
  font-size: 0.78rem;
  color: var(--moss);
  margin-bottom: 14px;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.permalink:hover { color: var(--forest); }

.badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.badge {
  padding: 4px 11px;
  border-radius: 12px;
  font-size: 0.74rem;
  font-weight: 500;
}
.b-type { background: rgba(31, 61, 42, 0.08); color: var(--forest); }
.b-free { background: var(--rust-soft); color: var(--rust); }
.b-paid { background: #FCE4EC; color: #880E4F; }

.alert {
  background: #FFF8E1;
  border-left: 3px solid var(--wheat);
  padding: 10px 13px;
  border-radius: 0 8px 8px 0;
  font-size: 0.86rem;
  color: #4E342E;
  margin-bottom: 14px;
}

.slabel {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
}
.stxt {
  font-size: 0.93rem;
  line-height: 1.5;
  margin-bottom: 16px;
  color: var(--ink-2);
}

.next-banner {
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.92rem;
  font-weight: 500;
  margin-bottom: 12px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.4;
}
.next-banner.is-open { background: #E8F5E9; color: #1B5E20; }
.next-banner.is-soon { background: rgba(31, 61, 42, 0.07); color: var(--forest); }
.next-banner.is-later { background: var(--sand); color: var(--ink-2); }
.next-banner.is-unkn { background: var(--sand); color: var(--muted); font-weight: 400; font-size: 0.86rem; }
.nb-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 6px;
}
.nb-dot.open { background: #2E7D32; }
.nb-dot.soon { background: var(--forest); }
.nb-dot.later { background: var(--muted); }
.nb-dot.unkn { background: var(--border); }
.nb-sub {
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 3px;
  font-weight: 400;
}

.slot-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 6px;
}
.slot-item {
  background: var(--cream);
  border-radius: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
}
.slot-main {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.slot-day { font-weight: 600; font-size: 0.92rem; }
.slot-time { font-size: 0.92rem; white-space: nowrap; color: var(--ink-2); }
.slot-unknown {
  font-size: 0.92rem;
  color: var(--muted);
  font-style: italic;
}
.freq-badge {
  font-size: 0.68rem;
  background: rgba(31, 61, 42, 0.07);
  color: var(--forest);
  padding: 2px 7px;
  border-radius: 6px;
  margin-left: 6px;
  vertical-align: middle;
}
.slot-meta {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.4;
}
.meta-warn { color: var(--rust); }
.slot-footer {
  display: flex;
  align-items: center;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  gap: 10px;
}
.slot-notes {
  font-size: 0.8rem;
  color: var(--muted);
  font-style: italic;
  flex: 1;
}
.slot-checked {
  font-size: 0.72rem;
  color: #BDBDBD;
  white-space: nowrap;
}

.amenities {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.chip {
  font-size: 0.8rem;
  color: var(--ink-2);
  background: var(--cream);
  padding: 5px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.links {
  display: flex;
  gap: 8px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.lnk {
  padding: 9px 18px;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 500;
  border: 1px solid var(--border);
  color: var(--ink-2);
  background: var(--paper);
  white-space: nowrap;
  transition: all 0.15s;
}
.lnk:hover { border-color: var(--forest); color: var(--forest); }
.lnk-primary {
  background: var(--forest);
  color: var(--cream);
  border-color: var(--forest);
}
.lnk-primary:hover { background: var(--moss); border-color: var(--moss); color: var(--cream); }

.addr-link {
  color: var(--moss);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-size: inherit;
}

.section-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 18px 0 10px;
  font-weight: 600;
}
.vlocation {
  font-size: 0.88rem;
  color: var(--rust);
  margin: 4px 0 10px;
}
.vtags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.vtags .tag {
  font-size: 0.74rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(31, 61, 42, 0.08);
  color: var(--forest);
}

/* Vendor detail photos */
.vd-photos {
  margin: -8px -22px 18px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  display: flex;
  gap: 10px;
  padding: 0 22px 8px;
}
.vd-photos::-webkit-scrollbar { display: none; }
.vd-photo-wrapper {
  flex-shrink: 0;
  width: 280px;
  height: 280px;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--sage), #B5C9A8);
}
.vd-photo {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.vd-photo-placeholder {
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 4rem;
  font-weight: 500;
  color: rgba(31, 61, 42, 0.28);
}
.vd-photo-credit {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: -8px;
  margin-bottom: 14px;
  text-align: center;
  font-style: italic;
}

.market-mini, .vendor-mini {
  background: var(--cream);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 7px;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: border-color 0.15s;
}
.market-mini:hover, .vendor-mini:hover { border-color: var(--forest); }
.mm-name { font-weight: 600; font-size: 0.94rem; color: var(--ink); }
.mm-when { font-size: 0.82rem; color: var(--rust); margin-top: 3px; font-weight: 500; }
.vm-name { font-weight: 600; font-size: 0.94rem; color: var(--ink); }
.vm-craft { font-size: 0.82rem; color: var(--muted); margin-top: 3px; }

@media (hover: hover) {
  .vendor-card:hover { background: var(--sand); }
}

/* Cluster restyle: remove leaflet defaults */
.marker-cluster {
  background: transparent !important;
  box-shadow: none !important;
}
.marker-cluster div {
  background: transparent !important;
  border: none !important;
}
