/* ============================================================
   FluxGeko account menu — presentation only
   Scope: .fg-account* (safe inside .fg-nav-right, .gfx-nav-right,
   and .topbar-right without touching global redesign styles).
   Tokens come from redesign/tokens.css first and fall back to the
   existing app-styles palette when tokens.css is not present.
   ============================================================ */

.fg-account,
.fg-account *,
.fg-account *::before,
.fg-account *::after {
  box-sizing: border-box;
}

.fg-account {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  min-width: 0;
  font-family: var(--font-sans, var(--sans, system-ui, -apple-system, 'Segoe UI', sans-serif));
  line-height: 1;
  color: var(--text-2, var(--dim-hi, #8fa3c0));
}

/* ---------- trigger ---------- */
.fg-account-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.13));
  border-radius: var(--r-2, 8px);
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: var(--fs-sm, 13px);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.fg-account-trigger:hover,
.fg-account-trigger[aria-expanded='true'] {
  background: var(--surface-2, var(--bg-2, #10131b));
  color: var(--text, var(--ink, #eaecEF));
}

.fg-account-trigger:focus-visible {
  outline: none;
  box-shadow: var(--ring, 0 0 0 2px rgb(72 124 255 / 0.45));
}

/* Sign-in link used by the account header on public pages. Kept in the
   same fg-account* scope so the public header matches the dark UI. */
.fg-account-signin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--r-2, 8px);
  background: transparent;
  color: var(--text-2, var(--dim-hi, #8fa3c0));
  font-size: var(--fs-sm, 13px);
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.fg-account-signin:hover {
  background: var(--surface-2, var(--bg-2, #10131b));
  color: var(--text, var(--ink, #eaecEF));
  text-decoration: none;
}

.fg-account-signin:focus-visible {
  outline: none;
  box-shadow: var(--ring, 0 0 0 2px rgb(72 124 255 / 0.45));
}

/* ---------- decorative avatar ---------- */
.fg-account-avatar {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.13));
  border-radius: 50%;
  background: var(--surface-3, var(--bg-3, #161a25));
  color: var(--text-2, var(--dim-hi, #8fa3c0));
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  text-transform: uppercase;
}

.fg-account-name {
  display: inline-block;
  max-width: 10ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--fs-sm, 13px);
  font-weight: 500;
}

/* Visually hidden "Account" label so the trigger's accessible name is
   "Account Sam" while still showing the compact first name. */
.fg-account-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- chevron ---------- */
.fg-account-chevron {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  color: var(--text-3, var(--dim, #6e80a0));
  transition: transform var(--t-med, 200ms) var(--ease, ease);
}

.fg-account-trigger[aria-expanded='true'] .fg-account-chevron {
  transform: rotate(180deg);
}

/* ---------- popup ---------- */
.fg-account-popup {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 1200;
  width: 248px;
  max-width: calc(100vw - 24px);
  margin: 0;
  padding: 8px;
  background: var(--surface, var(--bg-1, #0a0c12));
  border: 1px solid var(--border, var(--brd, rgba(72, 124, 255, 0.12)));
  border-radius: var(--r-3, 12px);
  box-shadow: var(--shadow-overlay, 0 16px 48px rgba(0, 0, 0, 0.55));
  color: var(--text, var(--ink, #eaecEF));
  font-family: var(--font-sans, var(--sans, system-ui, -apple-system, 'Segoe UI', sans-serif));
}

/* The hidden attribute must win even if a generic display rule appears later. */
.fg-account-popup[hidden],
.fg-account-user[hidden],
.fg-account-user-name[hidden],
.fg-account-user-email[hidden],
.fg-account-error[hidden] {
  display: none !important;
}

/* ---------- user block ---------- */
.fg-account-user {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  margin: 0 0 8px;
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--border, var(--brd, rgba(72, 124, 255, 0.12)));
}

.fg-account-user-name {
  color: var(--text, var(--ink, #eaecEF));
  font-size: var(--fs-md, 14px);
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.fg-account-user-email {
  color: var(--text-2, var(--dim-hi, #8fa3c0));
  font-size: var(--fs-xs, 12px);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

/* ---------- items ---------- */
.fg-account-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fg-account-item {
  display: flex;
  align-items: center;
  box-sizing: border-box;
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--r-2, 8px);
  background: transparent;
  color: var(--text-2, var(--dim-hi, #8fa3c0));
  font: inherit;
  font-size: var(--fs-sm, 13px);
  font-weight: 500;
  line-height: 1.2;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.fg-account-item:hover,
.fg-account-item:focus-visible {
  background: var(--surface-2, var(--bg-2, #10131b));
  color: var(--text, var(--ink, #eaecEF));
  text-decoration: none;
}

.fg-account-item:focus-visible {
  outline: none;
  box-shadow: var(--ring, 0 0 0 2px rgb(72 124 255 / 0.45));
}

.fg-account-item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ---------- inline error ---------- */
.fg-account-error {
  margin: 8px 2px 2px;
  padding: 6px 8px;
  border-radius: var(--r-1, 4px);
  background: var(--down-wash, rgba(246, 70, 93, 0.08));
  color: var(--down, var(--red, #f6465d));
  font-size: var(--fs-xs, 12px);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

/* ---------- mobile touch targets ---------- */
@media (max-width: 640px) {
  .fg-account-trigger,
  .fg-account-signin {
    min-height: 44px;
  }

  .fg-account-trigger {
    padding: 0 12px;
  }

  .fg-account-item {
    min-height: 44px;
  }

  .fg-account-popup {
    top: calc(100% + 6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .fg-account-chevron {
    transition: none;
  }
}

/* Keep landing identity and actions together on one mobile header row. */
@media (max-width: 640px) {
  .topbar--b .topbar-brand { margin-right: 8px; }
  .topbar--b .fg-account-name { display: none; }
  .topbar--b .topbar-right .btn { min-height: 44px; }
}
