/* Account menu — the one control for everything that is about you.
 *
 * Kept in its own file rather than appended to app.css: it is a self-contained
 * component, and app.css is already 1,400 lines of dashboard.
 */

.account { position: relative; margin-left: 8px; }

.account-btn {
  display: flex; align-items: center; gap: 8px;
  height: 30px; padding: 0 8px 0 4px;
  border: 1px solid var(--border); border-radius: 16px;
  background: var(--surface); cursor: pointer;
  font-family: var(--font); font-size: 12px; color: var(--text-muted);
  transition: border-color .15s, color .15s;
  max-width: 230px;
}
.account-btn:hover { border-color: var(--accent); color: var(--text); }
.account-btn[aria-expanded="true"] { border-color: var(--accent); color: var(--text); }

.account-avatar {
  flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%;
  overflow: hidden; display: grid; place-items: center;
  background: var(--accent-dim); color: var(--accent);
  font-family: var(--font); font-size: 10px; font-weight: 700; letter-spacing: .02em;
}
.account-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* The email is identity, not decoration, so it truncates rather than wrapping
   the toolbar onto a second line. */
.account-label {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 150px;
}
.account-caret { font-size: 9px; opacity: .7; }

/* ── the menu ─────────────────────────────────────────────────────────────── */

.account-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 9000;
  min-width: 260px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 6px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .55);
}

.account-who {
  padding: 10px 12px 12px;
  border-bottom: 1px solid var(--border-soft); margin-bottom: 6px;
}
.account-name {
  font-family: var(--font); font-size: 14px; font-weight: 600; color: var(--text);
}
.account-email {
  font-family: var(--mono); font-size: 12px; color: var(--text-muted);
  overflow-wrap: anywhere; margin-top: 2px;
}

.account-group { padding: 4px 0; border-bottom: 1px solid var(--border-soft); }
.account-group:last-child { border-bottom: none; }

.account-item {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  width: 100%; box-sizing: border-box;
  padding: 9px 12px; border: none; border-radius: 8px;
  background: transparent; cursor: pointer; text-align: left;
  text-decoration: none;
  font-family: var(--font); font-size: 14px; color: var(--text);
  transition: background .12s, color .12s;
}
.account-item:hover { background: var(--surface-2); }

/* A hint labels; it never doubles as the control's name. */
.account-hint {
  font-family: var(--font); font-size: 12px; color: var(--text-muted);
  white-space: nowrap;
}

/* Admin is the only entry not everyone sees, so it reads differently. */
.account-item.is-admin { color: var(--warn); }
.account-item.is-admin .account-hint { color: var(--warn); opacity: .75; }

/* Support is an ask, not an action, so it reads warmly rather than loudly. */
.account-item.is-support { color: var(--warn); }
.account-item.is-support .account-hint { color: var(--text-faint); }
.account-item.is-support:hover {
  background: color-mix(in srgb, var(--warn) 10%, transparent);
}

/* Sign out is the one destructive-ish action in here. */
.account-item.is-signout { color: var(--down); }
.account-item.is-signout:hover {
  background: color-mix(in srgb, var(--down) 12%, transparent);
}

/* ── mobile ───────────────────────────────────────────────────────────────
 *
 * On a narrow screen app.css gives .suite-bar `overflow-x: auto` so the tabs
 * can scroll. That single declaration broke this menu in two ways at once:
 *
 *   1. Per the CSS overflow spec, when one axis is not `visible` the other
 *      computes to `auto` as well. So the 42px-tall bar became a scroll
 *      container on BOTH axes, and an absolutely-positioned child opening
 *      below it was clipped to nothing. Measured at 375px wide: the menu was
 *      351px tall with 0px of it visible. It had been opening correctly the
 *      whole time.
 *   2. The bar scrolls sideways, so the menu's right:0 anchor sat at the
 *      right edge of the SCROLLED CONTENT (left: 542px), not of the screen.
 *
 * `position: fixed` escapes both: a fixed element is positioned against the
 * viewport and is not clipped by an ancestor's overflow. It only holds while
 * no ancestor has a transform, filter or perspective, none of which the bar
 * or .account carry -- verified in the browser, not assumed.
 */
@media (max-width: 768px) {
  .account-menu {
    position: fixed;
    top: 50px;                 /* .suite-bar is 42px tall, plus the 8px gap */
    right: 8px;
    left: auto;
    width: 260px;
    max-width: calc(100vw - 16px);
    /* Long menus must scroll rather than run off the bottom of the phone. */
    max-height: calc(100dvh - 62px);
    overflow-y: auto;
  }

  /* Keep the button reachable. Without this it scrolls away with the tabs and
     you have to drag the toolbar sideways to find your own account. */
  .account {
    position: sticky;
    right: 0;
    margin-left: auto;
    background: var(--surface);
    padding-left: 4px;
  }
}

@media (max-width: 640px) {
  .account-label { display: none; }
  .account-btn { padding: 0 4px; }
  .account-menu { width: 240px; }
}
