/* ═══════════════════════════════════════════════════════════════════════
   FORM ROW — the ONE rule for every multi-column form row (2026-11-16).

   Cain, on two forms the same day: "the input boxes aren't aligned at all ...
   the tops are in no way aligned and it looks terrible." Measured: on Record
   tranche the Amount box sat 6px above its neighbours and the date box was 2px
   taller; on the intake form a two-line label pushed one select 11px below its
   pair. Each page had its own row class and none of them said anything about
   where a control sits when the labels differ.

   USE: add `form-row` to the row container, next to the class that sets its
   columns (`pc-pair form-row`, `dr-form-grid form-row`). Every direct child is a
   cell; a cell's LABEL, CONTROL and optional HINT are its direct children, in
   that order. A wrapper between a cell and those three carries `form-row__cell`.
   A composite control (a £-prefixed `.pc-row`, a `.seg`, a `.pick`) is ONE child.

   WHAT IT DOES: each cell becomes a three-track subgrid of the row (label /
   control / hint), so the label tracks of a row share one height (the tallest
   label), every control starts on one line, and a hint under one control never
   moves its neighbour. Controls stretch to the control track, so a date input
   or a select is exactly as tall as the text box beside it.

   `[hidden]` cells are left alone — the intake form shows and hides questions
   with the attribute. Enforced by Static Audits (scripts/form_row_audit.py).
   ═══════════════════════════════════════════════════════════════════════ */

/* The row's own class sets the columns and the column gap. Row spacing inside
   a field (label → control → hint) is the cell's, so the row's row-gap is
   carried as space BELOW each cell instead of between its tracks. Doubled class:
   it must beat a component's `gap` shorthand whatever order the sheets load in. */
.form-row.form-row {
  --form-row-gap: 12px;
  row-gap: 0;
  align-items: stretch;
  /* Each cell carries the row gap BELOW it; the last line's must not push the next
     thing on the page down, so the row hands it back. */
  margin-bottom: calc(-1 * var(--form-row-gap));
}

.form-row > :not([hidden]),
.form-row .form-row__cell:not([hidden]) {
  display: grid;
  grid-row: span 3;
  grid-template-rows: subgrid;
  row-gap: 0;
  align-content: start;
  min-width: 0;
}

.form-row > :not([hidden]) {
  padding-bottom: var(--form-row-gap);
}

/* Label track: a short label sits on the control, not floating above it, and every
   label keeps the SAME gap to its control — a label row wrapping a label (Record
   tranche's Amount, with its budget prompt) would otherwise sit 6px lower than a bare
   label carrying app.css's margin. */
.form-row > :not([hidden]) > :first-child,
.form-row .form-row__cell:not([hidden]) > :first-child {
  align-self: end;
  margin-bottom: var(--form-row-label-gap, 6px);
}
.form-row > :not([hidden]) > :first-child label,
.form-row .form-row__cell:not([hidden]) > :first-child label {
  margin-bottom: 0;
}

/* Control track: one height for the row. A select, a date and a text input
   stretch to the tallest control in the row. Checkboxes and radios keep theirs. */
.form-row > :not([hidden]) > :nth-child(2),
.form-row .form-row__cell:not([hidden]) > :nth-child(2) {
  align-self: stretch;
  box-sizing: border-box;
  /* A composite control that wraps (the intake's £ box + % assists) fills the track
     but keeps its own lines packed at the top: measured 16 Nov, stretching shared the
     row's spare 4px between its lines and made one £ box 51px beside a 47px one. */
  align-content: start;
}

@media (max-width: 540px) {
  .form-row.form-row { --form-row-gap: 10px; }
}
