:root {
  --paper: #FAF7F1;
  --paper-alt: #F1ECE0;
  --ink: #1A1B1F;
  --ink-soft: #5B5D63;
  /* --accent is editable from /admin → Settings; --accent-contrast is
     recomputed alongside it (see app.js) so on-accent text stays legible. */
  --accent: #141414;
  --accent-contrast: #FFFFFF;
  --accent-pale: color-mix(in srgb, var(--accent) 8%, white);
  --gold-ink: #83652E;
  --border: #E2DDD0;
  --border-strong: #C9C1AC;
  --error: #B3271D;
  --white: #FFFFFF;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --font-display: "Helvetica Now Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--ink); }

html { scrollbar-color: var(--border-strong) var(--paper); scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--paper); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid var(--paper); }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ---------- app chrome ---------- */

.app-bar {
  position: fixed;
  top: 3px; left: 0; right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(250, 247, 241, 0.86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 9;
}
.wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}
.step-indicator {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
  text-transform: none;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--border);
  z-index: 10;
}
.progress-fill {
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: left;
  background: var(--accent);
  box-shadow: 0 0 8px color-mix(in srgb, var(--accent) 40%, transparent);
  transition: transform 0.45s var(--ease-out);
}

/* ---------- layout ---------- */

.form-shell {
  max-width: 680px;
  margin: 0 auto;
  padding: 96px 24px 96px;
}

.form-card { position: relative; }

@media (min-width: 640px) {
  .form-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 52px 56px 44px;
    box-shadow: 0 1px 2px rgba(20, 20, 20, 0.03), 0 24px 60px -28px rgba(20, 20, 20, 0.22);
  }
}

/* ---------- type ---------- */

h1 {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 1.35rem + 1.6vw, 2.6rem);
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--accent);
  margin: 0 0 20px;
  text-wrap: balance;
}

.lede {
  font-size: 1.08rem;
  line-height: 1.65;
  color: var(--ink);
  margin: 0 0 20px;
  max-width: 62ch;
}
.lede strong,
.teaching-block > p > strong {
  font-weight: 700;
  color: var(--accent);
}
.lede em { font-style: italic; }

.teaching-block {
  position: relative;
  background: var(--paper-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 32px 32px 28px;
  margin: 8px 0 32px;
  overflow: hidden;
}
.teaching-block::before {
  content: "\201C";
  position: absolute;
  top: -22px; left: 14px;
  font-family: var(--font-display);
  font-size: 6.5rem;
  font-weight: 800;
  color: var(--accent);
  opacity: 0.08;
  line-height: 1;
  pointer-events: none;
}
.teaching-block p { position: relative; margin: 0 0 14px; line-height: 1.6; font-size: 1rem; color: var(--ink); }
.teaching-block p:last-child { margin-bottom: 0; }
.teaching-block p.scripture {
  font-weight: 600;
  font-size: 1.18rem;
  line-height: 1.5;
  color: var(--accent);
}
.teaching-block p.scripture strong { font-weight: 700; color: inherit; font-family: inherit; }
.teaching-block .ref {
  display: block;
  margin-top: 6px;
  font-family: var(--font-body);
  font-style: normal;
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--gold-ink);
  font-weight: 600;
}

.field { margin-bottom: 32px; }

.q-title {
  display: block;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--ink);
  letter-spacing: -0.005em;
  margin-bottom: 14px;
}

/* ---------- inputs ---------- */

input[type="text"],
input[type="email"],
input[type="tel"],
textarea {
  width: 100%;
  font-size: 1rem;
  font-family: inherit;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--ink);
  caret-color: var(--accent);
  transition: border-color 0.18s var(--ease-out), box-shadow 0.18s var(--ease-out);
}
textarea { min-height: 96px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #777772; }

input[type="text"]:hover,
input[type="email"]:hover,
input[type="tel"]:hover,
textarea:hover { border-color: var(--border-strong); }

input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-pale);
}

/* max-height is a layout property, but this is a single small optional field
   toggled rarely by direct user action — negligible cost, and the reliable
   choice over content-dependent grid-row animation. */
.other-input-wrap {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s var(--ease-out);
}
.other-input-wrap.is-visible { max-height: 84px; }
.other-input-inner { opacity: 0; transition: opacity 0.22s ease; }
.other-input-wrap.is-visible .other-input-inner { opacity: 1; }
.other-input { margin-top: 12px; }

/* ---------- custom checkbox / radio ---------- */

.checkbox-group, .radio-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  cursor: pointer;
  font-size: 0.98rem;
  line-height: 1.45;
  color: var(--ink);
  transition: border-color 0.16s var(--ease-out), box-shadow 0.16s var(--ease-out),
    background-color 0.16s var(--ease-out), transform 0.12s var(--ease-out);
}
.option:hover { border-color: var(--accent); background: var(--accent-pale); }
.option:active { transform: scale(0.995); }
.option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-pale);
  box-shadow: 0 4px 14px -8px color-mix(in srgb, var(--accent) 35%, transparent);
}
.option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

input[type="checkbox"],
input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  margin-top: 2px;
  border: 1.6px solid var(--border-strong);
  background: var(--white);
  position: relative;
  cursor: pointer;
  transition: background-color 0.16s var(--ease-out), border-color 0.16s var(--ease-out);
}
input[type="checkbox"] { border-radius: 6px; }
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]:hover,
input[type="radio"]:hover { border-color: var(--accent); }
input[type="checkbox"]:checked,
input[type="radio"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-pale);
}
input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 6px; top: 2px;
  width: 5px; height: 10px;
  border: solid var(--accent-contrast);
  border-width: 0 2px 2px 0;
  animation: checkTick 0.22s var(--ease-out) forwards;
}
input[type="radio"]:checked::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--accent-contrast);
  animation: dotPop 0.2s var(--ease-out) forwards;
}
@keyframes checkTick {
  from { transform: rotate(45deg) scale(0); opacity: 0; }
  to { transform: rotate(45deg) scale(1); opacity: 1; }
}
@keyframes dotPop {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.checkbox-inline { align-items: flex-start; }

/* ---------- errors ---------- */

.error {
  display: none;
  color: var(--error);
  font-size: 0.87rem;
  margin: 8px 0 0;
}
.field.invalid .error,
.radio-group.invalid + .error,
.checkbox-group.invalid + .error {
  display: block;
}
.radio-group.invalid .option,
.checkbox-group.invalid .option {
  border-color: var(--error);
}
.field.invalid input,
.field.invalid textarea { border-color: var(--error); }

.shake { animation: shakeX 0.35s var(--ease-out); }
@keyframes shakeX {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}

/* ---------- pages & transitions ---------- */

.page { display: none; }
.page.active {
  display: block;
  animation: pageEnter 0.4s var(--ease-out) both;
}
.page.active.dir-back { animation-name: pageEnterBack; }
@keyframes pageEnter { from { transform: translateX(10px); } to { transform: none; } }
@keyframes pageEnterBack { from { transform: translateX(-10px); } to { transform: none; } }

.page[data-page="1"].active > *,
.page.thankyou.active > * {
  animation: childRise 0.5s var(--ease-out) both;
}
.page[data-page="1"].active > *:nth-child(1) { animation-delay: 0ms; }
.page[data-page="1"].active > *:nth-child(2) { animation-delay: 70ms; }
.page[data-page="1"].active > *:nth-child(3) { animation-delay: 140ms; }
.page[data-page="1"].active > *:nth-child(4) { animation-delay: 210ms; }
.page[data-page="1"].active > *:nth-child(5) { animation-delay: 280ms; }
.page.thankyou.active > *:nth-child(1) { animation-delay: 60ms; }
.page.thankyou.active > *:nth-child(2) { animation-delay: 160ms; }
.page.thankyou.active > *:nth-child(3) { animation-delay: 260ms; }
.page.thankyou.active > *:nth-child(4) { animation-delay: 340ms; }
@keyframes childRise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ---------- nav ---------- */

.nav-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  gap: 12px;
}

.btn {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.005em;
  padding: 13px 30px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: transform 0.15s var(--ease-out), box-shadow 0.2s var(--ease-out),
    background-color 0.18s var(--ease-out), border-color 0.18s var(--ease-out), color 0.18s var(--ease-out);
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
  margin-left: auto;
  box-shadow: 0 8px 20px -9px color-mix(in srgb, var(--accent) 60%, transparent);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 26px -8px color-mix(in srgb, var(--accent) 60%, transparent); }
.btn-primary:active { transform: translateY(0) scale(0.98); box-shadow: 0 4px 12px -6px color-mix(in srgb, var(--accent) 50%, transparent); }
.btn-primary:disabled { opacity: 0.72; cursor: default; transform: none; }
.btn-primary.is-loading { color: transparent; position: relative; }
.btn-primary.is-loading::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 16px; height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid color-mix(in srgb, var(--accent-contrast) 40%, transparent);
  border-top-color: var(--accent-contrast);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { border-color: var(--border-strong); color: var(--ink); background: rgba(0, 0, 0, 0.02); }
.btn-ghost[disabled] { visibility: hidden; }

@media (max-width: 640px) {
  .nav-row {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: rgba(250, 247, 241, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding: 14px 20px calc(14px + env(safe-area-inset-bottom));
    margin-top: 0;
    z-index: 8;
  }
  .form-shell { padding-bottom: 112px; }
}

/* ---------- thank you / error ---------- */

.thankyou { position: relative; text-align: left; padding-top: 24px; }
.thankyou::before {
  content: "";
  position: absolute;
  top: -40px; left: -40px;
  width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(168, 130, 60, 0.2), rgba(168, 130, 60, 0) 70%);
  pointer-events: none;
  z-index: -1;
  animation: glowBloom 1.1s var(--ease-out) both;
}
@keyframes glowBloom {
  from { opacity: 0; transform: scale(0.7); }
  to { opacity: 1; transform: scale(1); }
}

.honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .page.active,
  .page.active.dir-back { animation: none; }
  .page[data-page="1"].active > *,
  .page.thankyou.active > * { animation: none; opacity: 1; transform: none; }
  .thankyou::before { animation: none; }
  .shake { animation: none; }
  input[type="checkbox"]:checked::after,
  input[type="radio"]:checked::after { animation: none; }
  .btn, .option { transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease; }
  .btn-primary:hover, .btn-primary:active { transform: none; }
  .option:active { transform: none; }
}

/* ---------- responsive ---------- */

@media (max-width: 480px) {
  .app-bar { padding: 0 18px; height: 50px; }
  .form-shell { padding: 82px 18px 96px; }
  h1 { font-size: 1.6rem; }
  .teaching-block { padding: 26px 22px 22px; }
}
