* { margin: 0; padding: 0; box-sizing: border-box; }

body, html { width: 100%; height: 100%; overflow: hidden; }

#map { width: 100%; height: 100%; }

/* Search box */
#search-box {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 10;
  width: calc(100% - 70px);
  max-width: 280px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

#search-input {
  width: 100%;
  padding: 9px 32px 9px 12px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  outline: none;
}

#search-input:focus {
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.search-clear {
  position: absolute;
  right: 6px;
  top: 6px;
  border: none;
  background: none;
  font-size: 18px;
  color: #999;
  cursor: pointer;
  padding: 0 4px;
  line-height: 24px;
  display: none;
}

#search-input:not(:placeholder-shown) ~ .search-clear {
  display: block;
}

#search-results {
  margin-top: 4px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  overflow: hidden;
  display: none;
  max-height: 50vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

#search-results.visible {
  display: block;
}

.search-result {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.1s;
}

.search-result:last-child {
  border-bottom: none;
}

.search-result:hover {
  background: #e3f2fd;
}

.search-result-name {
  font-size: 13px;
  font-weight: 500;
  color: #333;
}

.search-result-context {
  font-size: 11px;
  color: #888;
  margin-top: 1px;
}

.search-no-results {
  padding: 10px 12px;
  color: #999;
  font-size: 13px;
  font-style: italic;
}

/* Day type toggle — added as a MapLibre control */
#day-toggle.maplibregl-ctrl-group {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  position: relative;
  overflow: visible;
  z-index: 1;
}

.day-current {
  border: none;
  background: #fff;
  color: #333;
  width: 29px;
  height: 29px;
  font-size: 15px;
  line-height: 29px;
  text-align: center;
  border-radius: 4px;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.1);
  cursor: pointer;
  display: block;
  padding: 0;
}

.day-current:hover { background: #f0f0f0; }

.day-options {
  display: none;
  margin-top: 4px;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  overflow: hidden;
  min-width: 90px;
  position: absolute;
  right: 0;
}

.day-options.open {
  display: block;
  z-index: 10;
}

#day-toggle .day-options .day-btn {
  display: block;
  width: 100%;
  border: none;
  background: #fff;
  color: #333;
  padding: 8px 16px !important;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
  border-bottom: 1px solid #f0f0f0;
}

.day-btn:last-child { border-bottom: none; }

.day-btn:hover { background: #e3f2fd; }

.day-btn.active {
  color: #1976D2;
  font-weight: 600;
}

/* Layer toggle — similar to day toggle */
#layer-toggle.maplibregl-ctrl-group {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  position: relative;
  overflow: visible;
}

.layer-current {
  border: none;
  background: #fff;
  color: #333;
  width: 29px;
  height: 29px;
  font-size: 15px;
  line-height: 29px;
  text-align: center;
  border-radius: 4px;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.1);
  cursor: pointer;
  display: block;
  padding: 0;
}

.layer-current:hover { background: #f0f0f0; }

.layer-options {
  display: none;
  margin-top: 4px;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  overflow: hidden;
  min-width: 110px;
  position: absolute;
  right: 0;
  white-space: nowrap;
}

.layer-options.open {
  display: block;
}

#layer-toggle .layer-options .layer-btn {
  display: block;
  width: 100%;
  border: none;
  background: #fff;
  color: #333;
  padding: 8px 16px !important;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
  border-bottom: 1px solid #f0f0f0;
}

.layer-btn:last-child { border-bottom: none; }

.layer-btn:hover { background: #e3f2fd; }

.layer-btn.active {
  color: #1976D2;
  font-weight: 600;
}

/* Contact link */
#contact-link {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 11px;
  background: rgba(255,255,255,0.85);
  padding: 3px 10px;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

#contact-link a {
  color: #666;
  text-decoration: none;
}

#contact-link a:hover {
  color: #333;
  text-decoration: underline;
}

/* Live bus tracking indicator */
#live-indicator {
  position: absolute;
  top: 10px;
  right: 60px;
  z-index: 10;
  background: rgba(229, 57, 53, 0.92);
  color: #fff;
  padding: 5px 12px;
  border-radius: 14px;
  font-size: 12px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 8px rgba(229, 57, 53, 0.35);
  pointer-events: none;
  user-select: none;
}

.live-dot {
  width: 8px;
  height: 8px;
  background: #fff;
  border-radius: 50%;
  animation: live-pulse 1.5s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* Geometry source legend */
#geo-source-legend {
  position: absolute;
  bottom: 30px;
  left: 10px;
  z-index: 10;
  background: rgba(255,255,255,0.9);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 11px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: #555;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  display: flex;
  gap: 10px;
}

.legend-item { display: flex; align-items: center; gap: 4px; }

.legend-swatch {
  display: inline-block;
  width: 20px;
  height: 3px;
  border-radius: 1px;
  background: #555;
}

.legend-dashed {
  background: repeating-linear-gradient(90deg, #555 0px, #555 5px, transparent 5px, transparent 9px);
}

/* MapLibre popup overrides */
.maplibregl-popup-content {
  border-radius: 8px;
  padding: 12px 14px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
  max-width: min(320px, 85vw);
  max-height: 60vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: 0 3px 12px rgba(0,0,0,0.2);
}

.popup-stop-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 2px;
}

.popup-locality {
  color: #666;
  font-size: 12px;
  margin-bottom: 6px;
}

.popup-routes {
  margin-bottom: 6px;
}

.popup-routes .route-badge {
  display: inline-block;
  background: #1976D2;
  color: #fff;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  margin: 1px 2px;
  cursor: pointer;
}

.popup-routes .route-badge:hover {
  background: #1255a1;
}

.popup-routes .route-badge-active {
  background: #0D47A1;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #0D47A1;
}

.popup-campsite-links {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
  font-size: 12px;
}

.popup-campsite-links li {
  margin: 2px 0;
  word-break: break-all;
}

.popup-campsite-links a {
  color: #2a6020;
  text-decoration: underline;
}

.popup-time-picker {
  margin-top: 6px;
  font-size: 12px;
  color: #555;
}

.popup-time-picker .time-label {
  font-weight: 600;
  text-decoration: underline;
  text-decoration-style: dotted;
  cursor: pointer;
}

.popup-time-picker .time-input-hidden {
  display: none;
}

.popup-time-picker input[type="time"] {
  font-size: 12px;
  padding: 1px 4px;
  border: 1px solid #ccc;
  border-radius: 3px;
  margin-left: 2px;
}

.popup-departures {
  border-top: 1px solid #e0e0e0;
  padding-top: 6px;
  margin-top: 4px;
}

.popup-departures h4 {
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.dep-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
  font-size: 12px;
}

.dep-route { font-weight: 600; color: #1976D2; }
.dep-dest { color: #555; flex: 1; margin: 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dep-time { font-variant-numeric: tabular-nums; color: #333; }

.popup-loading {
  color: #999;
  font-style: italic;
  font-size: 12px;
}

/* Route info popup */
.popup-route-name {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 2px;
}

.popup-route-dest {
  color: #555;
  font-size: 12px;
  margin-bottom: 4px;
}

.popup-route-meta {
  font-size: 12px;
  color: #777;
}

/* Route chooser (multiple overlapping routes) */
.popup-route-chooser {
}

.popup-route-chooser .chooser-title {
  font-size: 12px;
  color: #888;
  margin-bottom: 6px;
  position: sticky;
  top: 0;
  background: #fff;
  padding-bottom: 4px;
}

.chooser-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 8px;
  margin: 2px -8px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.1s;
}

.chooser-row:hover {
  background: #e3f2fd;
}

.chooser-route {
  font-weight: 700;
  font-size: 14px;
  color: #1565C0;
  min-width: 36px;
}

.chooser-dest {
  flex: 1;
  font-size: 13px;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chooser-op {
  font-size: 11px;
  color: #999;
  white-space: nowrap;
}
