/* Live turn-by-turn HUD — simple Google-like bottom sheet while navigating. */
.live-nav-hud {
  --nav-blue: #1a73e8;
  --nav-blue-deep: #1557b0;
  --nav-ink: #202124;
  --nav-muted: #5f6368;
  --nav-line: #e8eaed;
  --nav-radius: 22px;
  position: fixed;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(14px);
  z-index: 200;
  width: min(420px, calc(100vw - 20px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s ease;
}

/* Author `display:flex` must not beat the HTML hidden attribute. */
.live-nav-hud[hidden] {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.live-nav-hud:not([hidden]) {
  display: flex;
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
  pointer-events: none;
}

.live-nav-hud:not([hidden]) * {
  pointer-events: auto;
}

/* Hide chrome that would steal taps / crowd the map during nav. */
html.live-nav-active .side-panel-stack,
html.live-nav-active .side-panel-stack > *,
html.consumer-ui.live-nav-active .side-panel-stack,
html.consumer-ui.live-nav-active .side-panel-stack > *,
html.consumer-ui.live-nav-active.chrome-revealed .side-panel-stack,
html.consumer-ui.live-nav-active.chrome-revealed .side-panel-stack > *,
html.live-nav-active .search-chrome,
html.live-nav-active .search-chrome-float,
html.live-nav-active .side-panel-expand-tab,
html.live-nav-active .nav-rail,
html.live-nav-active .nav-rail-edge-toggle,
html.live-nav-active .nav-menu-fab,
html.live-nav-active .layers-control-bl,
html.live-nav-active .layers-menu {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.live-nav-sheet {
  overflow: hidden;
  border-radius: var(--nav-radius);
  background: #fff;
  box-shadow:
    0 1px 2px rgba(60, 64, 67, 0.18),
    0 8px 28px rgba(60, 64, 67, 0.22);
}

.live-nav-banner {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 16px 16px 15px;
  background: linear-gradient(165deg, #1a73e8 0%, #1765cc 100%);
  color: #fff;
}

.live-nav-icon {
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  backdrop-filter: blur(4px);
}

.live-nav-copy {
  min-width: 0;
  flex: 1;
}

.live-nav-dist {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: #fff;
  min-height: 1.15em;
}

.live-nav-instruction {
  margin: 5px 0 0;
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.35;
  color: #fff;
  min-height: 1.2em;
}

.live-nav-sub {
  margin: 4px 0 0;
  font-size: 0.88rem;
  font-weight: 500;
  opacity: 0.92;
  color: #e8f0fe;
}

.live-nav-lanes {
  display: flex;
  gap: 6px;
  justify-content: center;
  align-items: flex-end;
  padding: 10px 14px 6px;
  background: #f8f9fa;
  border-bottom: 1px solid var(--nav-line);
}

.live-nav-lane {
  width: 28px;
  height: 44px;
  border-radius: 8px;
  background: #e8eaed;
  color: #5f6368;
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 700;
  border: 2px solid transparent;
}

.live-nav-lane.is-valid {
  background: #e8f0fe;
  color: #1967d2;
}

.live-nav-lane.is-active {
  background: #1a73e8;
  color: #fff;
  border-color: #1557b0;
  box-shadow: 0 2px 8px rgba(26, 115, 232, 0.35);
  transform: translateY(-2px);
}

.live-nav-junction {
  height: 72px;
  margin: 0;
  background:
    radial-gradient(circle at 50% 58%, rgba(26, 115, 232, 0.18), transparent 55%),
    linear-gradient(180deg, #f1f3f4 0%, #fff 100%);
  position: relative;
  overflow: hidden;
}

.live-nav-junction::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 18%;
  width: 10px;
  height: 64%;
  transform: translateX(-50%);
  background: #dadce0;
  border-radius: 6px;
}

.live-nav-junction.is-left::after,
.live-nav-junction.is-right::after,
.live-nav-junction.is-straight::after {
  content: '';
  position: absolute;
  width: 36px;
  height: 10px;
  background: #1a73e8;
  border-radius: 6px;
  top: 42%;
}

.live-nav-junction.is-left::after {
  left: 18%;
  transform: rotate(-28deg);
}

.live-nav-junction.is-right::after {
  right: 18%;
  left: auto;
  transform: rotate(28deg);
}

.live-nav-junction.is-straight::after {
  left: 50%;
  width: 10px;
  height: 36px;
  transform: translateX(-50%);
  top: 22%;
}

.live-nav-next {
  margin: 5px 0 0;
  font-size: 0.84rem;
  font-weight: 500;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.88);
}

.live-nav-meta {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  background: #fff;
  color: var(--nav-ink);
}

.live-nav-meta-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 12px 8px;
  border-bottom: 1px solid var(--nav-line);
}

.live-nav-meta-stats.has-leave {
  grid-template-columns: 1fr 1fr 1fr;
}

.live-nav-meta-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  padding: 4px 10px;
  text-align: center;
}

.live-nav-meta-block + .live-nav-meta-block {
  border-inline-start: 1px solid var(--nav-line);
}

.live-nav-meta-label {
  font-size: 0.72rem;
  color: var(--nav-muted);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.live-nav-meta-block strong {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--nav-ink);
  line-height: 1.25;
  overflow-wrap: anywhere;
}

/* Three equal action cards */
.live-nav-meta-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
}

.live-nav-chip {
  margin: 0;
  border: 0;
  border-radius: 14px;
  min-height: 44px;
  padding: 10px 8px;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.2;
  background: #f1f3f4;
  color: var(--nav-blue-deep);
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease;
}

.live-nav-chip:hover {
  background: #e8eaed;
}

.live-nav-chip:active {
  transform: scale(0.98);
}

.live-nav-chip.danger {
  background: #fce8e6;
  color: #c5221f;
}

.live-nav-chip.danger:hover {
  background: #fad2cf;
}

.live-nav-chip[aria-pressed='true'] {
  background: var(--nav-blue);
  color: #fff;
}

.live-nav-banner,
.live-nav-meta {
  position: relative;
  z-index: 1;
}

.live-nav-status {
  margin: 0;
  padding: 10px 14px;
  border-radius: 14px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(154, 52, 18, 0.12);
}

.live-nav-status.is-ok {
  background: #ecfdf5;
  color: #047857;
}

.live-nav-status.is-busy {
  background: #eff6ff;
  color: #1d4ed8;
}

.live-nav-status.is-warn {
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fdba74;
}

html.live-nav-active .map-controls-br {
  bottom: calc(210px + env(safe-area-inset-bottom));
  z-index: 120;
}

html.live-nav-active #map {
  cursor: grab;
}

/* Google Maps–style navigation chevron: tip = direction of travel. */
.live-nav-puck {
  position: relative;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(15, 23, 42, 0.45));
}

.live-nav-puck-glow {
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: rgba(26, 115, 232, 0.22);
  box-shadow: 0 0 0 10px rgba(26, 115, 232, 0.12);
  z-index: 0;
}

.live-nav-puck-chevron {
  position: relative;
  z-index: 1;
  display: block;
  overflow: visible;
}

.live-nav-puck.is-off-route .live-nav-puck-chevron path {
  fill: #ea4335;
}

.live-nav-puck.is-off-route .live-nav-puck-glow {
  background: rgba(234, 67, 53, 0.2);
  box-shadow: 0 0 0 10px rgba(234, 67, 53, 0.12);
}

.live-nav-puck.is-gps-weak .live-nav-puck-chevron path {
  fill: #f9ab00;
}

.live-nav-puck.is-gps-weak .live-nav-puck-glow {
  background: rgba(249, 171, 0, 0.22);
  box-shadow: 0 0 0 10px rgba(249, 171, 0, 0.12);
}

.route-summary .start-nav-row {
  margin-top: 10px;
}

.route-summary .start-nav-btn {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-weight: 700;
  background: linear-gradient(160deg, #0c4da8, #083878);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(8, 56, 120, 0.25);
}

.route-summary .start-nav-btn:hover {
  filter: brightness(1.05);
}

@media (max-width: 900px) {
  .live-nav-hud {
    width: calc(100vw - 16px);
    bottom: max(10px, env(safe-area-inset-bottom));
  }

  .live-nav-chip {
    font-size: 0.8rem;
    padding: 10px 6px;
  }

  html.live-nav-active .map-controls-br {
    bottom: calc(220px + env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  .live-nav-hud,
  .live-nav-chip {
    transition: none !important;
  }
}
