/* forms: the components of this family, built only from the kit's tokens and the properties in layout.css.
   A form is a card: its fields in a grid in the card's body, its actions in one row in the card's foot.

     <form class="nasaq-card nasaq-form">
       <div class="nasaq-card__body"><div class="nasaq-fieldgrid">  fields (setup/_fields.html)
         <details class="nasaq-disclosure"><summary>…</summary><div class="nasaq-fieldgrid">  more fields  </div></details>
       </div></div>
       <div class="nasaq-card__foot">  partials/actions.html  </div>
     </form>

   Its read-only twin is the same card with a <div> for the <form> and no foot. */

:root {
  --nasaq-choice-min: 72px;      /* the least width of one choice in a list of choices */
  --nasaq-choice-col: 180px;     /* the least width of a column of choices in a long list */
}

/* ---------- nasaq-form: the card that is a form. Back stands at the start of its foot, the form's button at the
   end. (A form not yet a card keeps its old rules in app.css.) ---------- */
.nasaq-card.nasaq-form { display: block; }
@media (min-width: 761px) {
  .nasaq-form > .nasaq-card__foot > .nasaq-actions > .nasaq-btn:last-child { margin-inline-start: auto; }
}

/* ---------- nasaq-fieldset: a long form's fields in short groups, each under its own head and a line between
   them; the fields of each in their own nasaq-fieldgrid. ---------- */
.nasaq-fieldset { min-inline-size: 0; margin: 0; padding: 0; border: 0; }
.nasaq-fieldset + .nasaq-fieldset { margin-block-start: var(--nasaq-space-5); padding-block-start: var(--nasaq-space-4);
  border-block-start: 1px solid var(--nasaq-border); }
.nasaq-fieldset__title { float: inline-start; inline-size: 100%; padding: 0; font-size: var(--nasaq-text-sm);
  font-weight: 600; color: var(--nasaq-muted); }         /* a block above the fields, not a gap in the line */
.nasaq-fieldset__title + .nasaq-fieldgrid { clear: both; }

/* ---------- nasaq-fieldgrid: the fields of a form, six columns wide. A field takes half the row; --short a third
   (a number, a date, a time), so short ones stand side by side; --wide the whole row (a list of choices, a file, a
   grid). Anything else in the grid (an alert, a disclosure) takes the whole row. On a phone, one under the other.
   The fields of one row share three lines (label, box, error), so their boxes stand on one line whatever the
   labels' lengths. --single: every field takes the whole row (a narrow card). ---------- */
.nasaq-fieldgrid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); column-gap: var(--nasaq-space-4);
  align-items: start; min-inline-size: 0; margin-block-start: calc(-1 * var(--nasaq-space-4)); }
.nasaq-fieldgrid > * { grid-column: 1 / -1; min-inline-size: 0; margin-block-start: var(--nasaq-space-4); }
.nasaq-fieldgrid > .nasaq-field { grid-column: span 3; gap: 0; }
.nasaq-fieldgrid > .nasaq-field--short { grid-column: span 2; }
.nasaq-fieldgrid > .nasaq-field--wide, .nasaq-fieldgrid--single > .nasaq-field { grid-column: 1 / -1; }
.nasaq-fieldgrid > .nasaq-field > .nasaq-label:not(.nasaq-choice) { margin-block-end: var(--nasaq-space-2); }
.nasaq-fieldgrid .nasaq-input, .nasaq-fieldgrid .nasaq-select, .nasaq-fieldgrid .nasaq-daybox { inline-size: 100%;
  min-inline-size: 0; }
@supports (grid-template-rows: subgrid) {
  .nasaq-fieldgrid > .nasaq-field { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: subgrid;
    grid-row: span 3; row-gap: 0; }
  .nasaq-fieldgrid > .nasaq-field > .nasaq-label { align-self: end; }
  .nasaq-fieldgrid > .nasaq-field > .nasaq-fielderror { grid-row: 3; }
}
@media (max-width: 760px) {
  .nasaq-fieldgrid > .nasaq-field, .nasaq-fieldgrid > .nasaq-field--short { grid-column: 1 / -1; }
}

/* ---------- nasaq-field (the kit's): a label, one box, and under it the error. __box: a box made of several
   things (a picture and a file, a choice and a list). nasaq-label__note: a quiet word after a label. ---------- */
.nasaq-field__box { display: flex; flex-wrap: wrap; align-items: center; gap: var(--nasaq-space-2) var(--nasaq-space-4);
  min-inline-size: 0; }
.nasaq-label__note { margin-inline-start: var(--nasaq-space-2); color: var(--nasaq-muted); font-weight: 400; }

/* ---------- nasaq-fielderror: what is wrong with a field, in words under it. ---------- */
.nasaq-fielderror { margin: 0; margin-block-start: var(--nasaq-space-1); color: var(--nasaq-danger);
  font-size: var(--nasaq-text-xs); line-height: var(--nasaq-leading-body); }
.nasaq-field:has(> .nasaq-fielderror) .nasaq-input, .nasaq-field:has(> .nasaq-fielderror) .nasaq-select {
  border-color: var(--nasaq-danger); }

/* ---------- nasaq-choices: a list of ticks or of one choice among several, under its legend: side by side, each
   at least --nasaq-choice-min wide. A long list (more than eight) stands in columns in a box that scrolls. ---------- */
.nasaq-choices { min-inline-size: 0; margin: 0; padding: 0; border: 0; }
.nasaq-choices > legend { padding: 0; margin-block-end: var(--nasaq-space-1); }
.nasaq-choices__list { display: flex; flex-wrap: wrap; gap: 0 var(--nasaq-space-4); min-inline-size: 0; }
.nasaq-choices__list > .nasaq-choice { min-inline-size: var(--nasaq-choice-min); overflow-wrap: anywhere; }
.nasaq-choices__list:has(> :nth-child(9)) { display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--nasaq-choice-col), 1fr)); max-block-size: calc(var(--nasaq-control-h) * 5.5); overflow-y: auto; padding: 0 var(--nasaq-space-3);
  border: 1px solid var(--nasaq-border); border-radius: var(--nasaq-radius-sm); }
.nasaq-choices__list:has(> :nth-child(9)) > .nasaq-choice { min-inline-size: 0; }

/* ---------- nasaq-filebox: the one file control: a button and the chosen file's name, in the page's words (app.js
   writes the name; without it the browser's own control shows). --button: only the label it is on, as a button
   that opens the file chooser. ---------- */
.nasaq-filebox { position: relative; display: flex; align-items: center; gap: var(--nasaq-space-3);
  min-block-size: var(--nasaq-control-h); min-inline-size: 0; cursor: pointer; }
.nasaq-filebox > input { max-inline-size: 100%; font-family: var(--nasaq-font-body); font-size: var(--nasaq-text-sm); }
.nasaq-filebox[data-live] > input, .nasaq-filebox--button > input { position: absolute; inline-size: 1px;
  block-size: 1px; opacity: 0; overflow: hidden; clip-path: inset(50%); }
.nasaq-filebox:not([data-live]) > .nasaq-filebox__pick, .nasaq-filebox:not([data-live]) > .nasaq-filebox__name {
  display: none; }
.nasaq-filebox__pick { flex: none; }
.nasaq-filebox__name { min-inline-size: 0; overflow: hidden; color: var(--nasaq-muted); font-size: var(--nasaq-text-sm);
  text-overflow: ellipsis; white-space: nowrap; }
.nasaq-filebox:focus-within { outline: 2px solid var(--nasaq-accent-strong); outline-offset: 2px;
  border-radius: var(--nasaq-radius-sm); }

/* ---------- nasaq-disclosure: what most people leave alone (advanced options), closed until asked for: a line to
   press, then what it holds. ---------- */
.nasaq-disclosure { min-inline-size: 0; }
.nasaq-disclosure > summary { display: inline-flex; align-items: center; gap: var(--nasaq-space-2);
  min-block-size: var(--nasaq-control-h); color: var(--nasaq-accent-strong); font-size: var(--nasaq-text-sm);
  font-weight: 500; cursor: pointer; list-style: none; }
.nasaq-disclosure > summary::-webkit-details-marker { display: none; }
.nasaq-disclosure[open] > summary > .nasaq-i:first-child,
.nasaq-disclosure:not([open]) > summary > .nasaq-i + .nasaq-i { display: none; }
.nasaq-disclosure__body { display: flex; flex-direction: column; gap: var(--nasaq-space-3);
  padding-block: var(--nasaq-space-2); }
