/* Bayexpress Interactive Sailing Map */

/* ── Map Container ── */
#map {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

/* ── Loading ── */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(245, 241, 235, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 20;
  transition: opacity 0.4s;
}
.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #e0d5c0;
  border-top-color: #c8a860;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay p {
  font-size: 14px;
  color: #666;
}

/* ── Search Bar ── */
.search-wrap {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 12;
  width: calc(100% - 80px);
  max-width: 340px;
  pointer-events: none;
}
.search-inner,
.search-box,
.search-results {
  pointer-events: auto;
}
.search-inner {
  flex: 1;
  max-width: 320px;
  position: relative;
}
.search-box {
  display: flex;
  align-items: center;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  padding: 0 12px;
  height: 32px;
  gap: 8px;
}
.search-box svg {
  flex-shrink: 0;
  opacity: 0.45;
}
.search-box input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  background: transparent;
  color: #1a1a1a;
}
.search-box input::placeholder {
  color: #aaa;
}
.search-clear {
  display: none;
  width: 20px;
  height: 20px;
  border: none;
  background: #eee;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  line-height: 20px;
  text-align: center;
  color: #666;
  flex-shrink: 0;
  padding: 0;
}
.search-clear.visible {
  display: block;
}
.search-results {
  display: none;
  background: #fff;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  max-height: 260px;
  overflow-y: auto;
  margin-top: -4px;
  padding-top: 4px;
  position: relative;
  z-index: 20;
}
.search-results.open {
  display: block;
}
.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.15s;
}
.search-result-item:hover {
  background: #f5f3ee;
}
.search-result-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.search-result-text {
  flex: 1;
  min-width: 0;
}
.search-result-name {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-sub {
  font-size: 12px;
  color: #888;
}
.search-no-results {
  padding: 14px;
  font-size: 13px;
  color: #999;
  text-align: center;
}

/* ── Tool Buttons (next to search) ── */
.ctrl-tools {
  position: absolute;
  top: 120px;
  right: 12px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ctrl-icon-btn {
  width: 30px;
  height: 30px;
  background: #fff;
  border: none;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  transition: background 0.2s;
}
.ctrl-icon-btn:hover {
  background: #f0f0f0;
}
.ctrl-icon-btn.active {
  background: #c8a860;
}

/* ── Filter Pills ── */
.filter-bar {
  position: absolute;
  top: 62px;
  left: 12px;
  z-index: 10;
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  max-width: calc(100% - 24px);
}
.filter-pill {
  height: 32px;
  padding: 0 13px;
  background: rgba(255,255,255,0.92);
  border-radius: 16px;
  border: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  font-size: 13px;
  font-weight: 500;
  color: #444;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  white-space: nowrap;
}
.filter-pill:hover {
  background: rgba(255,255,255,1);
}
.filter-pill.active {
  background: #c8a860;
  color: #fff;
}
.filter-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.filter-pill.active .filter-dot {
  background: #fff !important;
}
.filter-count {
  font-size: 11px;
  opacity: 0.65;
}

/* ── GPS Button ── */
.ctrl-gps {
  position: absolute;
  bottom: 110px;
  right: 12px;
  z-index: 10;
}
.gps-btn {
  width: 30px;
  height: 30px;
  background: #fff;
  border: none;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  transition: background 0.2s;
}
.gps-btn:hover {
  background: #f0f0f0;
}
.gps-btn.active {
  background: #c8a860;
}

/* ── Range Slider (bottom sheet) ── */
.range-panel {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 10;
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(8px);
  border-radius: 10px;
  padding: 10px 16px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
  display: none;
  align-items: center;
  gap: 12px;
}
.range-panel.visible {
  display: flex;
}
.range-label {
  font-size: 12px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.range-panel input[type="range"] {
  width: 140px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: #ddd;
  border-radius: 2px;
  outline: none;
}
.range-panel input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: #fff;
  border: 2.5px solid #c8a860;
  border-radius: 50%;
  cursor: pointer;
}
.range-panel input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: #fff;
  border: 2.5px solid #c8a860;
  border-radius: 50%;
  cursor: pointer;
}
.range-value {
  font-size: 15px;
  font-weight: 700;
  color: #1a1a1a;
  min-width: 50px;
}
.range-value span {
  font-size: 12px;
  font-weight: 500;
  color: #888;
}
.range-close {
  width: 22px;
  height: 22px;
  border: none;
  background: #eee;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 22px;
  text-align: center;
  color: #888;
  padding: 0;
  flex-shrink: 0;
}
.range-close:hover {
  background: #ddd;
  color: #333;
}

/* ── Measure Panel ── */
.measure-panel {
  position: absolute;
  bottom: 60px;
  left: 12px;
  z-index: 10;
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(8px);
  border-radius: 10px;
  padding: 14px 18px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
  min-width: 190px;
  display: none;
}
.measure-panel.active {
  display: block;
}
.measure-panel h4 {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #999;
}
.measure-value {
  font-size: 22px;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0 0 4px;
}
.measure-value span {
  font-size: 13px;
  font-weight: 500;
  color: #666;
}
.measure-bearing {
  font-size: 13px;
  color: #666;
  margin: 0 0 10px;
}
.measure-clear {
  background: none;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 12px;
  color: #666;
  cursor: pointer;
  font-family: inherit;
}
.measure-clear:hover {
  border-color: #c8a860;
  color: #c8a860;
}

/* ── Markers ── */
.marker-icon {
  width: 28px;
  height: 28px;
  border: 2.5px solid #fff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  transition: transform 0.15s;
}
.marker-icon:hover {
  transform: scale(1.2);
}

/* ── Cluster Markers ── */
.cluster-marker {
  border-radius: 50%;
  border: 2.5px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: transform 0.15s;
  background: rgba(200, 168, 96, 0.88);
}
.cluster-marker:hover {
  transform: scale(1.1);
}

/* ── Popups ── */
.mapboxgl-popup-content {
  padding: 0;
  border-radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  box-shadow: 0 4px 20px rgba(0,0,0,0.18);
  overflow: hidden;
  min-width: 230px;
  max-width: 280px;
}
.mapboxgl-popup-close-button {
  font-size: 20px;
  color: #fff;
  right: 6px;
  top: 4px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  z-index: 2;
}
.popup-card-img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}
.popup-body {
  padding: 10px 14px 14px;
}
.popup-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}
.popup-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}
.popup-tag-region {
  background: #f0ede6;
  color: #555;
}
.popup-tag-access-paid {
  background: #fcebeb;
  color: #791f1f;
}
.popup-tag-access-members {
  background: #eeedfe;
  color: #3c3489;
}
.popup-card h3 {
  margin: 0 0 3px;
  font-size: 15px;
  font-weight: 700;
  color: #1a1a1a;
  line-height: 1.3;
}
.popup-coords {
  font-size: 12px;
  color: #999;
  margin: 0 0 6px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}
.popup-excerpt {
  font-size: 13px;
  color: #555;
  line-height: 1.4;
  margin: 0 0 10px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.popup-link {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  color: #c8a860;
  text-decoration: none;
}
.popup-link:hover {
  text-decoration: underline;
}

/* ── GPS Dot (rendered via JS as a source/layer, but pulsing ring is a marker) ── */
/* ── GPS Dot (SVG rendered in JS) ── */
.mapboxgl-marker {
  overflow: visible !important;
}

/* ── Ensure Mapbox controls stay clickable ── */
.mapboxgl-ctrl-top-right {
  z-index: 15 !important;
}

/* ── Modal ── */
.map-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
}
.map-modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}
.map-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
}
.map-modal-content {
  position: relative;
  width: 90%;
  max-width: 900px;
  height: 80vh;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,0.3);
}
.map-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1;
  width: 36px;
  height: 36px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 20px;
  line-height: 36px;
  text-align: center;
  cursor: pointer;
}
.map-modal-close:hover {
  background: rgba(0,0,0,0.8);
}
.map-modal-iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* ── Hide default draw controls ── */
.mapbox-gl-draw_ctrl-draw-btn {
  display: none !important;
}

/* ── Responsive ── */
@media (max-width: 767px) {
  .search-wrap { left: 8px; right: 50px; width: auto; }
  .ctrl-tools { top: 100px; right: 8px; }
  .search-wrap { left: 8px; width: calc(100% - 60px); max-width: none; }
  .search-inner { max-width: none; }
  .filter-bar { top: 58px; left: 8px; flex-wrap: nowrap; overflow-x: auto; max-width: calc(100% - 16px); -webkit-overflow-scrolling: touch; }
  .filter-bar::-webkit-scrollbar { display: none; }
  .filter-pill { flex-shrink: 0; }
  .ctrl-gps { bottom: 90px; right: 8px; }
  .range-panel { left: 8px; right: 8px; bottom: 8px; }
  .measure-panel { bottom: 55px; left: 8px; right: 8px; min-width: auto; }
  .map-modal-content { width: 100%; height: 100%; border-radius: 0; }
}