/* THE FORM-PAGE COMPONENT — page kit, C.58c.
 *
 * Title, one form, one primary action, the status line, the FAQ. The
 * page reading and the popup-fragment reading are the same markup with
 * the site chrome taken away, so this stylesheet states the difference
 * between them ONCE and nowhere else: a fragment fills the popup's width
 * and does not repeat the popup's own outer air.
 *
 * NOT ONE LENGTH IS WRITTEN HERE — see kit-choice.css.
 */

.kit-formpage-title {
  margin-top: 0;
}

.kit-formpage-intro {
  color: var(--ink-soft);
  max-width: var(--measure);
  margin-top: var(--rhythm-within);
}

/* The form stands a heading's air under the words above it: the form's
 * own margin plus its group's padding (below) is `--rhythm-heading`. */
.kit-form {
  margin-top: var(--rhythm-between);
  max-width: var(--measure);
}

/* One grid for the group, exactly as page design law 2 states it: labels
 * above their controls, equal columns, one gutter, and one column when
 * the popup is narrower than the law's 560 px.
 *
 * THE FIELDS ARE THE LAW'S GROUP (law 1, C.58f): the macro marks them
 * `data-group`, which is the sign the design-law gate measures, and the
 * group carries its air as padding on the rhythm's own rungs - the air a
 * settings section carries (`.settings-section`) - so every page built
 * on the component is measured, not assumed. */
.kit-form-fields,
.kit-form[data-group],
.kit-formpage-answer {
  padding-top: var(--s4);
  padding-bottom: var(--s4);
}

/* ...and a group none of whose parts is shown keeps no air: a tab
 * group's form while the tab before it is shown (the job settings'
 * Plankopf tab, batch 38) drew 32 px of nothing between its save row
 * and its foot */
.kit-form-fields:not(:has(> :not([hidden]))) {
  padding-top: 0;
  padding-bottom: 0;
}

/* the answer reading's group (C.131): its first and last words sit on
 * the group's own air, not on a paragraph's margin */
.kit-formpage-answer > :first-child {
  margin-top: 0;
}

.kit-formpage-answer > :last-child {
  margin-bottom: 0;
}

/* a form whose only controls are its buttons: the row IS the group */
.kit-form[data-group] > .kit-action {
  margin-top: 0;
}

.kit-form-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(var(--kit-card-min), 1fr));
  gap: var(--rhythm-between) var(--s4);
  align-items: start;
}

.kit-form-fields > * {
  grid-column: 1 / -1;
}

/* ONE FIELD, ITS HELP AND ITS SWITCH ARE ONE GROUP (C.217): the grid puts
 * the large between-gap between its children, so a switch that was its own
 * child stood nearer the next label than its own field. The group is the
 * child; inside it the within-gap, between groups the grid's own. */
.kit-field-group {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
  display: grid;
  gap: var(--rhythm-within);
}

.kit-field-group > .kit-switch {
  margin-top: 0;
}

.kit-form-fields > .kit-form-half {
  grid-column: auto;
}

@media (max-width: 35rem) {
  .kit-form-fields > .kit-form-half {
    grid-column: 1 / -1;
  }
}

/* -- the parts around the form (C.58f) ---------------------------- */

/* What the reader must know before the form (what closing the account
 * deletes, the steps of the second factor, the duty being confirmed)
 * and a further form after it are read at the measure like the intro,
 * and each stands a heading's air away from what precedes it. */
.kit-formpage-before,
.kit-formpage-after {
  max-width: var(--measure);
}

.kit-formpage-before {
  margin-top: var(--rhythm-heading);
}

.kit-formpage-before > :first-child,
.kit-formpage-side > :first-child {
  margin-top: 0;
}

.kit-formpage-sub {
  margin-top: var(--rhythm-heading);
  margin-bottom: var(--rhythm-within);
}

.kit-formpage-side {
  margin-top: var(--rhythm-section);
}

.kit-formpage-side .kit-form {
  margin-top: var(--rhythm-between);
}

/* The ways on after the form: one line of links, in the help grey.
 * Straight under a form the action row's status line already reserves
 * its row below the buttons, so the ways take no air of their own there
 * (the first pictures showed a band of five lines under a lone button). */
.kit-formpage-ways {
  margin-top: var(--rhythm-between);
  color: var(--ink-soft);
}

.kit-form + .kit-formpage-ways {
  margin-top: 0;
}

/* -- the FAQ ------------------------------------------------------ */

/* The rows are the kit's accordion (`_kit_accordion.html`, styled in
 * `kit.css`); the form page owns only the air above them. */
.kit-formpage-faq {
  margin-top: var(--rhythm-section);
}

/* -- the fragment reading ------------------------------------------ */

.kit-formpage.is-fragment {
  margin: 0;
  padding: 0;
}

.kit-formpage.is-fragment .kit-form,
.kit-formpage.is-fragment .kit-formpage-intro {
  max-width: none;
}

/* -- the field's frame (C.58j, the C.104 scope) --------------------- */

/* The kit field's frame is `--field-line`, which stands at least 3:1 on
 * its ground in both schemes; the site's older frame stood at 2.07:1,
 * under what the edge of a field needs to be seen. */
.kit-form-fields input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.kit-form-fields select,
.kit-form-fields textarea {
  border-color: var(--field-line);
}

/* -- the way back above the title (C.58k) ------------------------- */

/* One quiet line, a step above the title: the order page's way to the
 * prices. */
.kit-formpage-back {
  margin: 0 0 var(--s4);
  color: var(--ink-soft);
}
