/* ==========================================================================
   DAP Industry Pages - HubSpot form adapter styles

   hubspot-forms.js relabels HubSpot's DOM with the design's own class names, so
   the fields, labels and button are styled by components.css and pages.css
   verbatim. Nothing in this file restyles a field.

   What is here is only the parts HubSpot adds that the static markup has no
   equivalent for: its two wrapper divs, the required asterisk, its validation
   messages and its post-submit message.

   No em-dashes anywhere in this codebase, per brand guardrails.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Until onFormReady has run, the form is unclassed and unstyled. Hide it for
   that one frame so it never flashes as raw HubSpot markup.
   -------------------------------------------------------------------------- */
.dapv-hsform-target form:not(.dapv-hsform) {
  visibility: hidden;
}

/* dapv-hsform-nowobble
   Hiding it was not enough. HubSpot injects the form at its own height, 330px,
   and only when onFormReady adds .dapv-hsform does our CSS re-lay it out to
   314px. visibility:hidden still occupies layout, so that 16px difference
   landed as a visible settle at about 2.5s, and dragged .hc-fine 60px with it.
   Taking the unready form out of flow means only the finished, restyled form
   ever contributes height. The reservation below holds the box until then.
   Revert: restore assets/css/hubspot-forms.css.bak-20260918-hswobble */
.dapv-hsform-target[data-instance="hero"] form:not(.dapv-hsform),
.dapv-hsform-target[data-instance="ctaband"] form:not(.dapv-hsform) {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
}
.dapv-hsform-target[data-instance="hero"],
.dapv-hsform-target[data-instance="ctaband"] {
  position: relative;
}

.dapv-hsform-target {
  min-height: 1px;
}

/* dapv-hsform-reserve
   HubSpot injects the form about 800ms after first paint, and until it lands the
   card is only its heading and fine print. The card then grew by roughly 270px,
   which is the jolt you see when arriving from a page that has not already
   cached the HubSpot script. A reload never showed it because the script was
   cached and the form was in place by first paint.

   Measured on all three vertical pages, both instances: 314px at 600px and up,
   490px below that, where the fields stack. Reserved only while the target is
   :empty, so the space is released the moment the form arrives and there is no
   leftover gap behind the success message after a submit.

   If HubSpot's form gains or loses a field these numbers need remeasuring.
   Revert: restore assets/css/hubspot-forms.css.bak-20260918-hsreserve */
.dapv-hsform-target[data-instance="hero"]:not(:has(form.dapv-hsform)),
.dapv-hsform-target[data-instance="ctaband"]:not(:has(form.dapv-hsform)) {
  min-height: 490px;
}
@media (min-width: 600px) {
  .dapv-hsform-target[data-instance="hero"]:not(:has(form.dapv-hsform)),
  .dapv-hsform-target[data-instance="ctaband"]:not(:has(form.dapv-hsform)) {
    min-height: 314px;
  }
}
/* :has() is the load-time state test. Browsers without it fall back to the
   :empty rule below, which still covers the large pre-injection reservation. */
.dapv-hsform-target[data-instance="hero"]:empty,
.dapv-hsform-target[data-instance="ctaband"]:empty {
  min-height: 490px;
}
@media (min-width: 600px) {
  .dapv-hsform-target[data-instance="hero"]:empty,
  .dapv-hsform-target[data-instance="ctaband"]:empty {
    min-height: 314px;
  }
}

/* --------------------------------------------------------------------------
   HubSpot wraps each control in div.input and the submit in div.actions. The
   design's .form-group is a flex column of label + control, so those wrappers
   would add a layout box that the static markup does not have.
   display:contents removes the box while leaving the element in the DOM, so
   HubSpot's own error insertion and event wiring keep working.
   -------------------------------------------------------------------------- */
.dapv-hsform .form-group > .input,
.dapv-hsform .hs_submit > .actions {
  display: contents;
}

/* --------------------------------------------------------------------------
   Every field on this form is required in HubSpot, so HubSpot appends an
   asterisk to all five labels. The approved design shows none, and marking
   every field adds no information. Hidden visually, still read by screen
   readers, which is the accessible way round.
   -------------------------------------------------------------------------- */
.dapv-hsform .hs-form-required {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* HubSpot emits an empty legend for every field that has no help text. */
.dapv-hsform .hs-field-desc:empty {
  display: none;
}

/* --------------------------------------------------------------------------
   Validation messages. New UI - the static form had no validation at all - so
   these are built from the design's own tokens rather than invented values.
   -------------------------------------------------------------------------- */
.dapv-hsform .hs-error-msgs,
.dapv-hsform .hs_error_rollup ul {
  list-style: none;
  margin: var(--space-2) 0 0;
  padding: 0;
}

.dapv-hsform .hs-error-msg,
.dapv-hsform .hs-main-font-element {
  font-size: var(--t-small);
  line-height: var(--t-leading-body);
  color: var(--primary-500);
}

.dapv-hsform .form-input.error,
.dapv-hsform .form-input.invalid,
.dapv-hsform .form-textarea.error {
  border-color: var(--primary-500);
}

/* The roll-up above the button repeats what is already under each field. */
.dapv-hsform .hs_error_rollup {
  display: none;
}

/* --------------------------------------------------------------------------
   Post-submit message, shown in place of the form.
   -------------------------------------------------------------------------- */
.dapv-hsform-target .submitted-message {
  font-size: var(--t-body);
  line-height: var(--t-leading-body);
  color: var(--text-main);
}

.hc-closeband .dapv-hsform-target .submitted-message {
  color: var(--gray-900);
}


/* ---------------------------------------------------------------------------
   Reset the theme-inlined HubSpot card skin.
   The theme inlines `.hs-form, .wpcf7-form` into wp_head with a white card,
   21px padding, 35px vertical margins and a 2px orange border plus glow. The
   stylesheet dequeue cannot reach an inline block, and .hc-formcard already
   draws the card, so the form element itself is stripped back here.
   form.dapv-hsform is (0,1,1) and beats the theme's (0,1,0) without needing
   !important, which keeps the design's own field rules winning normally.
   --------------------------------------------------------------------------- */
form.dapv-hsform {
	background-color: transparent;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	font-size: inherit;
	text-align: inherit;
}


/* ---------------------------------------------------------------------------
   Layout without touching HubSpot's DOM: collapse HubSpot fieldsets.
   HubSpot nests fields as form > fieldset.form-columns-N > div.hs-form-field.
   The form carries .hc-form so it is the design's grid; display:contents on
   the fieldsets lifts the field divs into that grid where they already sit, so
   nothing has to be reparented and HubSpot's re-render on submit still finds
   the structure it built.
   --------------------------------------------------------------------------- */
form.dapv-hsform > fieldset {
	display: contents;
	max-width: none;
}

/* Rows that must run the full width of the card. */
form.dapv-hsform > .hs_error_rollup,
form.dapv-hsform > .hs-richtext,
form.dapv-hsform > .hs_recaptcha {
	grid-column: 1 / -1;
}


/* ---------------------------------------------------------------------------
   HubSpot's half-width field override.
   HubSpot injects its own style#hs-form-style per instance, which css:'' does
   NOT suppress, and it floats two-column fields at width:50%. That was
   invisible while the fields were reparented out of the fieldsets; now they are
   grid items it halves them inside their own column. The grid owns the columns,
   so the field just fills the one it is in.
   Specificity here is (0,3,2) against HubSpot's (0,3,1) - enough to win, and
   low enough that the design's own field rules still apply normally.
   --------------------------------------------------------------------------- */
form.dapv-hsform.hc-form > fieldset > .hs-form-field {
	width: auto;
	float: none;
}


/* 2026-10-20 (Nick): the form's own consent paragraph duplicated the one under the button and
   rendered white on white in half a column, so it is hidden; our card prints the consent text.
   The reCAPTCHA badge is made invisible but stays in the page (visibility, not display), as
   Google allows when the page carries their notice, which the fine print now does. */
form.dapv-hsform .legal-consent-container,
form.dapv-hsform > .hs-richtext,
form.dapv-hsform fieldset:has(> .legal-consent-container),
form.dapv-hsform fieldset:has(> .hs-richtext) { display: none !important; }
form.dapv-hsform .hs_recaptcha { visibility: hidden; position: absolute; width: 0; height: 0; overflow: hidden; margin: 0; padding: 0; }
.hc-fine__recaptcha { display: block; margin-top: var(--space-2); }


/* 2026-10-21 (Nick): every field fills its grid column. HubSpot wraps the email field in
   .hs-dependent-field, which became the grid item and left email alone in one column with
   phone pushed to the next row at 95% (HubSpot's single-column input width). The wrapper is
   lifted into the grid like the fieldsets, email and phone pair up as they do on the
   homepage form, and inputs take the whole column. */
form.dapv-hsform > fieldset > .hs-dependent-field { display: contents; }
form.dapv-hsform.hc-form .hs_email,
form.dapv-hsform.hc-form .hs_phone { grid-column: auto !important; }
form.dapv-hsform .hs-input:not([type="checkbox"]):not([type="radio"]) { width: 100% !important; max-width: none !important; }

/* The design spaces its form from the card heading with ".hc-formcard__h + form" (pages.css); a HubSpot form
   sits inside the embed target div instead, so give that div the same gap (13 Nov 2026, Jade). */
.hc-formcard__h + .dapv-hsform-target { margin-top: var(--space-6); }

/* 24 Nov 2026 (QA, Healthcare issue 1): the healthcare-template industry pages (body .p-healthcare:
   healthcare, financial services, B2B tech, SaaS) draw the hero form large in the design: a 56px button
   with 18px text (btn--lg) and a four-row goals box (127px). HubSpot's submit is an input, which the
   design-inline button rule (button[type=submit]) never reached. ABA and the other hero forms stay btn--md. */
.p-healthcare #hero form.dapv-hsform input[type="submit"] { height: 56px; min-height: 56px; font-size: 18px; }
.p-healthcare #hero form.dapv-hsform .form-textarea { min-height: 127px; }

/* 1 Dec 2026 (Nick, after QA Awards issue 1): every other design draws the hero form's goals box 62px tall
   (about, ABA, awards, contact-us, industries, services, technical-seo, the Chicago pages), not the 104px that
   design-inline.css copied from the healthcare design; 6px top and bottom as those designs, the sides level
   with the other fields. The healthcare-template pages keep their 127px (above). */
body:not(.p-healthcare) #hero form.dapv-hsform .form-textarea { height: 62px; min-height: 62px; padding-top: 6px !important; padding-bottom: 6px !important; }

/* 25 Nov 2026 (QA, Healthcare issue 7): the "Option 1 · Tell us your goals" card (contact-options, .cm-card--main:
   Healthcare, B2B Tech and the service pages) as its designs draw it. The fields are 34px (44px on phones), not
   the ABA design's 48px closing-form rule that design-inline.css applies to every #cta-band. On desktop the goals
   box stretches so the form fills the card beside the calendar: the design's stretch rules expect the form as the
   card's child, but HubSpot's form sits inside .dapv-hsform-target and its textarea inside .hs_message > .input. */
#cta-band .cm-card--main form.dapv-hsform .form-input { height: 34px; min-height: 34px; }
@media (max-width: 767px) {
  #cta-band .cm-card--main form.dapv-hsform .form-input { height: 44px; min-height: 44px; }
}
@media (min-width: 1024px) {
  #cta-band .cm-card--main > .dapv-hsform-target { flex: 1 1 auto; display: flex; flex-direction: column; }
  #cta-band .cm-card--main form.dapv-hsform { flex: 1 1 auto; grid-template-rows: auto auto minmax(0, 1fr) auto; align-content: stretch; }
  #cta-band .cm-card--main form.dapv-hsform .hs-fieldtype-textarea { display: flex; flex-direction: column; }
  #cta-band .cm-card--main form.dapv-hsform .hs-fieldtype-textarea > .input { flex: 1 1 auto; display: flex; flex-direction: column; }
  #cta-band .cm-card--main form.dapv-hsform textarea.form-textarea { flex: 1 1 auto; height: auto; min-height: 96px; resize: none; }
}

/* 26 Nov 2026 (QA, Financial Services issue 3): the book-call closing band (.bc-band: Financial Services, SaaS,
   Nonprofit, Professional Services) as the Financial Services design draws it, the same way as the card above:
   34px fields (44px on phones) and, on desktop, a message box that stretches so the form fills the card beside
   the calendar (the design's own stretch rule expects its static markup, not HubSpot's). */
#cta-band.bc-band .hc-formcard form.dapv-hsform .form-input { height: 34px; min-height: 34px; }
@media (max-width: 767px) {
  #cta-band.bc-band .hc-formcard form.dapv-hsform .form-input { height: 44px; min-height: 44px; }
}
@media (min-width: 1024px) {
  #cta-band.bc-band .careers__grid--2 > .hc-formcard:not(.careers__cal) > .dapv-hsform-target { flex: 1 1 auto; display: flex; flex-direction: column; }
  #cta-band.bc-band .careers__grid--2 > .hc-formcard:not(.careers__cal) form.dapv-hsform { flex: 1 1 auto; grid-template-rows: auto auto minmax(0, 1fr) auto; align-content: stretch; }
  #cta-band.bc-band form.dapv-hsform .hs-fieldtype-textarea { display: flex; flex-direction: column; }
  #cta-band.bc-band form.dapv-hsform .hs-fieldtype-textarea > .input { flex: 1 1 auto; display: flex; flex-direction: column; }
  #cta-band.bc-band form.dapv-hsform textarea.form-textarea { flex: 1 1 auto; height: auto; min-height: 96px; resize: none; }
}

/* 1 Dec 2026 (Nick: message boxes as their designs): the AI Audits "meet" band (#meet, hub-meet) is drawn like the
   book-call band above in ai-audits.html: 34px fields (44px on phones) and, on desktop, a goals box that stretches
   so the form fills the card beside the calendar (412px in the design); it stayed 62px. */
#meet .hc-formcard form.dapv-hsform .form-input { height: 34px; min-height: 34px; }
@media (max-width: 767px) {
  #meet .hc-formcard form.dapv-hsform .form-input { height: 44px; min-height: 44px; }
}
@media (min-width: 1024px) {
  #meet .careers__grid--2 > .hc-formcard > .dapv-hsform-target { flex: 1 1 auto; display: flex; flex-direction: column; }
  #meet .careers__grid--2 > .hc-formcard form.dapv-hsform { flex: 1 1 auto; grid-template-rows: auto auto minmax(0, 1fr) auto; align-content: stretch; }
  #meet form.dapv-hsform .hs-fieldtype-textarea { display: flex; flex-direction: column; }
  #meet form.dapv-hsform .hs-fieldtype-textarea > .input { flex: 1 1 auto; display: flex; flex-direction: column; }
  #meet form.dapv-hsform textarea.form-textarea { flex: 1 1 auto; height: auto; min-height: 96px; resize: none; }
}
