/* ===========================================================================
   Intake forms — one stylesheet, no build step.

   The look: a quiet, editorial, high-contrast form floating on a slowly
   drifting field of brand-coloured light. Everything that is brand-specific is
   a custom property injected into <head> per request (--accent, --accent-2,
   --ink), so one stylesheet dresses every domain.

   Rules held to throughout:
     - 16px minimum body text, 44px minimum tap target, 4.5:1 minimum contrast.
     - Motion is decorative only, and every bit of it is off under
       prefers-reduced-motion.
     - Light and dark are both first-class; the tokens swap, nothing else does.
   ========================================================================= */

:root {
  --accent: #1d4ed8;
  --accent-2: #7c3aed;
  --ink: #0c0a09;
  /* Derived per brand in <head> (see src/color.js). --accent is the raw brand
     colour and is only ever a fill; --accent-ink is the same hue adjusted until
     it can be read as text on the current surface, and --on-accent is whatever
     can be read on top of an accent fill. A pale brand gold needs both. */
  --on-accent: #ffffff;
  --accent-ink: #1d4ed8;
  --accent-hover: #1a45bb;

  --canvas: #f7f6f4;
  --card: rgba(255, 255, 255, 0.74);
  --card-solid: #ffffff;
  --text: #0c0a09;
  --text-muted: #57534e;
  --text-soft: #78716c;
  --line: rgba(12, 10, 9, 0.11);
  --line-strong: rgba(12, 10, 9, 0.22);
  --field: rgba(255, 255, 255, 0.72);
  --field-hover: rgba(255, 255, 255, 0.95);
  --danger: #b91c1c;
  --ok: #15803d;

  --shadow-card: 0 1px 2px rgba(12, 10, 9, 0.04), 0 12px 32px -12px rgba(12, 10, 9, 0.16);
  --shadow-pop: 0 2px 6px rgba(12, 10, 9, 0.06), 0 22px 48px -16px rgba(12, 10, 9, 0.28);

  --r-card: 24px;
  --r-control: 14px;
  --r-pill: 999px;

  --step: 0.25rem;
  --wrap: 44rem;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --fast: 160ms;
  --mid: 240ms;

  --orb-opacity: 0.5;
  --grid-opacity: 0.5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #0b0a09;
    --card: rgba(28, 25, 23, 0.72);
    --card-solid: #171514;
    --text: #fafaf9;
    --text-muted: #c3bdb7;
    --text-soft: #a8a29e;
    --line: rgba(250, 250, 249, 0.14);
    --line-strong: rgba(250, 250, 249, 0.3);
    --field: rgba(250, 250, 249, 0.05);
    --field-hover: rgba(250, 250, 249, 0.09);
    --danger: #fca5a5;
    --ok: #86efac;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.5), 0 18px 44px -16px rgba(0, 0, 0, 0.75);
    --shadow-pop: 0 2px 8px rgba(0, 0, 0, 0.55), 0 28px 60px -18px rgba(0, 0, 0, 0.85);
    --orb-opacity: 0.42;
    --grid-opacity: 0.22;
  }
}

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

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--canvas);
  color: var(--text);
  font-family: 'DM Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1,
h2 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.05;
  color: var(--text);
}

p {
  margin: 0;
}

a {
  color: var(--accent-ink);
  text-underline-offset: 3px;
}

.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 {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 50;
  padding: 12px 18px;
  background: var(--card-solid);
  border-radius: 0 0 12px 0;
  font-weight: 600;
}
.skip:focus {
  left: 0;
}

:where(a, button, input, textarea, select, [tabindex]):focus-visible {
  outline: 2px solid var(--accent-ink);
  outline-offset: 3px;
  border-radius: 6px;
}

/* --- the slow field of light ------------------------------------------- */

.field-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.orb {
  position: absolute;
  display: block;
  border-radius: 50%;
  opacity: var(--orb-opacity);
  filter: blur(70px);
  will-change: transform;
}

/* Three overlapping washes, each on its own long, prime-ish cycle so the
   composition never visibly repeats. 48-80s: slow enough to read as ambient
   rather than as something happening. */
.orb-1 {
  width: 62vmax;
  height: 62vmax;
  top: -22vmax;
  left: -18vmax;
  background: radial-gradient(circle at 30% 30%, var(--accent), transparent 68%);
  animation: drift-1 64s var(--ease) infinite alternate;
}
.orb-2 {
  width: 54vmax;
  height: 54vmax;
  bottom: -20vmax;
  right: -16vmax;
  background: radial-gradient(circle at 60% 40%, var(--accent-2), transparent 68%);
  animation: drift-2 79s var(--ease) infinite alternate;
}
.orb-3 {
  width: 40vmax;
  height: 40vmax;
  top: 40%;
  left: 45%;
  background: radial-gradient(circle at 50% 50%, var(--accent), transparent 70%);
  opacity: calc(var(--orb-opacity) * 0.55);
  animation: drift-3 53s var(--ease) infinite alternate;
}

@keyframes drift-1 {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(14vw, 12vh, 0) scale(1.18);
  }
}
@keyframes drift-2 {
  from {
    transform: translate3d(0, 0, 0) scale(1.1);
  }
  to {
    transform: translate3d(-16vw, -10vh, 0) scale(0.92);
  }
}
@keyframes drift-3 {
  from {
    transform: translate3d(-8vw, 6vh, 0) scale(0.9);
  }
  to {
    transform: translate3d(10vw, -14vh, 0) scale(1.25);
  }
}

/* A hairline grid over the wash. It gives the blur something to be measured
   against, which is what stops the background reading as a smudge. */
.grid {
  position: absolute;
  inset: -1px;
  display: block;
  opacity: var(--grid-opacity);
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: radial-gradient(ellipse 85% 65% at 50% 40%, #000 20%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 85% 65% at 50% 40%, #000 20%, transparent 100%);
}

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

/* --- shell -------------------------------------------------------------- */

.wrap {
  position: relative;
  z-index: 1;
  width: min(100% - 2rem, var(--wrap));
  margin-inline: auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  background: color-mix(in srgb, var(--canvas) 72%, transparent);
  border-bottom: 1px solid var(--line);
}

.topbar-in {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 56px;
  padding-block: 0.5rem;
}

.brand {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.02em;
}
.brand a {
  color: inherit;
  text-decoration: none;
}
.brand a:hover {
  color: var(--accent-ink);
}

.kind {
  font-size: 0.875rem;
  color: var(--text-soft);
  letter-spacing: 0.02em;
}

.rail {
  height: 3px;
  background: var(--line);
}
.rail-fill {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width var(--mid) var(--ease);
}

.intro {
  padding: clamp(2.5rem, 8vw, 4.5rem) 0 clamp(1.5rem, 4vw, 2.25rem);
}

.eyebrow {
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-ink);
  margin-bottom: 0.875rem;
}

.intro h1 {
  font-size: clamp(2.5rem, 9vw, 4.25rem);
}

.dot-accent {
  color: var(--accent-ink);
}

.lede {
  margin-top: 1rem;
  max-width: 34rem;
  font-size: 1.0625rem;
  color: var(--text-muted);
}

/* --- card --------------------------------------------------------------- */

.card {
  position: relative;
  background: var(--card);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  padding: clamp(1.25rem, 5vw, 2.25rem);
}

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

.step-count {
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}
.step-count span {
  color: var(--accent-ink);
  font-weight: 700;
}

.step-title {
  margin-top: 0.375rem;
  font-size: clamp(1.625rem, 5.5vw, 2.125rem);
}
/* Focused programmatically on every step change so a screen reader announces
   the new step. It is not interactive, so it must not draw a focus ring. */
.step-title:focus,
.step-title:focus-visible {
  outline: none;
}

.step-hint {
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.fields {
  display: grid;
  gap: 1.75rem;
  margin-top: 2rem;
}

.js .step {
  display: none;
}
.js .step.is-active {
  display: block;
  animation: step-in var(--mid) var(--ease) both;
}
.js .step.is-leaving {
  display: block;
}

@keyframes step-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.step + .step {
  margin-top: 3rem;
}
.js .step + .step {
  margin-top: 0;
}

/* --- fields ------------------------------------------------------------- */

.field[hidden] {
  display: none;
}

/* The sticky action bar on phones covers roughly this much, so a field scrolled
   to on validation is not parked underneath it. */
.field {
  scroll-margin-block: 6rem 8rem;
}

.label {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.req {
  color: var(--accent-ink);
  margin-left: 0.2em;
}

.help {
  margin: -0.25rem 0 0.625rem;
  font-size: 0.875rem;
  color: var(--text-soft);
}

.control {
  display: block;
  width: 100%;
  min-height: 3.25rem;
  padding: 0.875rem 1rem;
  font: inherit;
  font-size: 1rem; /* never below 16px — iOS zooms the page otherwise */
  color: var(--text);
  background: var(--field);
  border: 1.5px solid var(--line);
  border-radius: var(--r-control);
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
textarea.control {
  min-height: 7rem;
  resize: vertical;
  line-height: 1.55;
}
.control::placeholder {
  color: var(--text-soft);
  opacity: 0.75;
}
.control:hover {
  background: var(--field-hover);
  border-color: var(--line-strong);
}
.control:focus {
  outline: none;
  background: var(--field-hover);
  border-color: var(--accent-ink);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}
.field.is-bad .control {
  border-color: var(--danger);
}
.field.is-bad .control:focus {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 18%, transparent);
}

.err {
  display: flex;
  gap: 0.375rem;
  margin-top: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--danger);
}
.err[hidden] {
  display: none;
}

/* Options: full-size tappable rows, never a bare 20px checkbox. */
.opts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.625rem;
}
.opts-stack {
  grid-template-columns: 1fr;
}

.opt {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3.25rem;
  padding: 0.75rem 1rem;
  background: var(--field);
  border: 1.5px solid var(--line);
  border-radius: var(--r-control);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.opt:hover {
  background: var(--field-hover);
  border-color: var(--line-strong);
}
.opt input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.opt-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.375rem;
  height: 1.375rem;
  border: 1.5px solid var(--line-strong);
  border-radius: 7px;
  color: var(--on-accent);
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.opt input[type='radio'] ~ .opt-mark {
  border-radius: 50%;
}
.opt-mark svg {
  width: 0.875rem;
  height: 0.875rem;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.opt-text {
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.35;
}
.opt:has(input:checked) {
  border-color: var(--accent-ink);
  background: color-mix(in srgb, var(--accent) 9%, var(--field-hover));
}
.opt:has(input:checked) .opt-mark {
  background: var(--accent);
  border-color: var(--accent);
}
.opt:has(input:checked) .opt-mark svg {
  opacity: 1;
  transform: none;
}
.opt:has(input:focus-visible) {
  outline: 2px solid var(--accent-ink);
  outline-offset: 3px;
}

/* --- files -------------------------------------------------------------- */

.drop {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 0.25rem;
  padding: 1.75rem 1rem;
  text-align: center;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-control);
  background: var(--field);
  cursor: pointer;
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.drop:hover,
.drop.is-over {
  border-color: var(--accent-ink);
  background: color-mix(in srgb, var(--accent) 7%, var(--field-hover));
}
.drop-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.drop-icon svg {
  width: 1.5rem;
  height: 1.5rem;
  color: var(--accent-ink);
}
.drop-title {
  font-weight: 600;
}
.drop-sub {
  font-size: 0.8125rem;
  color: var(--text-soft);
}

.files {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}
.files:empty {
  display: none;
}

.file {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  background: var(--field-hover);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.file-icon svg {
  width: 1.25rem;
  height: 1.25rem;
  color: var(--text-soft);
}
.file-body {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 0.125rem;
}
.file-name {
  font-size: 0.9375rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-meta {
  font-size: 0.8125rem;
  color: var(--text-soft);
}
.file-bar {
  height: 3px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.file.is-done .file-bar {
  display: none;
}
.file-bar-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 120ms linear;
}
.file.is-bad {
  border-color: var(--danger);
}
.file.is-bad .file-meta {
  color: var(--danger);
}
.file-x {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  margin: -0.5rem -0.375rem -0.5rem 0;
  border: 0;
  background: none;
  color: var(--text-soft);
  border-radius: 50%;
  cursor: pointer;
  transition: color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.file-x:hover {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}
.file-x svg {
  width: 1rem;
  height: 1rem;
}

/* --- navigation --------------------------------------------------------- */

.form-error {
  margin-top: 1.5rem;
  padding: 0.875rem 1rem;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  border-radius: 12px;
}
.form-error[hidden] {
  display: none;
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.dots {
  display: flex;
  gap: 0.375rem;
  margin-inline: auto;
}
.dot {
  width: 2rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.dot::after {
  content: '';
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background var(--fast) var(--ease);
}
.dot.is-done::after {
  background: color-mix(in srgb, var(--accent) 55%, transparent);
}
.dot.is-current::after {
  background: var(--accent);
}
.dot[disabled] {
  cursor: default;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 3rem;
  padding: 0.75rem 1.375rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  border-radius: var(--r-pill);
  border: 1.5px solid transparent;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease), border-color var(--fast) var(--ease),
    box-shadow var(--fast) var(--ease);
}
.btn svg {
  width: 1.125rem;
  height: 1.125rem;
}
.btn[hidden] {
  display: none;
}

.btn.primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 1px 2px rgba(12, 10, 9, 0.16), 0 10px 24px -10px color-mix(in srgb, var(--accent) 70%, transparent);
}
.btn.primary:hover {
  background: var(--accent-hover);
}
.btn.primary:disabled {
  opacity: 0.55;
  cursor: progress;
}

.btn.ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--line-strong);
}
.btn.ghost:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.privacy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 1.5rem 0 3.5rem;
  font-size: 0.875rem;
  color: var(--text-soft);
  text-align: center;
}
.privacy svg {
  flex: none;
  width: 1rem;
  height: 1rem;
}

.noscript-note {
  margin: 1rem auto;
  padding: 0.875rem 1rem;
  font-size: 0.9375rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card-solid);
}

/* --- done / error page -------------------------------------------------- */

.done {
  display: grid;
  justify-items: start;
  gap: 1rem;
  min-height: 100dvh;
  align-content: center;
  padding-block: 4rem;
}
.done h1 {
  font-size: clamp(2.5rem, 9vw, 4.25rem);
}
.done .lede {
  margin-top: 0;
}
.done-tick {
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  color: var(--on-accent);
  background: var(--accent);
  box-shadow: 0 12px 32px -12px color-mix(in srgb, var(--accent) 80%, transparent);
}
.done-tick svg {
  width: 1.75rem;
  height: 1.75rem;
}
/* --- phones ------------------------------------------------------------- */

@media (max-width: 640px) {
  .card {
    border-radius: 20px;
  }

  /* The primary action lives within thumb reach and never scrolls away. */
  .js .nav {
    position: sticky;
    bottom: 0;
    margin: 2rem -1.25rem -1.25rem;
    padding: 0.875rem 1.25rem calc(0.875rem + env(safe-area-inset-bottom));
    /* Near-opaque: at 88% the fields underneath ghosted through as the step
       scrolled behind it, which read as a rendering fault rather than depth. */
    background: color-mix(in srgb, var(--card-solid) 97%, transparent);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--line);
    border-radius: 0 0 20px 20px;
  }
  .js .nav .dots {
    order: -1;
    width: 100%;
    margin: 0 0 0.5rem;
    justify-content: center;
  }
  .js .nav {
    flex-wrap: wrap;
  }
  .btn.primary {
    flex: 1;
  }
  .opts {
    grid-template-columns: 1fr;
  }
  .intro {
    padding-top: 2.25rem;
  }
}

@media (min-width: 641px) {
  .opts {
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  }
}
