/* Sign-in page. Builds on /brand.css (link it first); replaces style.css + onboarding.css on this page only. */
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); color: var(--text);
  font: var(--t-body); -webkit-font-smoothing: antialiased; overflow-x: clip; }
h1, p { margin: 0; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
a:not(.b-btn):focus-visible { border-radius: 4px; }
.icon-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.skip { position: fixed; left: 16px; top: 10px; z-index: 99; padding: 10px 14px; border-radius: 10px; background: var(--raised); border: 1px solid var(--line2);
  text-decoration: none; font-size: 14px; transform: translateY(-160%); }
.skip:focus { transform: none; }

/* the pixel word is drawn black; this page is always dark, so always invert it */
.b-word .b-pix, :root .b-word .b-pix { filter: invert(1) brightness(.95) !important; }
.b-word { min-height: 40px; }

/* header: the landing nav treatment (58px, hairline under a full-width bar, 1120px inner wrap) */
.auth-header { position: relative; z-index: 1; width: 100%; border-bottom: 1px solid var(--line); background: var(--bg); }
.auth-wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 58px;
  width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.auth-nav a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 6px; color: var(--muted); text-decoration: none; font-size: 14px; }
.auth-nav a:hover { color: var(--text); }

/* the card hangs from a fixed top edge, so it does not move when a state changes its height */
.auth-stage { position: relative; z-index: 1; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 12px; padding: clamp(48px, 12vh, 128px) 16px 32px; outline: none; }
.auth-card { width: 100%; max-width: 416px; padding: 32px; display: grid; text-align: left; box-shadow: none; }
.auth-heading { display: grid; gap: 8px; margin: 0 0 24px; }
.auth-heading h1 { font: var(--t-h2); font-weight: 650; letter-spacing: -0.025em; }
.auth-heading p { color: var(--muted); font: var(--t-small); font-size: 14.5px; text-wrap: balance; }

.auth-providers { display: grid; gap: 10px; }
.auth-providers:not(:has(> :not([hidden]))) { display: none; }
.b-btn { width: 100%; min-height: 44px; font-size: 14.5px; }
.provider-button { justify-content: flex-start; transition: opacity .15s; }
.signin-card[aria-busy="true"] .provider-button { opacity: .55; }

/* Shared email and invite-link form. */
.email-signin { display: grid; gap: 0; }
.email-signin > label { margin-bottom: 7px; font: var(--t-small); }
.field-error { min-height: 18px; margin: 6px 0 4px; text-align: left; font: var(--t-small); font-size: 12.5px; line-height: 18px; color: var(--amber); }
.field-error:empty { min-height: 0; margin: 0 0 12px; }
.email-signin .b-input { min-height: 44px; text-align: left; }
.email-signin .b-input::placeholder { color: var(--faint); }
.email-signin .b-input[aria-invalid="true"] { border-color: var(--amber); }
.email-signin .b-btn:disabled { cursor: progress; opacity: .7; }
.or { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--faint); font: var(--t-small); }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.email-signin[hidden] + .or,
.signin-card:not(:has(.auth-providers > :not([hidden]))) .or { display: none; }
.sent-to { color: var(--text); font-weight: 500; overflow-wrap: anywhere; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.signin-card[aria-busy="true"] .provider-button { pointer-events: none; cursor: progress; }
.signin-card[aria-busy="true"] { cursor: progress; }
.signin-card.swap { animation: card-in .15s ease-out; }
@keyframes card-in { from { opacity: .4; } to { opacity: 1; } }
.b-btn .icon { width: 17px; height: 17px; flex: none; fill: currentColor; }
.b-btn.p .icon { fill: #070908; }
#continue-session .icon { fill: none; stroke: #070908; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
#continue-session:hover .icon { transform: translateX(2px); }

/* status: empty when signed out, muted while checking, amber when sign-in failed, a green dot once signed in */
.status { margin: 0 0 16px; font: var(--t-small); color: var(--muted); overflow-wrap: break-word; text-wrap: pretty; }
.status:empty, .status.error:empty { display: none !important; }
.status.error:not(:empty) { display: flex; gap: 10px; align-items: flex-start; text-align: left; padding: 11px 13px; border-radius: 10px;
  color: var(--text); background: rgba(224,173,79,.07); border: 1px solid rgba(224,173,79,.28); }
/* note: a neutral notice, one plain muted line (no box, no dot); only an error gets the amber box */
.status.note:not(:empty) { display: block; font-size: 13px; color: var(--muted); }
.status.error::before { content: ""; flex: none; width: 7px; height: 7px; margin-top: 7px; border-radius: 50%; background: var(--amber); }
#email-sent:not([hidden]) { display: grid; }

/* no buttons under the status (e.g. no provider configured): no gap left behind it */
.signin-card:not(:has(.auth-providers > :not([hidden]))):not(:has(#signin-support-button:not([hidden]))):not(:has(#continue-session:not([hidden]))) #signin-status { margin-bottom: 0; }

/* disabled account: one way forward, emailing support */
#signin-support-button { margin-top: 0; }

/* signed in: one centred line of plain text, green dot, "Signed in as", then the identity, cut with an ellipsis when long (no pill) */
#signin-status.signed-in { justify-self: center; display: inline-flex; align-items: center; gap: 8px; max-width: 100%; min-width: 0;
  margin: 0 0 20px; padding: 0; border: 0; background: none;
  font: var(--t-small); white-space: nowrap; overflow: hidden; }
#signin-status.signed-in::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.who-label { flex: none; color: var(--muted); }
.who { display: block; min-width: 0; max-width: 100%; color: var(--text); font: var(--t-small); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who.b-num { font-family: var(--mono); font-size: 13px; }
.who-email { display: inline-flex; min-width: 0; max-width: 100%; overflow: hidden; }
.who-local { flex: none; white-space: nowrap; }
.who-domain { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signin-card:has(#continue-session:not([hidden])) .auth-heading { margin-bottom: 18px; }
#continue-session { margin-top: 0; }
.switch-account { justify-self: center; display: inline-flex; align-items: center; min-height: 40px; margin-top: 14px; padding: 0 10px;
  background: none; border: 0; border-radius: 8px; font: var(--t-small); color: var(--muted); cursor: pointer;
  text-decoration: underline; text-decoration-color: var(--line3); text-underline-offset: 3px; text-decoration-thickness: 1px; }
.switch-account:hover { color: var(--text); text-decoration-color: currentColor; }
.switch-account:disabled { cursor: progress; opacity: .7; }
/* sign-out failed: the amber box under the link; the identity above stays as it was */
.switch-status.error:not(:empty) { margin: 8px 0 0; }

.signin-help { display: grid; gap: 4px; margin-top: 16px; font: var(--t-small); font-size: 13px; color: var(--muted); }
.signin-help p { max-width: 36ch; }
/* the slow-check line takes the "New here?" line's place in the same grid cell, so nothing moves */
.signin-msg { display: grid; }
.signin-msg > p { grid-area: 1 / 1; }
.signin-checking { visibility: hidden; display: inline-flex; align-items: center; gap: 9px; color: var(--muted); }
.signin-checking::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); animation: pulse 1.6s ease-in-out infinite; }
.signin-card.checking .signin-checking { visibility: visible; }
.signin-card.checking #signin-new { visibility: hidden; }
@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
.signin-help a { color: var(--text); text-decoration: none; border-bottom: 1px solid var(--line3); }
.signin-help a:hover { border-color: var(--text); }

.legal-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 18px; }
.legal-links a { display: inline-flex; align-items: center; min-height: 40px; color: var(--muted); text-decoration: none; font-size: 12.5px; }
.legal-links a:hover { color: var(--text); }

@media (max-width: 480px) {
  .auth-stage { padding-top: clamp(30px, 7vh, 60px); }
  /* a phone has no room for the label and a full email: keep the domain, read the label out only to screen readers */
  #signin-status.signed-in.long .who-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .auth-card { padding: 24px 20px; }
}
@media (max-height: 700px) and (max-width: 480px) {
  .auth-stage { padding-top: 4vh; }
  .signin-help { margin-top: 16px; }
}
@media (max-width: 340px) {
  .auth-card { padding: 24px 16px 20px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Account entry shares the illustrated panel with the landing-page identity. */
.auth-brand { display: none; }
.auth-page .b-dots { display: none; }
.auth-card { background: transparent; border: 0; box-shadow: none; padding: 0; }
.auth-stage { justify-content: center; padding: 40px 24px; }
.auth-heading h1 { font-size: clamp(28px, 3vw, 36px); letter-spacing: -.05em; }
.provider-button { justify-content: center; }
.signin-help a { display: inline-flex; align-items: center; min-height: 44px; }
.auth-page .auth-card .b-btn { min-height: 46px; }
.auth-page .switch-account { min-height: 44px; }
.auth-page .legal-links a { min-height: 44px; }
@media (min-width: 700px) {
  .auth-header { position: absolute; inset: 0 0 auto; z-index: 2; background: transparent; border: 0; }
  .auth-header .auth-wrap { max-width: none; padding: 26px 48px; }
  .auth-brand { display: flex; flex-direction: column; justify-content: center; align-items: center; position: absolute; inset: 0 auto 0 0; width: 44.5%; min-height: 640px; border-right: 1px solid var(--line); background: #090b0a; }
  .auth-brand img { display: block; width: min(84%,470px); height: auto; margin-bottom: 100px; }
  .auth-brand div { position: absolute; left: 9%; right: 7%; bottom: 9%; }
  .auth-brand h2 { margin: 0 0 18px; font-size: clamp(36px,3.7vw,56px); line-height: 1; letter-spacing: -.055em; }
  .auth-brand p { max-width: 46ch; color: var(--muted); }
  .auth-stage { min-height: max(640px,100dvh); margin-left: 44.5%; position: relative; }
  .auth-card { width: min(100%,370px); }
  .auth-stage .legal-links { position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%); }
  .auth-recovery .auth-brand { display: none; }
  .auth-recovery .auth-stage { margin-left: 0; }
}
@media (max-width: 849px) {
  .auth-stage { width: 100%; justify-content: flex-start; align-items: center; padding: clamp(44px,8vh,74px) 24px 14px; }
  .auth-card { width: min(100%,370px); padding: 0; }
  .auth-stage .legal-links { margin-top: auto; padding-top: 28px; }
}
.invite-recovery { margin-top: 8px; font-size: 14px; color: var(--muted); }
.invite-recovery summary { padding-block: 12px; min-height: 44px; cursor: pointer; color: var(--text); }
.invite-recovery p { margin: 0 0 8px; }

/* Sign-in card, all widths (boat.dev-style: one bordered card, CLI first) */
.auth-page .auth-card { background: var(--bg2, #0b0d0c); border: 1px solid var(--line2); border-radius: 14px; padding: 28px; max-width: 440px; gap: 0; }
.cli-box { display: grid; gap: 8px; margin-bottom: 22px; }
.cli-l { font-size: 13px; color: var(--muted); }
.cli-row { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line2); border-radius: 10px; background: #050605; padding: 8px 8px 8px 12px; min-width: 0; }
.cli-row code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; font: 12.5px var(--mono); color: var(--text); scrollbar-width: none; }
.cli-copy { flex: none; border: 1px solid var(--line2); background: transparent; color: var(--text); border-radius: 7px; padding: 5px 10px; font: 500 12px var(--sans); cursor: pointer; }
.cli-copy:hover { background: rgba(255,255,255,.06); }
.human-key form, .human-key .keybar { display: grid; gap: 10px; margin: 0; }
.human-key label { font-size: 13px; color: var(--muted); }
.human-key input { width: 100%; box-sizing: border-box; }
.human-key button[type=submit] { width: 100%; min-height: 44px; justify-content: center; }
.human-key .err:empty { display: none; }
.invite-recovery.human-key summary { list-style: none; display: flex; align-items: center; justify-content: center; border-top: 1px solid var(--line); margin-top: 14px; padding-top: 16px; color: var(--muted); font-size: 13px; }
.invite-recovery.human-key summary::-webkit-details-marker { display: none; }
.invite-recovery.human-key summary:hover { color: var(--text); }
.invite-recovery.human-key[open] summary { margin-bottom: 12px; }
.key-direct { margin-top: 6px; }
.signin-card.key-only .or { display: none; }
.signin-card .cli-box { margin: 4px 0 18px; }
.auth-page .auth-card { box-sizing: border-box; width: 100%; max-width: min(440px, 100%); }
@media (min-width: 700px) and (max-width: 1000px) {
  .auth-stage { padding-left: 20px; padding-right: 20px; }
  .auth-page .auth-card { padding: 22px; }
  .auth-brand h2 { font-size: 32px; }
}
@media (min-width: 700px) { .auth-stage { width: auto; max-width: 55.5%; box-sizing: border-box; } }

/* Google / GitHub, then "or", then email + password (plugin/accounts.py) */
.auth-providers .provider-button { gap: 10px; }
.provider-button .icon-wrap { display: inline-flex; flex: none; width: 18px; height: 18px; }
.provider-button .icon-wrap svg { width: 18px; height: 18px; }
.provider-button[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.provider-button[aria-disabled="true"]:hover { background: inherit; }
.password-signin .b-input + label { margin-top: 14px; }
.password-signin .field-error:empty { margin: 0 0 14px; }
.password-signin #password-go { margin-top: 0; }
.signin-card .signin-help { margin: 14px 0 18px; justify-items: center; text-align: center; }
.signin-card .signin-help p { max-width: none; }

/* no box around the form: just the form, narrower and tighter */
.auth-page .auth-card { background: transparent; border: 0; border-radius: 0; padding: 0; max-width: min(360px, 100%); }
.auth-page .auth-heading { gap: 4px; margin-bottom: 16px; }
.auth-page .auth-heading h1 { font-size: 26px; }
.auth-page .auth-providers { gap: 8px; }
.auth-page .auth-card .b-btn { min-height: 40px; font-size: 14px; }
.auth-page .email-signin .b-input { min-height: 40px; }
.auth-page .password-signin .b-input + label { margin-top: 10px; }
.auth-page .or { margin: 12px 0; }
.auth-page .signin-help { margin-top: 10px; }
.auth-page .cli-box { margin: 16px 0 10px; gap: 6px; }
.auth-page .signin-card .cli-box { margin: 16px 0 10px; }
