/* Sohm tokens — mirrors apps/mobile/constants/theme.ts (app is source of truth). */
:root {
  --paper: #faf7f2; /* SohmColors.paperWarm — default canvas */
  --paper-hot: #f5eddf; /* SohmColors.paperHot — recessed surfaces */
  --ink: #1b1b1b;
  --ink-soft: #2a2826;
  --ink-mute: rgba(27, 27, 27, 0.78);
  --ink-label: rgba(27, 27, 27, 0.66);
  --ink-faint: rgba(27, 27, 27, 0.5);
  --stone: #d8d2c8;
  --stone-soft: #e7e1d7;
  --burgundy: #6f1d1b;
  --olive: #6e7f62;
  --mustard: #f0b53a;
  --hair: rgba(27, 27, 27, 0.18);
  --hair-strong: rgba(27, 27, 27, 0.6);

  --display: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --serif: "EB Garamond", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --gutter: 22px;
  --rise: 420ms cubic-bezier(0.25, 0.46, 0.45, 0.94); /* Easing.out(quad) */
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  padding: max(6px, env(safe-area-inset-top)) var(--gutter)
    max(16px, env(safe-area-inset-bottom));
}

/* ── Masthead ─────────────────────────────────────────── */

.masthead {
  padding-top: 10px;
}

.masthead-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-label);
}

.double-rule {
  margin-top: 13px;
}

.double-rule span {
  display: block;
  height: 1px;
  background: var(--hair-strong);
}

.double-rule span + span {
  margin-top: 2px;
}

main {
  flex: 1;
  padding: 28px 0 40px;
}

/* ── Type ─────────────────────────────────────────────── */

.eyebrow,
.label {
  margin: 0;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-label);
}

.label {
  display: block;
  font-size: 10.5px;
  color: rgba(27, 27, 27, 0.55);
  margin-bottom: 8px;
}

.optional {
  text-transform: none;
  letter-spacing: 0;
}

.headline {
  margin: 0 0 12px;
  font-family: var(--display);
  font-size: clamp(33px, 8.4vw, 42px);
  font-weight: 500;
  line-height: 1.04;
  letter-spacing: -0.005em;
  color: var(--ink);
  outline: none;
}

.headline em,
.wordmark em {
  font-style: italic;
  font-weight: 600;
  color: var(--burgundy);
}

.headline-lg {
  font-size: clamp(48px, 13vw, 64px);
}

.sub,
.help,
.prose p {
  font-family: var(--serif);
  color: var(--ink-mute);
}

.sub {
  margin: 0 0 22px;
  padding: 0;
  font-size: 16px;
  line-height: 1.45;
}

.help {
  margin: 10px 0 0;
  font-size: 14.5px;
  line-height: 1.45;
}

.prose p {
  margin: 0 0 14px;
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink-soft);
}

.prose cite {
  font-style: italic;
}

.fineprint {
  margin: 14px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--ink-faint);
}

/* ── Hero / wordmark ──────────────────────────────────── */

.hero {
  text-align: center;
  padding: 20px 0 26px;
}

.wordmark {
  margin: 2px 0 0;
  font-family: var(--display);
  font-size: clamp(96px, 30vw, 128px);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0;
  font-family: var(--display);
  font-style: italic;
  font-weight: 600;
  font-size: 19px;
  color: rgba(27, 27, 27, 0.65);
}

.hero + .prose {
  border-top: 1px solid var(--ink);
  padding-top: 22px;
}

/* ── Progress ─────────────────────────────────────────── */

.progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.progress[hidden] {
  display: none;
}

.dots {
  display: flex;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.dots li {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1px solid var(--hair-strong);
  transition: background-color 200ms, border-color 200ms;
}

.dots li.is-done {
  background: var(--olive);
  border-color: var(--olive);
}

.dots li.is-active {
  background: var(--mustard);
  border-color: var(--mustard);
}

/* ── Steps ────────────────────────────────────────────── */

.step[hidden] {
  display: none;
}

.step.is-entering {
  animation: rise var(--rise) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .step.is-entering {
    animation: fade 250ms both;
  }
  @keyframes fade {
    from {
      opacity: 0;
    }
  }
}

.step-end {
  padding-top: 18px;
}

.step-end .eyebrow {
  margin-bottom: 12px;
}

.step-end .prose {
  border-top: 1px solid var(--ink);
  padding-top: 20px;
  margin-top: 18px;
}

/* ── Fields ───────────────────────────────────────────── */

.field {
  margin-top: 22px;
}

.input {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 10px 0;
  border: 0;
  border-bottom: 1.5px solid var(--stone);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px; /* ≥16px keeps iOS Safari from zooming on focus */
  line-height: 1.3;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 160ms;
}

.input::placeholder {
  color: rgba(27, 27, 27, 0.3);
}

.input:focus {
  outline: none;
  border-bottom-color: var(--ink);
}

.input.is-filled {
  border-bottom-color: var(--ink);
}

.input[aria-invalid="true"] {
  border-bottom-color: var(--burgundy);
}

.input-signature {
  font-family: var(--display);
  font-style: italic;
  font-weight: 500;
  font-size: 28px;
  min-height: 56px;
}

.select-wrap {
  position: relative;
}

.select-wrap::after {
  content: "";
  position: absolute;
  right: 4px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 1.2px solid var(--ink);
  border-bottom: 1.2px solid var(--ink);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.select {
  padding-right: 24px;
  cursor: pointer;
}

.select:invalid,
.select option[value=""] {
  color: rgba(27, 27, 27, 0.4);
}

.select option {
  color: var(--ink);
}

.field-error {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--burgundy);
}

.field-error[hidden] {
  display: none;
}

.field-other {
  margin-top: 4px;
  padding-left: 30px;
}

/* ── Choice ledger ────────────────────────────────────── */

fieldset.choices {
  margin: 26px 0 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

fieldset.choices legend.label {
  margin-bottom: 0;
  padding: 0 0 12px;
}

fieldset.choices legend.sub {
  margin-bottom: 22px;
}

.choices .label + .choice,
.choices legend + .choice {
  border-top: 1px solid var(--ink);
}

.choice {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 54px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--hair);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.3;
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 160ms;
}

.choice:hover {
  background: rgba(231, 225, 215, 0.45);
}

.choice input {
  flex: none;
  position: relative;
  width: 16px;
  height: 16px;
  margin: 0;
  border: 1px solid var(--hair-strong);
  border-radius: 50%;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  transition: border-color 160ms;
}

.choice input::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--burgundy);
  transform: scale(0);
  transition: transform 160ms;
}

.choice input:checked {
  border-color: var(--burgundy);
}

.choice input:checked::after {
  transform: scale(1);
}

.choice input:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.choice:has(input:checked) {
  background: var(--paper-hot);
}

/* ── Agreement ledger ─────────────────────────────────── */

.ledger {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: clause;
  border-top: 1px solid var(--ink);
}

.ledger li {
  counter-increment: clause;
  display: grid;
  grid-template-columns: 34px 1fr;
  padding: 12px 0;
  border-bottom: 1px solid var(--hair);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink-soft);
}

.ledger li::before {
  content: counter(clause, lower-roman) ".";
  font-family: var(--display);
  font-style: italic;
  font-size: 17px;
  color: var(--burgundy);
}

.ledger-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-top: 18px;
  padding: 12px 0;
  border-top: 1px solid var(--hair);
  border-bottom: 1px solid var(--hair);
}

.ledger-row .label {
  width: 70px;
  margin: 0;
}

.ledger-value {
  font-family: var(--serif);
  font-size: 16px;
  color: var(--ink-soft);
}

/* ── Buttons ──────────────────────────────────────────── */

.actions {
  margin-top: 32px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 15px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* Hard rectangle per design (ledger, not chip). */
.btn-primary {
  width: 100%;
  min-height: 52px;
  padding: 0 18px;
  border: 0;
  border-radius: 0;
  background: var(--burgundy);
  color: var(--paper-hot);
  transition: opacity 120ms;
}

.btn-primary:active {
  opacity: 0.82;
}

.btn-primary:focus-visible,
.btn-link:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.btn-primary[disabled] {
  opacity: 0.5;
  cursor: progress;
}

.btn-primary .arrow {
  transition: transform 200ms;
}

@media (hover: hover) {
  .btn-primary:hover .arrow {
    transform: translateX(3px);
  }
}

.btn-link {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--burgundy);
}

.back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin: -6px 0 18px -2px;
  padding: 0;
  border: 1px solid rgba(27, 27, 27, 0.25);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  cursor: pointer;
}

.back:active {
  opacity: 0.45;
}

/* ── Inline error ─────────────────────────────────────── */

.inline-error {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 22px;
  padding: 11px 13px;
  background: rgba(111, 29, 27, 0.06);
  border-left: 3px solid var(--burgundy);
}

.inline-error[hidden] {
  display: none;
}

.bang {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  border-radius: 50%;
  background: var(--burgundy);
  color: var(--paper);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.inline-error-text {
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.4;
  color: var(--ink-soft);
}

/* ── Sign-off & footer ────────────────────────────────── */

.signoff {
  margin: 26px 0 0;
  font-family: var(--serif);
  font-size: 17px;
  color: var(--ink-mute);
}

.signoff span {
  display: inline-block;
  margin-top: 4px;
  font-family: var(--display);
  font-style: italic;
  font-weight: 600;
  font-size: 26px;
  color: var(--burgundy);
}

.colophon p {
  margin: 14px 0 0;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ── Utilities ────────────────────────────────────────── */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

@media (min-width: 640px) {
  main {
    padding-top: 48px;
  }
}
