/**
 * The threshold: log in, create an account, first setup (auth/_threshold.html).
 *
 * Native idea: the lamp is lit on the threshold. One lantern stands on the top edge
 * of the plate and its light lands on it; the plate is the one lit object, the rest
 * rests in the scheme's field (the auth view keeps #main's lamp and vignette). The
 * material law holds: no hairline borders; the plate is defined by its warm top
 * light and its cast shadow, the fields are carved wells, one gold action.
 */

.threshold {
  position: relative;
  z-index: 1;
  width: min(400px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  --threshold-on-gold: #17110a;
}

/* ---------- the sign: the name above the lamp ---------- */
.threshold-sign {
  text-align: center;
  margin-bottom: 14px;
}
.threshold-wordmark {
  margin: 0;
  font-family: var(--font-read);
  font-size: 44px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.005em;
  color: var(--ink);
}
.threshold-wordmark span {
  color: var(--accent-warm);
}
.threshold-line {
  margin: 10px 0 0;
  font-family: var(--font-read);
  font-style: italic;
  font-size: 17px;
  line-height: 1.4;
  color: var(--ink-muted);
}

/* ---------- the lamp, standing on the plate's top edge ---------- */
.threshold-lamp {
  position: relative;
  z-index: 2;
  /* the lantern's ground is y 54 of its 64 box: sink it so the post stands on the
     plate's edge and the pool spills across the plate's top. */
  margin-bottom: -30px;
  line-height: 0;
}

/* ---------- the plate: the lit object ---------- */
.threshold-plate {
  position: relative;
  width: 100%;
  box-sizing: border-box;
  padding: 44px 32px 30px;
  border-radius: var(--radius-card);
  color: var(--ink);
  background:
    radial-gradient(64% 42% at 50% 0%, color-mix(in oklab, var(--accent-warm) 22%, transparent), transparent 74%),
    linear-gradient(180deg, color-mix(in oklab, var(--surface-raised) 92%, var(--accent) 8%), var(--surface-raised) 42%);
  box-shadow:
    inset 0 1px 0 color-mix(in oklab, var(--accent-warm) 22%, transparent),
    0 2px 0 rgba(0, 0, 0, 0.22),
    0 30px 60px -22px rgba(0, 0, 0, 0.7);
}
[data-scheme="dawn"] .threshold-plate {
  box-shadow:
    inset 0 1px 0 rgba(255, 250, 238, 0.85),
    0 2px 0 rgba(92, 70, 30, 0.12),
    0 28px 54px -24px rgba(74, 52, 16, 0.42);
}

.threshold-heading {
  margin: 0 0 22px;
  text-align: center;
  font-family: var(--font-read);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
}
.threshold-intro {
  margin: -10px 0 22px;
  text-align: center;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-muted);
  text-wrap: pretty;
}

/* ---------- messages: said in the plate, not shouted above it ---------- */
.threshold-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0 0 18px;
  padding: 11px 14px;
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: color-mix(in oklab, var(--positive) 12%, var(--surface-sunk));
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
}
.threshold-note.is-problem {
  background: color-mix(in oklab, var(--caution) 14%, var(--surface-sunk));
}
.threshold-note svg {
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  fill: none;
  stroke: var(--positive);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.threshold-note.is-problem svg {
  stroke: var(--caution);
}

/* ---------- fields: carved wells ---------- */
.threshold-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.threshold-field label {
  display: block;
  margin-bottom: 7px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
}
.threshold-input {
  display: block;
  width: 100%;
  height: 46px;
  box-sizing: border-box;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 16px;
  color: var(--ink);
  caret-color: var(--accent-warm);
  background: var(--surface-sunk);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.5),
    0 1px 0 color-mix(in oklab, var(--accent-warm) 10%, transparent);
  transition: box-shadow 0.16s ease;
}
[data-scheme="dawn"] .threshold-input {
  box-shadow:
    inset 0 2px 4px rgba(74, 52, 16, 0.28),
    0 1px 0 rgba(255, 250, 238, 0.7);
}
.threshold-input:focus-visible {
  outline: none;
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.5),
    0 0 0 2px color-mix(in oklab, var(--accent-warm) 75%, transparent);
}
.threshold-input:-webkit-autofill {
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: inset 0 0 0 40px var(--surface-sunk), inset 0 2px 4px rgba(0, 0, 0, 0.5);
}
.has-error .threshold-input {
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.5),
    0 0 0 2px color-mix(in oklab, var(--caution) 70%, transparent);
}
.threshold-help,
.threshold-error {
  margin: 7px 0 0;
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-muted);
}
.threshold-error {
  color: var(--caution);
}
[data-scheme="dawn"] .threshold-error {
  color: #8a2f0c;
}

/* ---------- remember me: a small carved well that fills with gold ---------- */
.threshold-check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  align-self: flex-start;
  margin-top: 2px;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--ink-muted);
  cursor: pointer;
}
.threshold-check input {
  appearance: none;
  flex: none;
  width: 18px;
  height: 18px;
  margin: 0;
  border-radius: 4px;
  background: var(--surface-sunk);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.threshold-check input::after {
  content: "";
  width: 8px;
  height: 4px;
  margin-top: -2px;
  border-left: 2px solid var(--threshold-on-gold);
  border-bottom: 2px solid var(--threshold-on-gold);
  transform: rotate(-45deg);
  opacity: 0;
}
.threshold-check input:checked {
  background: linear-gradient(180deg, var(--accent-warm), var(--accent));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.threshold-check input:checked::after {
  opacity: 1;
}
.threshold-check input:focus-visible {
  outline: 2px solid color-mix(in oklab, var(--accent-warm) 75%, transparent);
  outline-offset: 2px;
}

/* ---------- the one gold action ---------- */
.threshold-submit {
  width: 100%;
  height: 48px;
  margin-top: 8px;
  border: 0;
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--threshold-on-gold);
  background: linear-gradient(180deg, var(--accent-warm), var(--accent));
  box-shadow:
    inset 0 1px 0 rgba(255, 246, 222, 0.55),
    0 2px 0 var(--accent-deep),
    0 10px 22px -10px color-mix(in oklab, var(--accent) 70%, transparent);
  cursor: pointer;
  transition: filter 0.16s ease, transform 0.08s ease;
}
.threshold-submit:hover {
  filter: brightness(1.05);
}
.threshold-submit:active {
  transform: translateY(1px);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25), 0 1px 0 var(--accent-deep);
}
.threshold-submit:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}
[data-scheme="dawn"] .threshold {
  --threshold-on-gold: #fbf3e2;
}
[data-scheme="dawn"] .threshold-submit {
  background: linear-gradient(180deg, #a65f10, #8a4a08);
}
/* The quiet second choice under the submit button (the connect page's Cancel): text, no
   hairline (the material law above), so the lit button stays the one choice that glows. */
.threshold-cancel {
  width: 100%;
  height: 40px;
  margin-top: -8px;
  border: 0;
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-muted);
  background: transparent;
  cursor: pointer;
}
.threshold-cancel:hover {
  color: var(--ink);
}
.threshold-cancel:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

/* ---------- under the plate ---------- */
.threshold-foot {
  margin: 22px 0 0;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--ink-muted);
  text-align: center;
}
.threshold-foot a,
.threshold-plate a {
  color: var(--accent-warm);
  font-weight: 600;
  text-decoration: none;
  text-underline-offset: 3px;
}
.threshold-foot a:hover,
.threshold-plate a:hover {
  text-decoration: underline;
}
.threshold-legal {
  position: relative;
  z-index: 1;
  margin: 14px 0 0;
  font-family: var(--font-ui);
  font-size: 13px;
  text-align: center;
}
.threshold-legal a {
  color: var(--ink-muted);
  text-underline-offset: 3px;
}
.threshold-legal a:hover {
  color: var(--ink);
}
[data-scheme="dawn"] .threshold-foot a {
  color: var(--accent-deep);
}

/* ---------- recovery codes: the one page that shows them ---------- */
.recovery-codes {
  margin: 0 0 16px;
  padding: 14px 16px 14px 44px;
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--ink-muted);
  background: var(--surface-sunk);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}
[data-scheme="dawn"] .recovery-codes {
  box-shadow: inset 0 2px 4px rgba(74, 52, 16, 0.28);
}
.recovery-codes li {
  padding: 3px 0;
}
.recovery-codes code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  font-size: 15px;
  letter-spacing: 0.04em;
  color: var(--ink);
  user-select: all;
}
.recovery-save {
  margin: 0 0 18px;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-muted);
}
.threshold-plate a.threshold-submit {
  display: block;
  box-sizing: border-box;
  line-height: 48px;
  text-align: center;
  text-decoration: none;
  color: var(--threshold-on-gold);
}
/* Sign-up's codes step: Download and Copy sit on the plate as raised stones (no hairline),
   the gold "I saved them" stays the one lit action, "Later in Settings" is quiet text. */
.recovery-actions {
  display: flex;
  gap: 10px;
  margin: -4px 0 12px;
}
.threshold-plate .recovery-action {
  flex: 1;
  height: 40px;
  border: 0;
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
  line-height: 40px;
  text-align: center;
  text-decoration: none;
  color: var(--ink);
  background: color-mix(in oklab, var(--ink) 9%, var(--surface-sunk));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 1px 2px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
.threshold-plate .recovery-action:hover {
  text-decoration: none;
  background: color-mix(in oklab, var(--ink) 14%, var(--surface-sunk));
}
.threshold-plate .recovery-action:focus-visible,
.threshold-later:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}
.recovery-action[hidden] {
  display: none;
}
.recovery-continue {
  gap: 0;
}
.threshold-plate a.threshold-later {
  display: block;
  margin-top: 6px;
  padding: 10px 0;
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  color: var(--ink-muted);
}
.threshold-plate a.threshold-later:hover {
  color: var(--ink);
}
.recovery-later-note {
  margin: 2px 0 0;
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  color: var(--ink-muted);
}

.threshold ::selection {
  background: color-mix(in oklab, var(--accent-warm) 40%, transparent);
  color: var(--ink);
}

/* ---------- phone ---------- */
@media (max-width: 480px) {
  .threshold-wordmark { font-size: 38px; }
  .threshold-line { font-size: 16px; }
  .threshold-lamp svg { width: 104px; height: 104px; }
  .threshold-lamp { margin-bottom: -24px; }
  .threshold-plate { padding: 38px 20px 24px; }
  .threshold-heading { font-size: 24px; margin-bottom: 18px; }
}
