/* Contact form at the bottom of the homepage (includes/contact.php, assets/contact.js). */
.contact {
  --cap: 5px;                 /* how far a line of 16px mono sits below its box: lines up the field rules with the label tops */
  --locked-text: #b2b2b2;     /* the fields once submitted */
  --locked-line: #eaeaea;
  --badge: #ededc1;           /* the "!" of the human test */
  --badge-sent: #caecc9;      /* ...once the message is sent */
  --blank: #f2f2f2;           /* the blank you fill in */
  display: grid;
  grid-template-columns: 405px minmax(0, 1fr);
  align-items: start;
}
#contact .sec { padding-top: 215px; padding-bottom: 233px; }
.contact__title { font-weight: 700; font-size: var(--t-list); line-height: 1; }
.contact__intro { max-width: 480px; padding-top: 8px; font-size: var(--t-body); line-height: 1.4; }
.form { margin-top: 65px; }

/* ---------- Fields: the label sits inside until you type, with a thin rule down the left ---------- */
.field { position: relative; display: block; }
.field + .field { margin-top: 29px; }
.field::before {
  content: "";
  position: absolute;
  left: 0;
  top: var(--cap);
  bottom: 0;
  width: 1px;
  background: var(--rule);
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
}
.field__input {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0 0 calc(34px - 22.4px + var(--cap)) 12px;   /* the rule runs 34px from the top of the text */
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 16px;            /* 16px or more, so phones don't zoom in on focus */
  line-height: 22.4px;
  letter-spacing: 0.04em;
  outline: none;
  appearance: none;
  transition: color 0.25s ease;
}
textarea.field__input { min-height: calc(98px + var(--cap)); padding-bottom: 12px; resize: none; overflow: hidden; }
.field__label { position: absolute; left: 12px; top: 0; line-height: 22.4px; pointer-events: none; transition: opacity 0.15s ease, color 0.25s ease; }
/* The label clears as soon as you're in the field, and stays clear once there's text.
   "~" rather than "+": password managers slip their own icon in right after the input. */
.field:focus-within .field__label,
.field__input:not(:placeholder-shown) ~ .field__label { opacity: 0; }
/* Browser autofill: clear the label too (kept as separate rules so older browsers don't drop the others) */
.field__input:-webkit-autofill ~ .field__label { opacity: 0; }
.field__input:autofill ~ .field__label { opacity: 0; }
/* ...and skip the autofill tint, so the field keeps the page background */
.field__input:-webkit-autofill,
.field__input:-webkit-autofill:hover,
.field__input:-webkit-autofill:focus { -webkit-text-fill-color: var(--ink); -webkit-box-shadow: 0 0 0 1000px var(--bg) inset; caret-color: var(--ink); transition: background-color 9999s ease 0s; }
.form.is-locked .field__input:-webkit-autofill { -webkit-text-fill-color: var(--locked-text); }
.field__req { position: relative; top: -0.15em; margin-left: 4px; font-size: 10px; vertical-align: top; }
.field:focus-within::before { background: var(--ink); box-shadow: -1px 0 0 var(--ink); }
.field.is-invalid::before { background: var(--ink); box-shadow: -1px 0 0 var(--ink); }

/* Submitted: the fields lock and fade back (click one to edit again) */
.form.is-locked .field::before { background: var(--locked-line); box-shadow: none; }
.form.is-locked .field__input, .form.is-locked .field__label { color: var(--locked-text); }
.form.is-locked:not(.is-done) .field__input { cursor: pointer; }

/* Hidden from people, irresistible to bots */
.form__trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Submit, the human test, and the social icons ---------- */
.form__foot { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-top: 30px; }
.form__step { min-width: 0; }
.form__submit { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 20px; padding-top: 24px; }
.form__submit[hidden], .ht[hidden] { display: none; }
.form__send, .ht__verify { text-decoration: underline; text-underline-offset: 3px; }
.form__send:hover, .ht__verify:hover { color: var(--mute); }
.form__note { color: var(--mute); }
.social { display: flex; gap: 17px; flex: none; padding-top: 22px; }
.social a { display: block; }
.social a:hover { opacity: 0.6; }
.social img { display: block; width: 20px; height: 20px; }

.ht { width: max-content; max-width: 100%; }
.ht__head { display: flex; align-items: center; gap: 9px; font-size: var(--t-body); line-height: 1.4; }
.ht__badge { display: grid; place-items: center; width: 22px; height: 31px; background: var(--badge); line-height: 1; transition: background-color 0.4s ease; }
.form.is-sent .ht__badge { background: var(--badge-sent); }   /* sent: the "!" turns green */
.form.is-denied .ht__badge { display: none; }
.ht__lead { margin-top: 12px; }
.ht__quote { margin-top: 3px; font-style: italic; }
.ht__end { white-space: nowrap; }   /* the blank and the punctuation after it stay together */
.ht__answer {
  width: max(88px, calc(var(--len, 0) * (1ch + 0.04em) + 24px));   /* widens with the answer (each letter is 1ch plus the letter spacing) */
  max-width: calc(100% - 3ch);   /* but never past the end of the line */
  height: 23px;
  margin: 0 1px 0 0;
  padding: 0 8px;
  border: 0;
  border-radius: 0;
  background: var(--blank);
  color: var(--ink);
  font: inherit;
  font-style: italic;
  letter-spacing: inherit;
  text-transform: uppercase;
  vertical-align: 1px;
  outline: none;
}
.form.is-done .ht__answer { width: calc(var(--len, 0) * (1ch + 0.04em) + 2px); background: transparent; padding: 0; color: var(--ink); vertical-align: baseline; }   /* sent: the answer sits in the line like the rest of the text */
.ht__foot { display: flex; justify-content: flex-end; align-items: baseline; flex-wrap: wrap; gap: 8px 20px; margin-top: 25px; text-align: right; }
.ht__status { color: var(--mute); }
.ht__status a { color: var(--ink); text-underline-offset: 3px; }
.ht__verify[disabled] { color: var(--mute); cursor: default; }

/* ---------- Smaller screens ---------- */
@media (max-width: 900px) {
  .contact { grid-template-columns: 1fr; }
  .contact__intro { margin-top: 24px; }
  .form { margin-top: 48px; }
  #contact .sec { padding-top: 120px; padding-bottom: 130px; }   /* same as the other sections on smaller screens */
}
@media (max-width: 640px) {
  .ht { width: auto; }
  .ht__quote { line-height: 1.8; }
}
@media (prefers-reduced-motion: reduce) {
  .field::before, .field__input, .field__label { transition: none; }
}
