/*
 * Login and signup — the label the account issues.
 *
 * The screen is a Forest field carrying one Paper object: an address label with the
 * warehouse lines printed down the left, the recipient line you fill in on the right,
 * and a register across the foot saying which of the three moves you are making.
 *
 * What this replaced: a 50/50 split with a 420px form floating in the middle of a
 * 720px column of empty Paper. The card occupied about a seventh of its own half, the
 * two panes shared no axis, and the loudest thing on the screen was a tab switcher
 * offering a choice between two identical actions. None of that was a spacing problem,
 * so none of it is fixed with spacing here.
 *
 * Everything below is the system's existing vocabulary. The stub rows are the landing
 * page's own .lb-address__row grammar, the mask is its .lb-address__value--masked, the
 * field names are the Label role opted into by lang="en", and the label is laid on the
 * desk with the same one-shot the calculator slip uses. No new motion, no new colour,
 * no second amber.
 */

.lb-auth {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  justify-items: center;
  align-content: start;
  gap: var(--space-8);
  padding: clamp(24px, 4vw, 48px) clamp(20px, 4vw, 40px);
  background: var(--surface-darker);
  color: var(--text-on-dark);
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

/*
 * The field the label is laid on, printed rather than plain.
 *
 * Same --pattern-anchor tile the homepage hero carries, at the same 80px and the same
 * 5% white, because this is the same Forest field seen one click later. A different
 * ornament here would say the customer had arrived somewhere else.
 *
 * It is a paint on a pseudo-element: no DOM, no request, nothing for a screen reader
 * to meet, and the screen is identical with the rule deleted.
 */
.lb-auth::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: var(--pattern-anchor);
  background-repeat: repeat;
  background-size: 80px 80px;
}

/* The tile is absolutely positioned and the rest of this screen is not, so the label
   and its neighbours need a layer of their own to sit on. Without this the pattern
   paints over them. */
.lb-auth > * {
  position: relative;
  z-index: 1;
}

@media (max-width: 767px) {
  .lb-auth::before {
    background-size: 64px 64px;
  }
}

/* The carrier's mark on the crate: top-left of the field, off the label itself. */
.lb-chrome a.lb-auth__mark {
  color: var(--white);
  justify-self: start;
}

.lb-chrome a.lb-auth__mark:hover,
.lb-chrome a.lb-auth__mark:focus-visible {
  color: var(--white);
  text-decoration: none;
}

/* -------------------------------------------------------------------------
 * The label
 * ---------------------------------------------------------------------- */

.lb-auth__label {
  width: 100%;
  max-width: 940px;
  align-self: center;
  display: grid;
  grid-template-rows: 1fr auto;
  border: var(--border-width) solid var(--border-default);
  border-radius: var(--radius-xl);
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
}

/*
 * Laid on the desk, once — the same gesture and the same curve the calculator's quote
 * slip uses, because this is the same kind of object: a Paper slip arriving on a dark
 * ground. Reusing it keeps the system at three sanctioned motions rather than four.
 */
.lb-auth__label {
  animation: lb-laid 560ms cubic-bezier(.16, 1, .3, 1) both;
}

@media (prefers-reduced-motion: reduce) {
  .lb-auth__label {
    animation: none;
  }
}

/*
 * Stub and recipient line. The stub is sized to its content and the action column
 * takes the rest, because the form is what the screen is for — a 50/50 here would
 * hand half the label back to the thing you cannot yet read.
 */
.lb-auth__body {
  display: grid;
  grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
}

/* -------------------------------------------------------------------------
 * The stub — what the account fills in
 * ---------------------------------------------------------------------- */

.lb-auth__stub {
  display: grid;
  align-content: start;
  gap: var(--space-6);
  padding: var(--space-8) var(--space-6);
  background: var(--green-tint-6);
  border-right: var(--border-width) solid var(--border-default);
}

.lb-auth__stub-rows {
  display: grid;
  align-content: start;
}

/* The landing card's rows, minus its own padding — here they are the whole column. */
.lb-auth__stub-row {
  grid-template-columns: 112px minmax(0, 1fr);
  padding: 11px 0;
}

.lb-auth__stub-row:first-child {
  border-top: 0;
}

/* The one row whose shape is real: a confirmed prefix, and the digits the account
   issues. Masking the digits states the format without inventing an identifier. */
.lb-auth__stub-id {
  font-weight: var(--weight-semibold);
  filter: none;
}

.lb-auth__stub-digits {
  color: var(--muted);
  letter-spacing: .06em;
}

.lb-auth__stub-note {
  margin: 0;
  font-size: var(--text-caption);
  line-height: var(--lh-small);
  color: var(--muted);
}

/* -------------------------------------------------------------------------
 * The recipient line — what you write on
 * ---------------------------------------------------------------------- */

.lb-auth__act {
  display: grid;
  align-content: start;
  gap: var(--space-5);
  padding: var(--space-8);
  min-width: 0;
}

.lb-auth__head {
  display: grid;
  gap: var(--space-1);
  align-content: start;
}

/*
 * The heading block reserves its tallest copy, so moving between states does not
 * shuffle the field and the button underneath it. On a phone the submit button
 * shifting mid-reach is the failure this prevents.
 */
.lb-auth[data-step="form"] .lb-auth__head,
.lb-auth[data-step="otp"] .lb-auth__head {
  min-height: 84px;
}

.lb-auth__h1 {
  margin: 0;
  font-size: var(--text-h2);
  line-height: var(--lh-h2);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  color: var(--deep-green);
  text-wrap: pretty;
}

.lb-auth__lede {
  margin: 0;
  font-size: var(--text-small);
  line-height: var(--lh-bangla);
  color: var(--muted);
  max-width: 46ch;
}

.lb-auth__sentto {
  color: var(--ink);
  font-weight: var(--weight-medium);
}

.lb-auth__notice[hidden] {
  display: none;
}

.lb-auth__form {
  display: grid;
  gap: 18px;
  align-content: start;
}

/*
 * The address slot and the code slot are the same slot: both reserve the taller of the
 * two so the label does not resize as you move from one to the other.
 */
.lb-auth[data-step="form"] .lb-auth__form,
.lb-auth[data-step="otp"] .lb-auth__form {
  min-height: 196px;
}

/* The field name sits in the address block's own hand, so the input reads as the
   recipient line of the label rather than as a control that landed on it. */
.lb-auth__line {
  display: grid;
  gap: var(--space-2);
}

.lb-auth__line-label {
  color: var(--muted);
}

/* -------------------------------------------------------------------------
 * The register — which of the three moves you are making
 * ---------------------------------------------------------------------- */

.lb-auth__register {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: var(--border-width) solid var(--border-default);
}

.lb-auth__reg {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-content: start;
  gap: 2px var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-left: var(--border-width) solid var(--border-default);
}

.lb-auth__reg:first-child {
  border-left: 0;
}

.lb-auth__reg-num {
  grid-row: span 2;
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-overline);
  line-height: 20px;
  color: var(--muted);
}

.lb-auth__reg-name {
  font-size: var(--text-small);
  line-height: 20px;
  font-weight: var(--weight-semibold);
  color: var(--muted);
}

.lb-auth__reg-note {
  font-size: var(--text-caption);
  line-height: var(--lh-small);
  color: var(--muted);
}

/*
 * The screen's single amber mark, spent on the one thing worth pointing at: where you
 * are standing right now. The old panel spent three ambers on decorative ordinals,
 * which is what the scarcity rule exists to stop.
 */
.lb-auth[data-step="form"] [data-lb-reg="form"] .lb-auth__reg-num,
.lb-auth[data-step="otp"] [data-lb-reg="otp"] .lb-auth__reg-num,
.lb-auth[data-step^="done"] [data-lb-reg="done"] .lb-auth__reg-num {
  color: var(--amber-ink);
}

.lb-auth[data-step="form"] [data-lb-reg="form"] .lb-auth__reg-name,
.lb-auth[data-step="otp"] [data-lb-reg="otp"] .lb-auth__reg-name,
.lb-auth[data-step^="done"] [data-lb-reg="done"] .lb-auth__reg-name {
  color: var(--ink);
}

.lb-auth[data-step="form"] [data-lb-reg="form"] .lb-auth__reg-note,
.lb-auth[data-step="otp"] [data-lb-reg="otp"] .lb-auth__reg-note,
.lb-auth[data-step^="done"] [data-lb-reg="done"] .lb-auth__reg-note {
  color: var(--text-body);
}

/* Steps already behind you read as done rather than pending. */
.lb-auth[data-step="otp"] [data-lb-reg="form"],
.lb-auth[data-step^="done"] [data-lb-reg="form"],
.lb-auth[data-step^="done"] [data-lb-reg="otp"] {
  opacity: .55;
}

/* -------------------------------------------------------------------------
 * Support line, under the label on the field
 * ---------------------------------------------------------------------- */

.lb-auth__support {
  margin: 0;
  font-size: var(--text-small);
  line-height: var(--lh-small);
  text-align: center;
  text-wrap: balance;
  color: var(--text-on-dark-4);
}

.lb-chrome .lb-auth__support a {
  color: var(--text-on-dark-2);
}

.lb-chrome .lb-auth__support a:hover,
.lb-chrome .lb-auth__support a:focus-visible {
  color: var(--white);
}

.lb-auth__sep {
  padding-inline: 2px;
}

/* -------------------------------------------------------------------------
 * New account, discovered at the code step
 * ---------------------------------------------------------------------- */

.lb-auth__new[hidden] {
  display: none;
}

.lb-auth__new {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--green-tint-6);
  border-radius: var(--radius-md);
}

.lb-auth__new-text {
  margin: 0;
  font-size: var(--text-small);
  line-height: var(--lh-small);
  color: var(--ink);
}

/* A button that reads as a link — used where the design has one inside a sentence. */
.lb-chrome .lb-linkbtn {
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  font-family: var(--font-bangla), var(--font-body);
  font-size: var(--text-small);
  font-weight: var(--weight-semibold);
  color: var(--deep-green);
  text-decoration: underline;
}

.lb-chrome .lb-linkbtn:hover {
  color: var(--forest);
}

.lb-chrome .lb-linkbtn[disabled] {
  color: var(--muted);
  text-decoration: none;
  cursor: default;
}

.lb-auth__terms {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 10px;
  align-items: start;
  font-size: var(--text-small);
  line-height: var(--lh-small);
  color: var(--muted);
  cursor: pointer;
}

/* Same checkbox grammar as the terms box, one step quieter: this one qualifies an
   action rather than taking a consent, so the hint carries the detail and the label
   stays a single short line. */
.lb-auth__remember {
  color: var(--ink);
}

.lb-auth__remember-hint {
  display: block;
  margin-top: 2px;
  font-size: var(--text-caption);
  color: var(--muted);
}

.lb-chrome .lb-auth__terms input {
  width: 18px;
  height: 18px;
  margin: 3px 0 0;
  accent-color: var(--deep-green);
}

/* The honeypot. Off-screen rather than display:none — some bots skip hidden fields. */
.lb-auth__trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* -------------------------------------------------------------------------
 * Code entry
 * ---------------------------------------------------------------------- */

.lb-chrome .lb-otp {
  width: 100%;
  height: 60px;
  padding: 0 var(--space-4);
  border: var(--border-width) solid var(--border-field);
  border-radius: var(--radius-md);
  background: var(--white);
  font-family: var(--font-body);
  font-variant-numeric: tabular-nums;
  /* 28px is a control dimension, not a prose step — the OTP entry sizes itself to its
     six digits the way the 52px large button does, and it moves with the control
     scale, never with the reading ramp. */
  font-size: 28px;
  font-weight: var(--weight-semibold);
  letter-spacing: .38em;
  /* The tracking is applied to the right of each glyph, including the last one,
     which pushes the string off-centre. Half of it back as padding re-centres it. */
  text-indent: .38em;
  text-align: center;
  color: var(--ink);
}

.lb-chrome .lb-otp:focus-visible {
  border-color: var(--deep-green);
  box-shadow: var(--ring-focus);
  outline: none;
}

[data-lb-code-field].is-error .lb-otp {
  border-color: var(--status-delayed);
}

[data-lb-code-field].is-error .lb-field__hint {
  color: var(--status-delayed);
}

.lb-auth__row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
  align-items: center;
  justify-content: space-between;
}

.lb-chrome a.lb-auth__change {
  font-size: var(--text-small);
  color: var(--muted);
  text-decoration: underline;
}

.lb-auth__spam {
  margin: 0;
  padding: var(--space-3) 14px;
  background: var(--green-tint-6);
  border-radius: var(--radius-md);
  font-size: var(--text-small);
  line-height: var(--lh-small);
  color: var(--ink);
}

/* -------------------------------------------------------------------------
 * Issued
 * ---------------------------------------------------------------------- */

.lb-auth__done {
  align-content: start;
}

.lb-auth__check {
  display: none;
  color: var(--status-delivered);
}

/* -------------------------------------------------------------------------
 * The state machine
 *
 * Everything above is laid out once; these rules decide what is on screen. Hidden
 * states are display:none, so they are out of the accessibility tree and out of the
 * tab order — a form nobody can see is a form nobody can tab into.
 * ---------------------------------------------------------------------- */

.lb-auth [data-lb-form] {
  display: none;
}

.lb-auth[data-step="form"] [data-lb-form="login"],
.lb-auth[data-step="otp"] [data-lb-form="otp"],
.lb-auth[data-step^="done"] [data-lb-form="done"] {
  display: grid;
}

.lb-auth[data-step^="done"] .lb-auth__check {
  display: block;
}

/* The stub is the thing you just earned, so it stops being a redacted teaser and
   becomes the receipt of what is now waiting in the portal. */
.lb-auth[data-step^="done"] .lb-auth__stub-note {
  color: var(--ink);
}

.lb-auth [data-lb-error][hidden] {
  display: none;
}

/* -------------------------------------------------------------------------
 * Narrow screens
 *
 * The label goes portrait and keeps every part: stub above the line you write on,
 * register still across the foot. Same composition, one column — which matters here
 * because the reference device is a low-end Android, not a desktop browser.
 * ---------------------------------------------------------------------- */

@media (max-width: 860px) {
  .lb-auth {
    gap: var(--space-6);
    padding-block: var(--space-6) var(--space-8);
  }

  .lb-auth__body {
    grid-template-columns: minmax(0, 1fr);
  }

  .lb-auth__stub {
    order: 2;
    padding: var(--space-6) var(--space-5);
    border-right: 0;
    border-top: var(--border-width) solid var(--border-default);
  }

  .lb-auth__act {
    order: 1;
    padding: var(--space-6) var(--space-5);
  }

  /* Three ruled cells become three ruled rows; the register keeps reporting state. */
  .lb-auth__register {
    grid-template-columns: minmax(0, 1fr);
  }

  .lb-auth__reg {
    padding: var(--space-3) var(--space-5);
    border-left: 0;
    border-top: var(--border-width) solid var(--border-default);
  }

  .lb-auth__reg:first-child {
    border-top: 0;
  }

  /* The notes are the panel's old selling copy; on a phone the register's job is
     wayfinding, and the step you are on is the only one that needs explaining. */
  .lb-auth__reg-note {
    display: none;
  }

  .lb-auth[data-step="form"] [data-lb-reg="form"] .lb-auth__reg-note,
  .lb-auth[data-step="otp"] [data-lb-reg="otp"] .lb-auth__reg-note,
  .lb-auth[data-step^="done"] [data-lb-reg="done"] .lb-auth__reg-note {
    display: block;
  }
}

/* A standalone link is a target and WCAG 2.5.8 puts the floor at 24px. These three sit
   in the login panel's small print, where the line box alone came in at 17px. */
.lb-chrome .lb-auth__home,
.lb-chrome .lb-auth__support a {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
}
