/* =============================================================================
 * we-header.css — SINGLE SHARED HEADER for every page in Walkthrough Engine.
 *
 * Used by: index.html, dashboard.html, capture-stops.html, authoring.html,
 * viewer.html, account.html
 *
 * RULE: anything that appears on more than one page MUST live here, not in a
 * page's inline <style>. Pages may add their OWN unique controls to .tb-right
 * (e.g. Export on /authoring, mode-toggle on /viewer) but they must NEVER
 * override the shared sizes / paddings / colors below.
 *
 * Required HTML structure on every page:
 *
 *   <header class="topbar">
 *     <div class="tb-left">
 *       <a href="/" class="brand">
 *         <span class="mark"><svg><use href="#i-spark"/></svg></span>
 *         <span class="name">Walkthrough Engine</span>
 *       </a>
 *     </div>
 *     <nav class="tb-mid primary-nav">
 *       <a href="/dashboard"      class="nav-link"><svg><use href="#i-grid"/></svg>Dashboard</a>
 *       <a href="/capture-stops"  class="nav-link"><svg><use href="#i-camera"/></svg>Capture</a>
 *       <a href="/authoring"      class="nav-link"><svg><use href="#i-edit"/></svg>Edit</a>
 *       <a href="/viewer"         class="nav-link"><svg><use href="#i-eye"/></svg>Tour</a>
 *     </nav>
 *     <div class="tb-right">
 *       <!-- page-specific controls go here, ABOVE theme + user pill -->
 *       <button class="icon-btn" id="btn-theme-toggle" title="Toggle light / dark">
 *         <svg id="theme-icon"><use href="#i-sun"/></svg>
 *       </button>
 *       <div id="user-pill"></div>
 *     </div>
 *   </header>
 * ============================================================================= */

.topbar {
  position: sticky; top: 0;
  height: 64px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 28px;
  background: var(--bg-overlay);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-bottom: 1px solid var(--line);
  z-index: 50;
}
.tb-left  { display: flex; align-items: center; gap: 14px; min-width: 0; justify-self: start; }
.tb-mid   { display: flex; align-items: center; gap: 4px;  justify-self: center; }
.tb-right { display: flex; align-items: center; gap: 6px;  justify-self: end; }

/* ---------- Brand block (left) ---------- */
.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none;
  color: var(--text);
}
.brand .mark {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.brand .mark svg { width: 14px; height: 14px; }
.brand .name {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

/* ---------- Primary nav segmented pill (center) ---------- */
.tb-mid.primary-nav {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 4px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
}
.nav-link {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease;
  white-space: nowrap;
}
.nav-link:hover { color: var(--text); }
.nav-link.active {
  background: var(--bg-surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}
.nav-link svg { width: 13px; height: 13px; flex: 0 0 13px; }

/* ---------- Theme toggle (right block, always present) ---------- */
.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  border: 0;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-elev); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ---------- User pill (right block, always present) ---------- */
#user-pill { display: inline-flex; align-items: center; flex-shrink: 0; }
.user-pill {
  display: inline-flex; align-items: center; gap: 10px;
  height: 36px;
  padding: 0 12px 0 4px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text-2);
  font-size: 12px; font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.user-pill:hover { background: var(--bg-surface); border-color: var(--line-strong); color: var(--text); }
.user-pill-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-fg);
  font-size: 11px; font-weight: 600;
  flex-shrink: 0;
}
.user-pill-email {
  max-width: 160px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.user-pill-chev { width: 13px; height: 13px; opacity: 0.7; flex-shrink: 0; }
.user-signin {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 12px; font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.user-signin:hover { background: var(--bg-surface); border-color: var(--line-strong); }
.user-signin svg { width: 14px; height: 14px; }
.user-menu {
  position: fixed;
  min-width: 220px;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  z-index: 200;
  animation: user-menu-in 0.12s ease-out;
}
@keyframes user-menu-in { from { opacity: 0; transform: translateY(-4px);} to { opacity: 1; transform: translateY(0);} }
.user-menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px; font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.1s ease;
}
.user-menu-item:hover { background: var(--bg-elev); }
.user-menu-item svg { width: 16px; height: 16px; color: var(--text-3); flex-shrink: 0; }
.user-menu-item[data-act="signout"]:hover { color: var(--danger); background: var(--danger-soft); }
.user-menu-item[data-act="signout"]:hover svg { color: var(--danger); }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .topbar { padding: 0 16px; }
  .tb-mid.primary-nav { padding: 3px; }
  .nav-link { padding: 0 9px; }
  .nav-link span, .brand .name { font-size: 12px; }
}
@media (max-width: 560px) {
  .topbar { grid-template-columns: 1fr auto; }
  .tb-mid { display: none; }
  .user-pill-email { display: none; }
  .user-pill { padding: 0 8px 0 4px; }
}
