/* ==========================================================================
   Contact page (view "contact", template page-enquiry.php).
   Figma: page "Prototype", frame 49:217 "Page 6 · Contact".
   Loaded after tokens.css and base.css. Desktop first (the 1440 frame), then
   tablet and phone.

   Sections 1 to 9 are build/contact/contact.css. The theme adds what the
   real form needs and the design did not draw:
   10. Without scripts            12. Status line: sending, success, error
   11. Field errors               13. Password-protected page

   Reused from base: fdm-container, fdm-page-head, fdm-lead, fdm-prose,
   fdm-card, fdm-option, fdm-field, fdm-input, fdm-textarea, fdm-btn,
   fdm-label, fdm-h2, fdm-h4, fdm-text-muted.

   State written by assets/js/contact.js:
     form     .is-enhanced (the script runs), .is-sending, .is-sent,
              [data-fdm-topic]
     wrapper  .has-error on [data-fdm-field]; hidden when the field is not
              part of the chosen topic
     control  [aria-invalid="true"] (red border, from base.css)
     status   [data-state="sending|success|error"]
     drop     .is-dragover
   ========================================================================== */

.fdm-contact {
  /* Page title block: 36px below the lead on this page (base default is 32). */
  --fdm-page-head-pb: var(--fdm-space-36);

  /* Values drawn in the frame that have no token in tokens.css. */
  --fdm-contact-col-form: 768fr;    /* form card, 768 of 1216 */
  --fdm-contact-col-aside: 400fr;   /* side cards, 400 of 1216 */
  --fdm-contact-narrow: 632px;      /* name, email and message are drawn 632 wide */
  --fdm-contact-dash: 6 4;          /* drop area outline: 6px dash, 4px gap */
  /* In the frame each white card holds content 2px wider than its padding
     allows (688 in the 768 card, 344 in the 400 cards), so the right padding
     is 2px less than the other three sides. Kept so widths match the frame. */
  --fdm-contact-form-pad: var(--fdm-space-40) calc(var(--fdm-space-40) - var(--fdm-space-2)) var(--fdm-space-40) var(--fdm-space-40);
  --fdm-contact-note-pad: var(--fdm-space-28) var(--fdm-space-26) var(--fdm-space-28) var(--fdm-space-28);
  --fdm-contact-option-pad-phone: var(--fdm-space-14);
  /* One line of status text with its padding and border: the box has its
     full height before the words arrive. */
  --fdm-contact-status-min: calc(var(--fdm-lh-17) + 2 * var(--fdm-space-14) + 2 * var(--fdm-border-width));
}

/* 1. Two columns: form 768, gap 48, side cards 400 ------------------------- */

.fdm-contact__layout {
  display: grid;
  grid-template-columns: minmax(0, var(--fdm-contact-col-form)) minmax(0, var(--fdm-contact-col-aside));
  align-items: start;
  gap: var(--fdm-space-48);
  padding-bottom: var(--fdm-space-80);
}

/* 2. Form card: 40px padding, 26px between blocks -------------------------- */

.fdm-contact__form {
  --fdm-card-padding: var(--fdm-contact-form-pad);
  display: flex;
  flex-direction: column;
  gap: var(--fdm-space-26);
  min-width: 0;
}

/* Fieldsets without the browser frame. The legend is floated so it lays out
   like an ordinary block and the gap below it can be set exactly. */
.fdm-contact__group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.fdm-contact__legend,
.fdm-contact__owner-legend {
  float: left;
  width: 100%;
  padding: 0;
}

.fdm-contact__legend {
  margin-bottom: var(--fdm-space-26);
}

.fdm-contact__legend + *,
.fdm-contact__owner-legend + * {
  clear: both;
}

/* 3. The three choices: 12px apart ----------------------------------------- */

.fdm-contact__options {
  display: flex;
  flex-direction: column;
  gap: var(--fdm-space-12);
}

.fdm-contact__options .fdm-option:hover {
  border-color: var(--fdm-muted);
}

.fdm-contact__options .fdm-option:has(.fdm-option__input:checked):hover {
  border-color: var(--fdm-green-900);
}

/* 4. Owner fields: tinted panel, 28px padding, 18px between rows ----------- */

.fdm-contact__owner {
  padding: var(--fdm-space-28);
  border-radius: var(--fdm-radius-panel);
  background: var(--fdm-color-surface-alt);
}

.fdm-contact__owner-legend {
  margin-bottom: var(--fdm-space-18);
}

.fdm-contact__owner-fields {
  display: flex;
  flex-direction: column;
  gap: var(--fdm-space-18);
}

/* Two fields side by side, 16px apart */
.fdm-contact__row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--fdm-space-16);
}

/* A hint that does not fit its field ends in an ellipsis, not a cut letter */
.fdm-contact__form .fdm-input:placeholder-shown {
  text-overflow: ellipsis;
}

/* Name, email and message stop at 632px, as drawn */
.fdm-contact__narrow {
  width: 100%;
  max-width: var(--fdm-contact-narrow);
}

/* 5. Photo drop area: 107px tall, white, dashed slate outline -------------- */

.fdm-contact__upload {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--fdm-space-7);
  min-width: 0;
}

.fdm-contact__drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--fdm-space-6);
  padding: var(--fdm-space-24) var(--fdm-space-20);
  border: var(--fdm-border-width) solid transparent;   /* room for the drawn outline */
  border-radius: var(--fdm-radius-control);
  background: var(--fdm-white);
  color: var(--fdm-slate);                              /* outline colour */
  text-align: center;
  cursor: pointer;
  transition: background-color var(--fdm-duration) var(--fdm-ease),
              color var(--fdm-duration) var(--fdm-ease);
}

/* The label is one target: a photo dragged across its words does not leave
   and enter it again, so the highlight does not flicker. */
.fdm-contact__drop > * {
  pointer-events: none;
}

/* The outline is an SVG so the dashes are 6px long with 4px gaps, which a
   CSS dashed border cannot do. It sits where a 1px inside border would. */
.fdm-contact__drop-outline {
  position: absolute;
  inset: calc(-1 * var(--fdm-border-width));
  width: calc(100% + 2 * var(--fdm-border-width));
  height: calc(100% + 2 * var(--fdm-border-width));
  max-width: none;
  overflow: hidden;
  fill: none;
  stroke: currentColor;
  stroke-width: var(--fdm-border-width);
  stroke-dasharray: var(--fdm-contact-dash);
  pointer-events: none;
}

.fdm-contact__drop-outline rect {
  width: calc(100% - var(--fdm-border-width));
  height: calc(100% - var(--fdm-border-width));
}

.fdm-contact__drop-title {
  font-size: var(--fdm-fs-18);
  font-weight: var(--fdm-weight-semibold);
  line-height: var(--fdm-lh-18-ui);
  color: var(--fdm-ink);
}

.fdm-contact__drop-hint,
.fdm-contact__drop-files {
  font-size: var(--fdm-fs-16);
  line-height: var(--fdm-lh-16);
  color: var(--fdm-color-text-muted);
}

/* The name of the photo that was added; stands where the hint stood. */
.fdm-contact__drop-files {
  max-width: 100%;
  color: var(--fdm-ink);
  overflow-wrap: anywhere;
}

.fdm-contact__drop:hover,
.fdm-contact__drop.is-dragover {
  color: var(--fdm-green-900);
}

.fdm-contact__drop.is-dragover {
  background: var(--fdm-green-tint);
}

/* The file input sits before the drop area; its focus ring shows on the
   drop area. With scripts it is hidden from view (section 10 shows it for
   visitors without them). */
.fdm-js .fdm-contact__file {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  border: 0;
  white-space: nowrap;
}

.fdm-contact__file:focus-visible + .fdm-contact__drop {
  outline: var(--fdm-focus-width) solid var(--fdm-color-focus);
  outline-offset: var(--fdm-focus-offset);
}

/* Message box: 93px as drawn. Where the browser can size a field to its
   text, it grows as you type and the corner grip is not needed. */
@supports (field-sizing: content) {
  .fdm-contact__form .fdm-textarea {
    field-sizing: content;
    resize: none;
  }
}

/* 6. Send row: button, 20px, reassurance ----------------------------------- */

.fdm-contact__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--fdm-space-12) var(--fdm-space-20);
}

.fdm-contact__reassure {
  font-size: var(--fdm-fs-17);
  line-height: var(--fdm-lh-17);
  font-style: italic;
  color: var(--fdm-color-text-muted);
}

/* While a message is on its way the button is switched off (base.css fades
   it) and the pointer says "working", not "forbidden". */
.fdm-contact__form.is-sending .fdm-btn:disabled {
  cursor: progress;
}

/* 7. Side cards: 400 wide, 28px padding, 20px apart ------------------------ */

.fdm-contact__aside {
  display: flex;
  flex-direction: column;
  gap: var(--fdm-space-20);
  min-width: 0;
}

.fdm-contact__note {
  --fdm-card-padding: var(--fdm-contact-note-pad);
  display: flex;
  flex-direction: column;
  gap: var(--fdm-space-8);
}

/* 8. Phone and tablet: one column, cards under the form -------------------- */

@media (max-width: 1023.98px) {
  .fdm-contact__layout {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--fdm-space-32);
    padding-bottom: var(--fdm-space-64);
  }

  .fdm-contact__form {
    --fdm-card-padding: var(--fdm-space-32);
  }

  .fdm-contact__note {
    --fdm-card-padding: var(--fdm-space-28);
  }
}

/* 9. Phone ------------------------------------------------------------------ */

@media (max-width: 599.98px) {
  .fdm-contact__layout {
    gap: var(--fdm-space-24);
    padding-bottom: var(--fdm-space-48);
  }

  .fdm-contact__form {
    gap: var(--fdm-space-22);
  }

  .fdm-contact__legend {
    margin-bottom: var(--fdm-space-18);
  }

  .fdm-contact__legend .fdm-h2 {
    font-size: var(--fdm-fs-26);
    line-height: var(--fdm-lh-26);
  }

  .fdm-contact__options {
    gap: var(--fdm-space-10);
  }

  /* Each choice stays on one line at 390 */
  .fdm-contact__options .fdm-option {
    gap: var(--fdm-space-12);
    padding: var(--fdm-contact-option-pad-phone);
    font-size: var(--fdm-fs-17);
    line-height: var(--fdm-lh-17);
  }

  .fdm-contact__owner {
    padding: var(--fdm-space-16);
  }

  .fdm-contact__owner-legend {
    margin-bottom: var(--fdm-space-14);
  }

  .fdm-contact__owner-fields {
    gap: var(--fdm-space-16);
  }

  .fdm-contact__row {
    grid-template-columns: minmax(0, 1fr);
  }

  .fdm-contact__drop {
    padding: var(--fdm-space-20) var(--fdm-space-16);
  }

  .fdm-contact__drop-title {
    font-size: var(--fdm-fs-17);
    line-height: var(--fdm-lh-17);
  }

  .fdm-contact__drop-hint,
  .fdm-contact__drop-files {
    font-size: var(--fdm-fs-15);
    line-height: var(--fdm-lh-15);
  }

  .fdm-contact__actions {
    flex-direction: column;
    align-items: stretch;
    gap: var(--fdm-space-12);
  }

  .fdm-contact__reassure {
    text-align: center;
  }

  .fdm-contact__aside {
    display: flex;
    gap: var(--fdm-space-16);
  }

  .fdm-contact__note {
    --fdm-card-padding-phone: var(--fdm-space-20);
  }

  .fdm-contact__note .fdm-h4 {
    font-size: var(--fdm-fs-24);
    line-height: var(--fdm-lh-24-heading);
  }
}

/* 10. Without scripts ------------------------------------------------------- */

/* The owner panel belongs to the first choice only. Each choice says in
   data-fdm-contact-panel whether it shows the panel ("owner") or not (""),
   so the panel steps aside for the other choices before any script runs,
   and for visitors who have none. The handler ignores the panel's fields
   for those topics either way. Browsers without :has() keep it in view. */
.fdm-contact__form:has([data-fdm-contact-panel=""]:checked) .fdm-contact__owner {
  display: none;
}

/* The browser's own file button, under the drop area, so that a chosen
   photo can be seen by name. With scripts the drop area shows the name. */
.fdm-contact__file {
  order: 1;
  max-width: 100%;
  font-family: var(--fdm-font-body);
  font-size: var(--fdm-fs-16);
  line-height: var(--fdm-lh-16);
  color: var(--fdm-ink);
}

.fdm-contact__upload > .fdm-field__error {
  order: 2;
}

/* 11. Field errors ---------------------------------------------------------- */

/* The sentence under a field uses fdm-field__error from base.css, and the
   field's border turns red through aria-invalid. A sentence the script has
   to add by itself (no slot in the markup) reads the same. */
.fdm-contact-error {
  font-size: var(--fdm-fs-16);
  line-height: var(--fdm-lh-16);
  color: var(--fdm-error);
}

/* "Please choose what your message is about": under the three choices */
.fdm-contact__topic-error {
  margin-top: var(--fdm-space-7);
}

.fdm-contact__group.has-error .fdm-option {
  border-color: var(--fdm-error);
}

/* A refused photo: the dashed outline turns red. Dragging a new one over it
   shows the usual green. */
.fdm-contact__upload.has-error .fdm-contact__drop:not(.is-dragover) {
  color: var(--fdm-error);
}

/* 12. Status line: sending, success, error ---------------------------------- */

/* One line under the send row, announced to screen readers. Hidden until
   there is something to say. */
.fdm-contact__status {
  min-height: var(--fdm-contact-status-min);
  padding: var(--fdm-space-14) var(--fdm-space-18);
  border: var(--fdm-border-width) solid transparent;
  border-radius: var(--fdm-radius-control);
  background: var(--fdm-color-surface-alt);
  color: var(--fdm-ink);
  font-size: var(--fdm-fs-17);
  line-height: var(--fdm-lh-17);
  scroll-margin-top: var(--fdm-space-24);
  scroll-margin-bottom: var(--fdm-space-24);
}

.fdm-contact__status[data-state="sending"] {
  color: var(--fdm-color-text-muted);
}

.fdm-contact__status[data-state="success"] {
  background: var(--fdm-green-tint);
}

.fdm-contact__status[data-state="error"] {
  border-color: var(--fdm-error);
  background: var(--fdm-white);
  color: var(--fdm-error);
}

/* 13. Password-protected page ------------------------------------------------ */

/* WordPress's password form (styled in base.css) stands in for the form. */
.fdm-contact__locked {
  padding-bottom: var(--fdm-space-80);
}

@media (max-width: 599.98px) {
  .fdm-contact__locked {
    padding-bottom: var(--fdm-space-48);
  }
}
