/* ---------------------------------------------------------------------------
   Ambleway -- main stylesheet
   --------------------------------------------------------------------------- */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #222;
  background: #EDE7DA;
  height: 100vh;
  overflow: hidden;
}

/* ---------------------------------------------------------------------------
   Top bar
   --------------------------------------------------------------------------- */

.top-bar {
  display: grid;
  grid-template-columns: 1fr minmax(0, 480px) 1fr;
  align-items: center;
  gap: 16px;
  height: 56px;
  padding: 0 16px;
  background: #37453B;
  box-shadow: inset 0 -2px 0 rgba(168,120,95,.75);
  z-index: 1001;
  position: relative;
}

.site-name {
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 700;
  font-size: 19px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #f3ecdd;
  text-decoration: none;
  flex-shrink: 0;
}

/* ---------------------------------------------------------------------------
   Search box -- lives in the persistent top bar
   --------------------------------------------------------------------------- */

.search-box {
  position: relative;
  grid-column: 2;
  width: 100%;
}

.search-box-inner {
  display: flex;
  align-items: center;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
  padding: 0 14px;
  height: 40px;
}

.search-box-inner svg.search-icon { flex-shrink: 0; color: #999; }

.search-box-inner input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 16px;
  padding: 0 10px;
  background: transparent;
  font-family: inherit;
}

.search-clear {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: #999;
  line-height: 0;
}
.search-clear.visible { display: block; }

.location-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: #999;
  line-height: 0;
  flex-shrink: 0;
}
.location-btn:hover { color: #4C6152; }
.location-btn.locating { color: #4C6152; animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Search results dropdown */
.search-results {
  position: absolute;
  top: 48px;
  left: 0;
  right: 0;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  max-height: 300px;
  overflow-y: auto;
  display: none;
  z-index: 1003;
}
.search-results.visible { display: block; }
/* Never show the dropdown as an empty rectangle (no autocomplete matches yet). */
.search-results:empty { display: none; }

.search-group {
  padding: 8px 16px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #a0968a;
}
.search-result {
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.4;
  border-bottom: 1px solid #f0f0f0;
}
.search-result:last-child { border-bottom: none; }
.search-result:hover, .search-result.active { background: #eef1ec; }
.search-result-name { font-weight: 600; color: #222; }
.search-result-context { color: #888; font-size: 12px; }

/* ---------------------------------------------------------------------------
   Explore (home landing) -- photo grid over the map until a search happens
   --------------------------------------------------------------------------- */

.explore {
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  bottom: 0;
  background: #EDE7DA;
  overflow-y: auto;
  z-index: 900;
}
.search-active .explore { display: none; }
.explore-inner { max-width: none; margin: 0; padding: 26px 24px 96px; }
.explore-title {
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 30px; font-weight: 700; margin: 0 0 6px; color: #2f3a30;
}
.explore-sub { color: #6b6656; margin: 0 0 22px; max-width: 660px; font-size: 15px; line-height: 1.5; }
.explore-grid { columns: 250px; column-gap: 16px; }
.explore-status { color: #8a8474; font-size: 14px; }
.explore-tile {
  display: block; break-inside: avoid; margin: 0 0 16px;
  position: relative; border-radius: 14px; overflow: hidden; text-decoration: none;
  background: linear-gradient(135deg, #c9d1c2, #e4dac4);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  transition: transform .18s cubic-bezier(.2,.7,.3,1), box-shadow .18s ease;
  will-change: transform;
}
.explore-tile:hover {
  transform: translateY(-5px) scale(1.015);
  box-shadow: 0 12px 26px rgba(35,45,35,.24);
  z-index: 1;
}
.explore-tile img { width: 100%; display: block; opacity: 0; transition: opacity .5s ease; }
.explore-tile img.is-loaded { opacity: 1; }
.explore-tile-cap {
  position: absolute; left: 0; right: 0; bottom: 0; color: #fff;
  padding: 28px 12px 10px;
  background: linear-gradient(to top, rgba(0,0,0,.72), transparent);
}
.explore-tile-name { font-weight: 600; font-size: 15px; line-height: 1.25; }
.explore-tile-meta { font-size: 12px; opacity: .9; margin-top: 2px; }
#explore-sentinel { height: 1px; }

/* ---------------------------------------------------------------------------
   Main layout (map + results) -- shown once a search is active
   --------------------------------------------------------------------------- */

.main-layout {
  display: flex;
  height: calc(100vh - 56px);
  position: relative;
}
/* On the home landing the explore grid covers the map; hide the map (and its
   controls) so nothing bleeds through, but keep it laid out so it's ready on search. */
body:not(.search-active) .main-layout { visibility: hidden; }

/* Map fills the space */
#map {
  flex: 1;
  height: 100%;
}

/* ---------------------------------------------------------------------------
   Results panel
   --------------------------------------------------------------------------- */

.results-panel {
  width: 0;
  overflow: hidden;
  background: #EDE7DA;
  border-right: 1px solid #e0e0e0;
  transition: width 0.3s ease;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.search-active .results-panel {
  width: 360px;
  overflow: hidden;
}

.results-panel-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  padding: 16px;
  min-width: 360px;
}

/* Filter controls */
.filter-section {
  flex-shrink: 0;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e0e0e0;
}

.filter-row {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}

.filter-row label {
  font-size: 13px;
  font-weight: 600;
  color: #555;
  width: 72px;
  flex-shrink: 0;
}

.filter-row .filter-value {
  font-size: 13px;
  color: #222;
  min-width: 48px;
  text-align: right;
  flex-shrink: 0;
}

.filter-row input[type="range"] {
  flex: 1;
  margin: 0 10px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: #ddd;
  border-radius: 2px;
  outline: none;
}

.filter-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  background: #fff;
  border: 2px solid #4C6152;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.filter-row select {
  font-size: 13px;
  padding: 4px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  font-family: inherit;
}

/* Small selects for length range */
.filter-select-sm {
  font-size: 13px;
  padding: 4px 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  font-family: inherit;
}

.filter-sep {
  font-size: 12px;
  color: #888;
  margin: 0 4px;
}

/* Segmented control */
.seg-ctrl {
  display: flex;
  border: 1px solid #ccc;
  border-radius: 4px;
  overflow: hidden;
}

.seg-btn {
  font-size: 12px;
  font-family: inherit;
  padding: 4px 10px;
  border: none;
  background: #fff;
  color: #555;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.seg-btn + .seg-btn {
  border-left: 1px solid #ccc;
}

.seg-btn.active {
  background: #4C6152;
  color: #fff;
}

/* Result count */
.result-count {
  flex-shrink: 0;
  font-size: 13px;
  color: #888;
  margin-bottom: 12px;
}

#results-list {
  flex: 1;
  overflow-y: auto;
  /* Clear the fixed disclaimer bar so the last cards aren't hidden behind it. */
  padding-bottom: 64px;
}

/* Hike cards */
a.hike-card {
  display: flex;
  gap: 12px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform 0.16s cubic-bezier(.2,.7,.3,1), border-color 0.15s, box-shadow 0.15s;
  margin-bottom: 8px;
}
a.hike-card:hover {
  border-color: #4C6152;
  transform: translateY(-3px);
  box-shadow: 0 10px 22px rgba(35,45,35,.16);
}

.hike-card-photo {
  flex-shrink: 0;
  width: 96px;
  align-self: stretch;
  min-height: 76px;
  background: #eef1ee;
}
/* No photo yet: a soft sage-to-sand wash so the card reads as intentional, not broken. */
.hike-card-photo-empty { background: linear-gradient(135deg, #c9d1c2, #e4dac4); }
.hike-card-photo img {
  width: 96px;
  height: 100%;
  min-height: 76px;
  object-fit: cover;
  display: block;
}
.hike-card-body {
  flex: 1;
  min-width: 0;
  padding: 10px 12px 10px 0;
}

.hike-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 3px;
}
.hike-detail {
  font-size: 12px;
  color: #666;
}
.no-results {
  padding: 24px 0;
  text-align: center;
  color: #888;
  font-size: 14px;
}

/* Infinite-scroll trigger: an invisible element at the end of the list. */
.results-sentinel {
  height: 1px;
}

/* ---------------------------------------------------------------------------
   Search-this-area button (floats over the map)
   --------------------------------------------------------------------------- */

.search-area-btn {
  display: none;
  position: absolute;
  top: 12px;
  /* Center over the map area, which sits to the right of the 360px sidebar */
  left: calc(360px + (100% - 360px) / 2);
  transform: translateX(-50%);
  z-index: 800;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 20px;
  padding: 8px 18px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  color: #4C6152;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  transition: background 0.15s, border-color 0.15s;
}
.search-area-btn:hover {
  background: #f0f4ff;
  border-color: #4C6152;
}
.search-area-btn.visible { display: block; }

/* ---------------------------------------------------------------------------
   Loading overlay
   --------------------------------------------------------------------------- */

#loading {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  padding: 24px 36px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  z-index: 10000;
  font-size: 15px;
  text-align: center;
}

#loading .spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 3px solid #ddd;
  border-top-color: #333;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin-right: 10px;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------------------
   Tile filter (seasonal hue rotation + radar dimming)
   --------------------------------------------------------------------------- */

.leaflet-tile-pane { transition: filter 0.4s ease; }

/* ---------------------------------------------------------------------------
   Road conditions -- legend
   --------------------------------------------------------------------------- */

.legend {
  background: #fff;
  padding: 10px 14px;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
  font-size: 13px;
  line-height: 2;
}

.legend h4 {
  margin-bottom: 2px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.legend h4 .toggle { font-size: 10px; color: #999; margin-left: 8px; }
.legend-body { overflow: hidden; transition: max-height 0.25s ease; }
.legend.collapsed .legend-body { max-height: 0; }
.legend.collapsed .legend-footer { display: none; }
.legend-row { display: flex; align-items: center; gap: 8px; }

.legend-icon {
  width: 24px; height: 24px; flex-shrink: 0;
  border-radius: 50%; border: 2px solid;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
}
.legend-icon svg { display: block; width: 13px; height: 13px; }

.legend-footer {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #ddd;
  font-size: 11px;
  color: #888;
}
.legend-footer a { color: #4a7fb5; text-decoration: none; }
.legend-footer a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------------------
   Road conditions -- popups + pins
   --------------------------------------------------------------------------- */

.condition-popup { max-width: 340px; font-size: 13px; line-height: 1.5; }
.condition-popup .route { font-weight: 700; font-size: 15px; }
.condition-popup .badge {
  display: inline-block; padding: 1px 7px; border-radius: 3px;
  color: #fff; font-size: 11px; font-weight: 600; margin-left: 6px;
  vertical-align: middle;
}
.condition-popup .desc { margin-top: 6px; color: #333; }
.condition-popup .meta { margin-top: 4px; color: #888; font-size: 11px; }
.condition-popup .source { margin-top: 4px; font-size: 11px; }
.condition-popup .source a { color: #4a7fb5; text-decoration: none; }
.condition-popup .source a:hover { text-decoration: underline; }

.seg-pin {
  display: flex; flex-direction: column; align-items: center;
  cursor: pointer;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,.4));
}
.seg-pin .icon {
  width: 34px; height: 34px;
  background: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2.5px solid;
}
.seg-pin .icon svg { display: block; width: 18px; height: 18px; }
.seg-pin .rte { margin-top: 0; }

/* ---------------------------------------------------------------------------
   Weather overlay controls
   --------------------------------------------------------------------------- */

.leaflet-control .weather-toggle {
  width: 30px; height: 30px;
  background: #fff;
  border: none;
  border-radius: 2px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  color: #333;
  line-height: 1;
}
.leaflet-control .weather-toggle:hover { background: #f4f4f4; }
.leaflet-control .weather-toggle.active { background: #4C6152; color: #fff; }

.radar-controls {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
  padding: 8px 14px;
  display: none;
  align-items: center;
  gap: 10px;
  max-width: 380px;
  width: calc(100vw - 48px);
  font-size: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.radar-controls.visible { display: flex; }

.radar-controls button {
  width: 28px; height: 28px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.radar-controls input[type="range"] {
  flex: 1;
  min-width: 0;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: #ddd;
  border-radius: 2px;
  outline: none;
}

.radar-controls input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  background: #fff;
  border: 2px solid #666;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.radar-controls .radar-timestamp {
  flex-shrink: 0;
  color: #555;
  min-width: 80px;
  text-align: right;
}

/* ---------------------------------------------------------------------------
   Disclaimer bar
   --------------------------------------------------------------------------- */

.disclaimer-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.92);
  border-top: 1px solid #e0e0e0;
  padding: 6px 16px;
  font-size: 10px;
  line-height: 1.4;
  color: #999;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.disclaimer-bar.hidden { display: none; }

.disclaimer-dismiss {
  flex-shrink: 0;
  background: none;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  padding: 3px 4px;
  color: #999;
  line-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.disclaimer-dismiss:hover { color: #666; border-color: #999; }

/* ---------------------------------------------------------------------------
   Mobile layout
   --------------------------------------------------------------------------- */

@media (max-width: 767px) {
  .search-active .top-bar { height: 48px; }

  /* On a phone, drop the centering column and let the search fill the row; it must
     never float over the content below (the old top:80px did exactly that). */
  .top-bar { grid-template-columns: auto 1fr; }
  .search-box { max-width: none; }
  .search-box-inner { height: 44px; }
  .site-name { font-size: 18px; }

  .search-active .main-layout {
    flex-direction: column;
    height: calc(100vh - 48px);
  }

  .search-active .results-panel {
    width: 100%;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid #e0e0e0;
    overflow: hidden;
  }

  .results-panel-inner {
    min-width: 0;
  }

  #map { min-height: 200px; }

  .search-area-btn {
    left: 50%;
  }

  .radar-controls { width: calc(100vw - 32px); }
}
