/* ==========================================================================
   Auth pages: brand panel + form

   Design notes, so later edits keep the intent:
   - Inputs are hairline rules, not boxes. A boxed, icon-filled, heavily
     rounded field is generic product-UI vocabulary; a single fine rule reads
     like a printed form and lets the paper (cream) carry the page.
   - Labels are small, LIGHT and widely tracked. Small tracked caps are a
     couture convention. The thing to avoid is *bold* tracked caps, which is
     what makes a form look like a template.
   - One accent colour, used sparingly: maroon for focus and action, gold only
     as a hairline flourish. No gradients on the button.
   ========================================================================== */

.auth {
  display: grid;
  grid-template-columns: 1.08fr 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---------- Brand panel ---------- */
.auth__brand {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 30px;
  padding: 56px 56px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 32%, rgba(171, 118, 30, 0.14), transparent 62%),
    linear-gradient(158deg, var(--maroon-deep) 0%, #4E1420 46%, var(--forest-deep) 100%);
  color: var(--cream);
  text-align: center;
}

/* Faint woven texture: diagonal hairlines, echoing warp and weft. */
.auth__brand::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(45deg, rgba(254, 247, 235, 0.028) 0 1px, transparent 1px 7px);
  pointer-events: none;
}

.auth__brand > * {
  position: relative;
  z-index: 1;
}

/* Transparent PNG: drop-shadow traces the artwork, box-shadow would draw a box. */
.auth__logo {
  width: 252px;
  filter: drop-shadow(0 20px 38px rgba(0, 0, 0, 0.45));
  animation: rise 0.8s var(--ease) both;
}

.auth__tagline {
  max-width: 22ch;
  margin: 0;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 400;
  font-style: italic;
  line-height: 1.28;
  letter-spacing: 0.005em;
  text-wrap: balance;
  color: var(--cream);
  animation: rise 0.8s var(--ease) 0.1s both;
}

.auth__sub {
  max-width: 40ch;
  margin: -14px 0 0;
  font-size: 0.845rem;
  font-weight: 300;
  line-height: 1.7;
  letter-spacing: 0.015em;
  text-wrap: pretty;
  color: rgba(254, 247, 235, 0.66);
  animation: rise 0.8s var(--ease) 0.18s both;
}

/* Gold hairline with a lozenge, echoing the divider in the logo. */
.auth__rule {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 168px;
  animation: rise 0.8s var(--ease) 0.26s both;
}

.auth__rule::before,
.auth__rule::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(201, 162, 39, 0.85), transparent);
}

.auth__rule span {
  width: 5px;
  height: 5px;
  background: var(--gold-light);
  transform: rotate(45deg);
}

/* ---------- Form panel ---------- */
.auth__panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
  background: var(--cream);
}

.auth__card {
  width: 100%;
  max-width: 356px;
  animation: rise 0.6s var(--ease) both;
}

/* Only on narrow screens, where the brand panel is dropped. */
.auth__mark {
  display: none;
  width: 104px;
  margin: 0 auto 22px;
}

.auth__title {
  font-size: 2.45rem;
  font-weight: 500;
  line-height: 1.06;
  letter-spacing: -0.012em;
  text-wrap: balance;
  color: var(--maroon-deep);
  margin-bottom: 10px;
}

.auth__lede {
  margin: 0 0 34px;
  font-size: 0.85rem;
  font-weight: 300;
  letter-spacing: 0.018em;
  color: var(--ink-muted);
}

/* ---------- Fields ---------- */
.field {
  margin-bottom: 22px;
}

.field__label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 3px;
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.19em;
  text-transform: uppercase;
  color: var(--ink-faint);
  transition: color 0.2s var(--ease);
}

.field__optional {
  font-size: 0.58rem;
  font-weight: 300;
  letter-spacing: 0.1em;
  text-transform: lowercase;
  font-style: italic;
  color: var(--ink-faint);
  opacity: 0.75;
}

.field__wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.field__input {
  width: 100%;
  padding: 9px 0 8px;
  font: inherit;
  font-size: 0.955rem;
  font-weight: 400;
  letter-spacing: 0.008em;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border-strong);
  border-radius: 0;
  transition: border-color 0.25s var(--ease);
}

.field__input::placeholder {
  color: var(--ink-faint);
  font-weight: 300;
  /* Quiet enough that it never reads as a filled value. */
  opacity: 0.5;
}

.field__input:hover:not(:focus) {
  border-bottom-color: var(--ink-faint);
}

.field__input:focus {
  outline: none;
  border-bottom-color: var(--maroon);
}

/* A second rule that draws itself in from the left on focus, the only
   motion in the form, and the reason the hairline feels deliberate. */
.field__wrap::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 1px;
  background: var(--maroon);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.32s var(--ease);
}

.field__wrap:focus-within::after {
  transform: scaleX(1);
}

.field:focus-within .field__label {
  color: var(--maroon);
}

/* Room for the reveal control */
.field__input--password {
  padding-right: 48px;
}

/* Text, not an eye icon. Quieter, and unambiguous. */
.field__toggle {
  position: absolute;
  right: 0;
  bottom: 10px;
  padding: 2px 0 2px 10px;
  font-family: var(--font-body);
  font-size: 0.575rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  background: none;
  border: 0;
  cursor: pointer;
  transition: color 0.2s var(--ease);
}

.field__toggle:hover {
  color: var(--maroon);
}

/* Invalid state */
.field--invalid .field__input {
  border-bottom-color: var(--danger);
}

.field--invalid .field__wrap::after {
  background: var(--danger);
}

.field--invalid .field__label {
  color: var(--danger);
}

.field__error {
  display: none;
  margin: 7px 0 0;
  font-size: 0.73rem;
  font-weight: 300;
  letter-spacing: 0.02em;
  color: var(--danger);
}

.field--invalid .field__error {
  display: block;
}

.field__hint {
  margin: 7px 0 0;
  font-size: 0.715rem;
  font-weight: 300;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
}

/* ---------- Remember + forgot ---------- */
.auth__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 26px 0 28px;
  font-size: 0.78rem;
  font-weight: 300;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  letter-spacing: 0.03em;
  color: var(--ink-muted);
  user-select: none;
}

/* Custom square mark; the native control is kept for keyboard and a11y. */
.checkbox input {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 13px;
  height: 13px;
  margin: 0;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 1px;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}

.checkbox input:hover {
  border-color: var(--maroon-soft);
}

.checkbox input:checked {
  background: var(--maroon);
  border-color: var(--maroon);
}

.checkbox input:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 3px;
  height: 7px;
  border: solid var(--cream);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(43deg);
}

.link--muted {
  color: var(--ink-muted);
  font-weight: 400;
  letter-spacing: 0.03em;
  border-bottom: 1px solid transparent;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.link--muted:hover {
  color: var(--maroon);
  border-bottom-color: var(--maroon-soft);
}

/* ---------- Button ---------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  width: 100%;
  padding: 16px 24px;
  font-family: var(--font-body);
  font-size: 0.685rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-indent: 0.22em; /* balances the trailing letter-space */
  border: 1px solid transparent;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.28s var(--ease), color 0.28s var(--ease);
}

.btn--primary {
  color: var(--cream);
  background: var(--maroon-deep);
}

.btn--primary:hover:not(:disabled) {
  background: var(--maroon);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn__spinner {
  display: none;
  width: 12px;
  height: 12px;
  border: 1px solid rgba(254, 247, 235, 0.3);
  border-top-color: var(--cream);
  border-radius: 50%;
  animation: spin 0.62s linear infinite;
}

.btn.is-loading .btn__spinner {
  display: block;
}

/* ---------- Alert ---------- */
.alert {
  display: none;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 22px;
  padding: 11px 14px;
  font-size: 0.79rem;
  font-weight: 300;
  letter-spacing: 0.015em;
  line-height: 1.5;
  text-align: left;
  border: 0;
  border-left: 2px solid;
  border-radius: 0;
  animation: rise 0.25s var(--ease);
}

.alert.is-visible {
  display: flex;
}

.alert svg {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  margin-top: 3px;
}

.alert--error {
  color: var(--danger);
  background: var(--danger-bg);
  border-left-color: var(--danger);
}

.alert--success {
  color: var(--success);
  background: var(--success-bg);
  border-left-color: var(--success);
}

/* ---------- Footer ---------- */
.auth__foot {
  margin: 26px 0 0;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.815rem;
  font-weight: 300;
  letter-spacing: 0.025em;
  color: var(--ink-muted);
}

.auth__foot a {
  font-weight: 500;
  color: var(--maroon);
  border-bottom: 1px solid var(--border-strong);
  transition: border-color 0.2s var(--ease);
}

.auth__foot a:hover {
  border-bottom-color: var(--maroon);
}

.auth__legal {
  margin: 18px 0 0;
  font-size: 0.68rem;
  font-weight: 300;
  line-height: 1.65;
  letter-spacing: 0.02em;
  text-wrap: pretty;
  text-align: center;
  color: var(--ink-faint);
}

.auth__legal a {
  color: var(--ink-muted);
  border-bottom: 1px solid var(--border);
}

.auth__legal a:hover {
  color: var(--maroon);
}

/* ---------- Animations ---------- */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

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

/* ---------- Responsive ----------
   Width decides whether the brand panel shows; height decides how tight the
   rhythm has to be, because the register form is tall enough to overflow a
   short laptop screen even at full desktop width.
   -------------------------------------------------------------------- */

@media (max-height: 880px) {
  .auth__panel {
    padding: 32px 40px;
  }
  .auth__title {
    font-size: 2.15rem;
  }
  .auth__lede {
    margin-bottom: 24px;
  }
  .field {
    margin-bottom: 17px;
  }
  .auth__row {
    margin: 20px 0 22px;
  }
  .auth__foot {
    margin-top: 20px;
    padding-top: 17px;
  }
  .auth__legal {
    margin-top: 13px;
  }
  .auth__logo {
    width: 214px;
  }
}

@media (max-height: 760px) {
  .auth__panel {
    padding: 24px 40px;
  }
  .auth__title {
    font-size: 1.95rem;
  }
  .auth__lede {
    margin-bottom: 18px;
  }
  .field {
    margin-bottom: 13px;
  }
  .auth__foot {
    margin-top: 16px;
    padding-top: 14px;
  }
  .auth__mark {
    width: 84px;
    margin-bottom: 14px;
  }
}

/* Narrow: the brand panel is dropped and the small mark stands in. */
@media (max-width: 900px) {
  .auth {
    grid-template-columns: 1fr;
  }
  .auth__brand {
    display: none;
  }
  .auth__mark {
    display: block;
  }
  .auth__panel {
    padding: 38px 28px;
  }
  .auth__card {
    text-align: center;
  }
  .auth__row,
  .field,
  .alert {
    text-align: left;
  }
  .auth__lede {
    margin-bottom: 30px;
  }
}

@media (max-width: 480px) {
  .auth__panel {
    padding: 30px 24px;
  }
  .auth__title {
    font-size: 2.05rem;
  }
  .auth__mark {
    width: 90px;
    margin-bottom: 16px;
  }
  .auth__lede {
    margin-bottom: 24px;
  }
  .field {
    margin-bottom: 16px;
  }
}

@media (max-width: 360px) {
  .auth__panel {
    padding: 24px 18px;
  }
  .auth__title {
    font-size: 1.85rem;
  }
  .auth__mark {
    width: 76px;
  }
  .field__label {
    letter-spacing: 0.15em;
  }
  .btn {
    letter-spacing: 0.16em;
  }
}

/* ==========================================================================
   OTP verification

   Multi-step panes live in one page: only `.step.is-active` renders, so the
   flow never reloads and the entered phone/state survives between steps.
   ========================================================================== */

.step {
  display: none;
}

.step.is-active {
  display: block;
  animation: rise 0.4s var(--ease) both;
}

/* The number the code went to, reassurance before they check their phone. */
.otp__target {
  margin: 0 0 26px;
  font-size: 0.85rem;
  font-weight: 300;
  letter-spacing: 0.018em;
  color: var(--ink-muted);
}

.otp__target strong {
  display: block;
  margin-top: 4px;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 500;
  font-style: italic;
  letter-spacing: 0.03em;
  color: var(--ink);
}

/* Six hairline cells rather than one boxed field, same vocabulary as the
   rest of the form, and each digit gets its own resting place. */
.otp {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.otp__digit {
  width: 100%;
  min-width: 0;
  padding: 8px 0 7px;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  text-align: center;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border-strong);
  border-radius: 0;
  transition: border-color 0.22s var(--ease), color 0.22s var(--ease);
  /* Hide the number spinner in every engine. */
  -moz-appearance: textfield;
  appearance: textfield;
}

.otp__digit::-webkit-outer-spin-button,
.otp__digit::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.otp__digit:hover:not(:focus) {
  border-bottom-color: var(--ink-faint);
}

.otp__digit:focus {
  outline: none;
  border-bottom-color: var(--maroon);
}

.otp__digit--filled {
  border-bottom-color: var(--maroon-soft);
}

.otp--invalid .otp__digit {
  border-bottom-color: var(--danger);
  color: var(--danger);
}

/* Resend row: countdown, then an active link. */
.otp__resend {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  margin: 22px 0 26px;
  font-size: 0.78rem;
  font-weight: 300;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
}

.otp__resend button {
  padding: 0;
  font: inherit;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--maroon);
  background: none;
  border: 0;
  border-bottom: 1px solid var(--border-strong);
  cursor: pointer;
  transition: border-color 0.2s var(--ease);
}

.otp__resend button:hover:not(:disabled) {
  border-bottom-color: var(--maroon);
}

.otp__resend button:disabled {
  color: var(--ink-faint);
  border-bottom-color: transparent;
  cursor: default;
}

/* A quiet "go back and fix the number" affordance. */
.step__back {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 0;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
  color: var(--ink-faint);
  background: none;
  border: 0;
  cursor: pointer;
  transition: color 0.2s var(--ease);
}

.step__back:hover {
  color: var(--maroon);
}

/* Development affordance: shown only when the API returns debug_code, which
   happens exclusively on the console SMS backend. Never appears in
   production, because the field is null there. */
.otp__devcode {
  display: none;
  margin: 0 0 22px;
  padding: 10px 12px;
  font-size: 0.74rem;
  font-weight: 300;
  letter-spacing: 0.02em;
  text-align: left;
  color: var(--ink-muted);
  background: rgba(171, 118, 30, 0.07);
  border: 1px dashed rgba(171, 118, 30, 0.45);
  border-radius: 2px;
}

.otp__devcode.is-visible {
  display: block;
}

.otp__devcode b {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--maroon);
}

@media (max-width: 400px) {
  .otp {
    gap: 5px;
  }
  .otp__digit {
    font-size: 1.25rem;
  }
}

/* ==========================================================================
   Channel selector: send the code by SMS or email
   ========================================================================== */

.channel {
  display: flex;
  gap: 0;
  margin: 4px 0 2px;
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  overflow: hidden;
}

.channel__option {
  flex: 1;
  position: relative;
}

/* The radio itself is hidden but still focusable and announced. */
.channel__option input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.channel__option span {
  display: block;
  padding: 10px 8px;
  font-size: 0.64rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-align: center;
  color: var(--ink-faint);
  background: transparent;
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
  pointer-events: none;
}

.channel__option + .channel__option span {
  border-left: 1px solid var(--border-strong);
}

.channel__option input:hover + span {
  color: var(--maroon);
}

.channel__option input:checked + span {
  color: var(--cream);
  background: var(--maroon-deep);
}

.channel__option input:focus-visible + span {
  outline: 2px solid var(--gold);
  outline-offset: -2px;
}
