/* bend-forms: the Form block. Loaded only on pages with a form (index.php, page.render:after), after bend's site.css.
   In bend's theme layer, so the site's Theme page (unlayered) wins over every rule here, as with bend's own blocks. */
@layer theme {
  /* Form block (blocks/form.twig, forminput/formchoice/formconsent.twig, form.js). Rows and columns from the block's layout:
     columns side by side from tablets, stacked on phones. Gap = the block's Gap field (--gap), else --form-gap.
     Tokens: --form-gap  --form-label-size  --form-label-weight  --form-help-color  --form-error  --form-success
             --input-bg  --input-border  --input-radius  --input-py  --input-px  --input-focus (shared with the password form)
             --input-scheme (dark = the browser's own parts, a date picker's icon, a dropdown, drawn for a dark background;
             on by itself on a dark row or block, .on-dark) */
  .form-block { width: 100%; }
  .form-rows {
    display: grid;
    gap: var(--gap, var(--form-gap, 1.25em));
  }
  .form-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--gap, var(--form-gap, 1.25em));
  }
  @media (width >= 768px) {
    .form-row { grid-template-columns: repeat(12, minmax(0, 1fr)); }
    .form-col { grid-column: span var(--span-md, 12); }
  }
  .form-col { display: grid; gap: var(--gap, var(--form-gap, 1.25em)); align-content: start; min-width: 0; }
  .form-field {
    display: grid;
    gap: 0.35em;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
  }
  .form-label {
    padding: 0;
    font-size: var(--form-label-size, inherit);
    font-weight: var(--form-label-weight, 600);
  }
  .form-required { margin-left: 0.15em; }
  .form-input {
    width: 100%;
    padding: var(--input-py, 0.8em) var(--input-px, 1em);
    border: 1px solid var(--input-border, color-mix(in srgb, currentColor 30%, transparent));
    border-radius: var(--input-radius, var(--btn-radius, 0));
    background: var(--input-bg, transparent);
    color: inherit;
    font: inherit;
    color-scheme: var(--input-scheme, normal);
  }
  /* a pill-shaped button radius would make a text area an oval */
  textarea.form-input { border-radius: min(var(--input-radius, var(--btn-radius, 0px)), 1em); }
  .on-dark :is(.form-input, .form-option input) { --input-scheme: dark; }
  .form-option input { color-scheme: var(--input-scheme, normal); }
  .form-input:focus-visible,
  .form-option input:focus-visible {
    outline: 2px solid var(--input-focus, currentColor);
    outline-offset: 2px;
  }
  select.form-input { cursor: pointer; }
  /* after the visitor has touched a field (or tried to send), not before */
  .form-input:user-invalid,
  .form-field[data-invalid] .form-input {
    border-color: var(--form-error, #b3261e);
  }
  .form-options {
    display: grid;
    gap: 0.4em;
  }
  .form-option {
    display: flex;
    align-items: flex-start;
    gap: 0.6em;
    cursor: pointer;
  }
  .form-option input {
    flex: none;
    width: 1.15em;
    height: 1.15em;
    margin: 0.15em 0 0;
    accent-color: var(--input-focus, currentColor);
  }
  .form-help, .form-error, .form-status { margin: 0; font-size: 0.875em; }
  .form-help { color: var(--form-help-color, color-mix(in srgb, currentColor 70%, transparent)); }
  .form-error { color: var(--form-error, #b3261e); }
  .form-actions { margin: var(--gap, var(--form-gap, 1.25em)) 0 0; }
  .form-actions button { cursor: pointer; }
  .form-busy .form-actions button { opacity: 0.6; cursor: progress; }
  .form-status:empty { display: none; }
  /* no forms service yet (only Panel users see the form): a note above it, the button off */
  .form-preview-note {
    margin: 0 0 1em;
    padding: 0.6em 0.9em;
    border: 1px dashed currentColor;
    font-size: 0.875em;
  }
  .form-actions button:disabled { opacity: 0.5; cursor: not-allowed; }
  .form-status { margin-top: 1em; }
  .form-status:focus { outline: none; }
  /* sent: the answer in the form's place */
  .form-sent .form-rows, .form-sent .form-actions { display: none; }
  .form-sent .form-status { margin: 0; font-size: inherit; color: var(--form-success, inherit); }
  /* the field people don't see (bots fill it in): clipped to nothing, not display: none, which some bots skip.
     aria-hidden and tabindex -1 keep it from screen readers and the keyboard */
  .form-hp {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    opacity: 0;
    pointer-events: none;
  }
  .form-block .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }
}
