/* ==========================================================================
   GPS trails on /map (js/features/geolocation-manager.js)
   ==========================================================================
   Map buttons sit beside the locate control and match it. The trail buttons
   are field tools, so on mouse-and-keyboard devices they are hidden unless a
   trail is live (.is-active): a restored trail always keeps its Stop/Save.
   Saved trails live in My Layers for every device.
   ========================================================================== */

/* ---- Map buttons -------------------------------------------------------- */

.leaflet-control-trail {
  display: flex;
  flex-direction: row;
  gap: 4px;
}

.leaflet-control-trail a.trail-btn-map {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: rgba(var(--nm-bg-rgb), 0.95);
  color: var(--nm-accent);
  border: 1px solid rgba(var(--nm-blue-rgb), 0.3);
  border-radius: var(--nm-radius-sm);
  text-decoration: none;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.leaflet-control-trail a.trail-btn-map:hover {
  background: rgba(var(--nm-bg-rgb), 1);
  color: var(--nm-text);
  border-color: rgba(var(--nm-blue-rgb), 0.6);
}

.leaflet-control-trail a.trail-record-btn .ti {
  color: var(--nm-orange-light);
}

.leaflet-control-trail a.trail-record-btn.recording {
  border-color: rgba(var(--nm-danger-rgb), 0.7);
  animation: trailPulse 1.5s ease-in-out infinite;
}

.leaflet-control-trail a.trail-record-btn.recording .ti {
  color: var(--nm-danger);
}

@keyframes trailPulse {
  0%, 100% { background-color: rgba(var(--nm-bg-rgb), 0.95); }
  50% { background-color: rgba(var(--nm-danger-rgb), 0.25); }
}

@media (hover: hover) and (pointer: fine) {
  .leaflet-control-trail:not(.is-active) {
    display: none;
  }
}

/* ---- "You're on" readout: a segment of the bottom status bar ------------
   Mirrors #tenementHoverInfo (the desktop hover readout) beside it. While GPS
   is on (body.gps-readout-on) it shows, the sponsor rotation pauses, and on
   phones it takes the hover slot's place since there is no hover there. */

.gps-status {
  display: none;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  padding-left: 14px;
  margin-left: 2px;
}

body.gps-readout-on .gps-status {
  display: block;
}

.gps-status.is-openable {
  cursor: pointer;
}

.gps-status.is-openable:hover {
  color: #fff;
}

.gps-status-icon {
  color: var(--nm-accent);
  margin-right: 5px;
  vertical-align: -2px;
}

.gps-status-dim {
  color: rgba(255, 255, 255, 0.45);
}

.gps-status-sep {
  color: rgba(255, 255, 255, 0.2);
  margin: 0 6px;
}

.gps-status-rec {
  color: var(--nm-text);
  font-variant-numeric: tabular-nums;
}

.trail-rec-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--nm-danger);
  vertical-align: 0;
  animation: trailRecBlink 1.5s ease-in-out infinite;
}

@keyframes trailRecBlink {
  50% { opacity: 0.35; }
}

@media (max-width: 768px), (max-height: 500px) and (pointer: coarse) {
  body.gps-readout-on #tenementHoverInfo {
    display: none !important;
  }

  /* The general status message ("Basemap switched to Satellite", layer
     loading) has no width cap and wrapped over four lines, squeezing the
     readout to a few characters. Keep its dot, drop the text, while GPS is on. */
  body.gps-readout-on #mainStatus {
    display: none;
  }

  .gps-status {
    padding-left: 8px;
  }
}

/* ---- Live-trail sheet (pinned to the bottom of the map) ----------------- */

/* On <body>, centred over the map area by JS (left = map centre). z-index:
   above the Ask bar (9500), status bar (1500), legend and side tabs; below the
   results panel (9999) and the analytics/marketplace panels (10000+). */
.trail-sheet {
  position: fixed;
  left: 50%;
  bottom: 48px; /* clear the 36px status bar */
  transform: translateX(-50%);
  z-index: 9600;
  width: min(340px, calc(100vw - 24px));
  max-height: calc(100dvh - 130px);
  overflow-y: auto;
  box-sizing: border-box;
  padding: 12px 14px;
  background: rgba(var(--nm-surface-rgb), 0.98);
  color: var(--nm-text);
  border: 1px solid var(--nm-border-strong);
  border-radius: var(--nm-radius);
  box-shadow: var(--nm-shadow-lg);
}

.trail-sheet-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--nm-radius-sm);
  color: var(--nm-text-dim);
  font-size: 16px;
  cursor: pointer;
}

.trail-sheet-close:hover {
  background: rgba(var(--nm-blue-rgb), 0.15);
  color: var(--nm-text);
}

/* ---- Cards (Leaflet popups): trail summary, waypoint, saved trail ------- */

.trail-popup .leaflet-popup-content-wrapper {
  background: rgba(var(--nm-surface-rgb), 0.98);
  color: var(--nm-text);
  border: 1px solid var(--nm-border-strong);
  border-radius: var(--nm-radius);
  box-shadow: var(--nm-shadow);
  padding: 0;
}

/* styles.css forces every .leaflet-popup-content to width:780px !important
   (for the feature popups), which made these cards wider than a phone. */
.trail-popup .leaflet-popup-content {
  width: min(240px, calc(100vw - 80px)) !important;
  margin: 12px 14px;
}

.trail-popup .leaflet-popup-tip {
  background: rgba(var(--nm-surface-rgb), 0.98);
  border: 1px solid var(--nm-border-strong);
}

.trail-popup a.leaflet-popup-close-button {
  color: var(--nm-text-dim);
}

.trail-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--nm-font);
}

.trail-card-title {
  font-size: 14px;
  font-weight: var(--nm-weight-med);
  color: var(--nm-text);
  padding-right: 28px; /* clear the sheet's close button */
  overflow-wrap: anywhere;
}

.trail-card-title .ti {
  color: var(--nm-orange-light);
}

.trail-card-stats {
  font-size: 13px;
  color: var(--nm-text);
}

.trail-card-sub {
  font-size: 11px;
  color: var(--nm-text-muted);
}

.trail-card-note {
  font-size: 11px;
  color: var(--nm-text-muted);
  padding: 4px 8px;
  border-left: 2px solid var(--nm-border-strong);
}

.trail-field {
  display: grid;
  gap: 3px;
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--nm-text-muted);
}

.trail-field input,
.trail-field textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 8px;
  background: rgba(var(--nm-bg-deep-rgb), 0.8);
  color: var(--nm-text);
  border: 1px solid var(--nm-border-strong);
  border-radius: var(--nm-radius-md);
  font-family: var(--nm-font);
  font-size: 13px;
  resize: vertical;
}

.trail-field input:focus,
.trail-field textarea:focus {
  outline: none;
  border-color: var(--nm-accent);
}

.trail-card-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.trail-card-row-end {
  justify-content: flex-end;
}

.trail-card-label {
  font-size: 11px;
  color: var(--nm-text-muted);
  margin-right: auto;
}

.trail-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 32px;
  padding: 5px 10px;
  background: rgba(var(--nm-blue-rgb), 0.12);
  color: var(--nm-text);
  border: 1px solid var(--nm-border);
  border-radius: var(--nm-radius-md);
  font-family: var(--nm-font);
  font-size: 12px;
  cursor: pointer;
}

.trail-action:hover {
  background: rgba(var(--nm-blue-rgb), 0.25);
}

.trail-action:disabled {
  opacity: 0.6;
  cursor: default;
}

.trail-action-primary {
  width: 100%;
  min-height: 36px;
  background: var(--nm-accent-bright);
  border-color: var(--nm-accent-bright);
  color: #fff;
  font-weight: var(--nm-weight-med);
}

.trail-action-primary:hover {
  background: var(--nm-accent-deep);
}

.trail-action-danger {
  color: var(--nm-text-muted);
}

.trail-action-danger:hover,
.trail-action-danger.armed {
  background: rgba(var(--nm-danger-rgb), 0.18);
  border-color: rgba(var(--nm-danger-rgb), 0.6);
  color: #fff;
}

/* ---- Waypoints on the map --------------------------------------------- */

/* 32px touch target (the divIcon box) around a 14px dot. */
.leaflet-marker-icon.trail-wp {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
}

.trail-wp-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-sizing: border-box;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}


.leaflet-tooltip.trail-wp-label {
  padding: 1px 5px;
  background: rgba(var(--nm-bg-rgb), 0.85);
  color: var(--nm-text);
  border: none;
  border-radius: var(--nm-radius-sm);
  box-shadow: none;
  font-family: var(--nm-font);
  font-size: 11px;
}

.leaflet-tooltip.trail-wp-label::before {
  display: none;
}

/* ---- Saved trails block in My Layers ------------------------------------ */

.user-trails-block {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--nm-border);
}

.user-trails-header {
  font-size: 11px;
  font-weight: var(--nm-weight-med);
  color: var(--nm-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.user-trails-empty {
  margin: 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--nm-text-dim);
}

.user-trails-empty a {
  color: var(--nm-text);
}

.trail-swatch {
  background: #E5521A; /* --nm-orange, the saved-trail line colour */
  cursor: default;
}

.trail-swatch:hover {
  transform: none;
}

.trail-item .trail-item-meta {
  color: var(--nm-text-dim);
}

.trail-fmt-btn {
  font-size: 10px;
  font-weight: var(--nm-weight-med);
}
