/* ==========================================================================
   Center for Deliverance and Healing — Student Registration & Admission
   Visual direction: institutional / documentary. Navy and gold lifted from the
   printed form, section headers kept as navy pills so the screen form reads as
   the same document. Deliberately light-only; the crest and the seal colours
   are the brand and do not invert.
   ========================================================================== */

:root {
  color-scheme: light;

  /* Brand — sampled from the crest */
  --navy-900: #0e1738;
  --navy-800: #16224b;
  --navy-700: #1f2d63;
  --navy-600: #2c3d7d;
  --gold-600: #b8842a;
  --gold-500: #d09a33;
  --gold-400: #e8b85a;

  /* Surfaces — warm paper, not flat white */
  --paper:    #f7f5f0;
  --card:     #ffffff;
  --card-2:   #fbfaf7;
  --line:     #e2ded4;
  --line-2:   #cfc9ba;

  --ink:      #171a22;
  --ink-2:    #4a505f;
  --ink-3:    #7d8393;

  --danger:   #b3261e;
  --danger-bg:#fdf1f0;
  --ok:       #1e7a53;

  /* Type */
  --display: "Oswald", "Arial Narrow", Impact, system-ui, sans-serif;
  --body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --step: clamp(.95rem, .9rem + .2vw, 1.02rem);

  /* Rhythm — deliberately uneven, tight inside a field, generous between blocks */
  --gap-field: .95rem;
  --gap-block: 1.9rem;
  --pad-panel: clamp(1.25rem, .6rem + 2.4vw, 2.6rem);

  --r-sm: 6px;
  --r-md: 12px;
  --r-lg: 20px;

  --shadow-card: 0 1px 2px rgba(14,23,56,.05), 0 18px 45px -22px rgba(14,23,56,.35);
  --shadow-pop:  0 10px 30px -12px rgba(14,23,56,.45);

  --t-fast: 140ms;
  --t-mid: 280ms;
  --ease: cubic-bezier(.22, 1, .36, 1);
}

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

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

body {
  margin: 0;
  font-family: var(--body);
  font-size: var(--step);
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  /* Faint paper grain so the page has a surface instead of a flat fill. */
  background-image:
    radial-gradient(circle at 18% 12%, rgba(208,154,51,.07), transparent 45%),
    radial-gradient(circle at 88% 78%, rgba(22,34,75,.06), transparent 50%);
  background-attachment: fixed;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

img { max-width: 100%; height: auto; display: block; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 60;
  background: var(--navy-800); color: #fff; padding: .7rem 1.1rem;
  border-radius: 0 0 var(--r-sm) 0; font-weight: 600; text-decoration: none;
}
.skip-link:focus { left: 0; }

/* ── Layout ───────────────────────────────────────────────────────────────── */

.shell {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: clamp(1rem, 2vw, 2.25rem);
  max-width: 1320px;
  margin: 0 auto;
  padding: clamp(1rem, 2.5vw, 2.5rem) clamp(1rem, 3vw, 2.5rem);
  align-items: start;
}

/* ── Brand rail ───────────────────────────────────────────────────────────── */

.rail {
  position: sticky;
  top: calc(env(safe-area-inset-top, 0px) + 1.5rem);
  background:
    linear-gradient(168deg, var(--navy-700) 0%, var(--navy-900) 72%);
  color: #fff;
  border-radius: var(--r-lg);
  padding: clamp(1.4rem, 2vw, 2rem);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

/* The gold rule under the masthead, exactly as on the printed form. */
.rail::after {
  content: "";
  position: absolute; inset: auto 0 0 0; height: 4px;
  background: linear-gradient(90deg, var(--gold-600), var(--gold-400) 40%, transparent 78%);
}

.rail__brand { display: flex; gap: 1rem; align-items: center; }

.rail__seal {
  width: 76px; height: 76px; flex: none;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,.35));
}

.rail__org {
  margin: 0 0 .3rem;
  font-size: .68rem; letter-spacing: .13em; text-transform: uppercase;
  color: var(--gold-400); font-weight: 600; line-height: 1.35;
}

.rail__title {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.25rem, 1rem + .9vw, 1.6rem);
  line-height: 1.08;
  letter-spacing: .01em;
  text-transform: uppercase;
}
.rail__title em { font-style: normal; color: var(--gold-400); }

.rail__note {
  margin: 1.35rem 0 0;
  padding-top: 1.1rem;
  border-top: 1px solid rgba(255,255,255,.14);
  font-size: .82rem; color: rgba(255,255,255,.72);
}
.rail__note strong { color: #fff; letter-spacing: .04em; }

/* Section index — the vertical progress spine */
.index { margin-top: 1.35rem; }
.index__list { list-style: none; margin: 0; padding: 0; counter-reset: sect; }

.index__item {
  position: relative;
  display: flex; align-items: center; gap: .7rem;
  padding: .42rem 0 .42rem .1rem;
  font-size: .84rem;
  color: rgba(255,255,255,.55);
  cursor: default;
  transition: color var(--t-fast) ease;
}
.index__item button {
  all: unset;
  display: flex; align-items: center; gap: .7rem;
  width: 100%; cursor: not-allowed;
}
.index__item.is-reachable button { cursor: pointer; }
.index__item.is-reachable:hover { color: rgba(255,255,255,.85); }

.index__mark {
  flex: none;
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: .68rem; font-weight: 700;
  border: 1.5px solid rgba(255,255,255,.25);
  color: rgba(255,255,255,.65);
  transition: all var(--t-mid) var(--ease);
}
.index__item.is-done .index__mark {
  background: var(--gold-500); border-color: var(--gold-500); color: var(--navy-900);
}
.index__item.is-done { color: rgba(255,255,255,.72); }
.index__item.is-current { color: #fff; font-weight: 600; }
.index__item.is-current .index__mark {
  background: #fff; border-color: #fff; color: var(--navy-800);
  box-shadow: 0 0 0 4px rgba(255,255,255,.14);
}
.index__item:focus-within .index__mark { box-shadow: 0 0 0 3px var(--gold-400); }

.rail__foot {
  margin: 1.4rem 0 0;
  font-size: .74rem; line-height: 1.5;
  color: rgba(255,255,255,.45);
}

/* ── Deck ─────────────────────────────────────────────────────────────────── */

.deck {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  min-width: 0;
}

.deck__head {
  padding: clamp(1rem, 1.6vw, 1.5rem) var(--pad-panel) 0;
  background: var(--card-2);
  border-bottom: 1px solid var(--line);
}

.deck__meta {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  margin-bottom: .7rem;
}
.deck__count {
  font-size: .74rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 600;
}
.deck__count b { color: var(--navy-700); font-size: .95rem; }
.deck__count i { font-style: normal; opacity: .6; }

.deck__sect {
  font-family: var(--display);
  font-size: clamp(1.05rem, .9rem + .5vw, 1.4rem);
  font-weight: 600; letter-spacing: .01em;
  text-transform: uppercase;
  color: var(--navy-800);
}

.deck__bar {
  height: 3px; background: var(--line);
  border-radius: 3px 3px 0 0; overflow: hidden;
  margin: 0 calc(var(--pad-panel) * -1);
}
.deck__fill {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--gold-600), var(--gold-400));
  transition: width var(--t-mid) var(--ease);
}

/* ── The swipe mechanism ──────────────────────────────────────────────────── */

.viewport {
  overflow: hidden;
  touch-action: pan-y;               /* horizontal drags belong to us */
  -webkit-user-select: none; user-select: none;
  /* Height is driven by the active panel so the card never leaves dead space. */
  transition: height var(--t-mid) var(--ease);
}
.viewport.is-typing { -webkit-user-select: auto; user-select: auto; }

.track {
  display: flex;
  align-items: flex-start;
  will-change: transform;
  transition: transform var(--t-mid) var(--ease);
}
.track.is-dragging { transition: none; }

.panel {
  flex: 0 0 100%;
  min-width: 100%;
  margin: 0;
  border: 0;
  padding: var(--pad-panel);
  /* Off-screen panels are inert but still measurable for height animation. */
  opacity: .35;
  transition: opacity var(--t-mid) var(--ease);
}
.panel.is-active { opacity: 1; }

/* Section label — the navy pill from the printed form */
.panel__tag {
  width: -moz-fit-content;
  width: fit-content;
  margin: 0 0 1.5rem;
  padding: .45rem .95rem;
  background: var(--navy-800);
  color: #fff;
  border-radius: var(--r-sm);
  font-family: var(--display);
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}

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

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap-field) 1.1rem;
  align-items: start;
}
.f--full, .opts.f--full, .sign.f--full, .declaration.f--full { grid-column: 1 / -1; }
.f--half { grid-column: span 1; }

.f {
  position: relative;
  margin: 0;
  padding-top: .55rem;
}

.f input, .f textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--card-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  padding: 1.35rem .9rem .55rem;
  transition: border-color var(--t-fast) ease, box-shadow var(--t-fast) ease, background var(--t-fast) ease;
  -webkit-appearance: none;
  appearance: none;
}
.f textarea { resize: vertical; min-height: 4.6rem; line-height: 1.45; }

.f input:hover, .f textarea:hover { border-color: var(--navy-600); }

.f input:focus, .f textarea:focus {
  outline: none;
  background: #fff;
  border-color: var(--navy-700);
  box-shadow: 0 0 0 3px rgba(44,61,125,.14);
}

/* Floating label */
.f label {
  position: absolute;
  left: .95rem;
  top: 1.35rem;
  font-size: .95rem;
  color: var(--ink-3);
  pointer-events: none;
  transform-origin: left top;
  transition: transform var(--t-fast) var(--ease), color var(--t-fast) ease;
}
.f input:focus + label,
.f textarea:focus + label,
.f input:not(:placeholder-shown) + label,
.f textarea:not(:placeholder-shown) + label,
.f input.is-filled-always + label {
  transform: translateY(-.78rem) scale(.78);
  color: var(--navy-700);
  font-weight: 600;
}
.f input:disabled, .f textarea:disabled { background: #f1efe9; color: var(--ink-3); }
.f input[readonly] { background: #f1efe9; color: var(--ink-2); }

.req { color: var(--gold-600); font-weight: 700; }

.hint {
  display: block;
  margin: .35rem 0 0 .2rem;
  font-size: .74rem; color: var(--ink-3);
}

.counter {
  position: absolute; right: .2rem; bottom: -1.05rem;
  font-size: .7rem; color: var(--ink-3); font-variant-numeric: tabular-nums;
}

.err {
  display: none;
  margin: .35rem 0 0 .2rem;
  font-size: .76rem; font-weight: 500; color: var(--danger);
}
.is-invalid .err, .opts.is-invalid > .err, .sign.is-invalid .err { display: block; }
.f.is-invalid input, .f.is-invalid textarea {
  border-color: var(--danger); background: var(--danger-bg);
}
.f.is-valid input, .f.is-valid textarea { border-color: #b9cdbe; }

.f.sub { padding-top: .35rem; }

/* ── Choice groups ────────────────────────────────────────────────────────── */

.opts {
  margin: .35rem 0 0;
  padding: 0;
  border: 0;
  min-width: 0;
}
.opts > legend {
  padding: 0 0 .6rem;
  font-size: .82rem; font-weight: 600; letter-spacing: .01em;
  color: var(--navy-800);
}

.opts__row { display: flex; flex-wrap: wrap; gap: .5rem .55rem; }
.opts__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: .5rem .55rem;
}
.opts__grid--wide { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.opt {
  display: flex; align-items: flex-start; gap: .55rem;
  padding: .58rem .8rem;
  background: var(--card-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  font-size: .87rem; line-height: 1.35;
  cursor: pointer;
  transition: border-color var(--t-fast) ease, background var(--t-fast) ease, transform var(--t-fast) var(--ease);
}
.opt:hover { border-color: var(--navy-600); background: #fff; }
.opt:active { transform: scale(.985); }

.opt input {
  flex: none;
  width: 17px; height: 17px;
  margin: .09rem 0 0;
  accent-color: var(--navy-700);
  cursor: pointer;
}
.opt input:focus-visible { outline: 2px solid var(--gold-500); outline-offset: 2px; }

/* Selected state carries real weight — the printed form's ticked box. */
.opt:has(input:checked) {
  background: #fff;
  border-color: var(--navy-700);
  box-shadow: inset 0 0 0 1px var(--navy-700);
}
.opt:has(input:checked) span { font-weight: 600; color: var(--navy-800); }

.opt--agree { align-items: flex-start; padding: .8rem .95rem; }
.opts.is-invalid .opt { border-color: var(--danger); }

/* ── Declaration ──────────────────────────────────────────────────────────── */

.declaration {
  margin: 0 0 .4rem;
  padding: 1.2rem 1.35rem;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold-500);
  border-radius: var(--r-md);
}
.declaration p { margin: 0 0 .85rem; font-size: .9rem; line-height: 1.62; color: var(--ink-2); }
.declaration p:last-child { margin-bottom: 0; }
.declaration strong { color: var(--navy-800); }

/* ── Signature pad ────────────────────────────────────────────────────────── */

.sign { margin-top: .4rem; }
.sign__head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: .45rem;
}
.sign__label { font-size: .82rem; font-weight: 600; color: var(--navy-800); }

.sign__pad {
  display: block;
  width: 100%;
  height: 150px;
  background:
    linear-gradient(transparent 68%, var(--line-2) 68%, var(--line-2) calc(68% + 1px), transparent calc(68% + 1px)),
    var(--card-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  cursor: crosshair;
  touch-action: none;             /* drawing must not scroll or swipe the deck */
}
.sign__pad:focus-visible { outline: 2px solid var(--navy-700); outline-offset: 2px; }
.sign.is-invalid .sign__pad { border-color: var(--danger); }

.linkbtn {
  all: unset;
  cursor: pointer;
  font-size: .76rem; font-weight: 600;
  color: var(--navy-700);
  border-bottom: 1px solid currentColor;
}
.linkbtn:hover { color: var(--gold-600); }
.linkbtn:focus-visible { outline: 2px solid var(--gold-500); outline-offset: 3px; }

/* ── Footer navigation ────────────────────────────────────────────────────── */

.nav {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.05rem var(--pad-panel);
  border-top: 1px solid var(--line);
  background: var(--card-2);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font: inherit; font-weight: 600;
  padding: .72rem 1.25rem;
  border-radius: 100px;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) ease,
              background var(--t-fast) ease, color var(--t-fast) ease, border-color var(--t-fast) ease;
}
.btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }

.btn--solid {
  background: var(--navy-800); color: #fff;
  box-shadow: 0 8px 18px -10px rgba(22,34,75,.85);
}
.btn--solid:hover:not(:disabled) {
  background: var(--navy-700);
  transform: translateY(-1px);
  box-shadow: 0 12px 24px -10px rgba(22,34,75,.9);
}
.btn--solid:active:not(:disabled) { transform: translateY(0) scale(.99); }

.btn--ghost {
  background: transparent; color: var(--navy-800); border-color: var(--line-2);
}
.btn--ghost:hover:not(:disabled) { border-color: var(--navy-700); background: #fff; }

.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--gold-500); outline-offset: 3px; }

.btn--submit { background: var(--gold-600); box-shadow: 0 8px 18px -10px rgba(184,132,42,.9); }
.btn--submit:hover:not(:disabled) { background: var(--gold-500); box-shadow: 0 12px 24px -10px rgba(184,132,42,.95); }

.spin { display: none; width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
  animation: spin .7s linear infinite; }
.btn.is-busy .spin { display: block; }
.btn.is-busy svg { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Dots — a compact second read of the same progress */
.dots {
  list-style: none; margin: 0 auto; padding: 0;
  display: flex; gap: .4rem; align-items: center;
}
.dots li {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--line-2);
  transition: all var(--t-mid) var(--ease);
}
.dots li.is-done { background: var(--gold-500); }
.dots li.is-current { width: 24px; border-radius: 4px; background: var(--navy-800); }

.swipe-hint {
  margin: 0; padding: 0 var(--pad-panel) 1rem;
  text-align: center;
  font-size: .72rem; color: var(--ink-3);
  background: var(--card-2);
}
.swipe-hint.is-gone { display: none; }

/* ── Completion ───────────────────────────────────────────────────────────── */

.done {
  padding: clamp(2rem, 5vw, 3.75rem) var(--pad-panel);
  text-align: center;
}
.done__seal {
  width: 62px; height: 62px; margin: 0 auto 1.25rem;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--navy-800);
  box-shadow: 0 0 0 8px rgba(22,34,75,.08);
  animation: pop 420ms var(--ease);
}
.done__seal svg { width: 28px; height: 28px; fill: none; stroke: var(--gold-400); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }

.done h2 {
  margin: 0 0 .5rem;
  font-family: var(--display); font-weight: 600; text-transform: uppercase;
  font-size: clamp(1.35rem, 1.1rem + 1vw, 1.85rem);
  color: var(--navy-800); letter-spacing: .02em;
}
.done p { margin: 0 auto 1.75rem; max-width: 46ch; color: var(--ink-2); text-wrap: pretty; }

.stub {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  margin: 0 0 1.9rem;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.stub > div { background: var(--card-2); padding: .95rem .8rem; }
.stub dt {
  font-size: .68rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 600; margin-bottom: .3rem;
}
.stub dd { margin: 0; font-weight: 600; color: var(--navy-800); font-size: .92rem; word-break: break-word; }

/* ── Toast ────────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 1.25rem);
  transform: translate(-50%, 140%);
  display: flex; align-items: center; gap: .6rem;
  max-width: min(92vw, 30rem);
  padding: .8rem 1.15rem;
  background: var(--navy-900); color: #fff;
  border-radius: 100px;
  box-shadow: var(--shadow-pop);
  font-size: .85rem; font-weight: 500;
  z-index: 50;
  transition: transform var(--t-mid) var(--ease), opacity var(--t-mid) ease;
  opacity: 0;
}
.toast.is-up { transform: translate(-50%, 0); opacity: 1; }
.toast.is-bad { background: var(--danger); }
.toast.is-good { background: var(--ok); }
.toast__ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* Honeypot */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }

  .rail { position: relative; top: auto; padding: 1.1rem 1.25rem; }
  .rail__seal { width: 56px; height: 56px; }
  .rail__note, .rail__foot { display: none; }
  .index { display: none; }           /* dots + progress bar carry it on phones */
}

@media (max-width: 620px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .f--half { grid-column: 1 / -1; }
  .opts__grid, .opts__grid--wide { grid-template-columns: minmax(0, 1fr); }

  .nav { gap: .6rem; padding: .85rem 1rem; }
  .btn { padding: .68rem .95rem; font-size: .88rem; }
  .btn span:not(.spin) { font-size: .88rem; }
  .dots { gap: .3rem; }
}

@media (max-width: 380px) {
  .btn--ghost span { display: none; }   /* Back collapses to its arrow */
  .btn--ghost { padding: .68rem .8rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .rail, .nav, .swipe-hint, .toast, .deck__bar { display: none !important; }
  .track { display: block; transform: none !important; }
  .panel { opacity: 1 !important; page-break-inside: avoid; }
  .deck { border: 0; box-shadow: none; }
  body { background: #fff; }
}
