/* Pre-qualification enquiry form.
 *
 * THESIS: an enquiry is a conversation you can see, not a tunnel you are
 * pushed down. Every answer stays on the page as one ruled line you can
 * change, and the live question is always the last thing on the card. It
 * refuses the category default of a wizard that swallows each answer and
 * shows a progress bar as an apology for it.
 *
 * OWN-WORLD: MyBarrister's own, unchanged — paper ground, a white card on a
 * 1px #DED7CF rule, Fraunces for the question and Outfit for everything a
 * hand touches, #B75049 for the one action and the one selection, slate for
 * every other word. No second accent, no card inside a card, no icon tiles.
 * Recognisable with all the words removed by the ruled ledger of answers
 * sitting above a single red-ringed choice.
 *
 * STORY: she sees her first answer land in the ledger and understands the
 * form is listening; she sees the ledger grow and knows exactly what she has
 * said; she corrects one line without losing the rest; she sends it.
 *
 * FIRST VIEWPORT: a 4px rule of progress, the step count and the time it
 * takes on one small line, then — once she has answered anything — the
 * ledger of her answers, each a label, its value and a Change link. A
 * hairline divides that from the question, set in Fraunces at 1.125rem, its
 * hint beneath, and the answers two to a row beneath that. The primary
 * action sits bottom-right only on the screens that need one; the pick-one
 * screens advance on the pick.
 *
 * FORM: "answers stack up as you go" — index 4 of seven ranked structures,
 * chosen by the user from the dealt hand. Seed key e123fabb.
 *
 * FINISH: unreviewed and undocumented is unfinished; this build ends with
 * the finish review, the verdict, DESIGN.md, and every shipping raster
 * carrying its provenance.
 *
 * ---------------------------------------------------------------------------
 * Why the tokens are declared on .mb-pq and not on :root: this component has
 * to render on the nine PPC landing pages, which are self-contained
 * documents that never load main.css and carry two thirds of attributable
 * leads. The values match the brand tokens in main.css.
 *
 * Red is --pq-red-dark everywhere it carries white or sits at body size:
 * white on #D15B54 is 3.94:1, which fails AA for a 1rem 600 label.
 */

.mb-pq {
  --pq-red: #d15b54;
  --pq-red-dark: #b75049;
  --pq-red-tint: #f7e6e5;
  --pq-slate: #41617a;
  --pq-slate-dark: #253846;
  --pq-slate-soft: #8da0af;
  --pq-slate-mist: #e4e8ec;
  --pq-slate-pale: #eef1f4;
  --pq-graphite: #313232;
  --pq-line: #ded7cf;
  --pq-ok: #2e6b4f;

  /* A fixed rem scale, not a fluid one. People use this at one DPI in one
     hand; a question that shrinks with the viewport reads worse, not
     better. The ratio is a tight 1.15 — there are a lot of type elements
     here and exaggerated contrast is noise. */
  --pq-f-micro: 0.75rem;
  --pq-f-small: 0.75rem;
  --pq-f-base: 0.8125rem;
  --pq-f-ui: 0.875rem;
  --pq-f-q: 1.125rem;

  --pq-s1: 4px;
  --pq-s2: 8px;
  --pq-s3: 12px;
  --pq-s4: 16px;
  --pq-s6: 24px;

  font: 400 16px/1.5 "Outfit", system-ui, sans-serif;
  color: var(--pq-graphite);
  background: #fff;
  border: 1px solid var(--pq-line);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(37, 56, 70, 0.05), 0 10px 24px rgba(37, 56, 70, 0.06);
  padding: var(--pq-s4);
  max-width: 560px;
  margin: 0 auto;
  text-align: left;
}
@media (min-width: 720px) {
  .mb-pq { padding: var(--pq-s6) 28px; }
}

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

/* The surfaces nobody draws. They ship with browser defaults that belong to
   no design system, and they are the cheapest proof the thing was built
   rather than assembled. */
.mb-pq ::selection { background: var(--pq-red-tint); color: var(--pq-slate-dark); }
.mb-pq input,
.mb-pq textarea { caret-color: var(--pq-red-dark); }
.mb-pq input[type="checkbox"] { accent-color: var(--pq-red-dark); }

.mb-pq h2 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--pq-slate-dark);
  margin: 0;
}
.mb-pq a { color: var(--pq-slate); text-underline-offset: 2px; }
.mb-pq a:hover { color: var(--pq-red-dark); }

/* ---------------------------------------------------------------- progress */

.mb-pq-prog { margin: 0 0 var(--pq-s3); }
.mb-pq-bar {
  height: 4px;
  background: var(--pq-slate-mist);
  border-radius: 99px;
  overflow: hidden;
}
.mb-pq-fill {
  height: 100%;
  width: 100%;
  background: var(--pq-red-dark);
  border-radius: 99px;
  /* scaleX rather than an animated width: transform is composited, so the
     bar never triggers layout. setProgress() sets the scale. */
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}
.mb-pq-lbl {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--pq-s3);
  margin: var(--pq-s2) 0 0;
  font-size: var(--pq-f-small);
  font-weight: 500;
  color: var(--pq-slate);
}
/* The step count changes under the reader; lining figures stop it jittering. */
.mb-pq-step { font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------- the ledger
 *
 * Every answer given so far, one ruled line each: what was asked, what was
 * said, and a way to change it. This is the form's whole idea, so it is a
 * ledger and not a panel — nothing to open, nothing hidden behind a count.
 */

.mb-pq-answers:empty { display: none; }
.mb-pq-answers { margin: 0 0 var(--pq-s4); }

.mb-pq-a-row {
  display: grid;
  grid-template-columns: 5.25rem minmax(0, 1fr) auto;
  align-items: baseline;
  gap: var(--pq-s2);
  padding: 3px 0;
  border-top: 1px solid var(--pq-slate-mist);
}
.mb-pq-a-row:first-child { border-top: 0; }
.mb-pq-a-q {
  font-size: var(--pq-f-micro);
  line-height: 1.4;
  color: var(--pq-slate);
}
.mb-pq-a-a {
  font-size: var(--pq-f-base);
  font-weight: 600;
  line-height: 1.4;
  color: var(--pq-slate-dark);
  /* Short answers are one line; a long one wraps to two and then clamps.
     It was a single nowrap line with a title attribute, and title never
     appears on a touch screen — so the free-text answer, the one people most
     want to re-read, could not be read at all without leaving the step. */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}
.mb-pq-a-change {
  /* 24px is the WCAG 2.2 target floor, made with padding rather than a tall
     line-height, which would drop this below the line it sits beside. */
  padding: 4px 2px;
  background: none;
  border: 0;
  font: 500 var(--pq-f-micro) / 1.4 "Outfit", system-ui, sans-serif;
  color: var(--pq-slate);
  text-decoration: underline;
  cursor: pointer;
}
.mb-pq-a-change:hover { color: var(--pq-red-dark); }
.mb-pq-a-change:focus-visible { outline: 2px solid var(--pq-slate); outline-offset: 2px; }

/* The newest line arrives rather than appearing: the one authored moment in
   the form, and the thing that tells her it heard her. */
.mb-pq-a-row.is-new { animation: mb-pq-land 0.2s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes mb-pq-land {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------------------------------- the live question
 *
 * More space above the heading than below it, and a rule to say the ledger
 * has ended and the asking has started.
 */

.mb-pq-stage {
  border-top: 1px solid var(--pq-line);
  padding-top: var(--pq-s4);
}
/* keepQuestionInView() scrolls to this. The site header is sticky at 880px
   and up, so the question would otherwise arrive underneath it — but below
   880px the header is deliberately static, and reserving the space there
   would push the question down the screen for no reason. */
@media (min-width: 880px) {
  .mb-pq-stage { scroll-margin-top: 80px; }
}
.mb-pq-answers:empty + .mb-pq-stage { border-top: 0; padding-top: 0; }

.mb-pq-q { font-size: var(--pq-f-q); line-height: 1.3; margin: 0 0 var(--pq-s1); }
.mb-pq-hint {
  margin: 0 0 var(--pq-s3);
  font-size: var(--pq-f-base);
  line-height: 1.5;
  color: var(--pq-slate);
}

/* Each question rises into place behind its own answer landing in the
   ledger: one orchestrated moment, from an already-visible default. The
   stage moves as one body — animating its children gave four parts the same
   entrance at the same time, which is scattering, not choreography. */
.mb-pq-stage { animation: mb-pq-rise 0.22s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes mb-pq-rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ----------------------------------------------------------------- options */

.mb-pq-opts { display: grid; grid-template-columns: 1fr 1fr; gap: var(--pq-s2); margin: 0; }
.mb-pq-opts.is-stacked { grid-template-columns: 1fr; }

.mb-pq-opt {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  text-align: left;
  font: 500 var(--pq-f-ui) / 1.3 "Outfit", system-ui, sans-serif;
  color: var(--pq-slate-dark);
  background: #fff;
  border: 1px solid var(--pq-slate-mist);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}
.mb-pq-opt:hover { border-color: var(--pq-slate-soft); background: var(--pq-slate-pale); }
.mb-pq-opt:focus-visible { outline: 2px solid var(--pq-slate); outline-offset: 2px; }
.mb-pq-opt[aria-pressed="true"] {
  background: var(--pq-red-tint);
  border-color: var(--pq-red-dark);
  /* An inset ring, not a thicker border: a border that grows on selection
     reflows the whole grid. */
  box-shadow: inset 0 0 0 1px var(--pq-red-dark);
}
/* No empty circle in front of every label. The tick is drawn only when there
   is something to tick and its space is never reserved, so a one-word answer
   gets the whole column. */
.mb-pq-tick { display: none; }
.mb-pq-opt[aria-pressed="true"] .mb-pq-tick {
  display: inline-block;
  width: 0.8em;
  height: 0.45em;
  margin-right: 0.45em;
  vertical-align: 0.12em;
  border: solid var(--pq-red-dark);
  border-width: 0 0 2px 2px;
  transform: rotate(-45deg);
}
.mb-pq-opt small {
  display: block;
  margin-top: 2px;
  font-weight: 400;
  font-size: var(--pq-f-small);
  line-height: 1.4;
  color: var(--pq-slate);
}

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

.mb-pq-field { margin: 0 0 var(--pq-s3); }
.mb-pq-field label {
  display: block;
  margin: 0 0 var(--pq-s1);
  font-size: var(--pq-f-small);
  font-weight: 600;
  line-height: 1.3;
  color: var(--pq-slate-dark);
}
.mb-pq-field input,
.mb-pq-field textarea {
  width: 100%;
  /* 16px, never smaller: iOS zooms the viewport on any field under it,
     which costs far more than the height saves. */
  font: 400 16px/1.4 "Outfit", system-ui, sans-serif;
  color: var(--pq-graphite);
  background: #fff;
  border: 1px solid var(--pq-slate-mist);
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 44px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.mb-pq-field textarea { min-height: 104px; resize: vertical; }
.mb-pq-field input:focus,
.mb-pq-field textarea:focus {
  outline: none;
  border-color: var(--pq-slate);
  box-shadow: 0 0 0 3px rgba(65, 97, 122, 0.16);
}
.mb-pq-field.is-bad input,
.mb-pq-field.is-bad textarea { border-color: var(--pq-red-dark); }
.mb-pq-err {
  display: none;
  margin: var(--pq-s1) 0 0;
  font-size: var(--pq-f-small);
  font-weight: 500;
  line-height: 1.4;
  color: var(--pq-red-dark);
}
.mb-pq-field.is-bad .mb-pq-err,
.mb-pq-err.is-shown { display: block; }

/* --pq-slate, not --pq-slate-soft: #8da0af on white is 2.70:1, which fails
   AA at this size. --pq-slate is 6.53:1. */
.mb-pq-optional { font-weight: 400; font-size: var(--pq-f-small); color: var(--pq-slate); }

.mb-pq-two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--pq-s3); }

.mb-pq-pcnote {
  margin: var(--pq-s1) 0 0;
  font-size: var(--pq-f-small);
  font-weight: 500;
  line-height: 1.4;
  color: var(--pq-ok);
  min-height: 1.3rem;
}
.mb-pq-pcnote.is-quiet { color: var(--pq-slate); font-weight: 400; }

.mb-pq-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: var(--pq-s3) 0 0;
  font-size: var(--pq-f-ui);
  line-height: 1.5;
  color: var(--pq-slate);
}
.mb-pq-check input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
}

/* --------------------------------------------------- follow-up on a screen
 *
 * The date and the referrer live on their parent question's screen rather
 * than taking one of their own. A rule, not a box: a card inside a card is
 * always wrong.
 */
.mb-pq-sub {
  margin: var(--pq-s3) 0 0;
  padding: var(--pq-s3) 0 0;
  border-top: 1px solid var(--pq-slate-mist);
}
.mb-pq-subq {
  margin: 0 0 var(--pq-s2);
  font-size: var(--pq-f-base);
  font-weight: 600;
  color: var(--pq-slate-dark);
}
.mb-pq-sub .mb-pq-field { margin: 0; }
.mb-pq-sub .mb-pq-err.is-shown { margin-top: var(--pq-s2); }
.mb-pq-opts.is-tight { gap: var(--pq-s2); }

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

.mb-pq-files {
  margin: var(--pq-s4) 0 0;
  padding: var(--pq-s3) 0 0;
  border-top: 1px solid var(--pq-slate-mist);
}
.mb-pq-filelabel {
  display: block;
  font-size: var(--pq-f-small);
  font-weight: 600;
  color: var(--pq-slate-dark);
}
.mb-pq-filehint {
  margin: 2px 0 var(--pq-s2);
  font-size: var(--pq-f-small);
  line-height: 1.4;
  color: var(--pq-slate);
}
.mb-pq-files input[type="file"] {
  max-width: 100%;
  font: 400 var(--pq-f-small) / 1.4 "Outfit", system-ui, sans-serif;
  color: var(--pq-slate);
}
.mb-pq-files input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 8px 14px;
  font: 600 var(--pq-f-small) / 1 "Outfit", system-ui, sans-serif;
  color: #fff;
  background: var(--pq-slate-dark);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.mb-pq-files input[type="file"]::file-selector-button:hover { background: var(--pq-slate); }
.mb-pq-filelist { margin: var(--pq-s2) 0 0; }
.mb-pq-filelist > div {
  display: flex;
  align-items: center;
  gap: var(--pq-s2);
  padding: 5px 0;
  border-top: 1px solid var(--pq-slate-mist);
  font-size: var(--pq-f-small);
}
.mb-pq-filelist > div:first-child { border-top: 0; }
.mb-pq-filename {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--pq-slate-dark);
}
.mb-pq-filesize { flex: none; color: var(--pq-slate); font-variant-numeric: tabular-nums; }
.mb-pq-fileremove {
  flex: none;
  min-height: 24px;
  padding: 0 2px;
  background: none;
  border: 0;
  font: 500 var(--pq-f-micro) / 24px "Outfit", system-ui, sans-serif;
  color: var(--pq-slate);
  text-decoration: underline;
  cursor: pointer;
}
.mb-pq-fileremove:hover { color: var(--pq-red-dark); }
.mb-pq-filetotal {
  margin: var(--pq-s2) 0 0;
  font-size: var(--pq-f-micro);
  color: var(--pq-slate);
  font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------- navigation
 *
 * Only rendered where there is something to press. The pick-one screens
 * advance on the pick, and there is no Back button anywhere: every line in
 * the ledger carries a Change link that names what it changes, which is a
 * better Back than Back.
 */
.mb-pq-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--pq-s3);
  margin: var(--pq-s4) 0 0;
}
.mb-pq-btn {
  min-height: 44px;
  padding: 11px 20px;
  font: 600 var(--pq-f-ui) / 1 "Outfit", system-ui, sans-serif;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}
.mb-pq-btn-primary { background: var(--pq-red-dark); color: #fff; }
.mb-pq-btn-primary:hover { background: #a3463f; }
.mb-pq-btn-ghost {
  background: transparent;
  color: var(--pq-slate);
  border-color: var(--pq-slate-mist);
}
.mb-pq-btn-ghost:hover { border-color: var(--pq-slate-soft); color: var(--pq-slate-dark); }
.mb-pq-btn:focus-visible { outline: 2px solid var(--pq-slate); outline-offset: 2px; }
.mb-pq-btn[disabled] { opacity: 0.5; cursor: wait; }
.mb-pq-skip {
  min-height: 44px;
  padding: 0 2px;
  background: none;
  border: 0;
  font: 500 var(--pq-f-small) / 1.3 "Outfit", system-ui, sans-serif;
  color: var(--pq-slate);
  text-decoration: underline;
  cursor: pointer;
}
.mb-pq-skip:hover { color: var(--pq-slate-dark); }
.mb-pq-skip:focus-visible { outline: 2px solid var(--pq-slate); outline-offset: 2px; }

/* ---------------------------------------------------------------- endings */

.mb-pq-end { text-align: left; }
.mb-pq-ico {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: 0 0 var(--pq-s3);
  border-radius: 50%;
  background: var(--pq-red-tint);
  color: var(--pq-red-dark);
}
.mb-pq-ico svg { width: 20px; height: 20px; }
.mb-pq-end h2 { font-size: var(--pq-f-q); line-height: 1.3; margin: 0 0 var(--pq-s2); }
.mb-pq-end p {
  margin: 0 0 var(--pq-s3);
  font-size: var(--pq-f-base);
  line-height: 1.6;
  color: var(--pq-slate);
}
.mb-pq-end p:last-child { margin-bottom: 0; }
.mb-pq-acts { display: flex; flex-wrap: wrap; gap: var(--pq-s2); margin: var(--pq-s4) 0 0; }

.mb-pq-failed {
  display: none;
  margin: var(--pq-s3) 0 0;
  padding: 10px 12px;
  background: var(--pq-red-tint);
  border-radius: 8px;
  font-size: var(--pq-f-base);
  line-height: 1.5;
  color: #8a3a34;
}
.mb-pq-failed a { color: inherit; font-weight: 600; }
.mb-pq.has-failed .mb-pq-failed { display: block; }

@media (prefers-reduced-motion: reduce) {
  .mb-pq-fill,
  .mb-pq-opt,
  .mb-pq-btn,
  .mb-pq-field input,
  .mb-pq-field textarea { transition: none; }
  .mb-pq-a-row.is-new,
  .mb-pq-stage { animation: none; }
}

/* Colour alone never carries the selection, and forced colours drops the
   box-shadow that draws the focus ring on a field — so the outline that is
   suppressed for ordinary colours has to come back here. */
@media (forced-colors: active) {
  .mb-pq-fill { background: Highlight; }
  .mb-pq-opt[aria-pressed="true"] { outline: 2px solid Highlight; }
  .mb-pq-field input:focus,
  .mb-pq-field textarea:focus { outline: 2px solid Highlight; outline-offset: 1px; }
}

/* ------------------------------------------- where the form sits on a page
 *
 * A plain shell, never .mb-inq-card. That card is a slate panel that paints
 * every <p> and <label> inside it white, which is right for the classic form
 * and fatal for this one — it brings its own white panel, so the questions
 * and hints went white on white.
 *
 * The card is also a 276px sidebar. Eight questions need the room the form
 * was designed at, so on a page with the sidebar grid this variant drops out
 * of the grid and takes the full width.
 */
.mb-prequal-shell { width: 100%; }
.mb-prequal-foot {
  margin: 16px 0 0;
  font-size: 0.875rem;
  color: var(--slate, #41617a);
  text-align: center;
}
.mb-prequal-foot a { color: inherit; font-weight: 600; }

/* The page's own two columns, rewidened — not a break out of them.
 *
 * Dropping the form out of the grid and letting it centre itself left it
 * floating in the middle of 1180px with 310px of nothing either side, which
 * is worse than the sidebar it escaped. So the grid keeps both columns and
 * the second one simply grows to the width the form was designed at. The
 * page copy stays beside it and the form has a wall to stand against.
 *
 * :has() is supported everywhere this site targets; without it the form just
 * stays in the sidebar, readable but narrow — a degradation, not a break.
 */
.mb-main-grid:has(.mb-prequal-shell) > aside { width: 100%; max-width: none; }
@media (min-width: 980px) {
  .mb-main-grid:has(.mb-prequal-shell) { grid-template-columns: minmax(0, 1fr) 560px; }
}

/* Hard against the left of whatever column it is in, so it lines up with the
   page copy above it. Centring is right when the form IS the page — the
   landing pages and the preview — and wrong when it is part of one. */
.mb-prequal-shell .mb-pq { margin-inline: 0; }

/* ------------------------------------------------------------------ phones
 *
 * Last in the file on purpose: these selectors are no more specific than the
 * ones they tighten, so higher up the file the later plain rule wins and the
 * whole block silently does nothing.
 *
 * The card stops being a card. On a 375px screen the page gutter, the card
 * padding and the border were taking a fifth of the width before a word was
 * written, which is what made it read as a long thin column.
 */
@media (max-width: 480px) {
  /* Measured from the viewport, not the gutter, so it does not need to know
     what the container's padding happens to be. */
  .mb-prequal-shell { margin-inline: calc(50% - 50vw); width: 100vw; }
  .mb-prequal-foot { padding-inline: 16px; }

  .mb-pq {
    padding: var(--pq-s3) var(--pq-s3) var(--pq-s4);
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    box-shadow: none;
  }
  .mb-pq-a-row { grid-template-columns: 4.5rem minmax(0, 1fr) auto; }
  .mb-pq-two { gap: 0 10px; }
}

/* The smallest phones. At 375px a half-width column is 166px, which holds
   every label we ask of it — measured. At 320px it is 140px and the longer
   ones wrap three deep, so below 360px everything stacks. Deliberately not
   the 400px the Barrister Connect form uses, which would stack on a
   standard iPhone. */
@media (max-width: 359px) {
  .mb-pq-opts { grid-template-columns: 1fr; }
  .mb-pq-two { grid-template-columns: 1fr; }
}
