/* SOTA account menu in the top bar. The same file is in all three repos (main-website/public/assets,
   and src/assets in guide-website and checklist-website); change all three together.
   Uses the color and font tokens from sota.css. */

/* A flex box, so the button is centred in the top bar like the Discord button. As an inline box it
   sat on a text baseline, which moved up once the avatar picture appeared. */
.account {
  position: relative;
  display: flex;
  align-items: center;
}

.account-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: var(--control-h);
  max-width: 14rem;
  padding: 0 12px; /* the same height and side padding as the boxed Discord button */
  font: inherit;
  line-height: 1;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--hairline);
  cursor: pointer;
}
.account-btn:hover,
.account-btn[aria-expanded="true"] { border-color: var(--ink); }
.account-label {
  padding-top: 3px; /* centres the letters by eye, like .box in sota.css; the avatar stays centred */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-avatar {
  display: none;
  flex: none;
  place-items: center;
  /* No taller than a line of text, so the button stays the same height as the Discord button */
  width: 20px;
  height: 20px;
  overflow: hidden;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  color: var(--paper);
  background: var(--graphite);
}
.account.is-signed-in .account-avatar { display: grid; }
/* The avatar gets the same space on its left as above and below it */
.account.is-signed-in .account-btn { padding-left: calc((var(--control-h) - 22px) / 2); }
.account-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* A small red mark on the button when changes couldn't be saved */
.account[data-sync="error"] .account-btn { border-color: var(--red); }

.account-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 60;
  display: grid;
  gap: 10px;
  width: min(300px, calc(100vw - 32px));
  padding: 16px;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--ink);
  box-shadow: 0 16px 40px rgb(22 22 29 / .14);
}
.account-menu p { margin: 0; }
.account-out,
.account-in { display: grid; gap: 10px; }
/* The display rules above would otherwise override the hidden attribute */
.account [hidden] { display: none !important; }

.account-title { font-weight: 700; }
.account-name { font-weight: 700; overflow-wrap: anywhere; }
.account-text,
.account-sync { color: var(--graphite); }
.account-fine { font-size: 13px; color: var(--graphite); }
.account-message:empty,
.account-sync:empty { display: none; }
.account-message { font-size: 14px; color: var(--ink); }
.account[data-sync="error"] .account-sync { color: var(--red); }

.account-providers { display: grid; gap: 6px; color: var(--graphite); }
.account-provider {
  width: 100%;
  padding: 7px 12px;
  font: inherit;
  font-size: 15px;
  text-align: left;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--hairline);
  cursor: pointer;
}
.account-provider:hover { border-color: var(--ink); background: var(--plate); }

.account-logout {
  justify-self: start;
  padding: 0;
  font: inherit;
  color: var(--blue);
  background: none;
  border: 0;
  cursor: pointer;
}
.account-logout:hover { text-decoration: underline; text-underline-offset: 2px; }

/* On phones the menu opens from the right edge of the top bar, wherever the button sits */
@media (max-width: 760px) {
  .account { position: static; }
  .account-menu { top: 52px; right: var(--gutter); }
}

@media (max-width: 640px) {
  .account.is-signed-in .account-label { display: none; }
  /* Just the avatar, in a square button */
  .account.is-signed-in .account-btn {
    justify-content: center;
    width: var(--control-h);
    padding: 0;
  }
}

@media print {
  .account { display: none; }
}
