/* ── User marker (pulsing blue dot) ──────────────────────────────────── */
.map-user-marker {
  background: #2196f3;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(33, 150, 243, 0.6);
  animation: map-pulse 2s ease-in-out infinite;
}
@keyframes map-pulse {
  0%, 100% { box-shadow: 0 0 4px rgba(33, 150, 243, 0.4); }
  50%      { box-shadow: 0 0 14px rgba(33, 150, 243, 0.7); }
}

/* ── Map view: fullscreen map + transparent HUD overlays ─────────────── */

#view-map {
  position: relative;
  height: 100dvh;
  overflow: hidden;
}

.map-container {
  position: absolute;
  inset: 0;
  z-index: 0;
}

/* ── HUD layer ───────────────────────────────────────────────────────── */
.map-hud {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding:
    calc(0.65rem + env(safe-area-inset-top))
    0.75rem
    calc(0.65rem + env(safe-area-inset-bottom));
}

.map-hud > * {
  pointer-events: auto;
}

/* ── Top row: back + GPS pill ────────────────────────────────────────── */
.map-hud__top {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

/* ── Route controls (pause/resume) — top right ──────────────────────── */
.map-hud__route-ctrls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.map-hud__route-ctrls.hidden { display: none; }

.map-hud__ctrl {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(165, 202, 214, 0.22);
  background: rgba(6, 16, 20, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text-main);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 160ms, border-color 160ms, transform 160ms;
  -webkit-tap-highlight-color: transparent;
}

.map-hud__ctrl:active {
  transform: scale(0.92);
}

.map-hud__ctrl--pause {
  color: #ffa64d;
  border-color: rgba(247, 147, 30, 0.3);
}
.map-hud__ctrl--pause:hover {
  background: rgba(247, 147, 30, 0.14);
  border-color: rgba(247, 147, 30, 0.5);
}

.map-hud__ctrl--resume {
  color: var(--primary);
  border-color: rgba(24, 191, 125, 0.3);
}
.map-hud__ctrl--resume:hover {
  background: rgba(24, 191, 125, 0.14);
  border-color: rgba(24, 191, 125, 0.5);
}

.map-hud__ctrl.hidden { display: none; }

.map-hud__back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(165, 202, 214, 0.22);
  background: rgba(6, 16, 20, 0.78);
  backdrop-filter: blur(8px);
  color: var(--text-main);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 160ms;
  -webkit-tap-highlight-color: transparent;
}

.map-hud__back:hover {
  background: rgba(6, 16, 20, 0.92);
}

.map-hud__pill {
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid rgba(165, 202, 214, 0.2);
  background: rgba(6, 16, 20, 0.78);
  backdrop-filter: blur(8px);
  color: var(--text-soft);
}

/* ── Lower group: guided/picker + metrics ────────────────────────────── */
.map-hud__lower {
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
}

/* ── Add guided session: + button + horizontal picker ────────────────── */
.map-guided-add {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
}
.map-guided-add.hidden { display: none; }

.map-guided-add__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(24, 191, 125, 0.3);
  background: rgba(6, 16, 20, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 160ms, border-color 160ms, transform 160ms;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
}
.map-guided-add__btn:hover {
  background: rgba(24, 191, 125, 0.16);
  border-color: rgba(24, 191, 125, 0.5);
}
.map-guided-add__btn:active { transform: scale(0.92); }

.map-guided-add__btn.is-open {
  transform: rotate(45deg);
  border-color: rgba(218, 65, 65, 0.4);
  color: var(--danger);
}
.map-guided-add__btn.is-open:hover {
  background: rgba(218, 65, 65, 0.14);
}

.map-guided-add__picker {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex: 1;
  min-width: 0;
  padding: 4px 0;
}
.map-guided-add__picker::-webkit-scrollbar { display: none; }
.map-guided-add__picker.hidden { display: none; }

.map-tpl-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid rgba(165, 202, 214, 0.14);
  background: rgba(6, 16, 20, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #eaf6fb;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 160ms, border-color 160ms;
  -webkit-tap-highlight-color: transparent;
}
.map-tpl-chip:hover {
  background: rgba(24, 191, 125, 0.12);
  border-color: rgba(24, 191, 125, 0.35);
}
.map-tpl-chip:active { transform: scale(0.96); }

.map-tpl-chip__name {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.2;
}
.map-tpl-chip__info {
  font-size: 0.68rem;
  color: rgba(165, 202, 214, 0.5);
  font-weight: 500;
}

/* ── Bottom bar: metrics + center button ─────────────────────────────── */
.map-hud__bottom {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border-radius: 16px;
  background: rgba(6, 16, 20, 0.78);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(165, 202, 214, 0.14);
}

.map-hud__metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.map-hud__value {
  font-family: "Barlow Condensed", sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.map-hud__label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-soft);
  margin-top: 0.1rem;
}

.map-hud__center {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(165, 202, 214, 0.22);
  background: rgba(24, 191, 125, 0.12);
  color: var(--primary);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 160ms, border-color 160ms;
  -webkit-tap-highlight-color: transparent;
}

.map-hud__center:hover {
  background: rgba(24, 191, 125, 0.22);
  border-color: rgba(24, 191, 125, 0.4);
}

.map-hud__center:active {
  transform: scale(0.95);
}

/* ── Guided session card on map ──────────────────────────────────────── */
.map-guided {
  pointer-events: auto;
  margin: 0 12px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(6, 16, 20, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(165, 202, 214, 0.12);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.map-guided.hidden { display: none; }

.map-guided__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.map-guided__name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.map-guided__session-time {
  font-size: 0.72rem;
  color: rgba(165, 202, 214, 0.55);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.map-guided__body {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.map-guided__current {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.map-guided__block-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: #eaf6fb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.map-guided__block-timer {
  font-size: 1.1rem;
  font-weight: 700;
  color: #eaf6fb;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.map-guided__progress {
  height: 4px;
  border-radius: 2px;
  background: rgba(165, 202, 214, 0.12);
  overflow: hidden;
}
.map-guided__bar {
  height: 100%;
  border-radius: 2px;
  background: var(--primary);
  width: 0%;
  transition: width 0.6s linear;
}

.map-guided__next {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 2px;
}
.map-guided__next.hidden { display: none; }
.map-guided__next-label {
  font-size: 0.72rem;
  color: rgba(165, 202, 214, 0.45);
}
.map-guided__next-name {
  font-size: 0.76rem;
  color: rgba(165, 202, 214, 0.7);
  font-weight: 500;
}

/* Paused state pulsing */
.map-guided.is-paused .map-guided__block-timer {
  animation: map-guided-pulse 1.2s ease-in-out infinite;
}
@keyframes map-guided-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

/* ── Map button in train view controls ───────────────────────────────── */
.map-open-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  padding: 0.6rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(24, 191, 125, 0.25);
  background: rgba(24, 191, 125, 0.08);
  color: var(--primary);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 160ms, border-color 160ms;
  -webkit-tap-highlight-color: transparent;
}

.map-open-btn:hover {
  background: rgba(24, 191, 125, 0.16);
  border-color: rgba(24, 191, 125, 0.45);
}

/* ── Hide bottom nav when map view is active ─────────────────────────── */
body.view-map .bottom-nav,
body.view-map .nav-fab {
  display: none;
}
