/* =========================================================
   Maps shared styles — covers /maps/ethanol and /maps/canyons.
   Both pages use the same .map-card aesthetic, brand blue
   (#0563bb), and Open Sans / Raleway typography.

   Sections:
     1. Section + section-title
     2. Card wrapper + controls
     3. Filter row + selects + toggles
     4. Status / loading
     5. Map pane + meta footer
     6. Side panel (list view + detail view)
     7. Station / route cards (light theme)
     8. Pills + tags
     9. Mapbox popup overrides
    10. Markers (ethanol pin + canyon endpoints)
    11. Attribution
    12. Responsive
   ========================================================= */

/* ── 1. Section + section-title ────────────────────────────── */
.ethanol-map {
  padding: 60px 0;
}

.ethanol-map .section-title .map-subtitle {
  max-width: 720px;
  margin: 12px auto 0;
  color: #6c757d;
  font-size: 14.5px;
  line-height: 1.6;
}

.ethanol-map .section-title .map-subtitle a {
  color: #0563bb;
  font-weight: 600;
  text-decoration: none;
  margin-left: 6px;
  white-space: nowrap;
}

.ethanol-map .section-title .map-subtitle a:hover {
  text-decoration: underline;
}

/* ── 2. Card wrapper + controls ────────────────────────────── */
.map-card {
  background: #fff;
  box-shadow: 0px 5px 90px 0px rgba(110, 123, 131, 0.1);
  padding: 30px 30px 36px;
  border-radius: 8px;
  max-width: 1200px;
  margin: 0 auto;
}

.map-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 22px;
}

/* Search bar (ethanol-only) */
.map-search {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.map-search-wrap {
  position: relative;
  flex: 1 1 280px;
  display: flex;
  align-items: center;
  border: 1px solid #ced4da;
  border-radius: 6px;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.map-search-wrap:focus-within {
  border-color: #0563bb;
  box-shadow: 0 0 0 3px rgba(5, 99, 187, 0.12);
}

.map-search-wrap i.bx {
  font-size: 18px;
  color: #6c757d;
  padding: 0 12px;
}

.map-search-wrap input {
  flex: 1;
  border: none;
  outline: none;
  padding: 11px 12px 11px 0;
  font-size: 15px;
  font-family: "Open Sans", sans-serif;
  color: #45505b;
  background: transparent;
}

.map-search-wrap input::placeholder {
  color: #adb5bd;
  font-size: 14px;
}

.map-search .search-button {
  margin: 0;
  padding: 10px 28px;
  font-size: 14px;
  font-family: "Open Sans", sans-serif;
}

.locate-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #e8f0fb;
  color: #0563bb;
  border: 1px solid #c8dcf2;
  border-radius: 50px;
  padding: 9px 18px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: "Open Sans", sans-serif;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  white-space: nowrap;
}

.locate-button:hover {
  background: #0563bb;
  color: #fff;
  border-color: #0563bb;
}

.locate-button i.bx { font-size: 16px; }

.locate-button:disabled {
  opacity: 0.75;
  cursor: progress;
}

.locate-button .locate-spinner { display: none; }
.locate-button.is-locating .locate-icon { display: none; }
.locate-button.is-locating .locate-spinner {
  display: inline-block;
  animation: mapSpin 0.8s linear infinite;
}

.locate-button .locate-label-short { display: none; }

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

/* ── 3. Filter row + selects + toggles ─────────────────────── */
.map-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  align-items: center;
  padding: 14px 16px;
  background: #f8fafd;
  border: 1px solid #e4eaf1;
  border-radius: 8px;
}

.map-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0; /* allow children with flex:1 to shrink instead of overflow */
}

.map-filter label {
  font-size: 13px;
  font-weight: 600;
  color: #45505b;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.map-filter select {
  padding: 7px 30px 7px 12px;
  border: 1px solid #ced4da;
  border-radius: 6px;
  font-size: 13.5px;
  font-family: "Open Sans", sans-serif;
  color: #45505b;
  background: #fff
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%236c757d' d='M0 0l5 6 5-6z'/></svg>")
    no-repeat right 10px center;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  transition: border-color 0.2s;
  /* Reset the ugly browser default min-width that selects inherit
     from their option contents — without this they refuse to shrink
     into narrow flex containers and overflow the viewport on phones. */
  min-width: 0;
  max-width: 100%;
}

.map-filter select:focus {
  border-color: #0563bb;
  outline: none;
  box-shadow: 0 0 0 3px rgba(5, 99, 187, 0.12);
}

.map-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: #45505b;
  cursor: pointer;
  margin: 0;
  user-select: none;
}

.map-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #0563bb;
  cursor: pointer;
}

/* ── 4. Status / loading ───────────────────────────────────── */
.map-status {
  display: block;
  padding: 12px 16px;
  border-radius: 8px;
  border-left: 4px solid transparent;
  font-size: 14px;
  font-weight: 600;
  font-family: "Open Sans", sans-serif;
  margin-bottom: 18px;
  line-height: 1.5;
}

.map-status[hidden] { display: none; }

.map-status.error {
  color: #b3261e;
  background: #fdecea;
  border-left-color: #d93025;
}

.map-status.info {
  color: #173b6c;
  background: #eaf3fc;
  border-left-color: #0563bb;
}

.map-status.success {
  color: #0b7a3d;
  background: #e6f7ed;
  border-left-color: #16a34a;
}

/* ── 5. Map pane + meta footer ─────────────────────────────── */
.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 22px;
}

.map-pane {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #e4eaf1;
  background: #f8fafd;
  display: flex;
  flex-direction: column;
}

.map-canvas {
  width: 100%;
  height: 540px;
  background: #eef2f6;
}

.map-loading {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(2px);
  font-size: 14px;
  color: #173b6c;
  font-weight: 600;
  z-index: 500;
}

.map-loading.is-active { display: flex; }

.map-loading .spinner {
  width: 22px;
  height: 22px;
  border: 3px solid #c8dcf2;
  border-top-color: #0563bb;
  border-radius: 50%;
  animation: mapSpin 0.8s linear infinite;
}

.map-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #fff;
  border-top: 1px solid #e4eaf1;
  font-size: 12.5px;
  color: #6c757d;
  font-family: "Open Sans", sans-serif;
}

.result-count {
  color: #45505b;
  font-weight: 700;
}

.result-updated {
  font-style: italic;
}

.result-fit-btn {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #e8f0fb;
  color: #0563bb;
  border: 1px solid #c8dcf2;
  font-family: "Open Sans", sans-serif;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 6px 12px;
  border-radius: 50px;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
}

.result-fit-btn:hover {
  background: #0563bb;
  color: #fff;
  border-color: #0563bb;
}

.result-fit-btn i { font-size: 14px; }

/* ── 6. Side panel (list view + detail view) ───────────────── */
.map-list-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.map-list-view {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.map-list-view[hidden] { display: none; }

.map-list-title {
  font-size: 15px;
  font-weight: 700;
  color: #45505b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 12px;
  font-family: "Raleway", sans-serif;
}

.map-back-btn {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #e8f0fb;
  color: #0563bb;
  border: 1px solid #c8dcf2;
  font-family: "Open Sans", sans-serif;
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 6px 12px 6px 8px;
  border-radius: 50px;
  cursor: pointer;
  align-self: flex-start;
  margin-bottom: 12px;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
}

.map-back-btn:hover {
  background: #0563bb;
  color: #fff;
  border-color: #0563bb;
}

.map-back-btn i { font-size: 16px; }

/* Scrollable list — used for both station list and route list */
.station-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 540px;
  overflow-y: auto;
  padding-right: 4px;
}

.station-list::-webkit-scrollbar { width: 6px; }
.station-list::-webkit-scrollbar-track {
  background: #f1f4f8;
  border-radius: 3px;
}
.station-list::-webkit-scrollbar-thumb {
  background: #cdd7e4;
  border-radius: 3px;
}
.station-list::-webkit-scrollbar-thumb:hover {
  background: #0563bb;
}

/* ── 7. Station + route cards ──────────────────────────────── */
.station-card {
  background: #fff;
  border: 1px solid #e4eaf1;
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s;
  font-family: "Open Sans", sans-serif;
}

.station-card:hover,
.station-card.is-active {
  border-color: #0563bb;
  box-shadow: 0 4px 14px rgba(5, 99, 187, 0.12);
  transform: translateY(-1px);
}

.station-card .station-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}

.station-card .station-name {
  font-size: 14.5px;
  font-weight: 700;
  color: #45505b;
  line-height: 1.3;
}

.station-card .station-distance {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  color: #0563bb;
  background: #e8f0fb;
  padding: 3px 10px;
  border-radius: 50px;
  white-space: nowrap;
}

.station-card .station-address {
  font-size: 12.5px;
  color: #6c757d;
  line-height: 1.45;
  margin-bottom: 8px;
}

.station-card .station-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Route card (canyons page) — same look-and-feel as .station-card */
.route-card {
  background: #fff;
  border: 1px solid #e4eaf1;
  border-left: 4px solid #e4eaf1;
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s;
  font-family: "Open Sans", sans-serif;
}

.route-card:hover,
.route-card.is-active {
  border-color: #0563bb;
  box-shadow: 0 4px 14px rgba(5, 99, 187, 0.12);
  transform: translateY(-1px);
}

.route-card.diff-beginner     { border-left-color: #16a34a; }
.route-card.diff-intermediate { border-left-color: #eab308; }
.route-card.diff-expert       { border-left-color: #dc2626; }

.route-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}

.route-card-name {
  font-size: 14.5px;
  font-weight: 700;
  color: #45505b;
  line-height: 1.3;
}

.route-card-len {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  color: #0563bb;
  background: #e8f0fb;
  padding: 3px 10px;
  border-radius: 50px;
  white-space: nowrap;
}

.route-card-region {
  font-size: 12.5px;
  color: #6c757d;
  line-height: 1.45;
  margin-bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.route-card-region i { font-size: 13px; }

.route-card-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ── 8. Pills + tags (shared across both maps) ─────────────── */
.station-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  color: #0b7a3d;
  background: #e6f7ed;
  padding: 2px 8px;
  border-radius: 50px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.station-tag.tag-private {
  color: #92400e;
  background: #fef3c7;
}

.station-tag.tag-fuel {
  color: #173b6c;
  background: #eaf3fc;
}

.station-tag.tag-custom {
  color: #92400e;
  background: #fff4e0;
}

.station-tag.tag-price {
  color: #0b7a3d;
  background: #e6f7ed;
}

.diff-pill {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 2px 8px;
  border-radius: 50px;
}

.diff-pill.diff-beginner     { color: #166534; background: #dcfce7; }
.diff-pill.diff-intermediate { color: #854d0e; background: #fef3c7; }
.diff-pill.diff-expert       { color: #991b1b; background: #fee2e2; }

.tag-pill {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  color: #173b6c;
  background: #eaf3fc;
  padding: 2px 8px;
  border-radius: 50px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* ── 9. Detail view (canyons) ──────────────────────────────── */
.route-detail {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  font-family: "Open Sans", sans-serif;
  color: #45505b;
  max-height: 540px;
}

.route-detail::-webkit-scrollbar { width: 6px; }
.route-detail::-webkit-scrollbar-track { background: #f1f4f8; border-radius: 3px; }
.route-detail::-webkit-scrollbar-thumb { background: #cdd7e4; border-radius: 3px; }
.route-detail::-webkit-scrollbar-thumb:hover { background: #0563bb; }

.detail-name {
  font-family: "Raleway", sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: #173b6c;
  margin: 0 0 4px;
  line-height: 1.25;
}

.detail-region {
  font-size: 12.5px;
  color: #6c757d;
  margin-bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.detail-region i { font-size: 14px; }

.detail-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.detail-photo {
  display: block;
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 8px;
  margin: 4px 0 12px;
  background: #eef2f6;
}

.detail-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.stat-block {
  background: #f8fafd;
  border: 1px solid #e4eaf1;
  border-radius: 8px;
  padding: 9px 12px;
}

.stat-label {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6c757d;
  margin-bottom: 3px;
}

.stat-value {
  font-family: "Raleway", sans-serif;
  font-size: 14.5px;
  font-weight: 700;
  color: #173b6c;
  line-height: 1.25;
}

.stat-value-sm {
  font-family: "Open Sans", sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #45505b;
  line-height: 1.4;
}

.detail-section-title {
  font-family: "Raleway", sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6c757d;
  margin: 0 0 6px;
}

.detail-notes {
  font-size: 13px;
  color: #3a4654;
  line-height: 1.55;
  margin: 0 0 14px;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.detail-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #0563bb;
  color: #fff;
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 50px;
  letter-spacing: 0.3px;
  transition: background 0.18s, transform 0.18s;
}

.detail-action:hover {
  background: #0466c8;
  color: #fff;
  text-decoration: none;
  transform: translateY(-1px);
}

.detail-action i { font-size: 16px; }

/* Empty / skeleton states */
.station-empty {
  padding: 22px 16px;
  text-align: center;
  color: #6c757d;
  font-size: 13.5px;
  font-family: "Open Sans", sans-serif;
  background: #f8fafd;
  border: 1px dashed #cdd7e4;
  border-radius: 10px;
  list-style: none;
  line-height: 1.55;
}

.station-skeleton {
  background: #fff;
  border: 1px solid #e4eaf1;
  border-radius: 10px;
  padding: 14px 16px;
  list-style: none;
}

.station-skeleton .sk-line {
  height: 12px;
  background: linear-gradient(90deg, #eef2f6 25%, #f8fafd 50%, #eef2f6 75%);
  background-size: 200% 100%;
  animation: skShimmer 1.4s infinite;
  border-radius: 6px;
  margin-bottom: 8px;
}

.station-skeleton .sk-line.short { width: 50%; }
.station-skeleton .sk-line.med   { width: 80%; }

@keyframes skShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.route-empty {
  padding: 22px 16px;
  text-align: center;
  color: #6c757d;
  font-size: 13.5px;
  font-family: "Open Sans", sans-serif;
  background: #f8fafd;
  border: 1px dashed #cdd7e4;
  border-radius: 10px;
  list-style: none;
  line-height: 1.55;
}

/* ── 10. Mapbox popup overrides ────────────────────────────── */
.mapboxgl-map {
  font-family: "Open Sans", sans-serif !important;
}

.mapboxgl-popup-content {
  border-radius: 10px !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12) !important;
  padding: 14px 16px !important;
  font-size: 13px !important;
  color: #45505b !important;
  line-height: 1.5 !important;
  min-width: 220px;
}

.mapboxgl-popup-close-button {
  font-size: 18px !important;
  color: #6c757d !important;
  padding: 4px 8px !important;
}

.mapboxgl-popup-close-button:hover {
  color: #0563bb !important;
  background: transparent !important;
}

.mapboxgl-popup-content .pop-name {
  font-size: 14.5px;
  font-weight: 700;
  color: #173b6c;
  margin-bottom: 4px;
  font-family: "Raleway", sans-serif;
  padding-right: 16px;
}

.mapboxgl-popup-content .pop-addr,
.mapboxgl-popup-content .pop-meta {
  color: #6c757d;
  margin-bottom: 8px;
}

.mapboxgl-popup-content .pop-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mapboxgl-popup-content .pop-link {
  display: inline-block;
  margin-top: 4px;
  color: #0563bb;
  font-weight: 600;
  font-size: 12.5px;
  text-decoration: none;
}

.mapboxgl-popup-content .pop-link:hover {
  text-decoration: underline;
}

/* Popup photo (admin uploads) */
.mapboxgl-popup-content .pop-photo {
  display: block;
  width: 100%;
  max-height: 140px;
  object-fit: cover;
  border-radius: 8px;
  margin: 4px 0 10px;
  background: #eef2f6;
}

/* ── 11. Markers ───────────────────────────────────────────── */
/* Ethanol station pins — SVG teardrop so the tip is the literal
   bottom edge of the element. anchor:"bottom" is exact, no drift. */
.eth-marker-pin {
  display: block;
  width: 28px;
  height: 38px;
  color: #0563bb;         /* drives fill="currentColor" in the SVG */
  cursor: pointer;
  filter: drop-shadow(0 3px 5px rgba(0,0,0,0.30));
  transition: filter 0.15s, transform 0.15s;
}
.eth-marker-pin:hover {
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.40));
  transform: scale(1.1) translateY(-2px);
}
.eth-marker-pin svg { display: block; }

/* Custom (admin-added) stations use amber */
.eth-marker-pin.custom { color: #f59e0b; }

/* "You are here" dot — circle with no transform, anchor:"center" is exact */
.eth-marker-you {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #16a34a;
  border: 3px solid #fff;
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.25), 0 3px 8px rgba(0,0,0,0.25);
  cursor: default;
}

/* Canyon endpoint markers (start = green, end = grey-bordered white) */
.canyon-endpoint {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #ced4da;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  transition: transform 0.15s;
}
.canyon-endpoint.start {
  background: #16a34a;
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.18), 0 2px 6px rgba(0, 0, 0, 0.18);
}
.canyon-endpoint.end {
  background: #fff;
  border-color: #6c757d;
}
.canyon-endpoint:hover { transform: scale(1.15); }

/* ── 12. Mapbox branding ───────────────────────────────────── */
/* Hide the Mapbox wordmark — attribution is preserved via the
   compact ⓘ control, which satisfies the ToS requirement. */
.mapboxgl-ctrl-logo {
  display: none !important;
}

/* ── 13. Attribution ───────────────────────────────────────── */
.map-attribution {
  text-align: center;
  font-size: 12px;
  color: #6c757d;
  margin: 18px auto 0;
  max-width: 720px;
  line-height: 1.5;
}

.map-attribution a {
  color: #0563bb;
  text-decoration: none;
}

.map-attribution a:hover { text-decoration: underline; }

/* ── 14. Responsive ────────────────────────────────────────── */

/* Tablet and below — single-column layout */
@media (max-width: 991.98px) {
  .ethanol-map { padding: 50px 0; }
  .map-card { padding: 26px 22px 30px; }
  .map-layout {
    grid-template-columns: 1fr;
    gap: 18px;
  }
  .map-canvas { height: 420px; }
  .station-list,
  .route-detail { max-height: 360px; }
}

/* Stack the filter row vertically as soon as it can't fit on one line.
   At ≤767px we stop trying to lay out filters horizontally — each filter
   becomes its own row with the label flush left and the control filling
   the rest, so dropdowns can never overflow the card on phones / small
   tablets. */
@media (max-width: 767.98px) {
  .map-filter-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .map-filter {
    width: 100%;
    justify-content: space-between;
    gap: 12px;
  }

  .map-filter select {
    flex: 1 1 0;
    min-width: 0;
    min-height: 38px;
  }

  .map-toggle {
    padding: 4px 0;
  }
}

/* Tablet between 576 and 767 — keep the search row on its own line */
@media (max-width: 767.98px) and (min-width: 576px) {
  .map-search-wrap { flex: 1 1 100%; }
  .map-search .search-button,
  .locate-button {
    flex: 1 1 auto;
    justify-content: center;
  }
}

/* Phone */
@media (max-width: 575.98px) {
  .ethanol-map { padding: 36px 0; }

  .ethanol-map .section-title h2 { font-size: 26px; }
  .ethanol-map .section-title .map-subtitle {
    font-size: 13.5px;
    padding: 0 6px;
  }

  .map-card {
    padding: 18px 14px 22px;
    border-radius: 6px;
    box-shadow: 0 4px 30px rgba(110, 123, 131, 0.08);
  }

  .map-controls {
    gap: 10px;
    margin-bottom: 14px;
  }

  /* Stack ethanol search controls vertically */
  .map-search {
    flex-direction: column;
    gap: 8px;
  }
  .map-search-wrap { flex: 1 1 100%; }
  .map-search-wrap input {
    /* 16px prevents iOS Safari from auto-zooming on focus */
    font-size: 16px;
    padding: 12px 12px 12px 0;
  }
  .map-search-wrap input::placeholder { font-size: 14px; }

  .map-search .search-button,
  .locate-button {
    width: 100%;
    justify-content: center;
    padding: 12px 16px;
    font-size: 14px;
    min-height: 44px;
  }

  .locate-button { border-radius: 8px; }
  .locate-button .locate-label-full { display: none; }
  .locate-button .locate-label-short { display: inline; }

  /* Smaller selects + tighter gaps on phones */
  .map-filter-row {
    padding: 12px;
    gap: 10px;
  }
  .map-filter select {
    min-height: 40px;
    font-size: 14px;
    padding: 8px 30px 8px 12px;
  }
  .map-toggle {
    padding: 6px 0;
    font-size: 13.5px;
  }

  /* Map + list compact heights */
  .map-canvas { height: 320px; }
  .map-list-pane { padding: 14px 0 0; }
  .map-list-title { font-size: 14px; }
  .station-list,
  .route-detail { max-height: 320px; }
  .station-card,
  .route-card { padding: 12px 14px; }
  .station-card .station-name,
  .route-card-name { font-size: 14px; }

  /* Detail view: single-column stats */
  .detail-stats { grid-template-columns: 1fr; }
  .detail-name { font-size: 17px; }

  /* Meta footer stacks cleanly */
  .map-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    font-size: 12px;
  }
  .result-updated { font-style: normal; color: #6c757d; }
  .result-fit-btn { align-self: stretch; justify-content: center; }

  /* Status bar */
  .map-status {
    padding: 10px 12px;
    font-size: 13px;
  }

  /* Keep Mapbox popup inside the viewport */
  .mapboxgl-popup-content {
    padding: 10px 12px !important;
    font-size: 12.5px !important;
    min-width: 0 !important;
    max-width: 240px !important;
  }
  .mapboxgl-popup-content .pop-name { font-size: 14px; }

  .map-attribution {
    font-size: 12px;
    padding: 0 4px;
  }
}

/* Very narrow phones (≤360px) */
@media (max-width: 360px) {
  .map-card { padding: 16px 12px 20px; }
  .ethanol-map .section-title h2 { font-size: 22px; }
  .map-canvas { height: 280px; }
  .station-list,
  .route-detail { max-height: 280px; }
}

/* =========================================================
   Canyon Run Recorder
   ========================================================= */

/* ── Record bar (above the map) ─────────────────────────── */
.record-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #f8fafd 0%, #eef4fb 100%);
  border: 1px solid #d6e3f3;
  border-radius: 10px;
  margin-bottom: 18px;
}

.record-btn {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 22px;
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  color: #fff;
  border: none;
  border-radius: 50px;
  font-family: "Open Sans", sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.4px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.25);
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}
.record-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(220, 38, 38, 0.35);
}
.record-btn:disabled {
  opacity: 0.85;
  cursor: progress;
}
.record-btn .record-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  display: inline-block;
  box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7);
}
.record-btn.is-recording .record-dot {
  animation: recPulse 1.4s ease-out infinite;
}
@keyframes recPulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.6); }
  70%  { box-shadow: 0 0 0 12px rgba(255, 255, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

.record-bar-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #45505b;
  font-family: "Open Sans", sans-serif;
}
.record-bar-link {
  color: #0563bb;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.record-bar-link:hover { text-decoration: underline; }

/* ── HUD overlay on map ─────────────────────────────────── */
.record-hud {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 600;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(6px);
  border: 1px solid #d6e3f3;
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  padding: 12px 14px;
  font-family: "Open Sans", sans-serif;
}

.record-hud[hidden] { display: none; }

.record-hud-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  align-items: stretch;
}

.record-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 4px;
  text-align: center;
  border-radius: 8px;
  background: #f8fafd;
  border: 1px solid #e4eaf1;
}

.record-stat-speed {
  background: linear-gradient(135deg, #eaf3fc 0%, #c8dcf2 100%);
  border-color: #0563bb;
}

.record-stat-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #6c757d;
}

.record-stat-value {
  font-family: "Raleway", sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: #173b6c;
  line-height: 1.1;
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  gap: 2px;
}
.record-stat-value small {
  font-size: 10px;
  color: #6c757d;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.record-hud-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.record-hud-btn {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 9px 14px;
  border-radius: 50px;
  font-family: "Open Sans", sans-serif;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, transform 0.15s, border-color 0.15s;
}

.record-hud-btn.record-pause {
  background: #fff;
  color: #0563bb;
  border-color: #c8dcf2;
}
.record-hud-btn.record-pause:hover { background: #eaf3fc; }

.record-hud-btn.record-stop {
  background: #dc2626;
  color: #fff;
  border-color: #dc2626;
}
.record-hud-btn.record-stop:hover { background: #b91c1c; }

.record-hud-btn i { font-size: 18px; }

.record-hud-foot {
  margin-top: 8px;
  font-size: 11.5px;
  text-align: center;
  color: #6c757d;
}

/* ── Sidebar tabs (Routes / My Runs / Leaderboard) ──────── */
.map-list-tabs {
  display: inline-flex;
  background: #f1f4f8;
  border-radius: 50px;
  padding: 3px;
  margin: 0 0 12px;
  flex-wrap: wrap;
  gap: 2px;
}

.map-list-tab {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: transparent;
  font-family: "Open Sans", sans-serif;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #6c757d;
  padding: 7px 14px;
  border-radius: 50px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.map-list-tab:hover { color: #173b6c; }
.map-list-tab.is-active {
  background: #fff;
  color: #0563bb;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* ── Run cards inside the My Runs tab ───────────────────── */
.run-card-delete {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: transparent;
  color: #adb5bd;
  cursor: pointer;
  margin-left: auto;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 16px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.run-card-delete:hover {
  background: #fee2e2;
  color: #dc2626;
}

/* ── Leaderboard list ───────────────────────────────────── */
.leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 540px;
  overflow-y: auto;
  padding-right: 4px;
}

.leaderboard-list::-webkit-scrollbar { width: 6px; }
.leaderboard-list::-webkit-scrollbar-track { background: #f1f4f8; border-radius: 3px; }
.leaderboard-list::-webkit-scrollbar-thumb { background: #cdd7e4; border-radius: 3px; }
.leaderboard-list::-webkit-scrollbar-thumb:hover { background: #0563bb; }

.leader-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid #e4eaf1;
  border-radius: 10px;
  padding: 10px 12px;
  font-family: "Open Sans", sans-serif;
}
.leader-row:hover { border-color: #c8dcf2; }

.leader-rank {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #eaf3fc;
  color: #0563bb;
  border-radius: 50%;
  font-weight: 700;
  font-size: 13px;
  font-family: "Raleway", sans-serif;
}
.leader-row:nth-child(1) .leader-rank { background: #fef3c7; color: #92400e; }
.leader-row:nth-child(2) .leader-rank { background: #e2e8f0; color: #475569; }
.leader-row:nth-child(3) .leader-rank { background: #fee2e2; color: #991b1b; }

.leader-link {
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: inherit;
  display: block;
}
.leader-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #173b6c;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.leader-meta {
  font-size: 11.5px;
  color: #6c757d;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leader-speed {
  flex: 0 0 auto;
  font-family: "Raleway", sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: #0563bb;
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
}
.leader-speed small {
  font-size: 10px;
  color: #6c757d;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* ── Post-run summary modal ─────────────────────────────── */
.run-summary-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1500;
  padding: 18px;
  backdrop-filter: blur(4px);
}
.run-summary-overlay[hidden] { display: none; }

.run-summary-card {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  font-family: "Open Sans", sans-serif;
}

.run-summary-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px 6px;
}
.run-summary-head h3 {
  font-family: "Raleway", sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: #173b6c;
  margin: 0;
}
.run-summary-close {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: transparent;
  color: #6c757d;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 0 6px;
}
.run-summary-close:hover { color: #173b6c; }

.run-summary-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 12px 22px 0;
}

.run-summary-stat {
  background: #f8fafd;
  border: 1px solid #e4eaf1;
  border-radius: 8px;
  padding: 8px 10px;
  text-align: center;
}
.run-summary-stat-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6c757d;
}
.run-summary-stat-value {
  display: block;
  font-family: "Raleway", sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: #173b6c;
  margin-top: 2px;
}

.elev-profile {
  padding: 14px 22px 0;
}
.elev-profile-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6c757d;
  margin-bottom: 6px;
  font-family: "Raleway", sans-serif;
}
.elev-profile-canvas {
  width: 100%;
  height: 100px;
  display: block;
  background: #f8fafd;
  border: 1px solid #e4eaf1;
  border-radius: 8px;
}
.elev-profile-empty {
  background: #f8fafd;
  border: 1px dashed #cdd7e4;
  border-radius: 8px;
  padding: 18px;
  text-align: center;
  color: #6c757d;
  font-size: 13px;
}

.run-summary-form {
  padding: 14px 22px 0;
}
.run-summary-form label {
  font-weight: 600;
  color: #45505b;
  font-size: 12.5px;
}

.run-summary-actions {
  display: flex;
  gap: 8px;
  padding: 14px 22px 18px;
  flex-wrap: wrap;
}

.run-summary-btn {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 50px;
  font-family: "Open Sans", sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s, border-color 0.15s;
}
.run-summary-btn:hover:not(:disabled) { transform: translateY(-1px); }
.run-summary-btn:disabled { opacity: 0.6; cursor: progress; }
.run-summary-btn i { font-size: 16px; }

.run-summary-btn-primary {
  background: #0563bb;
  color: #fff;
  border-color: #0563bb;
  margin-left: auto;
}
.run-summary-btn-primary:hover { background: #0466c8; }

.run-summary-btn-secondary {
  background: #fff;
  color: #45505b;
  border-color: #ced4da;
}
.run-summary-btn-secondary:hover {
  background: #f8fafd;
  border-color: #0563bb;
  color: #0563bb;
}

.run-summary-foot {
  padding: 0 22px 18px;
  margin: 0;
  font-size: 13px;
  color: #45505b;
}
.run-summary-foot a {
  color: #0563bb;
  font-weight: 600;
  text-decoration: none;
}
.run-summary-foot a:hover { text-decoration: underline; }

/* ── Run viewer page-specific ───────────────────────────── */
.run-stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 8px;
}

.run-share-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}
.run-share-row #run-share-feedback {
  font-size: 12.5px;
  color: #16a34a;
  font-weight: 600;
}
.run-notes {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #e4eaf1;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 767.98px) {
  .record-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .record-bar-info {
    justify-content: space-between;
  }
  .record-btn {
    justify-content: center;
  }
  .record-hud-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .run-summary-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .run-stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 575.98px) {
  .record-hud {
    top: 8px;
    left: 8px;
    right: 8px;
    padding: 10px;
  }
  .record-stat-value { font-size: 16px; }
  .map-list-tab {
    padding: 7px 10px;
    font-size: 11px;
  }
  .run-summary-card { max-height: 95vh; }
  .run-summary-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .run-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .run-summary-actions {
    flex-direction: column;
  }
  .run-summary-btn-primary { margin-left: 0; }
  .leader-row { padding: 8px 10px; }
  .leader-title { font-size: 13px; }
}
