/* The trip menu (app.trip.js): the tab dock, and the ?trip=cards prototype.
   Scoped to html.tp; with ?trip=card none of this applies. */

html.tp:not(.tpHold) #mfTrip {
  display: none !important;
}
html.tpHold .tpDockBar,
html.tpHold .tpCardsWrap,
html.tpHold .tpSheet {
  display: none !important;
}
html.mf.tp .mfFeedback {
  bottom: calc(24px + var(--tp-lift, 0px));
}
@media (max-width: 900px) {
  html.mf.tp .mfFeedback {
    bottom: calc(12px + env(safe-area-inset-bottom, 0px) + var(--tp-lift, 0px));
  }
}

/* shared bits */
html.tp .tpIcon {
  width: 36px;
  height: 36px;
  flex: none;
  border: 0;
  border-radius: var(--pill);
  background: transparent;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}
html.tp .tpIcon:hover {
  background: var(--accent-wash);
}
html.tp .tpIcon svg {
  width: 20px;
  height: 20px;
}
html.tp .tpHaz {
  color: var(--hazard);
}

/* ---------- the panel above the dock or the cards ---------- */
html.tp .tpSheet {
  position: absolute;
  /* over the map's buttons and the feedback button, under the search card */
  z-index: 1120;
  left: 0;
  right: 0;
  bottom: calc(var(--tp-base, 0px) + 8px);
  max-height: min(60dvh, calc(100% - var(--mf-search-h, 120px) - var(--tp-base, 0px) - 40px));
  overflow-y: auto;
  box-sizing: border-box;
  margin: 0 8px;
  padding: 6px 16px 14px;
  background: var(--surface);
  box-shadow: var(--shadow-2);
  border-radius: 18px;
}
html.tp .tpSheet[hidden] {
  display: none;
}
html.tpDock .tpSheet {
  margin: 0;
  bottom: var(--tp-base, 0px);
  border-radius: 0;
  box-shadow: 0 -1px 0 var(--line), 0 -10px 30px rgba(20, 28, 26, 0.12);
}
html.tp .tpSheet__head {
  display: flex;
  align-items: center;
  min-height: 44px;
}
html.tp .tpSheet__title {
  flex: 1 1 auto;
  font: 800 17px/1.2 var(--font-display);
}
html.tp .tpSheet__head .tpIcon {
  color: var(--ink-quiet);
}
html.tp .tpSec[hidden] {
  display: none;
}
html.tp .tpMixList {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
html.tp .tpMixList li {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 32px;
}
html.tp .tpMixList i {
  width: 10px;
  height: 10px;
  border-radius: var(--pill);
}
html.tp .tpMixList b {
  font-weight: 600;
  color: var(--ink-soft);
}
html.tp .tpSheet .mfOptions {
  margin-bottom: 12px;
}
html.tp .tpActs {
  display: flex;
  gap: 8px;
}
html.tp .tpAct {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--pill);
  background: var(--surface);
  color: var(--ink-soft);
  font: 600 14px var(--font-text);
  cursor: pointer;
}
html.tpDock .tpAct {
  border-radius: 4px;
}
html.tp .tpAct svg {
  width: 18px;
  height: 18px;
}
html.tp .tpEmpty {
  margin: 4px 0 8px;
  color: var(--ink-quiet);
  font-size: 14px;
}
html.tp .tpEmpty[hidden] {
  display: none;
}
/* the moved crossings list: always open, no header of its own */
html.tp .tpSheet .crossings:not(:empty) {
  margin: 0;
  padding: 0;
  border: 0;
  box-shadow: none;
  background: none;
}
html.tp .tpSheet .crossingsHead {
  display: none;
}
html.tp .tpSheet .crossingsReveal {
  grid-template-rows: 1fr;
  visibility: visible;
}
html.tp .tpSheet .directions {
  margin: 0;
}

/* ---------- ?trip=dock: a square tab bar ---------- */
html.tp .tpDockBar {
  position: absolute;
  z-index: 1100;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  box-shadow: 0 -1px 0 var(--line), 0 -8px 24px rgba(20, 28, 26, 0.08);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
html.tp .tpDockBar[hidden] {
  display: none;
}
html.tp .tpDockBar__bar {
  display: flex;
  gap: 2px;
  height: 5px;
}
html.tp .tpDockBar__bar span {
  display: block;
}
html.tp .tpDockBar__tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
html.tp .tpDockBar__tabs button {
  height: 62px;
  border: 0;
  border-radius: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 4px;
  font: 600 11.5px/1.1 var(--font-text);
  color: var(--ink-quiet);
  cursor: pointer;
  white-space: nowrap;
}
html.tp .tpDockBar__tabs button b {
  font: 800 17px/1 var(--font-display);
  letter-spacing: -0.01em;
  color: var(--ink);
}
html.tp .tpDockBar__tabs button svg {
  width: 21px;
  height: 21px;
}
html.tp .tpDockBar__tabs button[aria-pressed="true"] {
  background: var(--accent-wash);
  color: var(--accent-strong);
}
html.tp .tpDockBar__tabs button[aria-pressed="true"] b {
  color: var(--accent-strong);
}
html.tp .tpDockBar__tabs button:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ---------- ?trip=cards: swipeable cards ---------- */
html.tp .tpCardsWrap {
  position: absolute;
  z-index: 1100;
  left: 0;
  right: 0;
  bottom: calc(6px + env(safe-area-inset-bottom, 0px));
}
html.tp .tpCardsWrap[hidden] {
  display: none;
}
html.tp .tpTrack {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding: 0 16px;
  padding: 6px 16px 4px;
  scrollbar-width: none;
}
html.tp .tpTrack::-webkit-scrollbar {
  display: none;
}
html.tp .tpCard {
  position: relative;
  flex: 0 0 calc(100% - 56px);
  max-width: 340px;
  min-height: 118px;
  box-sizing: border-box;
  scroll-snap-align: start;
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow-2);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
html.tp .tpCard__top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -4px -8px 0 0;
}
html.tp .tpTime {
  font: 800 28px/1 var(--font-display);
  letter-spacing: -0.02em;
}
html.tp .tpDist {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-quiet);
  align-self: flex-end;
  padding-bottom: 6px;
}
html.tp .tpGrow {
  flex: 1 1 auto;
}
html.tp .tpBar {
  display: flex;
  gap: 2px;
  height: 7px;
}
html.tp .tpBar span {
  display: block;
  border-radius: var(--pill);
}
html.tp .tpFacts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  color: var(--ink-soft);
}
html.tp .tpLink {
  border: 0;
  background: none;
  padding: 0;
  font: 600 13.5px var(--font-text);
  color: var(--accent);
  cursor: pointer;
}
html.tp .tpStepNo {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-quiet);
}
html.tp .tpStepName {
  font-size: 16px;
  line-height: 1.3;
  padding-right: 36px;
}
html.tp .tpStepMeta {
  font-size: 13px;
}
html.tp .tpStepSv {
  position: absolute;
  right: 8px;
  top: 8px;
}
html.tp .tpDots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding-top: 6px;
  min-height: 8px;
}
html.tp .tpDots span {
  width: 6px;
  height: 6px;
  border-radius: var(--pill);
  background: rgba(23, 27, 28, 0.28);
  transition: width 0.2s var(--ease-out);
}
html.tp .tpDots span.on {
  width: 18px;
  background: var(--ink);
}
html.tp .tpDots .tpDots__count {
  width: auto;
  height: auto;
  padding: 2px 8px;
  background: rgba(23, 27, 28, 0.6);
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
}

/* ---------- desktop: bottom left, card width ---------- */
@media (min-width: 901px) {
  html.tp .tpDockBar {
    left: 16px;
    right: auto;
    bottom: 16px;
    width: 392px;
    box-shadow: var(--shadow-2);
  }
  html.tp .tpSheet {
    left: 16px;
    right: auto;
    width: 392px;
    margin: 0;
    bottom: calc(16px + var(--tp-base, 0px) + 8px);
  }
  html.tpDock .tpSheet {
    bottom: calc(16px + var(--tp-base, 0px));
    box-shadow: var(--shadow-2);
  }
  html.tp .tpCardsWrap {
    left: 0;
    right: auto;
    width: 440px;
    bottom: 10px;
  }
  html.tp .tpCard {
    flex-basis: 340px;
  }
  html.mf.tp .mfFeedback {
    bottom: calc(16px + var(--tp-lift, 0px));
  }
}

@media (prefers-reduced-motion: reduce) {
  html.tp .tpDots span {
    transition: none;
  }
  html.tp .tpTrack {
    scroll-behavior: auto;
  }
}
