/* Pipeline chrome and downstream stage results. Depends on tokens.css + base.css. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  /* At the top the header is invisible — one continuous background with the
     page. The glassy fill + hairline only materialize once you scroll. */
  background: transparent;
  border-bottom: 1px solid transparent;
  box-shadow: none;
  transition: background var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease),
    box-shadow var(--dur-2) var(--ease), backdrop-filter var(--dur-2) var(--ease);
}
body.scrolled .topbar {
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(16px) saturate(1.5);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  border-bottom-color: var(--border-soft);
  box-shadow: 0 1px 0 var(--accent-wash), 0 8px 24px -18px var(--accent-glow);
}

.topbar .wrap {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  min-height: 60px;
}

/* Wordmark base. The living treatment (color, paint, motion) is generated
   server-side per page load and consumed via CSS variables in wordmark.css. */
.topbar-logo {
  display: inline-flex;
  align-items: baseline;
  flex: 0 0 auto;
  font-family: var(--font-ui);
  font-size: 17px;
  font-weight: var(--wm-weight, 600);
  letter-spacing: var(--wm-tracking, -0.03em);
  text-decoration: none;
}

.topbar-search {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: var(--s-2);
  margin-left: 10px; /* breathing room after the wordmark — keeps its treatments clear */
  min-width: 0;
}

.topbar-search input {
  flex: 1 1 auto;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: var(--t-body);
  padding: var(--s-3) var(--s-5);
}

.topbar-search input::placeholder {
  color: var(--ink-3);
}

.topbar-search input:focus {
  border-color: var(--accent);
}

.topbar-search input:focus-visible {
  outline: none;
}

/* The Re-extract button is clutter until you're actually editing the field. */
.topbar-search button {
  display: none;
}
.topbar-search:focus-within button {
  display: inline-flex;
}

.topbar-search button,
.pipeline-action {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: var(--t-sm);
  font-weight: var(--w-semi);
  padding: var(--s-2) var(--s-3);
  transition: border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
  white-space: nowrap;
}

.topbar-search button:hover,
.pipeline-action:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.pipeline-action:disabled {
  color: var(--ink-3);
  cursor: wait;
}

.pipeline-bar {
  position: sticky;
  top: 60px;
  z-index: 19;
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: background var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease),
    backdrop-filter var(--dur-2) var(--ease);
}
body.scrolled .pipeline-bar {
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-bottom-color: var(--border-soft);
}

.pipeline-bar > .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  min-height: var(--s-12);
}

/* The stages read as one connected rail — nodes joined by a track that fills
   with the brand accent as each stage completes. */
.pipeline-rail {
  display: flex;
  align-items: center;
  gap: 0;
  min-width: 0;
}

.pipeline-stage {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: var(--s-2);
  border: 0;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  font: inherit;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm);
  transition: color var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}

.pipeline-stage:hover { color: var(--ink); background: var(--surface-2); }
.pipeline-stage[aria-current="step"] { color: var(--ink); }
.pipeline-stage[data-status="done"] { color: var(--ink-2); }

/* Connector between stages. Filled (accent) once the stage to its left is done. */
.stage-link {
  flex: 0 0 auto;
  width: var(--s-6);
  height: 2px;
  border-radius: 2px;
  background: var(--border);
  transition: background var(--dur-2) var(--ease);
}
.stage-link.filled { background: var(--accent-line); }

.stage-dot {
  position: relative;
  width: 9px;
  height: 9px;
  border-radius: var(--r-pill);
  background: var(--ink-4);
  transition: background var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}

.stage-dot.none { background: var(--ink-4); }
.stage-dot.active {
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-wash);
}
.stage-dot.done { background: var(--ok); }
.stage-dot.failed { background: var(--err); }

.stage-label {
  font-family: var(--font-mono);
  font-size: var(--t-label);
  font-weight: var(--w-med);
  letter-spacing: 0.02em;
}

/* Right-side global tools (vision / accessibility view). */
.pipeline-tools {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex: 0 0 auto;
}

/* Unified icon toolbar — wear / vision / download / save all share this. */
.tool-control { position: relative; flex: 0 0 auto; }
.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink-2);
  cursor: pointer;
  transition: color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease),
    background var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.tool-btn:hover { color: var(--ink); border-color: var(--accent); transform: translateY(-1px); }
.tool-btn svg { width: 18px; height: 18px; }
/* active view-mode (vision on / wearing the brand) */
.tool-btn.is-active {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-wash);
  box-shadow: 0 0 16px -6px var(--accent-glow);
}
/* saved — the heart fills in */
.tool-btn.is-saved { color: var(--accent); border-color: var(--accent-line); }
.tool-btn.is-saved svg { fill: currentColor; }

.tool-menu {
  position: absolute;
  top: calc(100% + var(--s-2));
  right: 0;
  z-index: 30;
  display: grid;
  gap: 2px;
  min-width: 220px;
  padding: var(--s-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  box-shadow: var(--shadow-3);
}
.tool-menu-item {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: var(--t-label);
  padding: var(--s-2);
  text-align: left;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.tool-menu-item:hover { background: var(--surface-3); color: var(--ink); }
.tool-menu-dot {
  width: 10px; height: 10px; flex: 0 0 auto;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
}
.tool-menu-item[aria-checked="true"] { color: var(--ink); }
.tool-menu-item[aria-checked="true"] .tool-menu-dot { background: var(--accent); border-color: var(--accent); }

.research-results,
.enhance-results {
  display: grid;
  gap: var(--s-4);
}

.research-roles,
.enhance-assets {
  display: grid;
  gap: var(--s-3);
  list-style: none;
}

.research-role,
.enhance-asset {
  display: grid;
  gap: var(--s-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: var(--s-4);
}

.research-role h3,
.enhance-asset h3 {
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--t-sm);
  font-weight: var(--w-semi);
}

.result-meta {
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: var(--t-label);
}

.result-copy {
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: var(--t-data);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.pipeline-note,
.pipeline-error {
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: var(--t-data);
  overflow-wrap: anywhere;
  padding: var(--s-4);
}

.pipeline-note { background: var(--surface); }

.pipeline-error {
  border-color: var(--err);
  background: var(--err-bg);
  color: var(--ink);
}

.result-error {
  color: var(--err);
  font-family: var(--font-mono);
  font-size: var(--t-data);
  overflow-wrap: anywhere;
}

@media (max-width: 720px) {
  .topbar .wrap {
    flex-wrap: wrap;
    min-height: auto;
    padding-top: var(--s-3);
    padding-bottom: var(--s-3);
  }

  .topbar-search {
    order: 3;
    flex-basis: 100%;
  }
}

/* On phones the rail + tools can't share one row — let them wrap, tools right. */
@media (max-width: 620px) {
  .pipeline-bar > .wrap {
    flex-wrap: wrap;
    row-gap: var(--s-2);
    padding-top: var(--s-2);
    padding-bottom: var(--s-2);
    min-height: 0;
  }
  .pipeline-rail { flex-wrap: wrap; }
  .pipeline-tools { margin-left: auto; }
}

@media (max-width: 480px) {
  .pipeline-bar > .wrap { gap: var(--s-1); row-gap: var(--s-2); }

  .pipeline-stage {
    gap: var(--s-1);
    padding: var(--s-2) var(--s-1);
  }

  .stage-label { font-size: var(--t-micro); }
  .tool-btn { width: 32px; height: 32px; }
  .tool-btn svg { width: 17px; height: 17px; }

  .topbar-search button,
  .pipeline-action { padding: var(--s-2); }
}
