/* Fluid's own sign-in page (pages/signin.js, pages/signin-gate.js): the gate beside the words and the ways in.

   When the content has room: the gate on the left, the form on the right, the pair centred on the page. The gate
   stays within its own column even when a message makes the form taller. Compact: one column, the gate a small
   emblem beside the title, leaving more room for the form. Container queries follow the room the form
   actually has, including Fluid's larger text setting. Short screens give that room to the controls.

   Every control is the one pill: the address, the code, the ways in, a status's one action. The filled pill is the
   press that continues; the quiet lines (a new code, another way, Start again, Cancel) are links in the text. What
   the page has to say is the line under the title, or under the field it is about; never a box. */
#content:has(.signin) {
  container: portal-signin / inline-size;
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}
.signin {
  --signin-wide: 0;  /* signin.js reads the same layout choice when measuring the gate */
  --title-size: 32px;
  --title-lh: 38px;
  --cap: calc(var(--title-lh) / 2 - var(--title-size) * .3);  /* the cap line under the line box's top: Funnel Display's ascent 1, descent .25, caps .675 */
  --control-h: 48px;
  --gap: 10px;  /* between pills */
  --or-h: 24px;
  --words-gap: 24px;  /* the title (and its line) to the first control */
  --col-w: 400px;
  --pair-gap: 72px;
  /* the doors: the address and Continue with email, or, Google, GitHub */
  --ways-h: calc(4 * var(--control-h) + 4 * var(--gap) + var(--or-h));
  --gate-h0: calc(var(--title-lh) - var(--cap) + var(--words-gap) + var(--ways-h));
  --gate: min(var(--gate-h, var(--gate-h0)), var(--gate-h0));
  display: grid; grid-template-columns: minmax(0, var(--col-w)); column-gap: var(--pair-gap); justify-content: center; align-items: start;
  padding-top: clamp(0px, 2.5vh, 20px);
  padding-top: clamp(0px, 2.5svh, 20px);
  min-width: 0;
}
.signin-gate-side { display: flex; grid-area: 1 / 1; justify-content: flex-start; min-width: 0; }
.signin-gate {
  display: block; flex: none; width: 48px; height: 60px;
  color: var(--ink); font-family: var(--font-mono); user-select: none;
}
.signin-main { grid-area: 1 / 1; min-width: 0; }
.signin-words { min-height: 60px; padding: 10px 0 0 68px; }

/* the words: the title (the step, one line, one tone) and the one line under it */
.signin-title {
  margin: 0; font-family: "Funnel Display", var(--font-sans); font-size: var(--title-size); line-height: var(--title-lh);
  font-weight: 600; letter-spacing: -.02em; color: var(--ink); text-wrap: balance;
}
.signin-title:focus { outline: none; }  /* given the keyboard when a step takes away what had it; never tabbed to */
.signin-lead {
  margin: 10px 0 0; max-width: 400px; color: var(--ink-2); font-size: 15px; line-height: 23px; letter-spacing: -.003em;
  text-wrap: balance; overflow-wrap: anywhere;
}
.signin-lead:empty { margin: 0; }  /* kept in the tree, so what it says next is announced */
.signin-lead[data-tone="bad"] { color: var(--bad); }
/* an address is one piece: it moves to the next line whole, and breaks inside only when it is longer than a line */
.signin-lead:has(.signin-address) { text-wrap: pretty; }
.signin-address { display: inline-block; max-width: 100%; color: var(--ink); font-weight: 550; }
.signin-address > span { white-space: normal; overflow-wrap: anywhere; }
.signin-address > .signin-address-long { white-space: normal; overflow-wrap: anywhere; }
.signin-address > .signin-address-tail { color: var(--ink-2); font-weight: 400; }
.signin-lead[data-tone="bad"] .signin-address, .signin-lead[data-tone="bad"] .signin-address-tail { color: inherit; }

/* the controls */
.signin-ways { display: grid; gap: var(--gap); margin-top: var(--words-gap); }
/* Turnstile's place: it takes room only while a person is asked (data-open). Otherwise it is out of the flow (no row,
   no gap in the form's grid) but still rendered, so the check runs, and nothing under the press moves. */
.signin-captcha { margin-top: 12px; }
.signin-email .signin-captcha { margin: 4px 0; }  /* under the press that asked */
.signin-captcha:not([data-open]) { position: absolute; width: 1px; height: 1px; margin: 0; overflow: hidden; clip-path: inset(50%); }
.signin-foot:empty { display: none; }
.signin-way {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; height: var(--control-h); padding: 0 20px;
  border: 1px solid var(--rule-2); border-radius: var(--radius-cap); background: var(--raised); color: var(--ink);
  font: inherit; font-size: 15px; font-weight: 550; letter-spacing: -.003em; line-height: 1; text-decoration: none;
  cursor: pointer; appearance: none; -webkit-tap-highlight-color: transparent;
  transition: border-color .15s ease-out, background-color .15s ease-out, color .15s ease-out;
}
.signin-way-mark { flex: none; width: 18px; height: 18px; }
.signin-way-words { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* the press that continues: Continue with email, a status's one action */
.signin-way-submit, .signin-way-primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.signin-way[disabled] { cursor: default; background: var(--raised); border-color: var(--rule); color: var(--ink-3); }
.signin-way[aria-busy="true"] { cursor: progress; }
/* A press under way, in place (no page in between): the pill keeps its look and says what it is doing, a soft light
   runs along its foot, and the rest of the step goes quiet and waits. */
.signin-way.signin-way-going { position: relative; cursor: progress; }
.signin-way.signin-way-going[disabled] { background: var(--raised); border-color: var(--edge); color: var(--ink); }
.signin-way-submit.signin-way-going[disabled], .signin-way-primary.signin-way-going[disabled] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.signin-way-going::after {
  content: ""; position: absolute; left: 22%; right: 22%; bottom: 9px; height: 1.5px; border-radius: var(--radius-cap);
  background: linear-gradient(90deg, transparent, currentColor, transparent) no-repeat; background-size: 40% 100%;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 25%, #000 75%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 25%, #000 75%, transparent);  /* the light fades at the ends, never cut */
  opacity: .55; animation: signin-going 1.3s linear infinite;
}
@keyframes signin-going { from { background-position: -70% 0; } to { background-position: 170% 0; } }
.signin-way[aria-disabled="true"] { cursor: progress; }
/* the rest of the step, quiet while the press is under way (inert in signin.js: neither pointer nor keyboard) */
.signin-ways[data-pressing] > :not(:has(.signin-way-going)):not(.signin-way-going) { opacity: .4; transition: opacity .2s ease-out; }
.signin-cancel .btn-link[aria-disabled="true"] { color: var(--ink-3); cursor: progress; text-decoration: none; }
.signin-way:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.signin-way:active { transition-duration: 40ms; }
@media (hover: hover) {
  .signin-way:not([disabled]):hover { border-color: var(--edge); text-decoration: none; }
  .signin-way-submit:not([disabled]):hover, .signin-way-primary:not([disabled]):hover {
    background: color-mix(in srgb, var(--ink) 84%, var(--paper)); border-color: transparent;
  }
}

/* the address first, then Continue with email, the page's one filled pill */
.signin-email { display: grid; gap: var(--gap); }
.signin .signin-email-field {  /* over the console's input[type=email] rule, which draws a ruled field */
  display: block; width: 100%; height: var(--control-h); margin: 0; padding: 0 20px;
  border: 1px solid var(--edge); border-radius: var(--radius-cap); background: var(--paper); color: var(--ink);
  font: inherit; font-size: 16px; letter-spacing: -.003em; line-height: normal; outline: none; appearance: none; box-shadow: none;
  transition: border-color .15s ease-out, box-shadow .15s ease-out;
}
.signin .signin-email-field::placeholder { color: var(--ink-3); opacity: 1; }
/* (0,3,0) and up, over the console's own field rules: no inset line under a focused or refused field, no grey border
   on hover over the refusing one */
.signin .signin-email-field:focus { border-color: var(--ink); box-shadow: none; }
.signin .signin-email-field[aria-invalid="true"], .signin .signin-email-field[aria-invalid="true"]:hover { border-color: var(--bad); }
@media (hover: hover) { .signin .signin-email-field:hover:not(:focus):not([aria-invalid="true"]) { border-color: var(--ink-3); } }
/* the browser's own fill keeps the page's paper (Chrome paints it pale yellow or blue otherwise) */
.signin .signin-email-field:-webkit-autofill, .signin .signin-email-field:-webkit-autofill:hover {
  -webkit-box-shadow: 0 0 0 40px var(--paper) inset; -webkit-text-fill-color: var(--ink); caret-color: var(--ink);
  transition: background-color 600000s 0s, color 600000s 0s;
}
/* a slip, said under the field it is about, on the column's edge */
.signin-problem { margin: -2px 0 0; color: var(--bad); font-size: 13.5px; line-height: 20px; text-wrap: pretty; overflow-wrap: anywhere; }

/* "or", on a hairline */
.signin-or { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; height: var(--or-h); color: var(--ink-3); font-size: 12.5px; line-height: 1; }
.signin-or::before, .signin-or::after { content: ""; height: 1px; background: var(--rule); }

/* The code from the email: the address field's pill holding six places, three and three as the email prints the
   code, spread across the field with a short rule between the groups. One real input, invisible, over it takes the
   typing. Each place is a digit over a low line: still to come, the line in the field's edge colour; next, in ink and
   pulsing; filled, the digit risen into place and its line gone quiet. */
.signin-code-field {
  position: relative; height: var(--control-h); border: 1px solid var(--edge); border-radius: var(--radius-cap);
  background: var(--paper); color: var(--ink); cursor: text; -webkit-tap-highlight-color: transparent;
  transition: border-color .15s ease-out, box-shadow .15s ease-out, background-color .26s ease-out, color .26s ease-out;
}
.signin-code-field .signin-code-input {
  position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; border-radius: var(--radius-cap);
  background: transparent; color: transparent; caret-color: transparent; font-size: 16px; opacity: 0; outline: none; appearance: none;
}
.signin-code-shown {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) 28px repeat(3, minmax(0, 1fr)); align-items: stretch;
  height: 100%; max-width: 336px; margin: 0 auto; padding: 0 22px;
  font-family: var(--font-mono); font-size: 22px; font-weight: 500; line-height: 1; font-variant-numeric: tabular-nums;
}
.signin-place { position: relative; display: grid; place-items: center; min-width: 0; }
.signin-digit { display: block; padding-bottom: 3px; }
/* the low line under each place */
.signin-place::after {
  content: ""; position: absolute; left: 50%; bottom: 10px; width: 14px; height: 2px; border-radius: var(--radius-cap);
  background: var(--edge); transform: translateX(-50%);
  transition: width .2s cubic-bezier(.2, .8, .2, 1), background-color .2s ease-out, opacity .2s ease-out;
}
.signin-place[data-filled]::after { width: 10px; background: var(--rule-2); }
/* the next place: its line in ink, longer, pulsing while the field has the keyboard */
.signin-code-field:focus-within .signin-place[data-active]::after {
  width: 20px; background: var(--ink); animation: signin-caret 1.1s ease-in-out infinite;
}
@keyframes signin-caret { 50% { opacity: .35; } }
/* the rule between the groups, darker once the first three are in */
.signin-code-space { position: relative; }
.signin-code-space::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: 8px; height: 2px; border-radius: var(--radius-cap);
  background: var(--rule-2); transform: translate(-50%, -50%); transition: background-color .2s ease-out, width .2s ease-out;
}
.signin-code-field:is([data-count="3"], [data-count="4"], [data-count="5"], [data-count="6"], [data-count="7"], [data-count="8"]) .signin-code-space::before { width: 10px; background: var(--ink-3); }
/* a code of eight digits: the last two places join the field with the seventh digit, and the eight are set four and four */
.signin-code-field[data-long] .signin-code-shown { grid-template-columns: repeat(4, minmax(0, 1fr)) 28px repeat(4, minmax(0, 1fr)); padding: 0 14px; }
.signin-code-field[data-long] .signin-place { grid-row: 1; grid-column: var(--c); }
.signin-code-field[data-long] .signin-code-space { grid-row: 1; grid-column: 5; }
/* a digit typed rises into its place; several at once arrive one after another */
.signin-place[data-new] .signin-digit { animation: signin-digit-in .24s cubic-bezier(.2, .8, .2, 1) both; animation-delay: var(--d, 0ms); }
@keyframes signin-digit-in { from { opacity: 0; transform: translateY(8px) scale(.86); } to { opacity: 1; transform: none; } }
.signin-code-field:focus-within { border-color: var(--ink); }
@media (hover: hover) { .signin-code-field:not(:focus-within):not([data-state]):hover { border-color: var(--ink-3); } }
/* under check: ink runs along the six lines, the digits a shade quieter */
.signin-code-field[data-state="checking"] .signin-digit { color: var(--ink-2); transition: color .2s ease-out; }
.signin-code-field:is([data-state="checking"], [data-state="sending"]) .signin-place::after {
  width: 10px; background: var(--rule-2); animation: signin-run 1.05s ease-in-out infinite; animation-delay: calc(var(--i) * 70ms);
}
@keyframes signin-run { 0%, 60%, 100% { width: 10px; background: var(--rule-2); } 25% { width: 20px; background: var(--ink); } }
/* a wrong code: one shake, the refusing colour on the field and its lines until the next digit, the digits dropping
   out from the last; said under the field, the address kept above */
.signin-code-field[data-state="wrong"] { border-color: var(--bad); animation: signin-shake .4s cubic-bezier(.36, .07, .19, .97) both; }
.signin-code-field[data-state="wrong"] .signin-place::after, .signin-code-field[data-state="wrong"] .signin-code-space::before,
.signin-code-field[data-state="wrong"]:focus-within .signin-place[data-active]::after { background: var(--bad); }
.signin-place[data-leaving] .signin-digit { animation: signin-digit-out .26s ease-in both; animation-delay: calc((5 - var(--i)) * 30ms); }
@keyframes signin-digit-out { to { opacity: 0; transform: translateY(-7px) scale(.9); } }
@keyframes signin-shake { 15%, 85% { transform: translateX(-1px); } 30%, 70% { transform: translateX(3px); } 45%, 55% { transform: translateX(-4px); } 50% { transform: translateX(4px); } }
/* the right code: the field fills in ink, the digits in paper, as the page leaves */
.signin-code-field[data-state="right"] { background: var(--ink); border-color: var(--ink); color: var(--paper); box-shadow: none; }
/* the digits turn to paper only once the ink is past halfway, so the code never stands in its own colour */
.signin-code-field[data-state="right"] .signin-digit {
  color: var(--paper); transition: color .1s linear .13s;
  animation: signin-settle .32s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(.13s + var(--i) * 30ms);
}
.signin-code-field[data-state="right"] .signin-place::after, .signin-code-field[data-state="right"] .signin-code-space::before { opacity: 0; }
@keyframes signin-settle { 40% { transform: translateY(-3px); } 100% { transform: none; } }
.signin-ways:has(.signin-code-field[data-state="right"]) :is(.signin-code .signin-way, .signin-again) {
  opacity: .3; pointer-events: none; transition: opacity .2s ease-out;
}

/* Entrances, so a step changes without a cut: its parts fade in one after another, a changed title or line fades in.
   Opacity only: nothing measured on the page (the gate's fit) ever sees a part out of its place. */
/* backwards, not both: the entrance holds each part out of sight through its delay, then lets opacity go, so a dim
   or a fade that follows (a press, the right code) transitions instead of cutting */
.signin-ways[data-enter] > *, .signin-terms[data-enter], .signin-foot[data-enter] {
  animation: signin-step-in .32s ease-out backwards; animation-delay: calc(var(--k, 0) * 45ms);
}
.signin-title[data-enter], .signin-lead[data-enter], .signin-way-words[data-enter] { animation: signin-step-in .26s ease-out backwards; }
@keyframes signin-step-in { from { opacity: 0; } }

/* the quiet line under the controls: a new code on the left, another way on the right, so the count moves nothing */
.signin-again { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 20px; margin: 2px 0 0; font-size: 13.5px; line-height: 20px; }
.signin-again .btn-link, .signin-again a, .signin-cancel .btn-link {
  font: inherit; font-weight: 500; color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--ink-4);
  text-underline-offset: 3px; text-decoration-thickness: 1px;
}
.signin-again .btn-link[disabled] { color: var(--ink-3); cursor: default; text-decoration: none; }
/* sized for its longest words ("Send a new code in 60 s"), so the line decides once whether it wraps, not as the
   count shortens */
.signin-again .signin-resend { font-variant-numeric: tabular-nums; min-width: 12.2em; text-align: left; }
@media (hover: hover) {
  .signin-again .btn-link:not([disabled]):hover, .signin-again a:hover, .signin-cancel .btn-link:hover { color: var(--ink); text-decoration-color: var(--ink); }
}

/* on a touch screen the quiet links keep their size of type and take a 40px target past it */
@media (pointer: coarse) {
  .signin-again .btn-link, .signin-again a, .signin-cancel .btn-link, .signin-terms a { position: relative; }
  .signin-again .btn-link::after, .signin-again a::after, .signin-cancel .btn-link::after, .signin-terms a::after {
    content: ""; position: absolute; inset: -10px -4px;
  }
}

@media (pointer: coarse) {
  .signin-terms:not([hidden]) ~ .signin-foot { margin-top: 20px; }  /* a tap under the terms is not Cancel */
}
@media (hover: none) {
  .signin-way:not([disabled]):active { border-color: var(--edge); }
  .signin-way-submit:not([disabled]):active, .signin-way-primary:not([disabled]):active {
    background: color-mix(in srgb, var(--ink) 84%, var(--paper)); border-color: transparent;
  }
}

/* a step under way: a hairline where the controls go, ink travelling along it */
.signin-working { position: relative; height: 2px; margin-top: calc((var(--control-h) - 2px) / 2); overflow: hidden; border-radius: var(--radius-cap); background: var(--rule); }
.signin-working::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 28%; border-radius: var(--radius-cap); background: var(--ink);
  animation: signin-travel 1.1s ease-in-out infinite alternate;
}
@keyframes signin-travel { from { transform: translateX(0); } to { transform: translateX(257%); } }

/* the foot: the terms where the next press continues the sign-in, and Cancel */
.signin-terms { margin: 20px 0 0; max-width: 400px; color: var(--ink-3); font-size: 12.5px; line-height: 18px; text-wrap: balance; overflow-wrap: anywhere; }
.signin-terms a { color: var(--ink-2); text-decoration-color: var(--ink-4); text-underline-offset: 2px; }
.signin-foot { margin-top: 20px; }
.signin-terms:not([hidden]) ~ .signin-foot { margin-top: 12px; }
.signin-cancel { margin: 0; font-size: 13.5px; line-height: 20px; }

/* The smaller pair needs 670px plus breathing room. The container excludes gutters and reflects CSS zoom, so an
   enlarged form switches to one column before either the controls or the artwork can escape the page. */
@container portal-signin (min-width: 720px) {
  .signin {
    --signin-wide: 1;
    --title-size: 40px; --title-lh: 44px; --words-gap: 28px; --col-w: 360px; --pair-gap: 56px;
    grid-template-columns: calc(var(--gate-h0) * .8) var(--col-w);
    /* a little above centre, with space for the terms and Cancel under the controls */
    padding-top: max(0px, calc((100vh - var(--topbar-h) - var(--gate-h0) - 72px) * .44 - 32px));
    padding-top: max(0px, calc((100svh - var(--topbar-h) - var(--gate-h0) - 72px) * .44 - 32px));
  }
  .signin-gate-side { grid-area: auto; justify-content: flex-end; padding-top: var(--cap); }
  .signin-main { grid-area: auto; }
  .signin-words { min-height: 0; padding: 0; }
  .signin-gate { width: calc(var(--gate) * .8); height: var(--gate); }
  .signin-lead { font-size: 15.5px; line-height: 24px; }
}
@container portal-signin (min-width: 900px) {
  .signin { --title-size: 44px; --title-lh: 48px; --col-w: 400px; --pair-gap: 72px; }
}
@container portal-signin (max-width: 320px) {
  .signin { --title-size: 30px; --title-lh: 36px; }
}
/* Short windows and landscape phones at any width: the first screen belongs to the controls. The same form width
   and full-size touch targets remain, with less space above them and no decorative column. */
@media (max-height: 480px) {
  #content:has(.signin) { padding-top: 16px; padding-bottom: max(24px, env(safe-area-inset-bottom)); }
  .signin {
    --signin-wide: 0;
    --title-size: 32px; --title-lh: 38px; --col-w: 400px; --words-gap: 16px; --gap: 8px; --or-h: 20px;
    grid-template-columns: minmax(0, var(--col-w)); padding-top: 0;
  }
  .signin-gate-side { display: none; }
  .signin-words { min-height: 0; padding: 0; }
}
html[data-reduced-motion="true"] .signin-working::after { width: 100%; opacity: .25; }
html[data-reduced-motion="true"] .signin-way-going::after { background-position: 50% 0; opacity: .3; }
@media (prefers-reduced-motion: reduce) {
  .signin-ways[data-enter] > *, .signin-title[data-enter], .signin-lead[data-enter], .signin-terms[data-enter], .signin-foot[data-enter],
  .signin-way-words[data-enter] { animation: none; }
  .signin-way-going::after { animation: none; background-position: 50% 0; opacity: .3; }  /* a still mark, centred */
  .signin-way, .signin .signin-email-field, .signin-code-field { transition: none; }
  .signin-code-field[data-state="wrong"], .signin-code-field[data-state="checking"] .signin-place::after,
  .signin-code-field:focus-within .signin-place[data-active]::after, .signin-place[data-new] .signin-digit,
  .signin-place[data-leaving] .signin-digit, .signin-code-field[data-state="right"] .signin-digit { animation: none; }
  .signin-place::after, .signin-code-space::before { transition: none; }
  .signin-ways:has(.signin-code-field[data-state="right"]) :is(.signin-code .signin-way, .signin-again) { transition: none; }
  .signin-working::after { animation: none; width: 100%; opacity: .25; }
}
/* Forced colours (Windows contrast themes) paint backgrounds as the canvas: the places, the caret, the working line and
   the "or" rules are drawn in system colours instead, and the code field, whose own input is invisible, shows focus. */
@media (forced-colors: active) {
  .signin-place::after, .signin-code-space::before, .signin-working, .signin-or::before, .signin-or::after { forced-color-adjust: none; background: GrayText; }
  .signin-code-field:focus-within .signin-place[data-active]::after, .signin-working::after { forced-color-adjust: none; background: Highlight; }
  .signin-code-field:focus-within { outline: 2px solid Highlight; outline-offset: 2px; }
  .signin-way-going::after { forced-color-adjust: none; background: none; background-color: CanvasText; opacity: .6; }
}

/* ---------------------------------------------------------------- one card in the middle of the page

   A site of the brand "fluid" (signin.js sets data-surface="card"): no picture. The sign-in is one card on the page's
   own ground (styles.css, :root[data-site="fluid"]), 448px wide and 404px tall as first drawn, and its gaps come
   from one unit, 28px: the card's sides are 40px; its title (Funnel Display 34/40) stands 48px over the first
   control, and the one line the page may say has its place in that space; one unit separates the address, the "or",
   the two providers and the terms. Its top is placed with 44% of the window's free height above the card and 56%
   below (its centre near 46% of the height) and holds there: a step that makes the card shorter or taller moves
   only its foot, over 200ms (signin.js resized).

   The address and its press are one control: the field, and at its right end a round press with an arrow, which
   says what it is doing in words while it does it. The code is the same control with the code's places in it, so
   the step changes what the control holds and nothing else moves. Google and GitHub are two equal quiet pills side
   by side; the one pressed takes the row. What a control has to say (a slip, a wrong code) has its line under the
   control from the start, so nothing moves when it is said.

   Focus: a field in use has an ink edge and a soft 4px halo; a press reached by keyboard has a 2px ink ring standing
   2px off it. Nothing loops. The one colour is Clusy's green, when the code is right. */
#content:has(.signin[data-surface="card"]) { padding-top: 0; padding-bottom: 48px; }
.signin[data-surface="card"] {
  --signin-wide: 0;
  --unit: 28px; --card-w: 448px; --card-pad: 40px; --card-h: 404px;
  --title-size: 34px; --title-lh: 40px; --control-h: 52px; --way-h: 48px; --or-h: 18px;
  --go: #00ceae; --on-go: #06221d;
  --ring: 0 0 0 2px var(--raised), 0 0 0 4px var(--ink);
  display: block;
  padding-top: max(16px, calc((100vh - var(--card-h)) * .44 - var(--topbar-h)));
  padding-top: max(16px, calc((100svh - var(--card-h)) * .44 - var(--topbar-h)));
}
.signin-panel {
  position: relative; box-sizing: border-box; width: min(var(--card-w), 100%); margin: 0 auto;
  /* 4px less over the title than at the sides: its line box holds air over the capitals, and the eye measures to them */
  padding: calc(var(--card-pad) - 4px) var(--card-pad) var(--card-pad); border: 1px solid var(--rule); border-radius: var(--radius-card);
  background: var(--raised); box-shadow: var(--card-shadow);
  transition: height .2s cubic-bezier(.2, .8, .2, 1);
  animation: signin-panel-in .26s cubic-bezier(.2, .8, .2, 1) backwards;
}
.signin-panel[data-sizing] { overflow: clip; }
@keyframes signin-panel-in { from { opacity: 0; transform: translateY(6px); } }

/* the words: the title, and under it the one line the page may say, whose place is kept */
.signin[data-surface="card"] .signin-words { min-height: 0; padding: 0; }
.signin[data-surface="card"] .signin-title { font-weight: 600; letter-spacing: -.022em; }
.signin[data-surface="card"] .signin-lead,
.signin[data-surface="card"] .signin-lead:empty { margin: 4px 0 0; min-height: 22px; max-width: none; font-size: 15px; line-height: 22px; }

/* the controls: one unit between them, two columns for the two providers */
.signin[data-surface="card"] .signin-ways {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 10px; margin-top: calc(var(--unit) - 6px);
  transition: grid-template-columns .18s cubic-bezier(.2, .8, .2, 1), column-gap .18s cubic-bezier(.2, .8, .2, 1);
}
.signin[data-surface="card"] .signin-ways > * { grid-column: 1 / -1; }
.signin[data-surface="card"] .signin-email { display: block; }

/* the address, or the code, and its press: one control */
.signin-combo {
  position: relative; display: flex; align-items: center; height: var(--control-h); margin-bottom: var(--unit); padding-right: 5px;
  border: 1px solid var(--edge); border-radius: var(--radius-cap); background: var(--paper); color: var(--ink);
  transition: border-color .14s ease-out, box-shadow .14s ease-out, background-color .16s ease-out;
}
.signin[data-surface="card"] .signin-combo .signin-email-field,
.signin[data-surface="card"] .signin-combo .signin-email-field:focus {
  flex: 1 1 auto; min-width: 0; height: 100%; padding: 0 12px 0 22px; border: 0; background: none; box-shadow: none;
}
.signin-combo:has(.signin-email-field:focus), .signin-combo:has(.signin-code-input:focus) {
  border-color: var(--ink); box-shadow: 0 0 0 4px var(--select);
}
@media (hover: hover) {
  .signin-combo:hover:not(:focus-within):not(:has([aria-invalid="true"])):not(:has([data-state])) { border-color: var(--ink-3); }
}
.signin-combo:has(.signin-email-field[aria-invalid="true"]), .signin-combo:has(.signin-code-field[data-state="wrong"]) { border-color: var(--bad); }
.signin-combo:has(.signin-email-field[aria-invalid="true"]:focus), .signin-combo:has(.signin-code-field[data-state="wrong"] .signin-code-input:focus) {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--bad) 16%, transparent);
}
/* while its press is under way the control goes quiet: the address is held as given */
.signin-combo:has(.signin-go.signin-way-going) { border-color: var(--rule-2); box-shadow: none; }
.signin-combo:has(.signin-go.signin-way-going) .signin-email-field { color: var(--ink-2); }

/* the press at the control's end: round, in ink, an arrow; it widens to say what it is doing */
.signin[data-surface="card"] .signin-go {
  flex: none; width: auto; min-width: 40px; max-width: 40px; height: 40px; padding: 0; gap: 0; overflow: hidden;
  border: 0; background: var(--ink); color: var(--paper); font-size: 14px;
  transition: max-width .18s cubic-bezier(.2, .8, .2, 1), padding .18s cubic-bezier(.2, .8, .2, 1), background-color .14s ease-out,
    color .14s ease-out, transform .12s ease-out, box-shadow .14s ease-out;
}
.signin-go-mark { flex: none; width: 20px; height: 20px; transition: transform .14s ease-out; }
.signin[data-surface="card"] .signin-go .signin-way-words { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
/* It is 40px to the eye and the whole end of the control to a finger: 48 by 52. */
.signin[data-surface="card"] .signin-go::before { content: ""; position: absolute; inset: -6px -6px -6px -2px; border-radius: var(--radius-cap); }
.signin[data-surface="card"] .signin-go { position: relative; z-index: 2; overflow: visible; }  /* over the code's own input, which lies over its places */
.signin[data-surface="card"] .signin-go.signin-way-going { overflow: hidden; }
/* Pointed at, it stands out of the control: a halo opens round it and its arrow leans forward. Under a thumb it gives. */
@media (hover: hover) {
  .signin[data-surface="card"] .signin-go:not([disabled]):not(.signin-way-going):hover { box-shadow: 0 0 0 4px var(--select); }
  .signin[data-surface="card"] .signin-go:not([disabled]):not(.signin-way-going):hover .signin-go-mark { transform: translateX(3px); }
}
.signin[data-surface="card"] .signin-go:not([disabled]):not(.signin-way-going):active {
  transform: scale(.92); background: color-mix(in srgb, var(--ink) 76%, var(--paper)); box-shadow: none; transition-duration: 40ms;
}
.signin[data-surface="card"] .signin-go.signin-way-going { max-width: 220px; padding: 0 16px; cursor: progress; }
.signin[data-surface="card"] .signin-go.signin-way-going .signin-go-mark { display: none; }
.signin[data-surface="card"] .signin-go.signin-way-going .signin-way-words { position: static; width: auto; height: auto; overflow: visible; clip-path: none; }
/* the code's press is quiet until it is the press to make: the code goes by itself once it is whole */
.signin[data-surface="card"] .signin-code .signin-go { background: none; color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--rule-2); }
.signin[data-surface="card"] .signin-code .signin-go.signin-way-primary { background: var(--ink); color: var(--paper); box-shadow: none; }
.signin[data-surface="card"] .signin-code .signin-go[disabled] { background: none; color: var(--ink-4); box-shadow: inset 0 0 0 1px var(--rule); }
@media (hover: hover) {
  .signin[data-surface="card"] .signin-code .signin-go:not([disabled]):not(.signin-way-primary):hover {
    background: var(--ink); color: var(--paper); box-shadow: 0 0 0 4px var(--select);
  }
}
.signin[data-surface="card"] .signin-code .signin-go:not([disabled]):active { background: var(--ink); color: var(--paper); box-shadow: none; }

/* What the control has to say, under it. The control keeps a unit of room under itself, and the line stands in that
   room (4px under the control, 20px of line), so saying it moves nothing; only a second line makes the card taller. */
.signin[data-surface="card"] .signin-problem { margin: calc(4px - var(--unit)) 0 calc(var(--unit) - 24px); font-size: 13px; line-height: 20px; }
.signin[data-surface="card"] .signin-email .signin-captcha[data-open] { margin: 0 0 var(--unit); }

/* "or", on its hairline, a unit under the address and a unit over the providers */
.signin[data-surface="card"] .signin-or { margin-bottom: var(--unit); }

/* Google and GitHub: two equal quiet pills */
.signin[data-surface="card"] .signin-way:not(.signin-go) { position: relative; height: var(--way-h); }
.signin[data-surface="card"] .signin-ways > .signin-way[data-method="google"] { grid-column: 1; }
.signin[data-surface="card"] .signin-ways > .signin-way[data-method="github"] { grid-column: 2; }
.signin[data-surface="card"] .signin-ways > .signin-way[data-method] {
  min-width: 0; padding: 0 16px; overflow: hidden;
  transition: border-color .14s ease-out, background-color .14s ease-out, color .14s ease-out, opacity .16s ease-out, padding .18s ease-out,
    box-shadow .14s ease-out;
}
.signin-way-lead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (hover: hover) {
  .signin[data-surface="card"] .signin-way:not(.signin-way-primary):not(.signin-go):not([disabled]):not(.signin-way-going):hover { background: var(--paper-2); border-color: var(--edge); }
}
.signin[data-surface="card"] .signin-way:not(.signin-go):not([disabled]):not(.signin-way-going):active { background: var(--paper-3); transition-duration: 40ms; }
.signin[data-surface="card"] .signin-way-primary:not([disabled]):active { background: color-mix(in srgb, var(--ink) 76%, var(--paper)); }
/* the one pressed takes the row, and says what it is doing; the other makes way */
.signin[data-surface="card"] .signin-ways[data-pressing]:has(> .signin-way-going[data-method="google"]) { grid-template-columns: minmax(0, 1fr) minmax(0, 0fr); column-gap: 0; }
.signin[data-surface="card"] .signin-ways[data-pressing]:has(> .signin-way-going[data-method="github"]) { grid-template-columns: minmax(0, 0fr) minmax(0, 1fr); column-gap: 0; }
.signin[data-surface="card"] .signin-ways[data-pressing]:has(> .signin-way-going[data-method]) > .signin-way[data-method]:not(.signin-way-going) {
  opacity: 0; padding: 0; border-color: transparent; pointer-events: none;
}
.signin[data-surface="card"] .signin-ways > .signin-way-going[data-method] { justify-content: center !important; padding: 0 16px !important; border-color: var(--edge); }
.signin[data-surface="card"] .signin-way-going::after { content: none; }  /* nothing loops: the words say it */

/* a press reached by keyboard: an ink ring standing off it */
.signin[data-surface="card"] .signin-way:focus-visible { outline: none; box-shadow: var(--ring); }
.signin[data-surface="card"] .signin-code .signin-go:focus-visible { box-shadow: inset 0 0 0 1px var(--rule-2), var(--ring); }
.signin[data-surface="card"] :is(.signin-again .btn-link, .signin-again a, .signin-cancel .btn-link, .signin-terms a):focus-visible {
  outline: 2px solid var(--ink); outline-offset: 2px; border-radius: var(--radius);
}

/* the code: the same control, six places (or eight) where the address was */
.signin[data-surface="card"] .signin-code-field { flex: 1 1 auto; min-width: 0; height: 100%; border: 0; border-radius: var(--radius-cap); background: none; animation: none; }
.signin[data-surface="card"] .signin-code-shown { max-width: 300px; margin: 0 auto; padding: 0 6px 0 16px; font-size: 21px; }
.signin[data-surface="card"] .signin-code-field:focus-within .signin-place[data-active]::after { animation: none; }
.signin[data-surface="card"] .signin-place[data-new] .signin-digit { animation-duration: .14s; animation-delay: calc(var(--d, 0ms) * .36); }
.signin[data-surface="card"] .signin-place[data-leaving] .signin-digit { animation-duration: .14s; animation-delay: calc((5 - var(--i)) * 10ms); }
/* under check, or while its first code goes: quiet, and still */
.signin[data-surface="card"] .signin-code-field:is([data-state="checking"], [data-state="sending"]) .signin-place::after { animation: none; width: 10px; background: var(--rule-2); }
.signin[data-surface="card"] .signin-code-field[data-state="sending"] .signin-place::after { background: var(--rule); }
/* the right code: the control turns Clusy's green, the one colour on the page, as the page leaves */
.signin-combo:has(.signin-code-field[data-state="right"]) { background: var(--go); border-color: var(--go); box-shadow: none; }
.signin[data-surface="card"] .signin-code-field[data-state="right"] { background: none; border: 0; color: var(--on-go); }
.signin[data-surface="card"] .signin-code-field[data-state="right"] .signin-digit { color: var(--on-go); transition: color .12s linear; animation: none; }
.signin-combo:has(.signin-code-field[data-state="right"]) .signin-go,
.signin-combo:has(.signin-code-field[data-state="right"]) .signin-go[disabled] { background: var(--on-go); color: var(--go); box-shadow: none; opacity: 1; }
.signin[data-surface="card"] .signin-ways:has(.signin-code-field[data-state="right"]) .signin-code .signin-way { opacity: 1; }

/* the quiet line under the code, the terms, and Cancel */
.signin[data-surface="card"] .signin-again { margin: 8px 0 0; }
.signin[data-surface="card"] .signin-terms { margin: var(--unit) 0 0; max-width: none; }
.signin[data-surface="card"] .signin-foot { margin-top: 12px; }
.signin[data-surface="card"] .signin-terms[hidden] ~ .signin-foot { margin-top: var(--unit); }

/* a step under way with nothing to press: one hairline that fills once, and waits */
.signin[data-surface="card"] .signin-working { margin: calc((var(--control-h) - 2px) / 2) 0; }
.signin[data-surface="card"] .signin-working::after { width: 100%; transform-origin: left; animation: signin-fill 2.4s cubic-bezier(.1, .7, .2, 1) both; }
@keyframes signin-fill { from { transform: scaleX(0); } to { transform: scaleX(.86); } }

/* A step dissolves into the next: what the card held goes first, in 90ms (signin.js dissolving), and what it holds
   now comes up as that ends, in 130ms, all of it together: the card is one thing. The two are never both readable. */
.signin-ghost {
  position: absolute; inset: calc(var(--card-pad) - 4px) var(--card-pad) auto; pointer-events: none;
  animation: signin-step-out .09s ease-in forwards;
}
@keyframes signin-step-out { to { opacity: 0; } }
.signin[data-surface="card"] .signin-ways[data-enter] > *, .signin[data-surface="card"] .signin-terms[data-enter], .signin[data-surface="card"] .signin-foot[data-enter] {
  animation-duration: .13s; animation-delay: 70ms;
}
.signin[data-surface="card"] :is(.signin-title, .signin-lead)[data-enter] { animation-duration: .13s; animation-delay: 70ms; }
.signin[data-surface="card"] .signin-way-words[data-enter] { animation-duration: .14s; }

/* ---------------------------------------------------------------- the card in the hand

   A phone keeps the card: a floating card with 16px of ground either side (never less than the screen's safe area),
   its sides 24px, the unit 24px, the providers stacked and saying Continue with. It stands a third of the way down
   the free height, not in the middle: with the keyboard up (it covers the lower 40% of the screen and resizes
   nothing) the title, the control and its press, and both providers are still in view, and nothing has moved. Heights
   are the small viewport's (svh), so the browser's bar collapsing moves nothing either. */
@container portal-signin (max-width: 480px) {
  .signin[data-surface="card"] {
    --unit: 24px; --card-pad: 24px; --title-size: 30px; --title-lh: 36px; --card-h: 410px;
    padding-top: max(12px, calc((100vh - var(--card-h)) * .32 - var(--topbar-h)));
    padding-top: max(12px, calc((100svh - var(--card-h)) * .32 - var(--topbar-h)));
  }
  .signin[data-surface="card"] .signin-ways > .signin-way[data-method] { grid-column: 1 / -1; padding: 0 20px; }
  .signin[data-surface="card"] .signin-ways > .signin-way[data-method="github"] { margin-top: 10px; }
  .signin[data-surface="card"] .signin-way-lead { position: static; width: auto; height: auto; overflow: visible; clip-path: none; }
  .signin[data-surface="card"] .signin-ways[data-pressing]:has(> .signin-way-going[data-method]) { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 10px; }
  .signin[data-surface="card"] .signin-ways[data-pressing]:has(> .signin-way-going[data-method]) > .signin-way[data-method]:not(.signin-way-going) {
    opacity: .4; padding: 0 20px; border-color: var(--rule-2);
  }
}
@container portal-signin (max-width: 320px) {
  .signin[data-surface="card"] { --card-pad: 20px; --title-size: 28px; --title-lh: 34px; --card-h: 400px; }
  .signin[data-surface="card"] .signin-code-shown { padding: 0 2px 0 10px; font-size: 19px; }
}
/* a column too narrow for "Continue with GitHub" (a small phone at the largest text size): each says its name, whole,
   as they do side by side; never two that both read "Continue with G" */
@container portal-signin (max-width: 280px) {
  .signin[data-surface="card"] .signin-way-lead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}
#content:has(.signin[data-surface="card"]) { padding-bottom: max(48px, calc(env(safe-area-inset-bottom) + 24px)); }
/* the field a keyboard is opened for is brought into view with its title over it and its press beside it */
.signin[data-surface="card"] .signin-combo :is(.signin-email-field, .signin-code-input) { scroll-margin: 104px 0 28px; }

/* A phone on its side (a short, wide window): the card is two columns, the words on the left and the controls on the
   right, so the field and its press are at the top of the screen, beside the title, over a keyboard that leaves less
   than half the height. The bar scrolls away with the page instead of staying. */
@media (max-height: 480px) {
  .signin[data-surface="card"] { --title-size: 28px; --title-lh: 34px; --unit: 20px; --card-pad: 24px; --control-h: 48px; --way-h: 44px; --card-h: 330px; }
  .signin[data-surface="card"] { padding-top: 8px; }
}
@media (max-height: 480px) and (min-width: 560px) {
  .signin[data-surface="card"] { --card-w: 680px; }
  .signin[data-surface="card"] :is(.signin-panel, .signin-ghost) {
    display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); grid-template-rows: auto auto 1fr; column-gap: 32px; align-content: start;
  }
  .signin[data-surface="card"] :is(.signin-panel, .signin-ghost) > .signin-words { grid-area: 1 / 1; }
  .signin[data-surface="card"] :is(.signin-panel, .signin-ghost) > .signin-ways { grid-area: 1 / 2 / span 3; margin-top: 2px; }
  .signin[data-surface="card"] .signin-panel > .signin-captcha[data-open] { grid-area: 4 / 2; }
  .signin[data-surface="card"] :is(.signin-panel, .signin-ghost) > .signin-terms { grid-area: 2 / 1; margin-top: 8px; }
  .signin[data-surface="card"] :is(.signin-panel, .signin-ghost) > .signin-foot { grid-area: 3 / 1; }
  .signin[data-surface="card"] .signin-terms[hidden] ~ .signin-foot { margin-top: 12px; }
  .signin[data-surface="card"] .signin-or { margin-bottom: 16px; }
  .signin[data-surface="card"] .signin-combo { margin-bottom: 16px; }
  .signin[data-surface="card"] .signin-problem { margin: -12px 0 -8px; }
  .signin[data-surface="card"] .signin-combo :is(.signin-email-field, .signin-code-input) { scroll-margin: 28px 0 16px; }
}
@media (max-height: 480px) and (min-width: 560px) and (max-width: 639px) {
  .signin[data-surface="card"] { --title-size: 24px; --title-lh: 30px; }
}

/* Touch. Every target is at least 44 by 44: the quiet links take the room round them without moving a line (a larger
   box drawn over each, which is in no line's flow). A tap leaves no grey flash, selects no label and is never a double tap's zoom. Hover is only ever a
   pointer's (every hover rule above is under hover: hover), so nothing stays lit after a tap. */
.signin[data-surface="card"] :is(.signin-way, .signin-go, .btn-link, a) { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.signin[data-surface="card"] :is(.signin-way, .signin-go, .btn-link, .signin-or) { -webkit-user-select: none; user-select: none; }
.signin[data-surface="card"] .signin-combo { -webkit-tap-highlight-color: transparent; }
@media (pointer: coarse) {
  .signin[data-surface="card"] .signin-terms a::after { inset: -15px -4px; }
  .signin[data-surface="card"] :is(.signin-again .btn-link, .signin-again a, .signin-cancel .btn-link)::after { inset: -13px -6px; }
  .signin[data-surface="card"] .signin-terms:not([hidden]) ~ .signin-foot { margin-top: 28px; }  /* a tap under the terms is not Cancel */
  .signin[data-surface="card"] .signin-again { gap: 24px; }  /* side by side, or one under the other where the column is narrow: never two targets on one spot */
}
@media (hover: none) {
  .signin[data-surface="card"] .signin-way:not(.signin-go):not(.signin-way-primary):not([disabled]):not(.signin-way-going):active { background: var(--paper-3); border-color: var(--edge); }
  .signin[data-surface="card"] :is(.signin-again .btn-link:not([disabled]), .signin-again a, .signin-cancel .btn-link, .signin-terms a):active { color: var(--ink); text-decoration-color: var(--ink); }
}
html[data-reduced-motion="true"] .signin[data-surface="card"] .signin-working::after { transform: scaleX(.86); width: 100%; opacity: .25; }
@media (prefers-reduced-motion: reduce) {
  .signin-ghost { display: none; }
  .signin-panel, .signin[data-surface="card"] .signin-ways, .signin-combo, .signin[data-surface="card"] .signin-go, .signin-go-mark,
  .signin[data-surface="card"] .signin-ways > .signin-way[data-method] { animation: none; transition: none; }
  .signin[data-surface="card"] .signin-working::after { animation: none; transform: scaleX(.86); width: 100%; opacity: .25; }
}
@media (forced-colors: active) {
  .signin-panel { border-color: CanvasText; }
  .signin-combo:has(.signin-email-field:focus), .signin-combo:has(.signin-code-input:focus), .signin[data-surface="card"] .signin-way:focus-visible {
    outline: 2px solid Highlight; outline-offset: 2px;
  }
}
