/* Contact (fixed template) — V0.1 Contact Page 62:2791 form: 403 wide, padding 30/64,
   groups 29 apart, fields 24 apart, 14px Ekstra labels on 1px white rules, white 37px
   "Send" pill (16 Ekstra Medium). Review 2026-09-24 (K1): no photo, a solid black page
   (content Theme: dark), the form centred in the first screen.
   Motion: the panel rises in, then its rules draw and its rows rise. */
.tpl-contact .contact {
  display: flex; justify-content: center; align-items: center;
  height: calc(100svh - var(--nav-height));
  min-height: 560px; max-height: 900px;
  background: var(--surface-page);
}

.tpl-contact .contact__panel {
  width: 488px; /* V0.1 was 403 (275 inside); the bigger message box widens it (Nick, 2026-09-26) */
  padding: 30px 64px;
  color: var(--ink-primary);
}

.tpl-contact .contact__form { display: grid; gap: 32px; }
.tpl-contact .contact__fields { display: grid; gap: 28px; }

/* ---------- Underline fields with a floating label ---------- */
.tpl-contact .field { position: relative; }
.tpl-contact .field__input {
  display: block; width: 100%; min-height: 22px;
  padding: 0 0 4px; margin: 0;
  border: 0; border-radius: 0; background: transparent; outline: 0;
  color: var(--ink-primary);
  font-family: var(--font-ui); font-size: var(--fs-label-sm); line-height: 18px; letter-spacing: -0.05em;
  resize: none;
}
/* Message: an outlined writing box in the rules' own colour and weight (Tucker, 2026-09-25:
   "too small"; Nick, 2026-09-26: "a little" bigger). It starts about eight lines tall,
   grows as people type (field-sizing, or contact.js where that's missing), and scrolls past fourteen. The label sits inside it and
   floats above it on focus, like the other fields'. Focus turns the outline to the accent. */
.tpl-contact .field--area { margin-top: 20px; }
.tpl-contact .field--area .field__line { display: none; }
.tpl-contact .field--area .field__input {
  --pad: 12px;
  field-sizing: content;
  min-height: calc(8 * 18px + 2 * var(--pad)); max-height: calc(14 * 18px + 2 * var(--pad)); overflow-y: auto;
  padding: var(--pad) 14px;
  border: 1px solid var(--ink-primary); border-radius: var(--radius-sm);
  transition: border-color 350ms var(--ease-out), box-shadow 350ms var(--ease-out);
}
.tpl-contact .field--area .field__input:focus { border-color: var(--ink-accent); box-shadow: inset 0 0 0 1px var(--ink-accent); }
.tpl-contact .field--area.is-invalid .field__input { border-color: var(--color-orange); }
.tpl-contact .field--area .field__label { left: 14px; top: 12px; }
.tpl-contact .field--area .field__input:focus + .field__label,
.tpl-contact .field--area .field__input:not(:placeholder-shown) + .field__label { transform: translate(-14px, -32px) scale(0.78); }
.tpl-contact .field__input::placeholder { color: transparent; }
.tpl-contact .field__label {
  position: absolute; left: 0; top: 0;
  font-family: var(--font-ui); font-size: var(--fs-label-sm); line-height: 18px; letter-spacing: -0.05em;
  color: var(--ink-primary);
  transform-origin: 0 100%;
  pointer-events: none;
  transition: transform 350ms var(--ease-out), color 350ms var(--ease-out);
}
.tpl-contact .field__input:focus + .field__label,
.tpl-contact .field__input:not(:placeholder-shown) + .field__label {
  transform: translateY(-15px) scale(0.78);
  color: var(--ink-muted);
}
.tpl-contact .field__line {
  position: relative; display: block; height: 1px;
  background: var(--ink-primary);
  transform-origin: 0 50%;
}
/* Focus: a 2px rule draws across from the left, in the focus-ring colour so it reads as
   focus, not just a thicker line (the input's own outline is off for the underline look). */
.tpl-contact .field__line::after {
  content: ""; position: absolute; inset: -1px 0 0;
  background: var(--ink-accent);
  transform: scaleX(0); transform-origin: 0 50%;
  transition: transform 450ms var(--ease-out);
}
.tpl-contact .field__input:focus ~ .field__line::after { transform: scaleX(1); }

/* Errors sit in the flow (not in the gap), so a floated label below never collides with one. */
.tpl-contact .field__error {
  margin-top: 6px;
  font-family: var(--font-ui); font-size: var(--fs-label-xs); line-height: 1; letter-spacing: -0.04em;
  color: var(--color-orange);
}
.tpl-contact .field__error:empty { display: none; }
.tpl-contact .is-invalid .field__line,
.tpl-contact .is-invalid .field__line::after { background: var(--color-orange); }

.tpl-contact .contact__alert { font-family: var(--font-ui); letter-spacing: -0.04em; color: var(--color-orange); line-height: 1.3; }
.tpl-contact .contact__alert:empty { display: none; }

/* ---------- Consent ---------- */
.tpl-contact .consent { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 0 4px; min-height: 22px; }
.tpl-contact .consent__box {
  appearance: none; flex: none;
  width: 12px; height: 12px; margin: 0;
  border: 1px solid var(--ink-primary); border-radius: 0;
  background: transparent center / 8px no-repeat;
  cursor: pointer;
  transition: background-color var(--dur-fast);
}
.tpl-contact .consent__box:checked {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 6'%3E%3Cpath d='M.7 3.1 3 5.2 7.3.8' fill='none' stroke='white' stroke-width='1.1'/%3E%3C/svg%3E");
}
.tpl-contact .consent__box:focus-visible { outline-offset: 2px; }
.tpl-contact .consent__label {
  font-family: var(--font-ui); font-size: var(--fs-label-sm); line-height: 22px; letter-spacing: -0.06em;
  cursor: pointer;
}
.tpl-contact .consent .field__error { flex-basis: 100%; margin-top: 2px; }
.tpl-contact .consent.is-invalid .consent__box { border-color: var(--color-orange); }

.tpl-contact .contact__hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.tpl-contact .contact__send {
  width: 100%;
  font-size: var(--fs-label-md); font-weight: 500;
}
.tpl-contact .contact__send[aria-busy="true"] { pointer-events: none; }
.tpl-contact .contact__send[aria-busy="true"] span { animation: contact-pulse 900ms var(--ease-in-out) infinite alternate; }

/* ---------- Sent ---------- */
.tpl-contact .contact__done:not([hidden]) { display: grid; gap: var(--space-16); justify-items: start; padding-block: 8px 4px; outline: 0; }
.tpl-contact .contact__again { text-decoration: underline; text-underline-offset: 3px; color: var(--ink-muted); }
:where([data-input="mouse"], .no-js) .tpl-contact .contact__again:hover { color: var(--ink-primary); }
.tpl-contact .contact__done.is-arriving > * { animation: contact-rise 700ms var(--ease-out) both; }
.tpl-contact .contact__done.is-arriving > * + * { animation-delay: 120ms; }

/* ---------- Entrance ---------- */
.tpl-contact .contact__panel { animation: contact-rise 1100ms cubic-bezier(0.16, 1, 0.3, 1) 150ms both; }
.tpl-contact .contact__form > *,
.tpl-contact .contact__fields > .field { animation: contact-rise 700ms var(--ease-out) both; }
.tpl-contact .contact__fields > .field:nth-child(1) { animation-delay: 620ms; }
.tpl-contact .contact__fields > .field:nth-child(2) { animation-delay: 700ms; }
.tpl-contact .contact__fields > .field:nth-child(3) { animation-delay: 780ms; }
.tpl-contact .contact__form > .consent { animation-delay: 880ms; }
.tpl-contact .contact__form > .contact__send { animation-delay: 960ms; }
.tpl-contact .contact__form > .contact__fields { animation: none; }
.tpl-contact .field__line { animation: contact-draw 900ms var(--ease-in-out) both; }
.tpl-contact .field:nth-child(1) .field__line { animation-delay: 560ms; }
.tpl-contact .field:nth-child(2) .field__line { animation-delay: 660ms; }
.tpl-contact .field:nth-child(3) .field__line { animation-delay: 760ms; }
/* Coming back from a submit: no second entrance. */
.tpl-contact .is-settled .contact__panel,
.tpl-contact .is-settled .contact__form > *,
.tpl-contact .is-settled .field,
.tpl-contact .is-settled .field__line { animation: none; }

@media (prefers-reduced-motion: reduce) {
  .tpl-contact .contact__panel, .tpl-contact .contact__form > *,
  .tpl-contact .field, .tpl-contact .field__line, .tpl-contact .contact__done > * { animation: none !important; }
}

@keyframes contact-rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes contact-draw { from { transform: scaleX(0); } }
@keyframes contact-pulse { to { opacity: 0.35; } }

/* ---------- Mobile: the form fills the width ---------- */
@media (max-width: 767px) {
  .tpl-contact .contact { display: block; height: auto; min-height: 0; max-height: none; }
  .tpl-contact .contact__panel { width: auto; padding: var(--space-40) var(--gutter) var(--space-48); }
  /* 16px type so iOS doesn't zoom on focus. Each field is a 44px tap target: the input
     starts 20px above its text, and the gap shrinks by as much, so the rows sit where they did. */
  .tpl-contact .contact__fields { gap: var(--space-12); }
  .tpl-contact .field__input, .tpl-contact .field__label, .tpl-contact .consent__label { font-size: var(--fs-label-md); }
  .tpl-contact .field__input { padding-top: 20px; min-height: 44px; }
  .tpl-contact .field--area { margin-top: var(--space-24); }
  .tpl-contact .field--area .field__input { padding: 12px 14px; min-height: calc(5 * 22px + 24px); max-height: calc(10 * 22px + 24px); line-height: 22px; }
  .tpl-contact .field--area .field__label { top: 12px; line-height: 22px; }
  .tpl-contact .field--area .field__input:focus + .field__label,
  .tpl-contact .field--area .field__input:not(:placeholder-shown) + .field__label { transform: translate(-14px, -36px) scale(0.72); }
  .tpl-contact .field__label { top: 20px; }
  .tpl-contact .field__input:focus + .field__label,
  .tpl-contact .field__input:not(:placeholder-shown) + .field__label { transform: translateY(-17px) scale(0.72); }
  /* Consent: a 16px box, and the row is 44px tall to tap. */
  .tpl-contact .consent { min-height: 44px; gap: 0 var(--space-8); }
  .tpl-contact .consent__box { width: 16px; height: 16px; background-size: 11px; }
  .tpl-contact .consent__label { padding-block: 11px; }
  .tpl-contact .contact__send { height: 44px; }
}
