/* The sign-in dialog. Shared by every page that can ask a visitor to sign in.
 *
 * The fields, the buttons and the messages reuse the classes from auth.css, so the dialog is
 * the sign-in form a visitor would have seen on a page, in the same words and the same look.
 * This file adds only what makes it a dialog: its panel, the backdrop behind it, and how it
 * sits on a narrow screen. */

.sign-in {
  width: min(440px, calc(100vw - 2 * var(--s4)));
  max-height: calc(100vh - 2 * var(--s4));
  padding: 0;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  /* A dialog is above everything; the browser keeps it in the top layer whatever the z-index. */
  overflow: auto;
  box-shadow: 0 20px 64px rgb(0 0 0 / 32%);
}

/* The backdrop dims the page the visitor was on, which stays in place underneath. */
.sign-in::backdrop {
  background: rgb(0 0 0 / 0.6);
}

.sign-in-panel {
  position: relative;
  display: grid;
  gap: var(--s6);
  padding: var(--s6);
}

.sign-in-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s3);
  align-items: center;
}

.sign-in-title {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
}

.sign-in-lead {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--secondary);
}

.sign-in-close {
  display: grid;
  place-items: center;
  padding: 0;
  min-width: 44px;
  min-height: 44px;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: var(--r-control);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.sign-in-close:hover {
  color: var(--text);
  background: var(--page);
}

@media (max-width: 480px) {
  /* On a phone the dialog sits at the bottom, where the thumb is, above the keyboard. */
  .sign-in {
    width: 100vw;
    max-width: none;
    max-height: calc(100vh - var(--s6));
    max-height: calc(100dvh - max(var(--s6), env(safe-area-inset-top)));
    margin: auto 0 0;
    border-radius: var(--r-card) var(--r-card) 0 0;
    border-bottom: 0;
  }

  .sign-in-panel {
    padding-inline: max(var(--s4), env(safe-area-inset-left))
      max(var(--s4), env(safe-area-inset-right));
    padding-bottom: max(var(--s6), env(safe-area-inset-bottom));
  }

  .sign-in .field-input {
    font-size: 16px;
  }
}
