/* ViewBrain public visitor profile - shared nav control.
 *
 * Scope: the public surface (home, /analysis hub, /analysis/{slug}, /privacy).
 * It rides the existing Aurora v2 tokens, so it inherits the same navy header,
 * Montserrat type and pill geometry as the rest of the site - no new palette.
 *
 * Mobile: the control sits inside `.nav-links`, which collapses to the primary
 * CTA at 768px. A 32px avatar fits inside that row (the row is padding-size +
 * the CTA's line box) so the header height and logo stay exactly as they are
 * and nothing can overflow the viewport.
 */

.vb-profile {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  margin-left: var(--space-4);
}
/* The `hidden` presentation hint, honoured explicitly: the rule above would
   otherwise win over the UA stylesheet (an author `display` beats it), so a
   hidden control would still paint. Sign-in is hidden while it is unconfigured. */
.vb-profile[hidden] { display: none; }

/* Until the session is verified, the control keeps its space but stays quiet. */
.vb-profile.vb-checking .vb-avatar-btn { opacity: 0.55; }

.vb-avatar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 34px;
  height: 34px;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface-overlay);
  color: var(--color-text-primary);
  font-family: var(--font-main);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.vb-avatar-btn:hover { border-color: var(--color-border-teal); transform: none; }
.vb-avatar-btn:active { transform: scale(0.97); }
.vb-avatar-btn:focus-visible { outline: 2px solid var(--color-teal); outline-offset: 2px; }

.vb-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}
/* The picture, when one is allowlisted, replaces the initial. */
.vb-profile.vb-signed-in .vb-avatar-img[src] { display: block; }
.vb-profile[data-has-picture="true"] .vb-avatar-img[src] { display: block; }
.vb-avatar-initial { display: inline-block; }
.vb-profile[data-has-picture="true"] .vb-avatar-initial { display: none; }

/* Signed out the control is the compact "Sign in" CTA, not a blank circle. */
.vb-profile.vb-signed-out .vb-avatar-btn {
  width: auto;
  height: auto;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-overlay);
  border-color: var(--color-border);
}
.vb-profile.vb-signed-out .vb-avatar-btn::after {
  content: "Sign in";
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.vb-profile.vb-signed-out .vb-avatar-img { display: none; }
/* The initial is a fallback for a signed-in visitor only: while signed out the
   control reads "Sign in" and carries no letter. */
.vb-profile.vb-signed-out .vb-avatar-initial { display: none; }
.vb-profile.vb-checking .vb-avatar-btn::after { content: ""; }

/* Private dropdown */
.vb-menu {
  position: absolute;
  top: calc(100% + var(--space-3));
  right: 0;
  z-index: 70;
  min-width: 232px;
  max-width: min(86vw, 320px);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4);
  text-align: left;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  background: rgba(14, 17, 34, 0.98);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-lg);
}
.vb-menu[hidden] { display: none; }

.vb-menu-avatar {
  width: 44px;
  height: 44px;
  margin-bottom: var(--space-2);
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--color-border);
  background: var(--color-surface-overlay);
}
.vb-menu-avatar:not([src]) { display: none; }
.vb-menu-avatar[alt] { }
.vb-name {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--color-text-primary);
  overflow-wrap: anywhere;
}
.vb-email {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--color-text-muted);
  overflow-wrap: anywhere;
}
.vb-email[hidden], .vb-signout[hidden] { display: none; }
.vb-signout {
  margin-top: var(--space-3);
  padding: 9px 18px;
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-primary);
  background: var(--color-surface-overlay);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  transition: all 0.15s ease;
}
.vb-signout:hover { border-color: var(--color-crimson); color: var(--color-crimson-light); }
.vb-signout:active { transform: scale(0.97); }

.vb-mount:empty { display: none; }
.vb-mount { margin-top: var(--space-3); }
.vb-mount-box { display: block; }

.vb-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  width: 100%;
  padding: 10px 18px;
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-text-primary);
  background: var(--gradient-passion);
  border: 0;
  border-radius: var(--radius-pill);
  transition: all 0.15s ease;
}
.vb-cta:hover { filter: brightness(1.08); }
.vb-cta:active { transform: scale(0.97); }

/* A disabled control must not respond to hover or press at all - leaving the
   lift in place would advertise a button that does nothing. Sign-in is a
   coming-soon placeholder, so this is its normal state, not an error state:
   muted surface, muted label, and `not-allowed` rather than a pointing hand.
   The `:disabled` selectors outrank the plain `.vb-cta` rules above, so no
   `!important` is needed. */
.vb-cta:disabled {
  background: var(--color-surface-overlay);
  color: var(--color-text-muted);
  cursor: not-allowed;
}
.vb-cta:disabled:hover { filter: none; }
.vb-cta:disabled:active { transform: none; }

.vb-note {
  margin-top: var(--space-3);
  font-size: 0.74rem;
  line-height: 1.5;
  color: var(--color-text-muted);
}
.vb-note:empty { display: none; }

@media (max-width: 768px) {
  .vb-profile { margin-left: var(--space-2); }
  .vb-menu {
    /* Right-anchored under the control, never wider than the viewport. */
    right: 0;
    min-width: min(78vw, 240px);
  }
  .vb-profile.vb-signed-out .vb-avatar-btn { padding: 8px 12px; }
  .vb-profile.vb-signed-out .vb-avatar-btn::after { font-size: 0.66rem; }
  .vb-avatar-btn { width: 32px; height: 32px; }
}
