/* the brief: the tabloid's form (one huge condensed question at a time, answers typed onto a line of points that
   inks lime, the pick a lime block, the big lime action) set in the film's main column. Every hook form.js reads is
   the live one. */

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

.stage {
  --s-trace: #686a60; /* a word of the question before it is inked */
  --s-line: #2c2d26; /* the line of points at rest */
  --s-hold: #8f9089; /* an example answer, before one is typed */
  --s-opt: #8f9089; /* a choice not taken */
  --s-opt-hi: #dadada;
  --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(44px, 7.4cqi, 104px);
  --ans: clamp(26px, 3.6cqi, 44px);
  --c: clamp(22px, min(3cqi, 3.6vh), 34px);
  color-scheme: dark;
}
.stage__crest { display: none; }

.stage__form { display: flex; flex-direction: column; margin-top: clamp(20px, 4vh, 40px); }

/* ---------- the edge: the form's name, the way back, where you are ---------- */

.stage__edge { display: flex; align-items: center; justify-content: space-between; gap: 24px; max-width: 720px; min-height: 44px; }
.stage__slot { display: grid; justify-items: start; }
.stage__title { font: 700 clamp(22px, 1.8vw, 28px)/1.2 var(--display); letter-spacing: -.01em; color: var(--bone); }
.stage__back {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-left: -12px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--fog);
  font: 600 17px/1 var(--body);
  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: rgba(255, 255, 255, .07); color: var(--bone); transition-duration: var(--t-in); }
.stage__back[hidden] { display: none; }
.stage__count { font-size: 17px; color: var(--fog); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stage__now { color: var(--lime); font-weight: 700; }

/* ---------- the question in hand ---------- */

.stage__unit { display: flex; flex-direction: column; align-items: flex-start; padding-top: clamp(20px, 4vh, 48px); }
.stage__steps { position: relative; width: 100%; }
.step { width: 100%; min-width: 0; border: 0; }
.q {
  display: block;
  width: 100%;
  max-width: 11em;
  font-family: var(--display);
  font-size: var(--q);
  font-weight: 800;
  font-stretch: 75%;
  line-height: .92;
  letter-spacing: -.004em;
  text-transform: uppercase;
  color: var(--bone);
  text-wrap: balance;
}
.q .w { display: inline-block; }
@supports (color: color-mix(in srgb, red 50%, blue)) {
  .js .q .w { color: color-mix(in srgb, var(--bone) calc(var(--f, 1) * 100%), var(--s-trace)); }
}
.q__help { max-width: 34em; margin-top: clamp(14px, 2vh, 22px); font-size: 18px; line-height: 1.45; color: var(--fog); text-wrap: balance; }

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

.answers { display: flex; flex-wrap: wrap; gap: 0 clamp(24px, 3.4vw, 56px); margin-top: clamp(30px, 5vh, 60px); }
.ans { position: relative; width: 12em; font-size: var(--ans); text-align: center; }
.ans--name { width: 7.4em; }
.ans--store { width: 9.4em; }
.ans--email { width: 12em; }
.ans--phone { width: 9em; }
.ans input {
  display: block;
  width: 100%;
  height: 1.42em;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--bone);
  font: 700 1em/1.42 var(--display);
  letter-spacing: -.01em;
  text-align: center;
  caret-color: var(--lime);
  outline: none;
}
.ans input::placeholder { color: var(--s-hold); opacity: 1; }
.ans input:focus-visible { box-shadow: 0 3px 0 var(--lime); }
.ans input:-webkit-autofill,
.ans input:-webkit-autofill:hover,
.ans input:-webkit-autofill:focus { -webkit-text-fill-color: var(--bone); caret-color: var(--lime); transition: background-color 600000s 0s; }
.ans__mirror { position: absolute; top: 0; left: 0; visibility: hidden; white-space: pre; font: 700 1em/1.42 var(--display); letter-spacing: -.01em; pointer-events: none; }

/* the line: a band of points, a trace everywhere, inked lime out from the centre under the text */
.ans__line { position: relative; display: block; height: 7px; margin-top: .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(--lime); 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: #6f7a2c; transition-duration: var(--t-in); }
.ans input[aria-invalid="true"] ~ .ans__line .ans__trace { background: #7a3a45; }
.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: 16px; line-height: 1.35; color: var(--fog); }
.ans__err, .step__err { min-height: 1.35em; margin-top: 2px; font-size: 16px; line-height: 1.35; color: var(--danger); text-wrap: balance; }

/* ---------- a choice: the ranges rest quiet, the one picked becomes the ad's lime block ---------- */

.choices { display: inline-grid; justify-items: start; gap: 6px; margin-top: clamp(22px, 3.6vh, 40px); }
.choice {
  position: relative;
  display: flex;
  align-items: center;
  gap: .5em;
  min-height: 48px;
  margin-left: -.36em;
  padding: .12em .5em .06em .36em;
  border-radius: 8px;
  font: 700 var(--c)/1.2 var(--display);
  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), background-color var(--t-out) var(--ease);
}
.choice::before { content: ""; flex: none; width: .28em; height: .28em; border-radius: 50%; background: #3a3b33; 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(--fog); transition-duration: var(--t-in); }
.choice:has(input:checked) { background: var(--lime); color: var(--on-lime); }
.choice:has(input:checked)::before { background: var(--on-lime); transform: scale(1.25); }
.choice:has(input:focus-visible) { outline: 3px solid var(--lime); outline-offset: 4px; }
.step__err { margin-top: 10px; }

/* ---------- the action: the big condensed lime block ---------- */

.stage__act { display: flex; flex-direction: column; align-items: flex-start; margin-top: clamp(8px, 2vh, 22px); }
.stage__next.cta {
  min-width: min(100%, 320px);
  min-height: 76px;
  padding: .1em 40px 0;
  border-radius: 12px;
  font-size: clamp(30px, 3vw, 44px);
  font-stretch: 75%;
  letter-spacing: 0;
}
.stage__next .spin { display: none; width: 22px; height: 22px; }
.stage__next .spin circle { fill: none; stroke: currentColor; stroke-width: 1.8; 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__fail { max-width: 36em; margin-top: 20px; font-size: 17px; line-height: 1.45; color: var(--fog); text-wrap: pretty; }
.stage__fail-title { margin-bottom: 4px; font: 800 26px/1.1 var(--display); color: var(--danger); }
.stage__fail a { color: var(--bone); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--lime); }

/* ---------- sent: the check, drawn in lime points over its trace ---------- */

.stage__done { display: flex; flex-direction: column; align-items: flex-start; }
.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: 34em; margin-top: clamp(14px, 2.2vh, 22px); font-size: 19px; line-height: 1.45; color: var(--fog); }

/* ---------- one question at a time once JS runs; without it every question is on the page 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(72px, 12vh, 128px); }
html:not(.js) .stage__act { margin-top: clamp(48px, 8vh, 80px); }

@media (max-width: 560px) {
  .stage { --q: clamp(38px, 11vw, 52px); --ans: 24px; --c: clamp(21px, 6vw, 25px); }
  .q__help { font-size: 17px; }
  .answers { gap: 0 16px; }
  .ans--name, .ans--store { width: calc(50% - 8px); }
  .ans--email, .ans--phone { width: 100%; }
  .ans__err { min-height: 2.7em; }
  .stage__next.cta { width: 100%; }
}

@media (pointer: coarse) {
  html:has(.stage input:not([type="radio"]):focus) .nav { visibility: hidden; }
}

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