/* ===========================================================================
   The account dialog.
   ---------------------------------------------------------------------------
   Borrows the tokens the rest of the interface uses rather than introducing a
   palette of its own. Signing in is a utility, not a destination, so it is
   styled as another terminal panel and not as a landing page.
   =========================================================================== */

/* --------------------------------------------------------- the nav control */

/* A box container, matching the background-data select beside it and the
   metronome flag elsewhere in the same bar. */
.authbtn {
  background: transparent;
  border: 1px solid var(--line);
  padding: 5px 9px;
  font: inherit;
  font-size: 10.5px;
  letter-spacing: .12em;
  color: var(--green-2);
  cursor: pointer;
  transition: color .14s var(--ease), border-color .14s var(--ease);
}

.authbtn:hover,
.authbtn:focus-visible { color: var(--green); border-color: var(--line-hot); }

/* ---------------------------------------------------------------- the box */

.authdlg {
  position: relative;
  width: min(340px, calc(100vw - 32px));
  padding: 22px 22px 20px;
  border: 1px solid var(--line);
  background: var(--bg-1);
  color: var(--fg);
}

/* The page behind it recedes rather than disappearing: this is a small task
   interrupting the work, not a new place. */
.authdlg::backdrop { background: rgba(10, 12, 11, .72); }

.authclose {
  position: absolute;
  top: 8px;
  right: 10px;
  background: transparent;
  border: 0;
  padding: 4px 6px;
  font-size: 15px;
  line-height: 1;
  color: var(--fg-3);
  cursor: pointer;
}

.authclose:hover,
.authclose:focus-visible { color: var(--fg); }

.authform > .lbl { margin: 0 0 14px; }

/* ------------------------------------------------------------------ fields */

.authfield { display: block; margin: 0 0 12px; }

.authfield > span {
  display: block;
  margin: 0 0 5px;
  font-family: var(--f-sans);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--fg-3);
}

.authfield input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid var(--line-soft);
  background: var(--bg);
  color: var(--fg);
  font-family: var(--f-mono);
  font-size: 12.5px;
}

.authfield input:focus {
  outline: none;
  border-color: var(--green-2);
}

/* `hidden` has to win here: the field elements are display:block, and a form
   that switches between four shapes relies on hidden actually hiding. */
.authfield[hidden] { display: none; }

.authhint {
  display: block;
  margin: 5px 0 0;
  font-size: 10px;
  letter-spacing: .04em;
  color: var(--fg-3);
}

/* `display: block` above outranks the browser's own rule for [hidden], so the
   hint has to be told again. Every element in this file that is both given a
   display and toggled by script needs its own [hidden] rule; without it the
   attribute is set correctly and nothing happens on screen. */
.authhint[hidden] { display: none; }

.authsubmit { width: 100%; margin: 4px 0 0; }
.authsubmit[data-busy="true"] { color: var(--fg-3); }

/* ---------------------------------------------------------------- messages */

/* Always in the layout, even when empty, so a failure does not shove the
   button out from under a cursor that is on its way to it. */
.authmsg {
  min-height: 1.5em;
  margin: 0 0 10px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--fg-2);
}

.authmsg[data-tone="bad"]  { color: var(--red); }
.authmsg[data-tone="good"] { color: var(--green); }

/* ----------------------------------------------------------- alternatives */

.authalt {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 14px 0 0;
  padding: 12px 0 0;
  border-top: 1px solid var(--line-hair);
}

.linkish {
  background: transparent;
  border: 0;
  padding: 0;
  font-family: var(--f-sans);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--fg-3);
  cursor: pointer;
  transition: color .14s var(--ease);
}

.linkish:hover,
.linkish:focus-visible { color: var(--green); }
.linkish[hidden] { display: none; }

/* The one irreversible control in the admin panel. Red at rest, not only on
   hover: somebody scanning a row of identical text buttons should be able to
   see which one deletes an account before their pointer is over it. */
.linkish-danger { color: var(--red); }
.linkish-danger:hover,
.linkish-danger:focus-visible { color: #ef8079; }

/* ------------------------------------------------------------- signed in */

.authwho {
  margin: 0 0 14px;
  font-family: var(--f-mono);
  font-size: 12.5px;
  color: var(--fg);
  overflow-wrap: anywhere;
}

/* -------------------------------------------------------------- reduced */

@media (prefers-reduced-motion: reduce) {
  .authbtn,
  .linkish { transition: none; }
}

/* ------------------------------------------------- narrow header rescue */

/*
 * .bar-right is `white-space: nowrap`, so its controls have to actually fit a
 * narrow screen rather than wrap. Every control up there is real and acted-on
 * — nothing decorative is left to drop — so the rescue is tightening spacing
 * rather than hiding anything.
 *
 * The tightening used to start at 380px, on the stated assumption that there
 * were two controls: login and background data. A signed-in administrator has
 * three, because ADM sits beside PROFILE, and three do not fit until well
 * above 380. On a 390px phone the ADM button hung nine pixels off the right
 * edge and took the whole page into horizontal scroll with it — visible only
 * to admins, which is exactly the sort of thing nobody reports. The rescue now
 * starts where three controls actually stop fitting.
 */
@media (max-width: 560px) {
  .bar-right { gap: 12px; }
}

@media (max-width: 460px) {
  .bar-right { gap: 10px; }
  /* At this width the controls fit only if they stop competing for the same
     tracking and padding. */
  .authbtn, .ambient-ctl select { letter-spacing: .06em; padding-left: 6px; padding-right: 6px; }
}
