/* ─────────────────────────────────────────────────────────────────────────
   FIELD SCHEMA EDITOR — the join_holon Page "Form fields" admin editor.

   Lives with web/invite because it styles one screen this app owns, and is
   linked from invite_page_settings.html's extra_css rather than the shell's shared
   component list: that list is included by base_invite.html too, so putting
   it there shipped an admin-only sheet to every public invitation page —
   the coupling this file exists to avoid, in the other direction
   (METIS-pub#290 review).

   Scoped under .field-schema-editor so it neither depends on nor leaks into
   the public invite-pack styling (pack_standard.css). That pack is a
   presentation concern authors pick per invitation page; this is an internal
   admin screen, and a pack's font or input reset must not reshape it.

   Why it needs its own rules at all: .form-fieldset and .form-row are styled
   only under ancestors this form does not have — .pack-form__card in the pack
   sheet, .team-add-form / .user-create-form / .page-config-form in detail.css
   — and the bare rules that do exist live in settings.css and signup.css,
   neither of which the invite-pages screen loads. The editor was falling all
   the way back to browser defaults.

   Known duplication, left deliberately: these are the same bare form
   primitives as settings.css:23 and signup.css:387. Consolidating them into a
   shared components-layer form primitive is the right fix and is worth doing,
   but it would restyle four unrelated screens (settings, signup, the packs,
   and the scoped variants in detail.css) — out of scope for a styling bug,
   and tracked separately rather than smuggled in here.
   ───────────────────────────────────────────────────────────────────────── */
@layer components {
  /* One field per block, and the block has to read as a block: a hairline on a
     background the same colour as the page left the boundary to be inferred
     from the border alone, which is why the sections ran together. This is the
     shared card treatment (components/card.css) expressed through the same
     --card-* tokens, so it stays in step with every other surface if they move
     — the markup keeps fieldset/legend because that is what a group of related
     controls is, and .card__header would mean giving that up.

     The lift does the separating; the page is --color-bg and each block is
     --card-bg (white) above it, with the inputs' own borders keeping them
     legible on it. --space-6 between blocks so the shadow has room to read. */
  .field-schema-editor .form-fieldset {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    padding: var(--space-4);
    margin-bottom: var(--space-6);
  }

  .field-schema-editor > .field-edit-actions--footer {
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border);
  }

  .field-schema-editor legend {
    color: var(--color-text-strong);
    font: inherit;
    font-size: var(--text-md);
    font-weight: 600;
    padding: 0 var(--space-2);
  }

  .field-schema-editor .form-row {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    margin-bottom: var(--space-3);
  }

  /* .field-label carries `flex: 0 0 120px` (detail.css:376) for the horizontal
     .field-row layout, where 120px is the label *column's width*. These rows
     stack, so on their main axis that same declaration is a fixed *height* —
     and with grow and shrink both 0 it stays 120px for a one-line label,
     which is where the ~120px of blank space between every label and its
     input came from.

     .page-config-form (detail.css:1377) is the same class in the same stacked
     shape and escapes only because its rows are not flex containers, so the
     basis never applies. Two forms now work around one row-layout assumption
     baked into a layout-agnostic class name; a third means .field-label's
     sizing belongs on .field-row rather than on .field-label. */
  .field-schema-editor .form-row .field-label {
    flex: 0 0 auto;
  }

  /* Validation belongs where the correction happens. The fieldset edge makes
     a bad row findable in a long editor; the field tint and message identify
     the exact control without relying on a page-top banner. */
  .field-schema-editor .field-schema-row--error {
    border-color: var(--color-danger-border);
  }

  .field-schema-editor .field-schema-field--error {
    background: var(--color-danger-bg);
    border-left: 2px solid var(--color-danger-border);
    border-radius: var(--radius-sm);
    padding: var(--space-2);
  }

  .field-schema-editor .field-schema-error {
    display: block;
    color: var(--color-danger-strong);
    font-size: var(--text-sm);
    margin-top: var(--space-1);
  }

  .field-schema-add {
    display: grid;
    gap: var(--space-3);
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border);
  }

  .field-schema-add__header h3,
  .field-schema-add__option h4 {
    color: var(--color-text-strong);
    font-size: var(--text-md);
    font-weight: 600;
  }

  .field-schema-add__header p,
  .field-schema-add__option p,
  .field-schema-add__available,
  .field-schema-add__save-note {
    color: var(--color-text-muted);
    font-size: var(--text-sm);
  }

  .field-schema-add__option {
    display: grid;
    gap: var(--space-2);
  }

  .field-schema-add__controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  .field-schema-add__controls .field-label {
    flex: 0 0 auto;
  }

  .field-schema-add__save-note {
    margin: 0;
  }

  /* A checkbox's own text, not a caption for something below it. Uppercase
     letterspaced grey is this screen's caption treatment, and wearing it made
     "Required" read as the heading for the Move up / Move down row rather than
     as the label of the box beside it. */
  .field-schema-editor .form-row--check .field-label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    text-transform: none;
    letter-spacing: normal;
    color: var(--color-text);
    padding-top: 0;
  }

  /* The select is scoped one level shallower than its siblings on purpose:
     the profile-field picker sits in .field-schema-add__controls rather than a
     .form-row, and it renders beside the in-row Type picker, so both have to
     look the same. Text inputs and textareas only ever appear inside a
     .form-row here. */
  .field-schema-editor .form-row input[type="text"],
  .field-schema-editor .form-row textarea,
  .field-schema-editor select {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: var(--space-2);
    font: inherit;
    color: var(--color-text);
    background: var(--color-surface);
  }

  /* No :focus-visible rule here on purpose. components/motion.css sets the
     ring at :where() zero specificity precisely so components need not
     restate it, and --focus-ring is --color-accent darkened to clear WCAG
     1.4.11's 3:1 non-text contrast bar (tokens/semantic.css) — restating it
     with raw --color-accent gave this one screen a thinner, lower-contrast
     ring than the rest of the product. */
}
