/* ================= Navigation mode ================= */
#map {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: none;
  background: #0b0d11;
}
.nav-on #map { display: block; }
.nav-on .ambient { display: none; }
.app { z-index: 1; }

.top-actions { display: flex; gap: 8px; }
.nav-btn .i-close { display: none; }
.nav-btn.on { background: var(--text); color: #07080a; border-color: transparent; }
.nav-btn.on .i-map { display: none; }
.nav-btn.on .i-close { display: block; }
.nav-btn[hidden] { display: none; }

.nav-top, .recenter, .nav-card { display: none; }

/* Layout: map fills the screen, controls float on top. */
.app.nav {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  pointer-events: none;
}
.app.nav::before {
  content: "";
  position: fixed;
  left: 0; right: 0; top: 0;
  height: calc(var(--sat) + 120px);
  background: linear-gradient(rgba(5, 6, 8, .85), rgba(5, 6, 8, 0));
  z-index: -1;
  pointer-events: none;
}
.app.nav > * { pointer-events: auto; }
.app.nav .topbar { grid-row: 1; }
.app.nav .nav-top { display: block; grid-row: 2; position: relative; }
.app.nav .gauge-wrap {
  grid-row: 3;
  align-self: end;
  justify-self: start;
  pointer-events: none;
}
.app.nav .recenter:not([hidden]) {
  display: inline-flex;
  grid-row: 3;
  align-self: end;
  justify-self: end;
}
.app.nav .side { grid-row: 4; gap: 8px; }
.app.nav .stats { display: none; }
.app.nav .nav-card:not([hidden]) { display: block; }
.app.nav .nav-card.nav-eta:not([hidden]) { display: flex; }

/* Compact speedometer over the map */
.app.nav .gauge { width: 138px; }
.app.nav .gauge::before {
  content: "";
  position: absolute;
  inset: -7%;
  border-radius: 50%;
  background: rgba(8, 9, 12, .82);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
}
.app.nav .tick-label, .app.nav .unit { display: none; }
.app.nav .readout { padding-top: 0; }
.app.nav .digits { font-size: 40cqw; }

/* Compact music card */
.app.nav .media { padding: 10px 12px 6px; border-radius: 22px; background: rgba(16, 18, 22, .9); }
.app.nav .art { width: 44px; height: 44px; border-radius: 10px; }
.app.nav .title { font-size: 15px; }
.app.nav .artist { font-size: 13px; }
.app.nav .progress { display: none; }
.app.nav .controls { padding-top: 2px; }
.app.nav .ctl { height: 50px; }
.app.nav .ctl.play { width: 56px; height: 56px; }

/* Search */
.search {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 8px 0 16px;
  border-radius: 18px;
  background: rgba(18, 20, 25, .92);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  color: var(--muted);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
}
.search[hidden], .banner[hidden], .then[hidden], .results[hidden] { display: none; }
.search input {
  flex: 1; min-width: 0;
  height: 100%;
  border: 0; outline: 0;
  background: none;
  color: var(--text);
  font: 500 17px var(--ui);
  -webkit-user-select: text;
  user-select: text;
}
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { display: none; }
.clear { width: 40px; height: 40px; display: grid; place-items: center; color: var(--muted); }
.clear[hidden] { display: none; }

.results {
  position: absolute;
  left: 0; right: 0; top: calc(100% + 8px);
  z-index: 5;
  max-height: 52dvh;
  overflow-y: auto;
  padding: 6px;
  border-radius: 18px;
  background: rgba(18, 20, 25, .97);
  border: 1px solid var(--line);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .55);
  animation: drop .3s var(--ease-out);
}
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } }
.results-note { padding: 14px 12px; color: var(--muted); font-size: 14px; }
.result {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 10px;
  border-radius: 12px;
  text-align: left;
}
.result:active { background: var(--surface-2); }
.r-icon { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.r-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.r-text b { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-text small { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-dist { flex: none; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Turn banner */
.banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px 14px 14px;
  border-radius: 22px;
  background: linear-gradient(135deg, #12493f, #0b2f29);
  border: 1px solid rgba(62, 230, 193, .25);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .45);
  animation: drop .35s var(--ease-out);
}
.m-icon { flex: none; width: 58px; height: 58px; color: #fff; }
.m-icon svg { width: 100%; height: 100%; }
.m-text { min-width: 0; }
.m-dist {
  font-family: var(--display);
  font-size: 34px;
  font-weight: 650;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.m-instr {
  margin-top: 4px;
  font-size: 16px;
  font-weight: 550;
  line-height: 1.25;
  color: rgba(255, 255, 255, .86);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.then {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 0 14px;
  padding: 5px 12px 6px 10px;
  border-radius: 0 0 14px 14px;
  background: #0b2f29;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, .8);
}
.then svg { width: 20px; height: 20px; color: #fff; }

/* Preview + ETA cards */
.nav-card {
  border-radius: 22px;
  padding: 14px 16px;
  background: rgba(16, 18, 22, .94);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  animation: rise-card .4s var(--ease-out);
}
@keyframes rise-card { from { opacity: 0; transform: translateY(12px); } }
.pv-name { font-size: 18px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-meta { margin-top: 4px; font-size: 14px; color: var(--muted); }
.nav-card .btn-row { padding: 12px 0 0; }
.btn.go { flex: 1.4; background: #3ee6c1; color: #04201a; font-size: 17px; }
.btn.go:disabled { opacity: .4; }

.nav-card.nav-eta { align-items: center; gap: 4px; padding: 8px 8px 8px 14px; }
.eta { flex: 1; display: flex; flex-direction: column; align-items: center; }
.eta b { font-family: var(--display); font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.eta span { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.voice-btn { width: 42px; height: 42px; flex: none; }
.voice-btn .i-off { display: none; }
.voice-btn.muted .i-on { display: none; }
.voice-btn.muted .i-off { display: block; }
.end-btn {
  flex: none;
  height: 42px;
  padding: 0 18px;
  margin-left: 6px;
  border-radius: 14px;
  background: #ff5a4e;
  color: #fff;
  font-weight: 700;
  transition: transform .25s var(--ease-spring);
}
.end-btn:active { transform: scale(.94); }

.recenter {
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px;
  margin-bottom: 8px;
  border-radius: 999px;
  background: rgba(18, 20, 25, .92);
  border: 1px solid var(--line);
  font-size: 14px;
  font-weight: 600;
  color: #3ee6c1;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .4);
}

/* Position puck + destination pin */
.puck { width: 44px; height: 44px; }
.puck svg { width: 100%; height: 100%; overflow: visible; }
.puck-halo { fill: rgba(62, 230, 193, .18); }
.puck-ring { fill: #3ee6c1; stroke: #fff; stroke-width: 3; }
.puck-arrow { fill: #04201a; }
.dest-pin {
  width: 26px; height: 34px;
  background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 26 34'%3E%3Cpath d='M13 33s11-10.5 11-19A11 11 0 0 0 2 14c0 8.5 11 19 11 19z' fill='%23ff5a4e' stroke='%23fff' stroke-width='2'/%3E%3Ccircle cx='13' cy='13.5' r='4' fill='%23fff'/%3E%3C/svg%3E");
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .5));
}
.maplibregl-ctrl-attrib { font-size: 10px; }

/* Landscape navigation: map on the left, controls on the right */
@media (orientation: landscape) {
  .app.nav { grid-template-rows: auto minmax(0, 1fr); }
  .app.nav .nav-top { grid-column: 1; grid-row: 2; align-self: start; max-width: 460px; }
  .app.nav .gauge-wrap { grid-column: 1; grid-row: 2; }
  .app.nav .recenter:not([hidden]) { grid-column: 1; grid-row: 2; }
  .app.nav .side { grid-column: 2; grid-row: 2; align-self: end; justify-content: flex-end; }
  .app.nav .gauge { width: 124px; }
  .m-dist { font-size: 30px; }
}
