/* PULSE — sign-in, sign-up and recovery screens (js/auth.js).
   Built on the tokens and the .auth, .planet, .input, .btn, .pill, .pwbox,
   .authform, .authtitle and .authhint styles of app.css: the same buttons
   (.btn.primary.large for the step's action, .btn.ghost for the way out),
   inputs and green as the rest of the app. Mobile first; nothing wider than
   the screen. */

.auth > * { flex: none; }
.auth:not([data-mode=legacy]) .authform { gap: 14px; }
.auth:not([data-mode=legacy]) .authform > .btn.primary { margin-top: 4px; }
.auth:not([data-mode=legacy]) .authform > .btn + .btn { margin-top: -4px; }
.auth[data-mode=legacy] .afield .authhint { margin-top: 6px; } /* the old server: placeholders, no labels */

/* Step screens: no planet; on top a bar with the back button, the progress
   in the middle and the language switch at the end. */
.auth.authstep { padding-top: max(10px, env(safe-area-inset-top)); }
.authbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 44px; margin: 0 -8px 22px; }
.authback { color: var(--text); justify-self: start; }
.authprog { display: flex; gap: 6px; grid-column: 2; }
.authprog i { width: 26px; height: 4px; border-radius: 2px; background: var(--surface-3); }
.authprog i.on { background: var(--accent); }

/* The heading, focused when the view opens. Under the planet it is the
   small mono label of app.css («SIGN IN», «NEW ACCOUNT») with the step on
   the right; on a step screen, a large heading under the step. */
.authtitle { outline: none; }
.auth:not(.authstep) .authtitle { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 0 4px 12px; }
.auth:not(.authstep) .authtitle small { order: 2; font-size: 11px; font-weight: 600; letter-spacing: .12em; color: var(--accent); white-space: nowrap; }
.authstep .authtitle { margin: 0 0 10px; font: 700 28px/1.2 var(--font); letter-spacing: -.01em; text-transform: none; color: var(--text); }
.authstep .authtitle small { display: block; margin-bottom: 8px; font: 600 11.5px/1.3 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.authlead { margin: 0 0 18px; color: var(--text-2); line-height: 1.5; overflow-wrap: anywhere; }
.authaddr { color: var(--text); font-weight: 600; overflow-wrap: anywhere; }

/* A field: the label, the control, a hint and the error under it. */
.afield { display: flex; flex-direction: column; min-width: 0; }
.afield > label { color: var(--text-2); font-size: 13px; margin: 0 2px 7px; }
.afield .authhint { margin: 7px 4px 0; }
.autherr { color: var(--danger); font-size: 12.5px; line-height: 1.4; margin: 0 4px; }
.autherr:not(:empty) { margin-top: 7px; }
.autherr:not(:empty)::before { content: "!"; display: inline-grid; place-items: center; width: 15px; height: 15px; margin-right: 6px; border-radius: 50%;
  background: var(--danger-dim); font-size: 10px; font-weight: 700; vertical-align: 1px; }
.afield .input[aria-invalid=true] { border-color: rgba(224, 87, 79, .6); }
.afield .input[readonly] { background: transparent; border-style: dashed; color: var(--text-2); }
.afield .input::placeholder { color: var(--text-3); }

/* Link-like buttons: «Forgot password?», «Change address», «Paste». Green
   text like the .btn.ghost under a form; underlined only inside a sentence. */
.authlink { color: var(--accent); font-weight: 500; font-size: 13.5px; min-height: 32px; padding: 4px 2px; text-align: left;
  text-decoration: none; text-decoration-color: rgba(159, 232, 112, .35); text-underline-offset: 3px; overflow-wrap: anywhere; }
.authlink:hover { text-decoration: underline; }
.authsuggest .authlink, .authdev .authlink { text-decoration: underline; }
.authlink:disabled { opacity: .5; cursor: default; }
.authrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: -10px 0 16px; }
.authrow.end { justify-content: flex-end; margin: -8px 0 -4px; }
.authwho { color: var(--text-3); font-size: 13.5px; min-width: 0; overflow-wrap: anywhere; }
.authwho .authaddr { color: var(--text-2); font-weight: 500; }
.authalt { display: flex; justify-content: center; margin-top: 14px; }

/* Lines above a form. */
.authnotice, .authnote, .authok { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 14px; font-size: 13.5px; line-height: 1.45; margin: 0 0 18px; }
.authnotice { background: rgba(140, 216, 255, .07); border: 1px solid rgba(140, 216, 255, .28); color: var(--text); }
.authnotice > .icon { color: var(--ice); margin-top: 1px; }
.authnote { background: rgba(255, 207, 110, .07); border: 1px solid rgba(255, 207, 110, .24); color: var(--text); }
.authnote > .icon { color: var(--amber); margin-top: 1px; }
.authok { background: var(--accent-dim); border: 1px solid var(--accent-line); color: var(--text); align-items: center; }
.authok > .icon { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--grad-primary); color: var(--accent-ink); box-shadow: 0 0 14px -4px var(--accent-glow); }
.authok > div { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.authok > div > span { color: var(--accent); font-weight: 600; }

/* The frequency of an «Invite» link over the form: the code never splits
   from its word, and on narrow phones the line keeps to one row (in English
   «code 7» is a letter longer than in Russian). */
.auth .invbig span { white-space: nowrap; }
@media (max-width: 359px) {
  .auth .invbig { font-size: 27px; }
  .auth .invbig span { font-size: 20px; }
}

/* An «Invite» link under a step screen (the first screens have .invite of app.css). */
.authinvite { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 14px; font-size: 13.5px; line-height: 1.45; margin: 22px 0 0;
  background: var(--accent-dim); border: 1px solid var(--accent-line); color: var(--text-2); }
.authinvite > .icon { flex: none; color: var(--accent); margin-top: 1px; }
.authinvite b { color: var(--accent); font-weight: 500; white-space: nowrap; }

/* The code: one input over six cells. */
.authcode { position: relative; max-width: 360px; }
.authcode-cells { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) 4px repeat(3, minmax(0, 1fr)); gap: 8px; }
.authcode-c:nth-child(4) { grid-column-start: 5; } /* 3 + 3, like the code in the letter */
.authcode-c { height: 58px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); display: grid; place-items: center;
  font: 600 25px/1 var(--mono); color: var(--text); transition: border-color .12s, box-shadow .12s, background .12s; }
.authcode-c.full { border-color: var(--line-2); background: var(--surface-2); }
.authcode-c.cur { border-color: var(--accent-line); box-shadow: 0 0 0 3px rgba(159, 232, 112, .08); }
.authcode-c.cur:empty::after { content: ""; width: 2px; height: 26px; border-radius: 1px; background: var(--accent); animation: authblink 1s steps(1) infinite; }
@keyframes authblink { 50% { opacity: 0; } }
.afield.bad .authcode-c { border-color: rgba(224, 87, 79, .6); }
.authcode-in { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; outline: none; background: transparent;
  color: transparent; -webkit-text-fill-color: transparent; caret-color: transparent; font-size: 16px; letter-spacing: 0; cursor: text; }
.authcode-in::selection { background: transparent; }

/* «Resend in 0:59» and the hints under the button. */
.authresendbox { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.authresend { min-height: 32px; display: flex; align-items: center; justify-content: center; color: var(--text-3); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.authresend .authlink { text-align: center; }
.authtips { display: flex; flex-direction: column; gap: 4px; color: var(--text-3); font-size: 12.5px; line-height: 1.45; max-width: 300px; }
.authtips:empty { display: none; }

/* -dev-mail: the code from the server's outbox. */
.authdev { padding: 10px 12px; border-radius: 12px; border: 1px dashed rgba(140, 216, 255, .4); background: rgba(140, 216, 255, .06);
  color: var(--text-2); font-size: 13px; display: flex; align-items: center; flex-wrap: wrap; gap: 0 4px; }
.authdev b { color: var(--ice); font-weight: 600; letter-spacing: .12em; }
.authdev .authlink { color: var(--ice); min-height: 0; text-decoration-color: rgba(140, 216, 255, .4); }

/* «Did you mean …?» */
.authsuggest { font-size: 13px; color: var(--text-2); margin: 6px 4px 0; overflow-wrap: anywhere; }
.authsuggest:empty { display: none; }
.authsuggest .authlink { display: inline; min-height: 0; padding: 0; font-size: inherit; }

/* Password strength: four bars and a word. */
.authmeter { display: flex; align-items: center; gap: 10px; margin: 8px 4px 0; font-size: 12.5px; color: var(--text-3); }
.authmeter-bars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; width: 84px; flex: none; }
.afield.bad .authmeter { display: none; } /* the error under the field says it better */
.authmeter-bars i { height: 4px; border-radius: 2px; background: var(--surface-3); transition: background .15s; }
.authmeter[data-score="1"] .authmeter-bars i:nth-child(-n+1),
.authmeter.bad .authmeter-bars i:nth-child(-n+1) { background: var(--danger); }
.authmeter[data-score="2"] .authmeter-bars i:nth-child(-n+2) { background: var(--amber); }
.authmeter[data-score="3"] .authmeter-bars i:nth-child(-n+3),
.authmeter[data-score="4"] .authmeter-bars i { background: var(--accent); }
.authmeter[data-score="1"] .authmeter-t, .authmeter.bad .authmeter-t { color: var(--danger); }
.authmeter[data-score="2"] .authmeter-t { color: var(--amber); }
.authmeter[data-score="3"] .authmeter-t, .authmeter[data-score="4"] .authmeter-t { color: var(--accent); }

/* EN | RU, the language before signing in (js/auth.js langSwitch): small
   mono labels like the step's, the current one lit like a .seg choice. Over
   the planet it keeps to the top right corner, level with a step's bar; on a
   step screen it ends that bar. */
.auth { position: relative; }
.langswitch { display: flex; gap: 2px; padding: 2px; border-radius: 11px; background: var(--surface); border: 1px solid var(--line); }
.langswitch button { position: relative; min-width: 36px; height: 28px; padding: 0 8px; border-radius: 8px;
  font: 600 11.5px/1 var(--mono); letter-spacing: .1em; color: var(--text-3); transition: background-color .15s, color .15s; }
.langswitch button::after { content: ""; position: absolute; inset: -7px -1px; } /* a taller target than it looks */
.langswitch button:hover:not([aria-pressed=true]) { color: var(--text); }
.langswitch button[aria-pressed=true] { background: var(--sheen), var(--surface-3); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-line); cursor: default; }
.auth > .langswitch { position: absolute; z-index: 2; top: calc(max(10px, env(safe-area-inset-top)) + 5px); right: max(16px, env(safe-area-inset-right)); }
.authbar > .langswitch { grid-column: 3; justify-self: end; }

/* No connection. */
.authoffline { display: flex; flex-direction: column; align-items: stretch; text-align: center; padding: 6px 4px 0; }
.auth .authoffline .authtitle { justify-content: center; margin: 0 0 10px; font: 700 22px/1.25 var(--font); letter-spacing: -.005em; text-transform: none; color: var(--text); }

/* A button busy with a request: the label stays, a spinner joins it. */
.btn.loading:disabled { opacity: .85; cursor: progress; }
.btn.loading::after { content: ""; width: 15px; height: 15px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: authspin .7s linear infinite; }
@keyframes authspin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .authcode-c.cur:empty::after, .btn.loading::after { animation: none; }
}
/* Energy saving (app.css) stills the same, but for the spinner: it shows
   the request is on its way. */
:where(:root.eco) .authcode-c.cur:empty::after { animation: none; }
/* A smaller planet keeps the form in view on short phones. */
@media (max-height: 700px) {
  .auth .planet { height: 196px; }
  .auth .planet::before { top: 22px; }
  .auth .planet .logo { top: 104px; }
}
.auth ::selection { background: rgba(159, 232, 112, .3); }
/* «I am 16 or older and accept the Rules» (auth.js termsField). */
.authterms { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; line-height: 1.4; color: var(--text-2); cursor: pointer; }
.authterms .authcheck { width: 20px; height: 20px; flex: none; margin: 1px 0 0; accent-color: var(--accent); }
.authterms .authlink { display: inline; padding: 0; font: inherit; }
