/* PosnerTopbar — the hub's posner-topbar glass-bar language, lifted into the
   canon (Lane 1, hub-topbar-port 2026-10-15; reference: the p31ca hub
   `apps/p31ca/src/styles/topbar.css`). Full-width sticky glass bar with named
   slots: brand · absolute-centered center · chip cluster · overflow.

   Token-only (canon no-raw-values contract): every color routes through a
   --p31-* token or a color-mix of one. Length/geometry values follow the canon
   recipe stance (token where a token exists, fixed where the recipe does).

   @scope isolation (posner-namespace-two-models / M1, Wave C P9): the shared
   `.posner-topbar` namespace spans TWO markup models — the hub Astro "acts"
   model (apps/p31ca CanonTopbar: .posner-acts/.posner-utils/.posner-chip) and
   this canon "center/chips/overflow" model. Both render a `.posner-topbar`
   root, so an unscoped rule in one model's CSS can cross-contaminate the
   other. Per the plan this is isolated with the NATIVE mechanism (@scope, no
   rename): every rule below is scoped to `[data-posner-topbar]` — the marker
   the app model's markup carries in every world (React PosnerTopbar, the
   canon-parts spec tree, and the generated capital TopbarChrome) and the hub
   root does NOT carry. The hub-side `@scope (.posner-topbar--hub)` wrap is
   filed (apps/p31ca is a protected target; see
   docs/fix-plans/p31ca-wavec-defect-sweep-2026-10-16.md).

   :scope root rules (Wave 2 lane L-A): `@scope` compiles a plain `.foo`
   selector inside the wrapper to `marker .foo` — an implied descendant
   combinator — and an element is not its own descendant, so a plain
   `.posner-topbar { … }` root rule would never match the scoping root (the
   bar itself). The root rules therefore target `:scope` explicitly. The
   `[data-spoons]` + reduced-motion rules ALSO name the root, so their subject
   is `:scope` (or `:scope *` for the descendant-of-root form); an ancestor
   `[data-spoons='n']` outside the scoping subtree stays legal because `:scope`
   marks the in-subtree element and the ancestor chain may cross the boundary.
   */

@scope ([data-posner-topbar]) {
/* ─── The glass bar ─────────────────────────────────────────────── */
:scope {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--p31-space-2, 8px);
  /* Header-height contract: owned by --p31-header-height (the ratified single
     header token, 4rem); a wired canon token wins via the fallback. */
  height: var(--p31-header-height, var(--p31-topbar-height, 4rem));
  padding: 0 clamp(var(--p31-space-3, 12px), 3vw, var(--p31-space-7, 28px));
  border-bottom: 1px solid var(--p31-glass-border);
  background: color-mix(in oklch, var(--p31-bg, var(--p31-void)) 86%, transparent);
  backdrop-filter: var(--p31-glass-blur) saturate(150%);
  -webkit-backdrop-filter: var(--p31-glass-blur) saturate(150%);
}

/* ─── Brand zone ────────────────────────────────────────────────── */
.posner-topbar__brand-zone {
  display: inline-flex;
  align-items: center;
  gap: var(--p31-space-2, 8px);
  flex-shrink: 0;
}
.posner-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--p31-space-2, 8px);
  padding: var(--p31-space-1, 4px) var(--p31-space-2, 8px);
  border: 0;
  border-radius: var(--p31-radius-candy);
  background: none;
  cursor: pointer;
  color: var(--p31-text);
  font-family: inherit;
  flex-shrink: 0;
}
.posner-brand:hover { background: var(--p31-accent-soft); }
.posner-brand__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--p31-radius-md, 12px);
  background: var(--p31-accent);
  color: var(--p31-void);
  font-weight: 800;
  font-size: 13px;
}
.posner-brand__name {
  font-weight: 700;
  font-size: clamp(0.88rem, 1.2vw + 0.4rem, 1rem);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
@media (max-width: 640px) { .posner-brand__name { display: none; } }
.posner-theme-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  /* SSR-safe: reads --p31-theme-dot (set by the shell's theme prefs + the
     brand-click handler); fallback to the live accent token. */
  background: var(--p31-theme-dot, var(--p31-accent));
}

/* ─── Center slot — ABSOLUTE on the bar's geometric midpoint ───── */
.posner-topbar__center {
  /* Screen-center, not flex-center: absolutely positioned on the bar's
     horizontal midpoint, independent of the side zones' widths. The fluid
     width keeps the slot clear of the trailing cluster at every width. */
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--p31-space-2, 8px);
  min-width: 0;
  width: min(40vw, 560px);
}
/* No room for a wide search beside brand + trailing on phones — hide the
   center (matches the portal's pre-port mobile affordance; the overflow keeps
   every control reachable). */
@media (max-width: 560px) {
  .posner-topbar__center { display: none; }
}

/* ─── SIMPLIFIED MOBILE TOPBAR (duplicated-mobile-topbar-css fix-plan) ───
   The shared ≤768px topbar override every portal used to patch locally (design
   workspace.css, workspace/workspace.css, mcp-marketplace/globals.css,
   monetization/workspace.css — byte-similar copies) now lives HERE: the canon
   owns the responsive behavior, token-only (all geometry, no colors). At ≤768px
   the topbar is brand | FULL-WIDTH search (flex-1) | ONE overflow trigger; the
   chips hide (their controls live inside the overflow menu — ARIA intact) and
   the search stretches between brand and the overflow button — overriding the
   ≤560px center-hide above so the search stays up. The portal sheets keep their
   (identical) copies until the protected-portal removal wave (filed in the Wave
   C summary); this block lands after the 560px rule so the cascade order the
   portals relied on is preserved. */
@media (max-width: 768px) {
  .posner-chips { display: none; }
  .posner-topbar__center {
    position: static;
    transform: none;
    width: auto;
    max-width: none;
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
  }
  .posner-topbar__brand-zone,
  .posner-topbar__trailing { flex-shrink: 0; }
  .search-kbd { display: none; }
}
/* The mobile-only overflow rows (GitHub + identity chips, the Lane-C rows) —
   shown at ≤768px (the hidden chips' controls stay reachable), hidden ≥769px so
   the desktop overflow remains the enterprise-cluster-only menu. */
.posner-overflow__item--mobile { display: none; }
@media (max-width: 768px) {
  .posner-overflow__item--mobile { display: flex; }
}

/* ─── Trailing cluster (chips + overflow) ───────────────────────── */
.posner-topbar__trailing {
  display: inline-flex;
  align-items: center;
  gap: var(--p31-space-2, 8px);
  flex-shrink: 0;
}
.posner-chips { display: inline-flex; align-items: center; gap: var(--p31-space-2, 8px); flex-shrink: 0; }

/* ─── Compact INLINE ACTIONS (compact profile — L1) ────────────────
   The compact topbar's trailing cluster holds the capability controls
   directly (no chips row, no overflow disclosure). Same layout stance as the
   chips cluster; the actions never become an overflow. */
.posner-topbar__actions {
  display: inline-flex;
  align-items: center;
  gap: var(--p31-space-2, 8px);
  flex-shrink: 0;
}
.posner-topbar__action {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

/* ─── Overflow ──────────────────────────────────────────────────── */
.posner-overflow { position: relative; flex-shrink: 0; }
.posner-overflow__trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: var(--p31-space-1, 4px) var(--p31-space-2, 8px);
  border-radius: var(--p31-radius-candy);
  border: 1px solid var(--p31-glass-border);
  background: var(--p31-surface);
  color: var(--p31-text-secondary);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.posner-overflow__trigger:hover {
  border-color: var(--p31-glass-border-strong);
  color: var(--p31-text);
}
.posner-overflow__menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 240px;
  max-width: min(92vw, 320px);
  padding: var(--p31-space-2, 8px);
  background: var(--p31-glass-bg-strong);
  border: 1px solid var(--p31-glass-border);
  border-radius: 16px;
  box-shadow: 0 20px 50px oklch(0% 0 0 / 0.6);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  z-index: 2100;
  display: flex;
  flex-direction: column;
  gap: var(--p31-space-1, 4px);
}
/* Invisible bridge across the 10px gap between trigger and menu — the
   pointer stays "inside" while crossing, so the menu doesn't close mid-move. */
.posner-overflow__menu::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 0;
  right: 0;
  height: 10px;
}
/* Menu row — the overflow slot's controls render as full-width rows. */
.posner-overflow__item {
  display: flex;
  align-items: center;
  gap: var(--p31-space-2, 8px);
  width: 100%;
  min-height: 38px;
  padding: var(--p31-space-1, 4px) var(--p31-space-3, 12px);
  border: 0;
  border-radius: var(--p31-radius-md, 12px);
  background: none;
  color: var(--p31-text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  transition: background 0.12s ease;
}
.posner-overflow__item:hover { background: var(--p31-surface2); }

/* Sensory-rest at spoons 0/1 REDUCES the bar — never removes it (the old
   display:none trap made it impossible to restore the topbar). The bar dims
   and loses motion; every control stays reachable. `:scope` (not the class) is
   the subject: the scoping root IS the .posner-topbar element, and the
   [data-spoons] ancestor lives outside the scoping subtree, which the rule may
   cross because the in-subtree element is marked with :scope. */
[data-spoons='0'] :scope,
[data-spoons='1'] :scope {
  opacity: 0.55;
}
[data-spoons='0'] :scope *,
[data-spoons='1'] :scope * {
  transition-duration: 0ms !important;
}
@media (prefers-reduced-motion: reduce) {
  :scope * {
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
  }
  :scope { backdrop-filter: none; -webkit-backdrop-filter: none; }
}
} /* /@scope ([data-posner-topbar]) — the canon app-model chrome is isolated from
     the hub acts model by the native scoping mechanism (no rename). */