/* movement-history.css — page chrome for the Movement Tracker, plus the theme bridge to the engine.
 *
 * Ported from the approved production bundle (movement-history.html in files.zip). The bundle
 * shipped its own light/dark palette in --mh-* variables; here those same variables are DERIVED
 * from the console's existing tokens, so the page follows the product's light/dark automatically
 * and never carries a second palette that can drift from the rest of the console.
 *
 * The replay engine injects its own stylesheet (<style id="vx-replay-css">), and every one of its
 * rules is scoped to `.vx-replay` — it cannot repaint the console. It reads eight `--vx-*` custom
 * properties for theming, mapped below.
 *
 * --vx-accent maps to --brand (indigo), NOT --accent: in this console --accent is the amber
 * warning colour, so using it would paint the selected person and the timeline scrubber amber.
 *
 * Everything here is scoped to `.mh-app`. Nothing in this file selects a bare element, :root, *
 * or html/body — a page stylesheet in a shared console must never reach outside its own page.
 */

.mh-app {
  /* engine theme bridge */
  --vx-font: inherit;
  --vx-ink: var(--ink);
  --vx-ink-2: var(--muted);
  --vx-line: var(--line);
  --vx-surface: var(--panel);
  --vx-surface-2: var(--panel-2);
  --vx-accent: var(--brand);
  --vx-radius: var(--r-sm, 11px);

  /* bundle chrome tokens, derived from the console's own tokens */
  --mh-card: var(--panel);
  --mh-border: var(--line);
  --mh-muted: var(--muted);
  --mh-hover: var(--panel-2);
  --mh-soft: var(--panel-2);
  --mh-accent-soft: color-mix(in srgb, var(--brand) 10%, var(--panel));
  --mh-shadow: 0 8px 30px rgba(16, 24, 40, .06);
  --mh-shadow-2: 0 4px 14px rgba(16, 24, 40, .08);

  display: flex;
  flex-direction: column;
  min-width: 0;                       /* containment: never let the canvas force page overflow */
  min-height: 0;
}

/* ---- mode bar ------------------------------------------------------------------------------ */
.mh-app .mh-modebar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
  min-width: 0;
}
.mh-app .mh-segment {
  display: inline-flex;
  background: var(--mh-soft);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.mh-app .mh-segment button {
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
.mh-app .mh-segment button.is-active {
  background: var(--panel);
  box-shadow: 0 1px 4px rgba(16, 24, 40, .12);
  outline: 1px solid color-mix(in srgb, var(--brand) 55%, transparent);
}
.mh-app .mh-dot { color: var(--brand) }
.mh-app .mh-dot2 { letter-spacing: -2px }

.mh-app .mh-person-chip {
  min-width: 260px;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 11px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  min-width: 0;
}
.mh-app .mh-person-main { min-width: 0; flex: 1 }
.mh-app .mh-person-main b {
  display: block;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mh-app .mh-person-main span { font-size: 11.5px; color: var(--muted) }
.mh-app .mh-chip-x {
  border: 0; background: transparent; color: var(--ink);
  font-size: 21px; line-height: 1; cursor: pointer; padding: 0 2px;
}

.mh-app .mh-head-actions {
  display: flex; gap: 8px; align-items: center; margin-left: auto; flex-wrap: wrap; min-width: 0;
}
.mh-app .mh-control {
  height: 40px; display: flex; align-items: center; gap: 8px; padding: 0 12px;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px;
  font: inherit; font-size: 13px; cursor: pointer;
}
.mh-app .mh-control--static { cursor: default }
.mh-app .mh-control strong { font-weight: 600 }
.mh-app .mh-ctl-ico { font-size: 14px; opacity: .75 }
.mh-app .mh-date {
  background: transparent; color: var(--ink); border: 0; font: inherit; font-size: 13px; padding: 0;
}

/* ---- main split ---------------------------------------------------------------------------- */
/* The map is the dominant surface and must stay so. Height is viewport-derived with a floor: a
   fixed px height leaves the time navigator off-screen on a short landscape phone. */
.mh-app .mh-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 12px;
  height: clamp(360px, calc(100dvh - 232px), 1000px);
  min-height: 0;
}
.mh-app .mh-map {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  overflow: hidden;                   /* the plan pans inside its own box, never the page */
  min-width: 0;
}
.mh-app #mhStage { position: absolute; inset: 0 }

.mh-app .mh-float {
  position: absolute; z-index: 3;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--mh-shadow-2);
}
.mh-app .mh-floors { left: 12px; top: 12px; display: flex; overflow: hidden }
.mh-app .mh-floors button {
  border: 0; background: none; padding: 8px 12px; display: flex; gap: 8px; align-items: center;
  color: var(--ink); font: inherit; font-weight: 600; font-size: 12.5px; cursor: pointer;
}
.mh-app .mh-floors button + button { border-left: 1px solid var(--line) }
.mh-app .mh-floors button.is-active {
  background: color-mix(in srgb, var(--brand) 12%, var(--panel));
  color: var(--brand);
}
.mh-app .mh-floors i {
  font-style: normal; font-size: 11px; min-width: 20px; text-align: center;
  border-radius: 9px; padding: 1px 6px; background: color-mix(in srgb, var(--ink) 9%, transparent);
}
.mh-app .mh-floors button.is-active i { background: var(--brand); color: #fff }

.mh-app .mh-mapctl { right: 12px; top: 12px; display: flex; gap: 4px; padding: 5px }
.mh-app .mh-mapctl button {
  border: 0; background: transparent; border-radius: 7px; padding: 6px 10px;
  font: inherit; font-weight: 600; font-size: 12.5px; color: var(--ink); cursor: pointer;
}
.mh-app .mh-mapctl button.is-active { background: var(--ink); color: var(--panel) }

.mh-app .mh-follow {
  left: 12px; bottom: 12px; padding: 7px 11px; font-size: 12px;
  color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, var(--panel));
  transition: opacity .25s; opacity: 0; pointer-events: none;
}
.mh-app .mh-follow.is-on { opacity: 1 }
.mh-app .mh-mapstatus { right: 12px; bottom: 12px; padding: 6px 10px; font-size: 12px; color: var(--muted) }

.mh-app .mh-empty {
  display: flex; align-items: center; justify-content: center; height: 100%;
  padding: 24px; text-align: center; color: var(--muted); font-size: 13px;
}

/* ---- popover menus ------------------------------------------------------------------------- */
.mh-app .mh-menu {
  position: absolute; z-index: 20; min-width: 220px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 34px rgba(16, 24, 40, .18); padding: 6px;
}
.mh-app .mh-menu--sm { min-width: 200px }
.mh-app .mh-mapctl .mh-menu { right: 0; top: calc(100% + 8px) }
.mh-app .mh-menu label,
.mh-app .mh-menu button.mh-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px;
  border: 0; background: none; border-radius: 7px; text-align: left;
  font: inherit; font-size: 13px; color: var(--ink); cursor: pointer;
}
.mh-app .mh-menu label:hover,
.mh-app .mh-menu button.mh-item:hover { background: var(--mh-hover) }
.mh-app .mh-menu input[type=checkbox],
.mh-app .mh-menu input[type=radio] { accent-color: var(--brand); margin: 0 }
.mh-app .mh-menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px }
.mh-app .mh-menu .mh-menu-h {
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px 4px;
}
.mh-app .mh-menu .mh-rangelbl { display: block }
.mh-app .mh-menu input[type=range] { width: 100%; accent-color: var(--brand) }
.mh-app .mh-menu .mh-row { display: flex; gap: 6px; padding: 4px 10px 6px }
.mh-app .mh-menu .mh-row button {
  flex: 1; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 7px; padding: 6px; font: inherit; font-size: 12px; cursor: pointer;
}

/* ---- side panel ---------------------------------------------------------------------------- */
.mh-app .mh-side {
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel);
  overflow: hidden; display: flex; flex-direction: column; min-height: 0; min-width: 0;
}
.mh-app .mh-pane { display: flex; flex-direction: column; min-height: 0; flex: 1 }
.mh-app .mh-side-head { padding: 16px 16px 0; border-bottom: 1px solid var(--line) }
.mh-app .mh-profile { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center }
.mh-app .mh-profile-id { min-width: 0 }
.mh-app .mh-profile h2 {
  margin: 0; font-size: 19px; letter-spacing: -.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mh-app .mh-profile p {
  margin: 3px 0 0; color: var(--muted); font-size: 12.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mh-app .mh-more {
  border: 0; background: transparent; font-size: 20px; color: var(--ink);
  cursor: pointer; width: 32px; height: 32px; border-radius: 8px;
}
.mh-app .mh-more:hover { background: var(--panel-2) }
.mh-app .mh-tabs { display: flex; gap: 22px; margin-top: 14px }
.mh-app .mh-tabs button {
  position: relative; border: 0; background: transparent; padding: 0 0 10px;
  color: var(--muted); font: inherit; font-weight: 600; cursor: pointer;
}
.mh-app .mh-tabs button.is-active { color: var(--brand) }
.mh-app .mh-tabs button.is-active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px;
  border-radius: 3px; background: var(--brand);
}

.mh-app .mh-overview { padding: 14px 16px 0 }
.mh-app .mh-metrics { display: grid; grid-template-columns: repeat(4, 1fr) }
.mh-app .mh-metric { padding: 2px 8px; border-right: 1px solid var(--line); min-width: 0 }
.mh-app .mh-metric:first-child { padding-left: 0 }
.mh-app .mh-metric:last-child { border-right: 0 }
.mh-app .mh-metric b { display: block; font-size: 16px; font-variant-numeric: tabular-nums }
.mh-app .mh-metric span { font-size: 10.5px; color: var(--muted) }

.mh-app .mh-current {
  margin: 14px 0; padding: 12px; border-radius: 10px;
  background: var(--mh-accent-soft); display: flex; gap: 10px; align-items: center;
}
.mh-app .mh-pin {
  width: 32px; height: 32px; border-radius: 50%;
  background: color-mix(in srgb, var(--brand) 16%, var(--panel));
  color: var(--brand); display: grid; place-items: center; font-size: 17px; flex: none;
}
.mh-app .mh-current small { display: block; color: var(--muted); font-size: 11.5px }
.mh-app .mh-current b { display: block; font-size: 16px; margin: 1px 0 }
/* REPLAY is playback state, not dwell. It sits on its own line, dimmer and smaller than the two
   authoritative numbers above it, so the eye never groups it with them. */
.mh-app .mh-replayline {
  display: block; margin-top: 3px; font-size: 11px; color: var(--muted); opacity: .8;
  font-variant-numeric: tabular-nums;
}

.mh-app .mh-journey-title {
  padding: 0 16px 8px; display: flex; justify-content: space-between; align-items: center;
  font-weight: 700; font-size: 13px;
}
.mh-app .mh-journey-title .mh-jt { font-size: 13px; font-weight: 700 }
.mh-app .mh-journey-title span:last-child { font-size: 12px; color: var(--muted); font-weight: 500 }
.mh-app .mh-journey { padding: 0 10px 16px; overflow: auto; flex: 1; min-height: 0 }
.mh-app .mh-jrow {
  position: relative; display: grid; grid-template-columns: 46px 16px minmax(0, 1fr) auto;
  gap: 8px; align-items: start; padding: 8px 4px; border-radius: 8px;
  border: 0; background: none; width: 100%; text-align: left; font: inherit; cursor: pointer;
}
.mh-app .mh-jrow:hover { background: var(--mh-hover) }
.mh-app .mh-jtime { font-size: 12px; color: var(--muted); padding-top: 2px; font-variant-numeric: tabular-nums }
.mh-app .mh-node {
  position: relative; width: 11px; height: 11px; border-radius: 50%;
  background: var(--muted); margin-top: 3px;
}
.mh-app .mh-jrow:not(:last-child) .mh-node::after {
  content: ""; position: absolute; left: 4.5px; top: 11px; width: 2px; height: 34px;
  background: var(--line);
}
.mh-app .mh-jrow.is-active { background: var(--mh-accent-soft) }
.mh-app .mh-jrow.is-active .mh-node { background: var(--brand) }
.mh-app .mh-jrow.is-floor { cursor: default; padding: 2px 4px }
.mh-app .mh-jrow.is-floor .mh-node { width: 8px; height: 8px; margin: 5px 2px 0 }
.mh-app .mh-jrow.is-floor .mh-jname { font-size: 12px; color: var(--muted); font-weight: 500; padding-top: 2px }
.mh-app .mh-jname { font-size: 13px; font-weight: 650; min-width: 0 }
.mh-app .mh-jname span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.mh-app .mh-jname small { display: block; color: var(--muted); font-weight: 500; margin-top: 2px }
.mh-app .mh-jdur {
  font-size: 12px; color: var(--muted); padding-top: 2px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

.mh-app .mh-all-summary { padding: 16px 16px 0 }
.mh-app .mh-all-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px }
.mh-app .mh-statcard { border: 1px solid var(--line); border-radius: 10px; padding: 10px }
.mh-app .mh-statcard b { display: block; font-size: 19px; font-variant-numeric: tabular-nums }
.mh-app .mh-statcard span { font-size: 10.5px; color: var(--muted) }
.mh-app .mh-search {
  margin: 12px 0 4px; height: 36px; width: 100%;
  border: 1px solid var(--line); border-radius: 9px; padding: 0 11px;
  background: var(--panel); color: var(--ink); font: inherit; font-size: 13px;
}
.mh-app .mh-people-list { overflow: auto; flex: 1; min-height: 0; padding: 0 16px 12px }
.mh-app .mh-prow {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 8px 4px; border: 0; border-bottom: 1px solid var(--line);
  background: none; width: 100%; text-align: left; font: inherit; cursor: pointer;
}
.mh-app .mh-prow:hover { background: var(--mh-hover) }
.mh-app .mh-prow-id { min-width: 0 }
.mh-app .mh-prow b { font-size: 12.5px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.mh-app .mh-prow span { display: block; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.mh-app .mh-pstay { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap }
.mh-app .mh-prow.is-away { opacity: .6 }

/* ---- person imagery -------------------------------------------------------------------------
   The product standard is ONE passport frame everywhere: 7:9 portrait, object-fit: cover, with the
   approved glyph or initials in the SAME frame when there is no retained crop. The frame never
   changes size between those states, so a missing or expired image cannot reflow a row. */
.mh-app .mh-avatar,
.mh-app .mh-profile-avatar {
  border-radius: 6px; overflow: hidden; display: grid; place-items: center;
  background: var(--panel-2); color: var(--muted);
  font-weight: 700; flex: none; padding: 0;
}
.mh-app .mh-avatar { width: 30px; height: 38px; font-size: 11px }          /* 7:9 */
.mh-app .mh-profile-avatar { width: 44px; height: 56px; font-size: 14px }  /* 7:9, larger */
.mh-app .mh-avatar img,
.mh-app .mh-profile-avatar img {
  width: 100%; height: 100%; object-fit: cover; display: block;             /* never stretch */
}
.mh-app .mh-avatar.is-unlinked,
.mh-app .mh-profile-avatar.is-unlinked { border: 1.5px dashed var(--line) }
.mh-app .mh-profile-avatar--all { background: var(--panel-2); font-size: 12px }
/* The engine desaturates a person who is currently away; keep that signal on photos. */
.mh-app .mh-prow.is-away .mh-avatar { filter: saturate(0) }

/* ---- bottom time navigator ------------------------------------------------------------------ */
.mh-app .mh-nav {
  margin-top: 12px;
  display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto auto;
  gap: 12px; align-items: center; padding: 10px 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
}
.mh-app .mh-transport { display: flex; align-items: center; gap: 6px }
.mh-app .mh-transport button {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 50%; width: 36px; height: 36px; display: grid; place-items: center;
  padding: 0; cursor: pointer;
}
.mh-app .mh-transport button svg { width: 15px; height: 15px; fill: currentColor }
.mh-app .mh-play {
  width: 46px !important; height: 46px !important;
  background: var(--brand) !important; color: #fff !important; border: 0 !important;
}
.mh-app .mh-clock { display: grid; line-height: 1.15; min-width: 10ch }
.mh-app .mh-clock b { font-size: 19px; font-weight: 650; font-variant-numeric: tabular-nums }
.mh-app .mh-clock span { font-size: 11px; color: var(--muted) }
.mh-app #mhTimeline { min-width: 0 }
.mh-app #mhTimeline .vx-replay__timeline {
  height: 56px; background: var(--panel-2); border-radius: 8px;
}
.mh-app .mh-nav-right { display: flex; gap: 8px; align-items: center }
.mh-app .mh-navstatus { font-size: 12px; color: var(--muted); white-space: nowrap }
.mh-app .mh-dd { position: relative }
.mh-app .mh-dd > button {
  height: 36px; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 9px; padding: 0 11px; display: flex; gap: 7px; align-items: center;
  font: inherit; font-weight: 600; font-size: 13px; cursor: pointer;
}
.mh-app .mh-dd > button small { font-weight: 500; color: var(--muted) }
.mh-app .mh-dd .mh-menu { right: 0; bottom: calc(100% + 8px) }
.mh-app .mh-dd--down .mh-menu { bottom: auto; top: calc(100% + 6px) }

.mh-app .mh-statusline {
  margin-top: 8px; font-size: 12px; color: var(--muted);
  min-width: 0; overflow-wrap: anywhere;
}
.mh-app .mh-footnote {
  margin-top: 6px; color: var(--muted); font-size: 11.5px;
  display: flex; justify-content: flex-end; gap: 6px; align-items: center; text-align: right;
}

/* ---- responsive ------------------------------------------------------------------------------
   Tablet and below: the side panel stacks under the map rather than squeezing it, and the time
   navigator wraps so no control drops below the fold. */
@media (max-width: 1100px) {
  .mh-app .mh-main { grid-template-columns: 1fr; height: auto }
  .mh-app .mh-map { height: clamp(360px, 58vh, 620px) }
  .mh-app .mh-side { max-height: 430px }
  .mh-app .mh-nav { grid-template-columns: auto auto minmax(0, 1fr); grid-auto-flow: row }
  .mh-app .mh-nav-right { grid-column: 1 / -1; justify-content: flex-end }
}

@media (max-width: 760px) {
  .mh-app .mh-modebar { flex-direction: column; align-items: stretch }
  .mh-app .mh-person-chip { min-width: 0; width: 100% }
  .mh-app .mh-head-actions { margin-left: 0 }
  .mh-app .mh-head-actions .mh-control { flex: 1 1 auto }
  .mh-app .mh-map { height: clamp(340px, 52vh, 560px) }
  .mh-app .mh-metrics { grid-template-columns: repeat(2, 1fr) }
  .mh-app .mh-metric { border-right: 0; padding: 4px 0 }
}

/* Phone landscape: very little vertical room. Two panes, map dominant, one-line controls — the
   approved landscape layout, not a fallback. */
@media (orientation: landscape) and (max-height: 520px) {
  .mh-app .mh-modebar { flex-wrap: nowrap; overflow-x: auto; gap: 6px }
  .mh-app .mh-modebar > * { flex: 0 0 auto }
  .mh-app .mh-segment button { height: 34px; padding: 0 12px; font-size: 12px }
  .mh-app .mh-person-chip { height: 38px; min-width: 180px }
  .mh-app .mh-control { height: 34px; font-size: 12px }
  .mh-app .mh-main {
    grid-template-columns: minmax(0, 70fr) minmax(0, 30fr);
    height: calc(100dvh - 132px); gap: 8px;
  }
  .mh-app .mh-map { height: 100%; min-height: 0 }
  .mh-app .mh-side { max-height: none; height: 100%; min-height: 0 }
  /* The max-width:1100px rule above wraps the navigator onto two rows; in landscape that pushes
     the speed control below the fold, so it goes back to one row here. */
  .mh-app .mh-nav {
    padding: 6px 9px; gap: 8px;
    grid-template-columns: auto auto minmax(0, 1fr) auto auto; grid-auto-flow: column;
  }
  .mh-app .mh-nav-right { grid-column: auto; justify-content: flex-end }
  .mh-app .mh-clock b { font-size: 15px }
  .mh-app .mh-clock span { display: none }        /* the date is in the header; the time is enough */
  .mh-app .mh-play { width: 38px !important; height: 38px !important }
  .mh-app .mh-transport button { width: 30px; height: 30px }
  .mh-app #mhTimeline .vx-replay__timeline { height: 38px }
  .mh-app .mh-footnote { display: none }        /* the disclaimer is on the desktop/portrait view */
}

/* Touch targets: a coarse pointer needs a bigger hit area than a mouse. */
@media (pointer: coarse) {
  .mh-app .mh-floors button,
  .mh-app .mh-mapctl button { min-height: 38px }
  .mh-app .mh-jrow { padding: 10px 4px }
  .mh-app .mh-prow { padding: 10px 4px }
}
