/* The sheet: the card a form sits on. The sheets of the console (ending a case, handing an incident on, asking for emergency access, recording a contact, the person search that comes before them)
   were bare fields and hairlines on the page's canvas, so the thing a person was filling in had no edge and looked like part of the page's furniture. A sheet is a raised surface with a hairline and a small
   radius, the same card the entries and the panels are, padded by the space scale; its sections are separated by hairlines and its actions sit under one at the foot.

   WHICH FORMS. A form with sections (`.tform` with a `.form-section` in it: Forms::FormComponent) and the two person searches (`.person-picker`, `.person-search`) are sheets. A form with no sections is a
   one-field inline form (a Save beside the choice it saves) and is not framed: drawing a card inside a panel would nest one. `.sheet` is the same look for a wrapper that is not a form.

   THE FORM IS STILL THE CONTAINER. `.tform` is the query container its sections lay out by (36-form-fields.css), and a container's padding comes off the width its query measures, so the card's padding is
   inside the room the sections have: the two-column sections start at 44rem of the form, which is 3rem more of card than before.

   Tokens only and logical properties only, both enforced (test/styles/tokens_test.rb, test/styles/components_test.rb), so it reads on the light shell and the console, in light and in dark, and mirrors in a
   right-to-left language. Nothing pinned to an edge, no height in vh, and everything that holds words may shrink and wrap (WCAG 1.4.10). */

.sheet,
.tform:has(> .form-section),
.person-picker,
.person-search {
  padding-block: var(--space-5) var(--space-4);
  padding-inline: var(--space-5);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  box-shadow: var(--shadow-soft);
}

/* On a phone the card's side padding is the page's gutter, so the fields are not squeezed twice. */
@media (max-width: 40rem) {
  .sheet,
  .tform:has(> .form-section),
  .person-picker,
  .person-search {
    padding-inline: var(--space-4);
  }
}

/* The first section has the card's top edge above it, so it needs no hairline and no padding of its own there; a section that follows a note or the error summary keeps both. The request forgery
   token is a hidden input and the form's first child, so "first" is the first thing a person can see: the second rule says so for the browsers that know it (Chrome 111, Firefox 113, Safari 9),
   and the first rule is what the others get. */
.tform:has(> .form-section) > .form-section:first-child {
  padding-block-start: 0;
  border-block-start: 0;
}
.tform:has(> .form-section) > .form-section:nth-child(1 of :not(input[type="hidden"])) {
  padding-block-start: 0;
  border-block-start: 0;
}

/* A form behind a disclosure (Forms::DisclosureComponent: Add a goal, Record a level of care) is a part of the section it is in and not a sheet: the card would be a card inside a panel. It keeps its
   sections, its note and its actions, and loses the card. */
.form-disclosure-body > .tform:has(> .form-section) {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

/* The actions are the sheet's foot: the hairline above them runs the card's inner width, and the card's bottom padding is theirs to share. */
.tform:has(> .form-section) > .form-actions {
  padding-block-end: 0;
}
