/* Urban Boulder — design tokens borrowed from LFoghorn for sibling feel.
   Different accent (stone/orange) so the two apps are visually distinguishable. */
:root {
  --primary: #d65a1e;        /* Urban Boulder accent: weathered orange/stone */
  --primary-dark: #a8451a;
  --secondary: #6c757d;
  --success: #28a745;
  --danger: #dc3545;
  --warning: #ffc107;
  --light: #f8f9fa;
  --dark: #2c3e50;
  --border: #e0e0e0;
  --shadow: rgba(0, 0, 0, 0.1);
  --bg: #f7f5f1;
  --card-bg: #ffffff;
  --muted: #6b6b6b;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg);
  color: var(--dark);
  line-height: 1.5;
}

a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.75rem 1.25rem;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px var(--shadow);
}
.topbar .brand { font-weight: 700; font-size: 1.1rem; color: var(--dark); }
.topbar nav { display: flex; gap: 1rem; align-items: center; }
.topbar nav .user { color: var(--muted); font-size: 0.9rem; }

main.page { max-width: 880px; margin: 0 auto; padding: 1.5rem 1.25rem; }

body.map-body { overflow: hidden; }
main.fullscreen-map { padding: 0; }
#map { height: calc(100vh - 53px); width: 100vw; }

.map-source-note {
  position: absolute; bottom: 12px; right: 12px; z-index: 999;
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-size: 0.8rem;
  color: var(--muted);
  max-width: 320px;
  box-shadow: 0 1px 3px var(--shadow);
}
.map-source-note code { background: var(--light); padding: 0 0.25rem; border-radius: 3px; }

.admin-map-notice {
  position: absolute; top: 65px; left: 12px; z-index: 999;
  background: var(--primary);
  color: #fff;
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  box-shadow: 0 1px 3px var(--shadow);
}

.flashes { list-style: none; padding: 0; margin: 0; }
.flash { padding: 0.6rem 1.25rem; }
.flash-error { background: #fde2e2; color: #8b1f1f; }
.flash-success { background: #e2f5e7; color: #1f5b2f; }
.flash-info { background: #fff4e0; color: #6b4400; }

.hero { padding: 2rem 0 1.5rem; }
.hero h1 { font-size: 2.25rem; margin: 0 0 0.5rem; }
.hero .lead { font-size: 1.1rem; color: var(--muted); max-width: 60ch; }

.btn {
  display: inline-block;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--dark);
  cursor: pointer;
  text-decoration: none;
  font-size: 0.95rem;
  font-family: inherit;
}
.btn:hover { text-decoration: none; border-color: var(--primary); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-small { padding: 0.3rem 0.6rem; font-size: 0.85rem; }
.btn-link { background: transparent; border-color: transparent; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; padding: 1rem 1.25rem; box-shadow: 0 1px 3px var(--shadow); }
.card h3 { margin-top: 0; }

.disclaimer-banner {
  background: #fff4e0; color: #6b4400;
  padding: 1rem 1.25rem; border-radius: 8px; margin: 1.5rem 0;
}

.site-detail .site-header { display: flex; justify-content: space-between; align-items: center; }
.site-photo {
  display: block; max-width: 100%; max-height: 420px;
  margin: 0.75rem 0 1rem; border-radius: 8px; object-fit: cover;
}
.site-photo.placeholder {
  background: var(--border); color: var(--muted);
  height: 220px; display: flex; align-items: center; justify-content: center;
}
.site-desc { font-size: 1.05rem; color: #333; }
.site-specs { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1rem; margin: 1rem 0; }
.site-specs dt { color: var(--muted); }
.site-specs dd { margin: 0; }
.warnings { background: #fde2e2; color: #8b1f1f; padding: 0.5rem 1rem; border-radius: 6px; }
.external-links { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.board { margin-top: 1.5rem; }
.post-form textarea, .post-form input { width: 100%; padding: 0.5rem; border: 1px solid var(--border); border-radius: 6px; font: inherit; }
.post-form-row { display: flex; gap: 1rem; align-items: center; margin-top: 0.5rem; flex-wrap: wrap; }
.posts { list-style: none; padding: 0; }
.post { background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem 1rem; margin-bottom: 0.75rem; }
.post-meta { display: flex; gap: 0.75rem; color: var(--muted); font-size: 0.9rem; margin-bottom: 0.3rem; }
.post-photo { max-width: 100%; max-height: 320px; border-radius: 6px; margin-top: 0.5rem; }
.muted { color: var(--muted); }

.form-card { max-width: 420px; margin: 2rem auto; background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; padding: 1.5rem; box-shadow: 0 1px 3px var(--shadow); }
.form-card.wide { max-width: 720px; }
.form-card label { display: block; margin-bottom: 0.75rem; font-size: 0.95rem; }
.form-card input[type=text], .form-card input[type=email], .form-card input[type=password],
.form-card input:not([type]), .form-card input[type=number], .form-card textarea {
  display: block; width: 100%; padding: 0.5rem;
  border: 1px solid var(--border); border-radius: 6px; font: inherit; margin-top: 0.25rem;
}
.form-card .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-card label.checkbox { display: flex; align-items: center; gap: 0.5rem; margin-top: 1.25rem; }

.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); }

.chat { max-width: 640px; margin: 0 auto; }
.chat-messages { list-style: none; padding: 0.75rem; background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; height: 50vh; overflow-y: auto; }
.chat-messages li { padding: 0.4rem 0; border-bottom: 1px dashed var(--border); }
.chat-form { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
.chat-form input { flex: 1; padding: 0.5rem; border: 1px solid var(--border); border-radius: 6px; font: inherit; }

.prose { max-width: 70ch; }

/* ===== Batch A additions: photos gallery + route cards ===== */
.group-label { margin: -0.5rem 0 1rem; }

.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}
.photo-card {
  position: relative;
  margin: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.photo-card img { display: block; width: 100%; height: 180px; object-fit: cover; }
.photo-card figcaption { padding: 0.4rem 0.6rem; font-size: 0.9rem; color: var(--muted); }
.photo-card .inline-delete { position: absolute; top: 6px; right: 6px; }

.upload-form {
  display: flex; gap: 0.75rem; align-items: end; flex-wrap: wrap;
  background: var(--light); border: 1px dashed var(--border);
  padding: 0.75rem 1rem; border-radius: 8px; margin: 0.75rem 0;
}
.upload-form label { display: flex; flex-direction: column; font-size: 0.85rem; color: var(--muted); }
.upload-form input { padding: 0.3rem; }

.routes-section { margin: 1.5rem 0; }
.routes-header { display: flex; justify-content: space-between; align-items: center; }
.routes-list { list-style: none; padding: 0; }
.route-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}
.route-card-header { display: flex; justify-content: space-between; align-items: center; }
.route-card-header h3 { margin: 0; display: flex; align-items: center; gap: 0.5rem; }
.route-dot {
  display: inline-block; width: 14px; height: 14px; border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.2);
  background: var(--c, #888);
}
.route-specs { display: grid; grid-template-columns: max-content 1fr; gap: 0.2rem 1rem; margin: 0.5rem 0 0; }
.route-specs dt { color: var(--muted); font-size: 0.9rem; }
.route-specs dd { margin: 0; font-size: 0.95rem; }
.route-actions { display: flex; gap: 0.3rem; }

.inline-delete { display: inline; margin: 0; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #a4242f; border-color: #a4242f; }


/* ===== Batch B additions: carousel, lightbox, route mini-cards, drafts ===== */

/* --- Carousel --- */
.carousel {
  position: relative;
  max-width: 480px;          /* 3:4 ratio in a portrait-friendly width */
  margin: 1rem auto;
}
.carousel-viewport {
  overflow: hidden;
  border-radius: 8px;
  background: var(--card-bg);
  border: 1px solid var(--border);
}
.carousel-track {
  display: flex;
  transition: transform 0.3s ease;
  will-change: transform;
}
.carousel-slide {
  flex: 0 0 100%;
  margin: 0;
  position: relative;
  aspect-ratio: 3 / 4;        /* portrait */
  background: #111;
}
.carousel-slide img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
}
.carousel-slide figcaption {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 0.4rem 0.75rem;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 0.9rem;
}
.carousel-slide .slide-delete {
  position: absolute; top: 8px; right: 8px;
  margin: 0;
}

.carousel-prev, .carousel-next {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.9);
  color: var(--dark);
  font-size: 1.4rem; line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 4px var(--shadow);
}
.carousel-prev { left: 8px; }
.carousel-next { right: 8px; }
.carousel-prev:hover, .carousel-next:hover { background: #fff; }

.carousel-dots {
  display: flex; justify-content: center; gap: 0.4rem;
  margin-top: 0.5rem;
}
.carousel-dots .dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: none;
  background: var(--border);
  cursor: pointer;
  padding: 0;
}
.carousel-dots .dot.active { background: var(--primary); }

/* --- Lightbox --- */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 1rem;
}
.lightbox.open { display: flex; }
.lightbox-img {
  max-width: 95vw;
  max-height: 85vh;
  object-fit: contain;
  user-select: none;
}
.lightbox-caption {
  color: #eee;
  font-size: 0.95rem;
  margin-top: 0.75rem;
  text-align: center;
  max-width: 70ch;
}
.lightbox-close, .lightbox-prev, .lightbox-next {
  position: absolute;
  border: none;
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-radius: 50%;
  width: 44px; height: 44px;
  font-size: 1.5rem; line-height: 1;
  cursor: pointer;
}
.lightbox-close { top: 16px; right: 16px; }
.lightbox-prev  { left: 16px; top: 50%; transform: translateY(-50%); }
.lightbox-next  { right: 16px; top: 50%; transform: translateY(-50%); }
.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover { background: rgba(255,255,255,0.25); }

/* --- Route mini-cards --- */
.routes-grid {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.route-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.route-card::before {
  content: '';
  display: block;
  height: 6px;
  background: var(--route-color, #888);
}
.route-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.9rem 0;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.route-card-header .route-name { margin: 0; font-size: 1.05rem; }
.route-difficulty {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.85rem; color: var(--muted);
}
.route-dot {
  display: inline-block; width: 12px; height: 12px;
  border-radius: 50%; border: 1px solid rgba(0,0,0,0.2);
}
.route-card .route-specs {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 0.75rem;
  margin: 0.6rem 0;
  padding: 0 0.9rem;
  font-size: 0.92rem;
}
.route-card .route-specs dt { color: var(--muted); }
.route-card .route-specs dd { margin: 0; }
.route-card .route-actions {
  display: flex; gap: 0.4rem;
  padding: 0.5rem 0.9rem 0.75rem;
  margin-top: auto;
}

/* --- Drafts (admin-only) --- */
.draft-banner {
  background: #fff4e0;
  color: #6b4400;
  border-left: 4px solid #e6a847;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  margin: 1rem 0;
}
.photo-placeholder {
  background: var(--light);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
  margin: 1rem 0;
}
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-published { background: #e2f5e7; color: #1f5b2f; }
.badge-draft     { background: #fff4e0; color: #6b4400; }

/* --- Mobile tweaks --- */
@media (max-width: 600px) {
  .carousel { max-width: 100%; margin: 1rem 0; }
  .routes-grid { grid-template-columns: 1fr; }
  .lightbox-prev, .lightbox-next { width: 38px; height: 38px; font-size: 1.2rem; }
}

/* ===== Batch C additions: cluster pin, popup dots, group bottom sheet ===== */

/* --- Cluster pin (multi-site group) --- */
.cluster-marker {
  cursor: pointer;
}
.cluster-pin {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}
.cluster-marker:hover .cluster-pin {
  background: var(--primary-dark);
}

/* --- Marker popup contents --- */
.popup { min-width: 160px; }
.popup .popup-name { font-size: 1rem; }
.popup .popup-dots {
  display: flex;
  gap: 4px;
  margin: 6px 0;
}
.popup-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.25);
}
.popup .popup-icons {
  margin: 4px 0 6px;
  font-size: 1.05rem;
  letter-spacing: 4px;
}
.popup .popup-link {
  display: inline-block;
  margin-top: 6px;
  color: var(--primary-dark);
  font-weight: 500;
}

/* --- Group bottom sheet --- */
.group-sheet {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.group-sheet.open {
  pointer-events: auto;
  opacity: 1;
}
.group-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
}
.group-sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--card-bg);
  border-radius: 12px 12px 0 0;
  padding: 0.75rem 1rem 1rem;
  max-height: 60vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.25);
}
.group-sheet.open .group-sheet-panel {
  transform: translateY(0);
}
.group-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.group-sheet-title {
  margin: 0;
  font-size: 1.05rem;
}
.group-sheet-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0 0.5rem;
}
.group-sheet-close:hover { color: var(--dark); }

.group-sheet-cards {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding: 0.25rem 0 0.5rem;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.group-sheet-card {
  flex: 0 0 200px;
  background: var(--light);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  text-decoration: none;
  color: var(--dark);
  scroll-snap-align: start;
  transition: border-color 0.15s;
}
.group-sheet-card:hover,
.group-sheet-card:focus {
  text-decoration: none;
  border-color: var(--primary);
}
.group-sheet-card-name {
  display: block;
  font-size: 1rem;
  margin-bottom: 0.4rem;
}

/* --- Desktop: constrain bottom sheet width --- */
@media (min-width: 720px) {
  .group-sheet-panel {
    left: 50%;
    right: auto;
    width: 100%;
    max-width: 600px;
    transform: translateX(-50%) translateY(100%);
  }
  .group-sheet.open .group-sheet-panel {
    transform: translateX(-50%) translateY(0);
  }
}

/* ===== Batch D additions: filter bar, dropdown panels, info legend ===== */

body.map-body { overflow: hidden; }
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 2;
}
#map {
  height: calc(100vh - 103px);
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--light);
  color: var(--dark);
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.filter-pill .filter-label { color: var(--muted); }
.filter-pill .filter-state { font-weight: 500; }
.filter-pill:hover { border-color: var(--primary); }
.filter-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.filter-pill.active .filter-label { color: rgba(255,255,255,0.8); }
.filter-pill.panel-open { border-color: var(--primary); }
.filter-legend { margin-left: auto; }

.filter-panel-host {
  position: absolute;
  left: 0; right: 0;
  top: 103px;
  z-index: 3;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 8px var(--shadow);
  max-height: 60vh;
  overflow-y: auto;
  display: none;
}
.filter-panel-host.open { display: block; }

.filter-panel {
  padding: 0.75rem 1rem;
  max-width: 480px;
  margin: 0 auto;
}
.filter-panel h4 { margin: 0 0 0.25rem; }
.filter-panel .filter-help {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 0.5rem;
}
.filter-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  cursor: pointer;
}
.filter-option input { margin: 0; }

.legend-panel {
  position: absolute;
  top: 60px;
  right: 0.75rem;
  z-index: 4;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px var(--shadow);
  padding: 0.75rem 1rem;
  width: 320px;
  max-width: calc(100vw - 1.5rem);
  display: none;
}
.legend-panel.open { display: block; }
.legend-panel h4 {
  margin: 0.5rem 0 0.25rem;
  font-size: 0.9rem;
}
.legend-panel h4:first-child { margin-top: 0; }
.legend-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}
.legend-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.2rem 0;
}

@media (max-width: 600px) {
  .filter-bar {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .filter-pill { flex-shrink: 0; }
  .filter-legend { margin-left: 0; }
  .legend-panel {
    right: 0.5rem;
    left: 0.5rem;
    width: auto;
  }
}