/* ==========================================================================
   Contact form
   Loaded after css/site.css by the pages of this family ('styles' in render_page()).
   Conventions and tokens: css/README.md.

   The card is the core's .portal-card in a wider .auth-card-wrapper; the fields, their labels, help and error
   lines are the core's (.portal-form-group, .field-label, .portal-input-field, .field-help, .field-error).
   ========================================================================== */
@layer pages {
  .contact-card-wrapper {
    max-inline-size: 57.5rem;
  }

  /* The sign-in card centres its text; a form reads from the start of the line */
  .contact-card,
  .contact-card .auth-header-group {
    text-align: start;
  }

  .contact-card .auth-subtitle {
    margin-inline: 0;
  }

  /* The form is a container: its groups follow the room it has, not the window */
  .contact-form {
    container: contact / inline-size;
  }

  .field-optional {
    font-weight: 400;
    color: var(--text-subtle);
  }

  /* A signed-in customer writes from the address of the account: a line of text, no field */
  .contact-locked-email {
    font-size: var(--fs-md-plus);
    color: var(--text);
    overflow-wrap: anywhere;
  }

  /* Honeypot: not shown to people (one clipped pixel, taken out of the flow of the form), still in the page
     for the bots that fill every field. Never display: none, which they detect. */
  .hp-field {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  /* With room (40em of form), the label sits beside its field; help and error lines stay under the field */
  @container contact (min-width: 40em) {
    .contact-form .portal-form-group {
      grid-template-columns: 10rem minmax(0, 1fr);
      column-gap: var(--space-6);
      align-items: start;
    }

    .contact-form .field-label {
      grid-column: 1;
      padding-block-start: var(--space-3-5);   /* on the middle of the first line of a field */
    }

    .contact-form .portal-form-group > :not(.field-label) {
      grid-column: 2;
    }

    .contact-form .contact-locked-email {
      padding-block-start: var(--space-3);
    }
  }
}
