/* ---------- contact: the page floods to black and the form becomes a stage, one question at a time ---------- */

.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.stage {
  --s-trace: #3a3b41; /* a word before it is inked */
  --s-line: #3c3d44; /* the line of ink points at rest */
  --s-line-on: rgba(255, 255, 171, 0.8); /* the line of the field in hand: the house focus tone */
  --s-hold: #5e6168; /* an example answer, before one is typed */
  --s-opt: #7a7c82; /* a choice not taken */
  --s-opt-hi: #c4c7cc;
  --s-point: #2a2b31;
  --s-point-hi: #6a6c73;
  /* the hero's stipple, as a band of ink points a line can be drawn with */
  --stipple: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='7'%3E%3Cg fill='black'%3E%3Ccircle cx='1.7' cy='1.9' r='1.05'/%3E%3Ccircle cx='6.1' cy='1.2' r='.8'/%3E%3Ccircle cx='9.9' cy='3.2' r='1.1'/%3E%3Ccircle cx='4.2' cy='5.2' r='.9'/%3E%3Ccircle cx='13.6' cy='1.4' r='.85'/%3E%3Ccircle cx='12.2' cy='5.4' r='.95'/%3E%3Ccircle cx='17.4' cy='3.3' r='1'/%3E%3Ccircle cx='21.3' cy='1.5' r='.8'/%3E%3Ccircle cx='20.4' cy='5.5' r='.85'/%3E%3Ccircle cx='25.2' cy='3.6' r='1.05'/%3E%3C/g%3E%3C/svg%3E");
  --q: clamp(32px, 5.2vw, 78px); /* the question */
  --a: clamp(24px, 3vw, 44px); /* an answer */
  --c: clamp(22px, min(2.4vw, 3.6vh), 34px); /* a choice */
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100svh;
  padding: 0 max(var(--gutter), calc((100% - var(--measure)) / 2));
  background: linear-gradient(180deg, var(--floor-top) 0%, var(--floor) 70%);
  color: var(--d-mid);
  color-scheme: dark;
  scroll-margin-top: -88px; /* a jump to the contact lands with the stage filling the screen */
}

.stage :focus-visible { outline: 2px solid var(--focus-dark); outline-offset: 3px; border-radius: 6px; }
.stage ::selection { background: var(--d-hi); color: var(--floor); }
/* an answer field shows focus on its own line of points, not with a box */
.stage .ans input:focus-visible { outline: none; }

/* the flood: the stage's own top edge, arched like the letter's turn while the black rises up the screen */
.stage__crest {
  position: absolute;
  left: 0;
  bottom: calc(100% - 1px);
  width: 100%;
  height: clamp(40px, 7vw, 110px);
  fill: var(--floor-top);
  transform: scaleY(0);
  transform-origin: 50% 100%;
  pointer-events: none;
}

.stage__form { flex: 1; display: flex; flex-direction: column; padding: 96px 0 clamp(36px, 5vh, 56px); }

/* ---------- the edges: where you are, and the way back ---------- */

.stage__edge { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 40px; font-size: 15px; line-height: 1.3; }
.stage__slot { display: grid; justify-items: start; }
.stage__title { font-size: inherit; font-weight: 500; line-height: inherit; letter-spacing: -0.01em; color: var(--d-low); }
.stage__back {
  display: inline-flex;
  align-items: center;
  height: 40px;
  margin-left: -12px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--d-low);
  font-size: inherit;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--t-out) var(--ease), color var(--t-out) var(--ease);
}
.stage__back:hover { background: var(--d-fill); color: var(--d-hi); transition-duration: var(--t-in); }
.stage__back[hidden] { display: none; }
.stage__count { color: var(--d-low); font-variant-numeric: tabular-nums; }
.stage__now { color: var(--d-hi); font-weight: 500; }

/* ---------- the unit: the question in hand, its answers and the one action ---------- */

.stage__unit { display: flex; flex-direction: column; align-items: center; padding-top: clamp(28px, 10vh, 120px); text-align: center; }
.stage__steps { position: relative; width: 100%; }

.step { width: 100%; min-width: 0; }

.q {
  display: block;
  width: 100%;
  padding-inline: max(0px, calc((100% - 15em) / 2));
  font-size: var(--q);
  font-weight: 600;
  line-height: 1.04;
  letter-spacing: -0.04em;
  color: var(--d-hi);
  text-wrap: balance;
}
.q .w { display: inline-block; }
/* the grey start exists only where the fill to ink is guaranteed; anywhere else every word is plain ink */
@supports (color: color-mix(in srgb, red 50%, blue)) {
  .js .q .w { color: color-mix(in srgb, var(--d-hi) calc(var(--f, 1) * 100%), var(--s-trace)); }
}

.q__help { max-width: 40ch; margin: clamp(12px, 2vh, 20px) auto 0; font-size: 17px; line-height: 1.45; color: var(--d-low); text-wrap: balance; }

/* ---------- an answer: typed straight onto the stage, over a line of ink points ---------- */

.answers { display: flex; justify-content: center; gap: 0 clamp(24px, 3.4vw, 56px); margin-top: clamp(32px, 6.5vh, 68px); }

.ans { position: relative; width: 14em; font-size: var(--a); }
.ans--name { width: 6.6em; }
.ans--store { width: 9.4em; }
.ans--email { width: 14.5em; }

.ans input {
  display: block;
  width: 100%;
  height: 1.42em;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--d-hi);
  font-size: inherit;
  font-weight: 500;
  line-height: 1.42;
  letter-spacing: -0.025em;
  text-align: center;
  caret-color: var(--d-hi);
  outline: none;
}
.ans input::placeholder { color: var(--s-hold); opacity: 1; transition: color var(--t-out) var(--ease); }
.ans input:focus::placeholder { color: #45474e; }
.ans input:-webkit-autofill,
.ans input:-webkit-autofill:hover,
.ans input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--d-hi);
  caret-color: var(--d-hi);
  transition: background-color 600000s 0s;
}

/* measures what is typed, so the ink under it can spread exactly that far */
.ans__mirror { position: absolute; top: 0; left: 0; visibility: hidden; white-space: pre; font-weight: 500; letter-spacing: -0.025em; pointer-events: none; }

/* the line: a band of the hero's points, a faint trace everywhere, inked out from the centre under the text.
   each half reveals its ink by sliding a window over it while the points slide back, so nothing moves */
.ans__line { position: relative; display: block; height: 7px; margin-top: 0.22em; }
.ans__line i { position: absolute; top: 0; display: block; height: 100%; }
.ans__trace, .ans__dots {
  -webkit-mask: var(--stipple) 0 0 / 28px 7px repeat-x;
  mask: var(--stipple) 0 0 / 28px 7px repeat-x;
}
.ans__trace { left: 0; width: 100%; background: var(--s-line); transition: background-color var(--t-out) var(--ease); }
.ans__clip { width: 50%; overflow: hidden; }
.ans__clip--l { left: 0; }
.ans__clip--r { left: 50%; }
.ans__line .ans__slide { left: 0; width: 100%; overflow: hidden; transition: transform var(--t-move) var(--ease); }
.ans__clip--l .ans__slide { transform: translateX(calc(100% - var(--h, 0px))); }
.ans__clip--r .ans__slide { transform: translateX(calc(var(--h, 0px) - 100%)); }
.ans__line .ans__dots { left: 0; width: 200%; background: var(--d-hi); transition: transform var(--t-move) var(--ease), background-color var(--t-out) var(--ease); }
.ans__clip--l .ans__dots { transform: translateX(calc(var(--h, 0px) - 50%)); }
.ans__clip--r .ans__dots { transform: translateX(calc(var(--h, 0px) * -1)); }

.ans input:focus ~ .ans__line .ans__trace { background: var(--s-line-on); transition-duration: var(--t-in); }
.ans input[aria-invalid="true"] ~ .ans__line .ans__trace { background: var(--danger-edge); }
.ans input[aria-invalid="true"]:focus ~ .ans__line .ans__trace,
.ans input[aria-invalid="true"] ~ .ans__line .ans__dots { background: var(--danger); }

.ans label { display: block; margin-top: 12px; font-size: 14px; line-height: 1.35; color: var(--d-low); }
/* every error line keeps its room, so nothing below it moves when one appears */
.ans__err, .step__err { min-height: 1.35em; margin-top: 2px; font-size: 14px; line-height: 1.35; color: var(--danger); text-wrap: balance; }

/* ---------- a choice: the ranges rest as traces, the one picked inks ---------- */

.choices { display: inline-grid; justify-items: start; margin-top: clamp(22px, 3.6vh, 40px); padding-right: 0.72em; text-align: left; }

.choice {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.48em;
  padding: 0.08em 0.24em 0.08em 0;
  border-radius: 6px;
  font-size: var(--c);
  font-weight: 500;
  line-height: 1.24;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  color: var(--s-opt);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: color var(--t-out) var(--ease);
}
/* the ink point beside each range */
.choice::before {
  content: "";
  flex: none;
  width: 0.24em;
  height: 0.24em;
  border-radius: 50%;
  background: var(--s-point);
  transform: translateY(-0.02em);
  transition: background-color var(--t-out) var(--ease), transform var(--t-out) var(--ease);
}
.choice input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.choice:hover { color: var(--s-opt-hi); transition-duration: var(--t-in); }
.choice:hover::before { background: var(--s-point-hi); transition-duration: var(--t-in); }
.choice:has(input:checked) { color: var(--d-hi); }
.choice:has(input:checked)::before { background: var(--d-hi); transform: translateY(-0.02em) scale(1.3); }
.choice:has(input:focus-visible) { outline: 2px solid var(--focus-dark); outline-offset: 4px; }
.step__err { margin-top: 10px; }

/* ---------- the action ---------- */

.stage__act { display: flex; flex-direction: column; align-items: center; margin-top: clamp(4px, 1.4vh, 16px); }

.stage__next {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 132px;
  height: 48px;
  padding: 0 22px;
  border: 0;
  border-radius: 8px;
  background: #f4f4f5;
  color: #121216;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow: var(--cast), inset 0 -1px 0 rgba(0, 0, 0, 0.12);
  transition: background-color var(--t-out) var(--ease), transform var(--t-press) ease-out;
}
.stage__next:hover { background: #ffffff; transition-duration: var(--t-in), var(--t-press); }
.stage__next:active { background: #e4e4e6; transform: scale(0.97); }
.stage__next .spin { display: none; width: 16px; height: 16px; }
.stage__next .spin circle { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-dasharray: 26 40; }
.stage__next[aria-busy="true"] { pointer-events: none; }
.stage__next[aria-busy="true"] [data-label] { display: none; }
.stage__next[aria-busy="true"] .spin { display: block; animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.stage__consent { max-width: 64ch; margin-top: 18px; font-size: 13px; line-height: 1.45; color: var(--d-faint); text-wrap: balance; }

.stage__fail { max-width: 44ch; margin-top: 18px; font-size: 14px; line-height: 1.45; color: var(--d-mid); text-wrap: pretty; }
.stage__fail-title { font-size: 15px; font-weight: 500; color: var(--danger); }
.stage__fail a { color: var(--d-hi); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(255, 255, 255, 0.4); }

/* ---------- sent: the hero's check, drawn in ink points over its trace ---------- */

.stage__done { display: flex; flex-direction: column; align-items: center; }
.stage__done[hidden] { display: none; }
.ck { display: block; width: clamp(104px, 11vw, 160px); height: auto; margin-bottom: clamp(18px, 3vh, 30px); overflow: visible; }
.ck__pen { stroke-dasharray: 1; stroke-dashoffset: 0; }
.stage .stage__done-title { outline: none; }
.stage__done-line { max-width: 46ch; margin-top: clamp(14px, 2.2vh, 22px); font-size: 17px; line-height: 1.45; color: var(--d-low); text-wrap: balance; }

/* ---------- one question at a time once JS runs; without it every question is on the stage and posts ---------- */

.js .step:not(.is-current):not(.is-leaving) { display: none; }
.js .step.is-leaving { position: absolute; top: 0; left: 0; right: 0; pointer-events: none; }
.js .stage__form.is-done .step:not(.is-leaving),
.js .stage__form.is-done .stage__act { display: none; }
.js .stage__form.is-done .stage__edge { visibility: hidden; }

html:not(.js) .stage__count { display: none; }
html:not(.js) .step + .step { margin-top: clamp(80px, 14vh, 140px); }
html:not(.js) .stage__act { margin-top: clamp(48px, 8vh, 80px); }

/* ---------- sizes ---------- */

@media (max-width: 900px) {
  .ans--store { width: 8.2em; }
}

@media (max-width: 560px) {
  .stage { --q: clamp(30px, 8.8vw, 40px); --a: 24px; --c: clamp(22px, 6.2vw, 26px); }
  .stage__form { padding-top: 76px; }
  .stage__edge { min-height: 36px; font-size: 14px; }
  .stage__unit { padding-top: clamp(20px, 6vh, 56px); }
  .q__help { font-size: 15px; }
  .answers { gap: 0 16px; }
  .ans--name, .ans--store { width: calc(50% - 8px); }
  .ans--email { width: 100%; }
  .ans label { margin-top: 10px; font-size: 13px; }
  .ans__err { min-height: 2.7em; font-size: 13px; }
  .step__err { font-size: 13px; }
}

/* phones, while the keyboard is up: the stage is exactly what is visible above it, and the nav steps aside */
@media (max-width: 760px) {
  html.is-typing .nav { transform: translateY(-140%); transition: transform var(--t-move) var(--ease); }
  /* the stage keeps its height, so it can still be scrolled to the top; only the form fits the visible part */
  .stage.is-typing .stage__form { flex: none; min-height: var(--vvh, 100svh); padding: 14px 0 16px; }
  .stage.is-typing .stage__unit { padding-top: 14px; }
  .stage.is-typing .answers { margin-top: 24px; }
  .stage.is-typing .stage__consent { display: none; }
}
@media (min-width: 761px) {
  html.is-typing .nav { transition: transform var(--t-move) var(--ease); }
}

/* ---------- user settings ---------- */

@media (prefers-reduced-motion: reduce) {
  .stage__crest { display: none; }
  .stage__next:active { transform: none; }
  .stage__next[aria-busy="true"] .spin { animation: none; opacity: 0.5; }
}

@media (prefers-contrast: more) {
  .stage { --s-trace: #8a8c92; --s-line: #6a6c73; --s-hold: #8a8d94; --s-opt: #a6a9af; --s-point: #6a6c73; }
}

@media (forced-colors: active) {
  .ans__trace, .ans__dots, .choice::before { forced-color-adjust: none; }
  .ans__trace { background: GrayText; }
  .ans__line .ans__dots { background: CanvasText; }
  .ans input:focus ~ .ans__line .ans__trace { background: Highlight; }
  .ans input[aria-invalid="true"] ~ .ans__line .ans__trace { background: Mark; }
  .choice::before { background: GrayText; }
  .choice:has(input:checked)::before { background: Highlight; }
  .choice:has(input:checked) { outline: 1px solid CanvasText; outline-offset: 4px; }
  .choice:has(input:focus-visible) { outline: 2px solid Highlight; }
  .stage__next, .stage__back { border: 1px solid ButtonText; }
  .stage :focus-visible { outline-color: Highlight; }
  .stage__crest { display: none; }
}
