/* prakses — the signed-in account menu on the public pages.

   None of this exists in the markup: site.js ("Signed in: the account menu") builds the menu and the footer sign-out
   once /api/me says someone is signed in, so a visitor, and anyone with the script blocked, never sees a rule from
   here. It uses the tokens from dist/prakses.css and the same 820px breakpoint as .nav-panel.

   Below 820px the nav is a stacked list inside the Menu disclosure, so the menu opens inline under its button, as
   more rows of that list. From 820px up the nav is a row in the topbar, so the menu floats under its button. */

.acct-nav {
  position: relative;
}

/* The button is a .btn-ghost like its neighbours; in the stacked nav it is a full-width row. The name is the only part
   that can be long, so it alone gives way (an ellipsis), never the chevron. */
.acct-nav-btn {
  display: flex;
  width: 100%;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  text-align: left;
}
.acct-nav-btn[aria-expanded="true"] {
  background: var(--panel);
  color: var(--muted);
}
.acct-nav-name {
  min-width: 0;
  max-width: 16ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The menu, inline: the nav panel is already a surface, so the rows sit under the button with a quiet rule to show
   they belong to it. */
.acct-nav-menu {
  display: grid;
  gap: 2px;
  margin: 2px 0 4px 8px;
  padding: 2px 0 4px 8px;
  border-left: 1px solid var(--line);
}

.acct-nav-who {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 8px 12px 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line-soft);
}
.acct-nav-full {
  font: 600 var(--ui-sm) / 1.3 var(--font-ui);
  color: var(--text);
  overflow-wrap: anywhere;
}
.acct-nav-user {
  font: 500 var(--ui-xs) / 1.3 var(--font-mono);
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* Change email: a small form that opens under its row. Its fields use the page's tokens; the inputs are not rows, so
   they opt out of the button/link rules below by being inputs. */
.acct-nav-form {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 4px 12px 8px;
}
.acct-nav-form[hidden] {
  display: none;
}
.acct-nav-form label {
  font: 500 var(--ui-xs) / 1.3 var(--font-ui);
  color: var(--muted);
}
.acct-nav-form input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel-2);
  color: var(--text);
  font: 400 var(--ui-sm) / 1.2 var(--font-ui);
}
.acct-nav-status {
  margin: 0;
  font: 500 var(--ui-xs) / 1.4 var(--font-ui);
  color: var(--text-soft);
  overflow-wrap: anywhere;
}
.acct-nav-status:empty {
  display: none;
}
.acct-nav-status.acct-nav-bad {
  color: var(--red);
}
.acct-nav-menu .acct-nav-send {
  justify-content: center;
  background: var(--panel-2);
  color: var(--text);
}
.acct-nav-menu > .acct-nav-status {
  padding: 0 12px 6px;
}
.acct-nav-menu button[disabled] {
  opacity: 0.6;
  cursor: progress;
}
.acct-nav-send[disabled] {
  opacity: 0.6;
  cursor: progress;
}

/* Rows: links and the sign-out button look the same, full width, with the same hover and keyboard focus. The global
   :focus-visible ring is drawn 2px outside its element, which would hang off the menu's edge, so here it is just inside. */
.acct-nav-menu form {
  margin: 0;
}
.acct-nav-menu a,
.acct-nav-menu button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 36px;
  margin: 0;
  padding: 8px 12px;
  border: 0;
  border-radius: var(--r-md);
  background: none;
  color: var(--text-soft);
  font: 500 var(--ui-sm) / 1.2 var(--font-ui);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: color var(--t-state), background var(--t-state);
}
.acct-nav-menu a:hover,
.acct-nav-menu button:hover {
  background: var(--panel-2);
  color: var(--text);
}
.acct-nav-menu :focus-visible {
  outline-offset: -2px;
  border-radius: var(--r-md);
}

/* The footer's sign-out: a button that reads as one of the footer's links (it carries .btn-ghost .text-ui, as they do).
   Only the browser's own button chrome needs resetting. */
.acct-foot {
  margin: 0;
}
.acct-foot button {
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  text-align: left;
}

@media (min-width: 820px) {
  .acct-nav {
    display: flex;
    align-items: center;
  }
  .acct-nav-btn {
    display: inline-flex;
    width: auto;
  }

  /* Floating under the button, right-aligned to it. It lives inside the sticky topbar (z-index 20), so it is above
     the page that scrolls beneath. */
  .acct-nav-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 30;
    min-width: 220px;
    max-width: min(320px, calc(100vw - 32px));
    margin: 0;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
    box-shadow: 0 18px 40px -12px rgb(0 0 0 / 0.55), 0 2px 8px rgb(0 0 0 / 0.3);
  }
}

@media print {
  .acct-nav,
  .acct-foot {
    display: none;
  }
}
