/* /login. One screen, one column, nothing else on the page.
 *
 * Every colour here is a token from app.css, so the dark theme is inherited
 * rather than re-declared: data-theme="dark" moves --white, --ink, --line-2 and
 * --brand, and this file moves with them. The one rule that is not a token is the
 * error red, which uses the market-down hue because it is the only red in the
 * system that is defined on both grounds.
 *
 * Sizes that are deliberate and not to be trimmed:
 *   - inputs at 16px, which is the size below which iOS Safari zooms the page on
 *     focus. A login form is exactly where that is felt.
 *   - 48px on both buttons and 44px on the two text links, which are the tap
 *     targets a phone needs.
 */

.sf-login {
  /* 74px is the marketing nav bar. The form centres in what is left, sitting
     a little above true centre so it reads as centred to the eye. */
  min-height: calc(100dvh - 74px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px 10vh;
  box-sizing: border-box;
}

.sf-login-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
}

.sf-login h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.15;
  text-align: center;
  margin: 0 0 6px;
  color: var(--ink);
}

/* ---------- fields ---------- */

.sf-login-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sf-login-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
}

.sf-login-field input {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.3;
  min-height: 48px;
  padding: 12px 13px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--white);
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.sf-login-field input::placeholder { color: var(--ink-3); }

.sf-login-field input:focus {
  border-color: var(--action);
  box-shadow: 0 0 0 3px var(--focus);
}

.sf-login-field input[aria-invalid="true"] { border-color: var(--mkt-dn); }

/* The honeypot. Off screen rather than display:none, because a bot that reads
   computed styles skips a hidden field and fills a visible one. Never focusable,
   never announced. */
.sf-login-hp {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- buttons ---------- */

.sf-login-card .sf-login-submit,
.sf-login-card .sf-login-alt {
  min-height: 48px;
  width: 100%;
  justify-content: center;
  font-size: 15.5px;
}

.sf-login-card .sf-login-submit { margin-top: 14px; }

.sf-login-card .btn:disabled { opacity: 0.55; cursor: default; transform: none; }

/* The two text actions. Buttons, not links: they do work on this page rather
   than going anywhere, and a screen reader should be told which it is. */
.sf-login-linkbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  background: none;
  font-family: var(--sans);
  font-size: 13.5px;
  color: var(--brand);
  cursor: pointer;
  border-radius: 8px;
}

.sf-login-linkbtn:hover { text-decoration: underline; }
.sf-login-linkbtn:disabled { opacity: 0.55; cursor: default; text-decoration: none; }
.sf-login-linkbtn:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }

/* ---------- divider ---------- */

.sf-login-or {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-3);
  font-size: 12.5px;
}

.sf-login-or::before,
.sf-login-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ---------- messages ---------- */

.sf-login-msg {
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.5;
  border-radius: 9px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink-2);
}

.sf-login-msg.is-error {
  border-color: color-mix(in srgb, var(--mkt-dn) 45%, transparent);
  background: color-mix(in srgb, var(--mkt-dn) 9%, transparent);
  color: var(--ink);
}

/* ---------- the two standing lines ---------- */

.sf-login-note {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-3);
  text-align: center;
  margin: 0;
}

.sf-login-foot {
  font-size: 13.5px;
  color: var(--ink-2);
  text-align: center;
  margin: 8px 0 0;
}

.sf-login-foot a {
  color: var(--brand);
  font-weight: 600;
}

.sf-login-foot a:hover { text-decoration: underline; }

/* ---------- the already-signed-in case ----------
 *
 * The head script in app/layout.tsx sets `is-authed` on <html> BEFORE first paint
 * when this browser holds the signed-in hint, which is the only way to keep the
 * form off the screen for somebody who is already logged in: the real answer
 * needs supabase-js, and that is hundreds of milliseconds after the page has
 * painted. So the hint hides the form and shows a waiting line, and the client
 * then does the real check: signed in, it redirects; hint stale, it stamps
 * data-ready on the section and the form appears.
 *
 * Guests never get the class and never see either rule, so their form is in the
 * first painted frame with no JavaScript involved. */
.sf-login-checking {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--ink-3);
  font-size: 14px;
  padding: 40px 0;
}

html.is-authed .sf-login:not([data-ready]) .sf-login-card { display: none; }
html.is-authed .sf-login:not([data-ready]) .sf-login-checking { display: flex; }

.sf-login-spin {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid var(--line-2);
  border-top-color: var(--brand);
  animation: sf-login-spin .7s linear infinite;
}

@keyframes sf-login-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .sf-login-spin { animation-duration: 2.4s; }
}

@media (max-width: 420px) {
  .sf-login { padding-left: 16px; padding-right: 16px; }
  .sf-login h1 { font-size: 24px; }
}
