/* The sign-in pages (NEX-65): /login, /login/verify, the two signup pages
   and the pending page. Loaded by templates/sign_in/_layout.html, which sits
   inside the public layout (base.html) and its navbar, after azraq-theme.css,
   whose tokens it uses and never redefines -- light and dark come from there.

   The layout follows the Azraq Laravel app's auth screens (its "simple" auth
   layout): no card, one narrow centred column, the mark alone above a centred
   title and description, labels over fields, underlined text links, the code
   as one joined strip. Two things are kept from the portal on purpose:
   - one control height, 44px, for every input, button and code box -- the
     Laravel 36px is under the usual touch-target size, and researchers sign
     in on phones;
   - borders, not shadows (docs/brand.md): no glow under the button.

   Motion: colour, border and focus ring only, 150ms. Nothing moves, slides,
   fades in or shakes. */

.signin {
  box-sizing: border-box;
  /* The page under the public navbar (base.html), no taller than the screen. */
  min-height: calc(100vh - var(--nav-height));
  min-height: calc(100dvh - var(--nav-height));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}

/* ── The column ── */

.signin-card {
  box-sizing: border-box;
  width: 100%;
  max-width: 384px;
}

/* ── The mark, alone, centred ── */

.signin-brand {
  display: flex;
  justify-content: center;
  margin: 0 auto 16px;
  width: max-content;
  border-radius: 6px;
}
.signin-brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.signin-brand img { display: block; height: 36px; width: auto; }

/* ── Title and description, centred ── */

.signin-head { margin-bottom: 32px; text-align: center; }
.signin-title {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.25rem;
  line-height: 1.75rem;
  font-weight: 500;
  color: var(--text-primary);
}
.signin-lead {
  margin: 8px 0 0;
  font-size: 0.875rem;
  line-height: 1.375rem;
  color: var(--text-muted-dark);
}
.signin-lead strong {
  color: var(--text-primary);
  font-weight: 500;
  overflow-wrap: anywhere;
}

/* ── Messages: one line of text above the form ── */

.signin-notice {
  margin: 0 0 24px;
  font-size: 0.875rem;
  line-height: 1.25rem;
  text-align: center;
  color: var(--text-secondary);
}
.signin-notice--error   { color: var(--critical); }
.signin-notice--success { color: var(--low); }

/* ── Form ── */

.signin-form { display: flex; flex-direction: column; gap: 24px; }
.signin-field { display: flex; flex-direction: column; gap: 8px; }
.signin-label {
  font-size: 0.875rem;
  line-height: 1;
  font-weight: 500;
  color: var(--text-primary);
}
.signin-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.signin-note {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.375rem;
  color: var(--text-muted-dark);
}

.signin-input {
  box-sizing: border-box;
  width: 100%;
  height: 44px;
  margin: 0;
  padding: 0 12px;
  font-family: var(--font-body);
  font-size: 1rem; /* 16px: iOS does not zoom into the field */
  color: var(--text-primary);
  background: transparent;
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-sm);
  -webkit-appearance: none;
  appearance: none;
  transition: border-color var(--transition-fast) var(--ease-default),
              box-shadow var(--transition-fast) var(--ease-default);
}
.signin-input::placeholder { color: var(--text-muted-dark); }
.signin-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(17, 122, 202, 0.5);
}
/* Browser autofill keeps the theme instead of painting the field yellow or blue. */
.signin-input:-webkit-autofill {
  -webkit-text-fill-color: var(--text-primary);
  -webkit-box-shadow: 0 0 0 1000px var(--bg) inset;
  caret-color: var(--text-primary);
}
.signin-input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--bg) inset, 0 0 0 3px rgba(17, 122, 202, 0.5);
}

/* ── Buttons ── */

.signin-button {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 44px;
  margin: 16px 0 0;
  padding: 0 16px;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  color: #FFFFFF;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  transition: background-color var(--transition-fast) var(--ease-default),
              border-color var(--transition-fast) var(--ease-default);
}
.signin-button:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.signin-button:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(17, 122, 202, 0.5); }
.signin-button:disabled { cursor: default; opacity: 0.85; }

.signin-button--secondary {
  margin-top: 0;
  color: var(--text-primary);
  background: transparent;
  border-color: var(--border-hover);
}
.signin-button--secondary:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--border-hover);
}

/* The submit state: a spinner inside the button, whose size never changes. */
.signin-spinner {
  display: none;
  box-sizing: border-box;
  flex: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: signin-spin 0.7s linear infinite;
}
.signin-button[aria-busy="true"] .signin-spinner { display: inline-block; }
@keyframes signin-spin { to { transform: rotate(360deg); } }

/* ── Text links: text colour, a faint underline that firms up on hover ── */

.signin-link,
.signin-textbutton {
  color: var(--text-primary);
  font-weight: 400;
  text-decoration: underline;
  text-decoration-color: var(--border-hover);
  text-underline-offset: 4px;
  border-radius: 4px;
  transition: text-decoration-color var(--transition-fast) var(--ease-default),
              color var(--transition-fast) var(--ease-default);
}
.signin-link:hover,
.signin-textbutton:hover:not(:disabled) { text-decoration-color: currentColor; }
.signin-link:focus-visible,
.signin-textbutton:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.signin-textbutton {
  margin: 0;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.signin-textbutton:disabled {
  color: var(--text-muted-dark);
  text-decoration-color: transparent;
  cursor: default;
}

/* The verify page's two secondary actions, centred under the button. */
.signin-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 12px;
  margin-top: 24px;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: var(--text-muted-dark);
}
.signin-row form { margin: 0; }

.signin-foot {
  margin: 24px 0 0;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: var(--text-muted-dark);
  text-align: center;
}

/* ── The code: six joined squares ──
   Without JS the server's single field is shown as is; static/js/sign_in.js
   adds `is-ready` and the boxes. Each box keeps its own full border and
   overlaps its neighbour by 1px, so shared edges are single lines and a
   focused box can lift its whole border above the others. */

.signin-code-fallback {
  text-align: center;
  letter-spacing: 0.5em;
  font-variant-numeric: tabular-nums;
}
.signin-code-fallback[hidden] { display: none; }

.signin-code-strip {
  display: flex;
  justify-content: center;
}

.signin-code-box {
  position: relative;
  box-sizing: border-box;
  width: 44px;
  height: 44px;
  margin: 0 0 0 -1px;
  padding: 0;
  text-align: center;
  font-family: var(--font-body);
  font-size: 1.125rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  caret-color: var(--accent);
  background: transparent;
  border: 1px solid var(--border-hover);
  border-radius: 0;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color var(--transition-fast) var(--ease-default),
              box-shadow var(--transition-fast) var(--ease-default);
}
.signin-code-box:first-child { margin-left: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.signin-code-box:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.signin-code-box:focus {
  z-index: 1;
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.signin-code.is-invalid .signin-code-box,
.signin-code.is-invalid .signin-code-fallback { border-color: var(--critical); }
.signin-code.is-invalid .signin-code-box:focus,
.signin-code.is-invalid .signin-code-fallback:focus {
  border-color: var(--critical);
  box-shadow: 0 0 0 1px var(--critical);
}

@media (max-width: 480px) {
  .signin { padding: 40px 16px; }
}
