/* Journey Navigation Bar — stage progress indicator styles
   Used by the authenticated app bar (header.app-bar).
   Class schema matches the handoff doc: .stages > .stage[.done|.active]
*/

/* ─── Authenticated app bar ───────────────────────────────────────────────────
   Single bar replacing site-header + journey-nav for signed-in users.
   Layout: [ logo ] [ stages (flex-grow) ] [ account actions ]
   ──────────────────────────────────────────────────────────────────────────── */

.app-bar {
  position: sticky;
  top: 0;
  z-index: var(--bp-z-chrome);
  /* 🚩 REQUIRED, AND ITS ABSENCE IS INVISIBLE UNTIL THE BAR IS FULL. The shell
     makes `body` a grid, so this header is a GRID ITEM — and a grid item's
     `min-width` defaults to `auto`, meaning min-content. The stage row inside
     scrolls (`.stages` is `overflow-x: auto`), but that never got a chance:
     the header refused to shrink below its own min-content, widened the grid
     column past the viewport, and every other row — including the footer —
     stretched to match.
     ⚠️ Measured at 360px while adding the Execution chip (#2089): the header
     came out at 386 against a 360 body, and the failure surfaced as
     `/journey scrolls horizontally` with `.site-footer` as the widest element.
     The footer was innocent. */
  min-width: 0;
  backdrop-filter: saturate(140%) blur(8px);
  background: color-mix(in srgb, var(--bp-paper) 80%, transparent);
  border-bottom: 1px solid var(--bp-rule);
}

.app-bar__inner {
  display: flex;
  align-items: center;
}

/* Logo */
.app-bar .brand {
  flex-shrink: 0;
  padding-right: var(--bp-s-3);
}

/* Stages list — grows to fill available space between logo and account */
.app-bar__stages {
  flex: 1 1 auto;
  min-width: 0;
}

/* Phase label shown in place of the stepper on post-journey surfaces
   (e.g. Search Execution). Occupies the same flexible middle slot. */
.app-bar__phase {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: var(--bp-s-2);
  padding-left: var(--bp-s-4);
}
.app-bar__phase-name {
  font-family: var(--bp-mono-family);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bp-ink-muted);
}
/* On a sub-surface the phase label links back to the dashboard hub. */
a.app-bar__phase-name--link {
  text-decoration: none;
  transition: color var(--bp-dur-fast) var(--bp-easing);
}
a.app-bar__phase-name--link:hover { color: var(--bp-ink); }
a.app-bar__phase-name--link:focus-visible {
  outline: 2px solid var(--bp-accent);
  outline-offset: 2px;
  border-radius: var(--bp-r-sm);
}
.app-bar__phase-sep { color: var(--bp-ink-subtle); font-size: 13px; }
.app-bar__phase-surface {
  font-family: var(--bp-serif-family);
  font-size: 16px;
  font-weight: 500;
  color: var(--bp-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Account actions (Profile, Log out) */
nav.account {
  flex-shrink: 0;
  display: flex;
  align-items: stretch;
}

/* "Log out" is a native form submission rather than a Turbo-driven link
   (#1796) — see the comment on it in shared/_app_bar — so it is a <button>
   that has to read as the link beside it. */
nav.account form {
  display: flex;
  margin: 0;
}

nav.account a,
nav.account button {
  display: flex;
  align-items: center;
  padding: var(--bp-s-2) var(--bp-s-3);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  color: var(--bp-ink-muted);
  text-decoration: none;
  background: none;
  border: 0;
  cursor: pointer;
  transition: background var(--bp-dur-fast) var(--bp-easing),
              color var(--bp-dur-fast) var(--bp-easing);
}

nav.account a:hover,
nav.account button:hover {
  background: color-mix(in srgb, var(--bp-ink) 5%, transparent);
  color: var(--bp-ink);
}

nav.account a:focus-visible,
nav.account button:focus-visible {
  outline: 2px solid var(--bp-accent);
  outline-offset: -2px;
}

/* Medium viewports: collapse stage names to badge-only.
   Names stay in the DOM so screen readers still have labels (badge is aria-hidden). */
@media (max-width: 1024px) {
  .app-bar__stages .stage > a > span:last-child,
  .app-bar__stages .stage > span > span:last-child {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .app-bar__stages .stage {
    flex: 1 1 0;
  }

  .app-bar__stages .stage > a,
  .app-bar__stages .stage > span {
    justify-content: center;
    padding: var(--bp-s-2) var(--bp-s-1);
  }

  .app-bar__stages .stages {
    overflow-x: visible;
  }
}

@media (max-width: 640px) {
  .app-bar .brand {
    padding-right: var(--bp-s-1);
  }

  /* 🚩 THE ROW SCROLLS AGAIN AT PHONE WIDTH, AND #2089 IS WHY IT HAS TO.
     The 1024px tier above turns scrolling OFF (`overflow-x: visible`) and
     distributes the chips with `flex: 1 1 0` instead. That fits SIX badges at
     360px with about 3px to spare — measured — because a badge cannot shrink
     below its own min-content. The seventh chip (the Execution phase) has
     nowhere to go, so it pushes `header.app-bar` to 386px, the body grid widens
     to match, and the whole page scrolls horizontally.

     ⚠️ It surfaced as a FOOTER failure — `support_intake_test`'s "the control is
     a real hit target at phone width" reported `/journey scrolls horizontally at
     360px`, and the widest element measured was `.site-footer`. The footer was
     innocent: it is a body-grid row stretched to a column the app bar had
     widened. The first element over the line is the one to fix.

     📌 Scrolling is the sanctioned behaviour, not a workaround — the Handoff's
     principle 9 says the journey row scrolls horizontally and never wraps. */
  .app-bar__stages .stages {
    overflow-x: auto;
  }

  .app-bar__stages .stage {
    flex: 0 0 auto;
  }

  nav.account a,
  nav.account button {
    padding: var(--bp-s-2) var(--bp-s-2);
  }
}

/* ─── Stage list ─────────────────────────────────────────────────────────────── */

.stages {
  display: flex;
  align-items: stretch;
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  gap: 0;
}

.stages::-webkit-scrollbar {
  display: none;
}

/* Each stage item */
.stage {
  flex: 0 0 auto;
  position: relative;
}

/* Divider between stages */
.stage + .stage::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 1px;
  height: 60%;
  background: var(--bp-rule-soft);
}

/* Inner content — both <a> and <span> share layout */
.stage > a,
.stage > span {
  display: flex;
  align-items: center;
  gap: var(--bp-s-2);
  padding: var(--bp-s-2) var(--bp-s-3);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  color: var(--bp-ink-muted);
  transition: background var(--bp-dur-fast) var(--bp-easing),
              color var(--bp-dur-fast) var(--bp-easing);
}

.stage > a:hover {
  background: color-mix(in srgb, var(--bp-ink) 5%, transparent);
  color: inherit;
  text-decoration: none;
}

/* ─── The phase change: preparation ends, execution begins (#2089) ──────────
   The six stages are numbered and completable; Search Execution is neither. It
   sits in the same bar because the bar's job is the SHAPE of the work — a
   tester read six chips as the whole program — but it must not read as a
   seventh stage.

   🚩 `.stage + .stage--phase::before`, not `.stage--phase::before`: the base
   divider rule is `.stage + .stage::before` (two classes), so a single-class
   override loses on specificity and the heavier rule silently never applies. */
.stage + .stage--phase::before {
  background: var(--bp-rule);
  width: 2px;
  height: 100%;
}

/* Square and dashed where a stage's badge is a filled circle. That contrast is
   the requirement of #2089, not decoration. */
.stage--phase .num {
  border-radius: var(--bp-r-sm);
  border: 1px dashed var(--bp-rule);
  background: transparent;
}

/* Number / checkmark badge */
.stage .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--bp-mono-family);
  flex-shrink: 0;
  background: var(--bp-surface-2);
  color: var(--bp-ink-muted);
}

/* In progress — active */
.stage.active > a,
.stage.active > span {
  color: var(--bp-accent);
}

.stage.active .num {
  background: var(--bp-accent);
  color: var(--bp-accent-ink);
}

.stage.active > a > span:last-child,
.stage.active > span > span:last-child {
  font-weight: 600;
}

/* Complete — done */
.stage.done > a,
.stage.done > span {
  color: var(--bp-success);
}

.stage.done .num {
  background: var(--bp-success);
  color: var(--bp-accent-ink);
}

/* Focus ring */
.stage > a:focus-visible {
  outline: 2px solid var(--bp-accent);
  outline-offset: -2px;
}
