/* Sign-in pages, on top of app.css (which keeps the base look: stone on the left, or a band on top on a phone).
   What's here is how they behave on a phone: the first paint, the keyboard, errors at the field, busy buttons that
   look busy, thumb-sized links, and the iPhone's edges. Light only, like the rest of the app. */

/* Same-site page changes cross-fade (Safari 18.2+, Chrome 126+) instead of flashing white, once the dashboard opts in
   too. Not for people who ask for less motion. */
@media (prefers-reduced-motion: no-preference) { @view-transition { navigation: auto; } }

/* login.html draws the sign-in form so it shows with the first paint. A link from an email (or #signup…) hides it
   until login.js draws the right view; the team's address shows its own words (login.html's first script decides). */
html.auth-other #card[data-static] > * { display: none; }
html:not(.auth-team) .for-team, html.auth-team .for-app { display: none; }
.auth-card h1:focus { outline: none; }        /* focused only so a screen reader starts reading a new view there */

/* a new view rises in, quickly, as iOS screens do */
.auth-card.view-in > * { animation: auth-view-in .26s var(--ease) both; }
@keyframes auth-view-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- fields ---------- */
.input[readonly] { background: var(--stone-50); color: var(--ink-2); }
.input[readonly]:focus { border-color: var(--line-2); box-shadow: none; }
.input[aria-invalid="true"] { border-color: var(--bad); }
.input[aria-invalid="true"]:focus { border-color: var(--bad); box-shadow: 0 0 0 3px rgba(179, 38, 30, .14); }
/* the six digits sit in the middle: letter-spacing leaves a gap after the last one, the indent balances it */
.input[data-code] { text-indent: .3em; }
/* the show-password eye: a full 44pt-wide target the height of the field, with the same small square on hover */
.pw .input { padding-right: 48px; }
.pw .eye { right: 0; top: 0; width: 44px; height: 100%; padding: 4px; border-radius: 12px; background-clip: content-box; }
@media (hover: none) { .pw .eye:hover { background-color: transparent; color: var(--ink-3); } }

/* ---------- errors ---------- */
/* under the field it's about: plain red text (the boxed one is for errors about no field) */
.field > .auth-err { padding: 0; background: none; font-size: 13px; line-height: 1.4; }
/* while it shows, it takes the place of the field's hint (the two would say much the same thing twice) */
.field:has(> .auth-err:not([hidden])) > small { display: none; }
.auth-err:not([hidden]) { animation: auth-err-in .22s var(--ease); }
@keyframes auth-err-in { from { opacity: 0; transform: translateY(-4px); } }
/* a wrong password or code: a short shake, as iOS does */
.shake { animation: auth-shake .36s var(--ease); }
@keyframes auth-shake { 18%, 54% { transform: translateX(-7px); } 36%, 72% { transform: translateX(6px); } 90% { transform: translateX(-2px); } }

/* ---------- buttons ---------- */
/* busy: still the button's own color (a faded button reads as "can't"), with a spinner, until the next view or page */
.auth-card .btn[aria-busy="true"] { opacity: .92; }
.auth-card .btn[aria-busy="true"]::before { content: ""; width: 15px; height: 15px; flex: none; border-radius: 50%; border: 2px solid currentColor;
  border-right-color: transparent; animation: auth-spin .7s linear infinite; }
@keyframes auth-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .auth-card .btn[aria-busy="true"]::before { display: none; } }
.auth-mail { margin: 0 0 10px; }
.auth-mail .btn { flex: 1; }
.auth-mail + .auth-note, .auth-mail ~ .auth-err { margin-top: 0; }
#sent { margin: 0 0 10px; }
#again + .auth-alt { margin-top: 16px; }
.auth-2fa-acts { display: grid; gap: 10px; margin: 0 0 16px; }
.auth-manual .auth-qr { margin: 12px 0 4px; }

/* ---------- links a thumb can hit ---------- */
/* text links get a 44pt-tall tap area without moving anything (the padding is taken back by the margin) */
.lnk, .auth-alt a, .auth-foot a { display: inline-block; padding: 12px 8px; margin: -12px -8px; }
.auth-alt .linkish { font-size: 13px; padding: 12px 8px; margin: -12px -8px; }

/* ---------- the iPhone's edges ---------- */
/* landscape: nothing runs under the camera housing; the last line clears the home indicator */
.auth-stone { padding-left: max(36px, env(safe-area-inset-left)); }
.auth-main { padding-right: max(24px, env(safe-area-inset-right)); padding-bottom: max(40px, calc(env(safe-area-inset-bottom) + 16px)); }
@media (max-width: 860px) {
  .auth-stone { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
  .auth-main { padding-left: max(18px, env(safe-area-inset-left)); padding-right: max(18px, env(safe-area-inset-right));
    padding-bottom: max(32px, calc(env(safe-area-inset-bottom) + 16px)); }
}
/* While someone types on a phone, the stone band shrinks to a strip, so the form, its error and its button fit in
   the space the keyboard leaves. */
@media (max-width: 860px) and (hover: none) {
  .auth-stone { transition: min-height .3s var(--ease), padding .3s var(--ease); }
  body.auth:has(.auth-card input:focus) .auth-stone { min-height: 64px; padding-top: 15px; padding-bottom: 15px; }
}
