/**
 * Form styling for Stage 1 and Stage 2, the card page, sign-in and the
 * physiotherapist application.
 *
 * Everything here sits under .form-ui (D63): the site's frame, headings and
 * reading styles are in site.css, and these rules cannot restyle an
 * information page. The one exception is the shared base rule for controls,
 * kept unscoped and by exclusion (CLAUDE.md, A32).
 *
 * Layout principles, in priority order:
 *   1. One decision per screen, inside a single card, so nothing floats.
 *   2. Large targets and few keystrokes — choices are buttons wherever the
 *      option count allows. Minimum 44px, and short label-only options use a
 *      compact centred variant rather than a full row with an empty icon slot.
 *   3. Icons always sit beside a text label, never instead of one.
 *   4. Density. Vertical space on a phone is the scarce resource: a two-word
 *      option on its own 58px line is what made the first version feel loose.
 *      Long labels get a full-width row, short ones stay in columns.
 *   5. The same component set works at 360px and at 1440px; the card is
 *      capped so a wide screen does not stretch a two-column grid into
 *      something unreadable.
 */

.form-ui {
  /* Direction A (D67): the site's warm paper and greens, rounder shapes. */
  --ink: #183e35;
  --paper: #f8f6f0;
  --card: #fffdf8;
  --line: #d8d2c4;
  --line-soft: #e5e1d6;
  --primary: #1c493c;
  --primary-hover: #2a5c44;
  --tint: #eaf0e4;
  --selected-bg: #e7efdd;
  --selected-border: #4d7a3f;
  --focus: #547e3f;
  --error: #8f2f2f;
  --error-bg: #fbf1f0;
  --muted: #55695e;
  --radius: 14px;
  --card-radius: 24px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  font-size: 16px;
  line-height: 1.55;
}

/* The step heading is focused programmatically so a screen reader announces
   the new step. It carries tabindex="-1", so no keyboard user can ever reach
   it by tabbing and there is nothing for a focus ring to communicate — it
   just draws a box around the title on load. */
.form-ui h1[tabindex]:focus, .form-ui h1[tabindex]:focus-visible { outline: none; }

/* ---- step heading and progress ----------------------------------------- */

.form-ui .step-head { margin-bottom: 12px; }

/* The site's serif, as on every other page; the rest of the form is the text face. */
.form-ui h1 {
  font-family: var(--display, Georgia, serif);
  font-size: clamp(28px, 5vw, 36px);
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.12;
  margin: 0 0 6px;
}
.form-ui h2, .form-ui h3 { font-family: var(--text, Arial, sans-serif); letter-spacing: 0; line-height: 1.35; }

.form-ui .context-line {
  font-size: 13.5px;
  color: var(--muted);
  margin: 0 0 12px;
}

.form-ui .progress {
  display: flex;
  gap: 5px;
  margin-bottom: 8px;
}
/* Each finished step fills from the left, so moving on is seen, not just read. */
.form-ui .progress-seg {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--line-soft);
  position: relative;
  overflow: hidden;
}
.form-ui .progress-seg::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 3px;
  background: var(--primary);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.5s var(--ease);
}
.form-ui .progress-seg.done::after { transform: scaleX(1); }
.form-ui .progress-label { font-size: 12.5px; color: var(--muted); margin: 0 0 12px; }

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

.form-ui .card {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--card-radius);
  padding: 22px;
  box-shadow: 0 20px 40px -34px rgba(24, 62, 53, 0.45);
}

.form-ui .step-help { color: var(--muted); font-size: 14.5px; margin: 0 0 16px; }

.form-ui h2, .form-ui .field > span {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 9px;
}
.form-ui h2 { margin-top: 20px; }
.form-ui h2:first-child { margin-top: 0; }
.form-ui h2 svg, .form-ui .field > span svg {
  width: 18px;
  height: 18px;
  stroke: var(--muted);
  fill: none;
  stroke-width: 1.7;
  flex: 0 0 auto;
}

/* ---- choices ----------------------------------------------------------- */

.form-ui .choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.form-ui .choice-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-ui .choice-grid.cols-1 { grid-template-columns: 1fr; }

.form-ui .choice {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 50px;
  padding: 8px 11px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s var(--ease);
}
.form-ui .choice:hover { border-color: #a8bda6; }
.form-ui .choice:active { transform: scale(0.985); }
.form-ui .choice[aria-pressed='true'] { background: var(--selected-bg); border-color: var(--selected-border); }

/* Icon in a soft tile: gives the row an anchor and keeps labels aligned. */
.form-ui .choice-icon {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--tint);
  display: grid;
  place-items: center;
  transition: background 0.2s, color 0.2s;
}
.form-ui .choice[aria-pressed='true'] .choice-icon { background: var(--primary); }
.form-ui .choice[aria-pressed='true'] .choice-icon svg { stroke: #fff; }
.form-ui .choice-icon svg { width: 17px; height: 17px; stroke: var(--ink); fill: none; stroke-width: 1.6; }

.form-ui .choice-label { flex: 1; min-width: 0; }

/* A visible box on multi-selects, so "you may pick several" is obvious
   before anything is picked rather than only after. */
.form-ui .choice-box {
  flex: 0 0 auto;
  width: 21px;
  height: 21px;
  border: 1.5px solid var(--line);
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: #fff;
}
.form-ui .choice[aria-pressed='true'] .choice-box {
  background: var(--selected-border);
  border-color: var(--selected-border);
}
.form-ui .choice-box { transition: background 0.2s, border-color 0.2s; }
.form-ui .choice-box svg {
  width: 13px; height: 13px; stroke: #fff; fill: none; stroke-width: 2.6; opacity: 0;
  transform: scale(0.5); transition: transform 0.24s var(--ease), opacity 0.18s;
}
.form-ui .choice[aria-pressed='true'] .choice-box svg { opacity: 1; transform: none; }

/* Single-select shows a tick, not a box: only one answer is possible. It grows in when chosen. */
.form-ui .choice-tick {
  flex: 0 0 auto; width: 19px; height: 19px; stroke: var(--selected-border); fill: none; stroke-width: 2.4; opacity: 0;
  transform: scale(0.5); transition: transform 0.24s var(--ease), opacity 0.18s;
}
.form-ui .choice[aria-pressed='true'] .choice-tick { opacity: 1; transform: none; }

.form-ui .choice.compact {
  min-height: 46px;
  justify-content: center;
  text-align: center;
  gap: 8px;
  padding: 8px 10px;
}
.form-ui .choice.compact .choice-label { flex: 0 1 auto; }

.form-ui .choice.large {
  flex-direction: column;
  justify-content: center;
  text-align: center;
  min-height: 78px;
  gap: 6px;
  font-size: 15.5px;
  padding: 11px 10px;
}
/* No tick on the large cards: the fill and border already say "chosen", and
   reserving a row for a hidden glyph cost height on the first screen anyone
   sees. */
.form-ui .choice.large .choice-tick { display: none; }
.form-ui .choice.large .choice-icon { width: 40px; height: 40px; }
.form-ui .choice.large .choice-icon svg { width: 21px; height: 21px; }
.form-ui .choice.large .choice-label { flex: 0 0 auto; }

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

.form-ui .field { display: block; margin-bottom: 14px; }
.form-ui .field:last-child { margin-bottom: 0; }
.form-ui .optional { color: var(--muted); font-weight: 400; font-size: 14px; }

/* A field following a grid of choices gets the same air a new section would.
   Without this the select sat tight under the last option and read as part
   of it. */
.form-ui .choice-grid + .field, .form-ui .choice-grid + .field-row { margin-top: 20px; }

/*
 * Every control, one shape.
 *
 * This listed types explicitly, which does NOT match a bare `<input>` -- and
 * most of ours are written that way -- nor `type="email"` or `type="date"`.
 * Those fell back to the browser's own box: narrower, differently bordered,
 * and sitting beside styled selects. Selecting by exclusion means a new field
 * is styled by default rather than by remembering to add a type.
 */
input:not([type='checkbox']):not([type='radio']), select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 13px;
  font: inherit;
  font-size: 16px; /* 16px stops iOS zooming the page on focus */
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235d7160' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 18px;
  padding-right: 42px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  border-color: var(--focus); outline-offset: 0;
}
/* A date input renders its own spin/picker furniture at a height we do not
   control; without this it sits a pixel proud of the text field beside it. */
input[type='date'] { min-height: 48px; padding-top: 10px; padding-bottom: 10px; }
textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
input::placeholder { color: #9aa89a; }

.form-ui .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---- info and errors --------------------------------------------------- */

.form-ui .soft-box {
  background: var(--tint);
  border-radius: var(--radius);
  padding: 13px 14px;
  margin: 12px 0 0;
}
.form-ui .soft-box-head { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 15px; }
.form-ui .soft-box-head svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; flex: 0 0 auto; }
.form-ui .soft-box p { margin: 7px 0 0; font-size: 14px; line-height: 1.5; color: var(--muted); }
.form-ui .card-terms p { color: var(--ink); }

.form-ui .muted { color: var(--muted); font-size: 13.5px; line-height: 1.5; margin: 12px 0 0; }

.form-ui .error-box {
  border: 1.5px solid #e2bfbc;
  background: var(--error-bg);
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  color: var(--error);
  font-size: 14.5px;
}
.form-ui .error-box ul { margin: 6px 0 0; padding-left: 18px; }
.form-ui .error-box li + li { margin-top: 4px; }

/* ---- consent ----------------------------------------------------------- */

.form-ui .consent {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  margin-top: 18px;
}
.form-ui .consent:has(input:checked) { background: var(--selected-bg); border-color: var(--selected-border); }
/* Styled to match the .choice-box used for every other multi-select in the
   form. A native 24px checkbox sat oversized beside 14.5px text and looked
   like a different control from a different form. */
.form-ui .consent input {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  /* Nudged to sit on the first line of text rather than above it. */
  margin: 2px 0 0;
  border: 1.5px solid var(--line);
  border-radius: 6px;
  background: #fff;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 13px;
  cursor: pointer;
}
.form-ui .consent input:checked {
  background-color: var(--selected-border);
  border-color: var(--selected-border);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 13 4 4L19 7'/%3E%3C/svg%3E");
}
.form-ui .consent span { font-size: 14.5px; line-height: 1.5; }

/* ---- summary ----------------------------------------------------------- */

.form-ui .summary { margin: 0; }
.form-ui .summary > div {
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
}
.form-ui .summary > div:first-child { padding-top: 0; }
.form-ui .summary dt { color: var(--muted); font-size: 13.5px; }
.form-ui .summary dd { margin: 0; font-size: 15px; }

/* ---- actions ----------------------------------------------------------- */

.form-ui .actions { display: flex; gap: 8px; margin-top: 16px; }
.form-ui .btn {
  min-height: 50px;
  padding: 12px 20px;
  border-radius: 999px;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: background 0.2s, border-color 0.2s, transform 0.15s var(--ease);
}
.form-ui .btn:active:not(:disabled) { transform: scale(0.98); }
.form-ui .btn-primary { background: var(--primary); color: #fff; flex: 1; }
.form-ui .btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.form-ui .btn-primary:disabled { opacity: 0.55; cursor: wait; }
.form-ui .btn-back { background: var(--card); border-color: var(--line); color: var(--primary); min-width: 92px; }
.form-ui .btn-back:hover:not(:disabled) { border-color: #a8bda6; }
.form-ui .btn-back:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---- confirmation ------------------------------------------------------ */

.form-ui .case-ref {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.4px;
  background: var(--tint);
  padding: 14px 18px;
  border-radius: var(--radius);
  text-align: center;
  margin: 4px 0 20px;
}
.form-ui .next-steps { padding-left: 20px; margin: 0 0 18px; }
.form-ui .next-steps li { margin-bottom: 9px; line-height: 1.5; font-size: 15px; }
.form-ui .wa-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 52px;
  padding: 13px 22px;
  border-radius: 26px;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  font-size: 16px;
  width: 100%;
}
.form-ui .wa-link svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.8; }

.form-ui .noscript-note { padding: 4px 0; }

/* ---- responsive -------------------------------------------------------- */

@media (max-width: 600px) {
  .form-ui .card { padding: 14px 13px; border-radius: 18px; }

  .form-ui h1 { font-size: 27px; }
  .form-ui .context-line { font-size: 12.5px; margin-bottom: 10px; }
  .form-ui .progress-label { font-size: 12px; margin-bottom: 10px; }
  .form-ui .step-help { font-size: 14px; margin-bottom: 14px; }
  .form-ui h2, .form-ui .field > span { font-size: 14.5px; margin-bottom: 8px; }
  .form-ui h2 { margin-top: 16px; }

  /* Long labels get a full-width row; short ones stay in columns. Stacking a
     two-word option one per line is what made this feel loose. */
  .form-ui .choice-grid { grid-template-columns: 1fr; gap: 7px; }
  .form-ui .choice-grid.keep-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-ui .choice-grid.keep-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  /* The two entry points stay side by side. Stacked they cost a third of the
     screen before a single question is answered. */
  .form-ui .choice-grid.entry { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .form-ui .choice { min-height: 48px; padding: 7px 10px; gap: 9px; font-size: 14.5px; }
  .form-ui .choice-icon { width: 28px; height: 28px; border-radius: 7px; }
  .form-ui .choice-icon svg { width: 16px; height: 16px; }
  .form-ui .choice-box { width: 19px; height: 19px; }
  .form-ui .choice.compact { min-height: 44px; font-size: 14.5px; }
  .form-ui .choice.large { min-height: 70px; padding: 9px 6px; gap: 5px; font-size: 14px; }
  .form-ui .choice.large .choice-icon { width: 32px; height: 32px; border-radius: 9px; }
  .form-ui .choice.large .choice-icon svg { width: 18px; height: 18px; }

  .form-ui .field { margin-bottom: 12px; }
  .form-ui .field-row { grid-template-columns: 1fr; gap: 0; }
  .form-ui .choice-grid + .field, .form-ui .choice-grid + .field-row { margin-top: 16px; }
  .form-ui .soft-box { padding: 12px; }
  .form-ui .soft-box p { font-size: 13.5px; }
  .form-ui .summary > div { grid-template-columns: 1fr; gap: 2px; padding: 9px 0; }
  .form-ui .summary dd { font-size: 14.5px; }
  .form-ui .consent { padding: 13px; gap: 10px; }
  .form-ui .consent input { width: 19px; height: 19px; background-size: 12px; }
  .form-ui .consent span { font-size: 14px; }
  .form-ui .muted { font-size: 13px; }

  .form-ui .actions { position: sticky; bottom: 0; background: var(--paper); padding: 10px 0; margin-top: 14px; }
  .form-ui .btn { min-height: 48px; font-size: 15.5px; }
  .form-ui .btn-back { min-width: 80px; padding: 12px 14px; }
}

@media (min-width: 900px) {
  .form-ui .card { padding: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .form-ui .progress-seg::after, .form-ui .choice, .form-ui .btn, .form-ui .choice-tick, .form-ui .choice-box svg { transition: none; }
}

/* A new step slides in from the side it comes from (D66): forward from the
   right, back from the left. An error appears at once, with only a short fade. */
@keyframes form-step-fwd { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes form-step-back { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: none; } }
@keyframes form-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: no-preference) {
  .form-ui .card.step-fwd { animation: form-step-fwd 0.32s var(--ease) both; }
  .form-ui .card.step-back { animation: form-step-back 0.32s var(--ease) both; }
  .form-ui .error-box { animation: form-fade 0.15s linear both; }
}

/* A validation message, tied to the field it belongs to rather than collected
   in a box at the top. The colour is not the only signal: it is also the only
   italic text in the form and sits directly under its own input. */
.form-ui .field-error {
  display: block; margin-top: 5px; font-size: 13px; font-style: italic;
  color: var(--danger, #b42318);
}

/* ---- long option lists ------------------------------------------------- */

/*
 * Twenty-eight districts as full-height rows is a wall, not a choice. These
 * are the same control at half the weight: the label carries the meaning and
 * the tick sits inside the box rather than reserving a column of its own.
 */
.form-ui .choice-grid.dense { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; }
.form-ui .choice-grid.dense .choice {
  min-height: 38px; padding: 6px 10px; font-size: 14px; gap: 8px; border-width: 1px;
}
.form-ui .choice-grid.dense .choice-box { width: 17px; height: 17px; }

/* A zone: a heading, a select-all, and its districts. */
.form-ui .zone { margin-bottom: 14px; }
.form-ui .zone-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin-bottom: 7px;
}
.form-ui .zone-head h3 { font-size: 14px; font-weight: 600; margin: 0; }
.form-ui .zone-head .count { font-size: 13px; color: var(--muted); font-weight: 400; }
.form-ui .zone-all {
  font: inherit; font-size: 13px; background: none; border: 0; padding: 2px 4px;
  color: var(--link, #2f6b45); cursor: pointer; text-decoration: underline;
  text-underline-offset: 2px;
}
.form-ui .zone-all:hover { opacity: 0.75; }

@media (max-width: 600px) {
  .form-ui .choice-grid.dense { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- questions inside a step ------------------------------------------- */

/*
 * A question is not help text. These were set in the help style — grey, small,
 * no space above — so each one sat against the grid before it and read as a
 * caption for the wrong group. A question gets the weight of a label and the
 * air of a new section, so a step reads as a list of questions.
 */
.form-ui .question {
  margin: 24px 0 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
}
.form-ui .card > .question:first-child, .form-ui .step-help + .question { margin-top: 4px; }
/* An area confirmation box is followed by a question, not glued to it. */
.form-ui .soft-box + .question { margin-top: 20px; }
/* A text field after a grid of choices gets the same separation. */
.form-ui .choice-grid + .field { margin-top: 18px; }

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

.form-ui .uploads { list-style: none; margin: 12px 0 0; padding: 0; }
.form-ui .uploads li {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; color: var(--ink); padding: 4px 0;
}
.form-ui .upload-tick {
  flex: 0 0 auto; width: 16px; height: 16px;
  stroke: var(--selected-border); fill: none; stroke-width: 2.4;
}

/* ---- usual working hours (D30) ----------------------------------------- */

/*
 * Days down the side, blocks across the top. Every cell is the same square
 * toggle, so the grid reads as one control rather than twenty-one.
 */
.form-ui .hours-grid { margin: 6px 0 18px; }
.form-ui .hours-row {
  display: grid; grid-template-columns: 44px repeat(3, minmax(0, 1fr));
  gap: 6px; align-items: center; margin-bottom: 6px;
}
.form-ui .hours-head { align-items: end; margin-bottom: 8px; }
.form-ui .hours-col {
  font: inherit; background: none; border: 0; padding: 2px 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 1px; color: var(--ink);
}
.form-ui .hours-col strong { font-size: 13px; font-weight: 600; }
.form-ui .hours-col span { font-size: 12px; color: var(--muted); }
.form-ui .hours-col:hover strong { text-decoration: underline; text-underline-offset: 2px; }
.form-ui .hours-day { font-size: 14px; font-weight: 600; color: var(--ink); }
.form-ui .hours-cell {
  font: inherit; height: 38px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--selected-border, #2f6b45);
  font-size: 15px; font-weight: 700; transition: background 0.12s, border-color 0.12s;
}
.form-ui .hours-cell:hover { border-color: #a8bda6; }
.form-ui .hours-cell[aria-pressed='true'] {
  background: var(--selected-bg, #e8f1e4); border-color: var(--selected-border, #2f6b45);
}

