/* =========================================================================
   AMHEALTH — FORMS
   The single source of truth for every form style on the site.

   Covers BOTH form renderers used by the theme:
     1. The hand-built two-step benefits-check form in
        template-amhealth-landing.php  (.form / .field / .consent / .form__nav)
     2. The Gravity Forms render of the same form, skinned to match
        (.amh-gform_wrapper, scoped so other GF forms are untouched)

   The .form card is also reused as a plain panel by template-thank-you.php
   and 404.php, so the card shell is deliberately renderer-agnostic.

   Loaded after theme.css (and after Gravity Forms' own stylesheets) — see
   amh_enqueue_assets() in functions.php and amh_enqueue_gravity_skin() in
   inc/gravity-form.php.

   Nothing in this file styles anything outside a form card. Global tokens,
   .btn, [hidden], :focus-visible and section layout (.close__grid) stay in
   theme.css.

   CONTENTS
     1.  Tokens
     2.  Form card shell
     3.  Two-step progress
     4.  Fields — labels, inputs, focus, validation
     5.  Segmented radio pairs
     6.  Secure note / privacy boundary
     7.  Consent checkbox
     8.  Form navigation buttons
     9.  Submission alerts
     10. Step visibility
     11. Gravity Forms skin
     12. Responsive — desktop / tablet / mobile
     13. Reduced motion
   ========================================================================= */


/* =========================================================================
   1. TOKENS
   Mirrors theme.css :root with literal fallbacks so this file renders
   correctly even if it is ever loaded on its own.
   ========================================================================= */
.form,
.amh-gform_wrapper {
  --amf-canvas:    var(--canvas,    #F6F9FB);
  --amf-canvas-2:  var(--canvas-2,  #EBF2F5);
  --amf-canvas-3:  var(--canvas-3,  #DDE9EE);
  --amf-ink:       var(--ink,       #0d2140);
  --amf-ink-2:     var(--ink-2,     #2c405e);
  --amf-muted:     var(--muted,     #5b6e86);
  --amf-teal:      var(--teal,      #2b6689);
  --amf-teal-dark: var(--teal-dark, #1f4d68);
  --amf-line:      var(--line,      rgba(13,33,64,.14));
  --amf-line-soft: var(--line-soft, rgba(13,33,64,.08));
  --amf-pend-bg:   var(--pend-bg,   rgba(43,102,137,.08));

  --amf-err:       #b3261e;
  --amf-err-bg:    #faeeee;
  --amf-err-line:  #e3bcbc;
  --amf-err-ink:   #7c2626;
  --amf-ok-bg:     #eef6ef;
  --amf-ok-line:   #bcd9c0;
  --amf-ok-ink:    #1d4a28;

  --amf-radius:      var(--r-lg, 24px);
  --amf-radius-ctl:  11px;
  --amf-radius-note: 12px;
  --amf-control-h:   56px;
  --amf-pad:         clamp(26px, 3vw, 40px);

  --amf-head: var(--head, 'Literata', Georgia, 'Times New Roman', serif);
  --amf-body: var(--body, 'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif);
  --amf-ease: var(--ease, cubic-bezier(.22,.61,.36,1));
}


/* =========================================================================
   2. FORM CARD SHELL
   The light card that sits on the navy .close section.
   ========================================================================= */
.form {
  background: var(--amf-canvas);
  border-radius: var(--amf-radius);
  padding: var(--amf-pad);
  color: var(--amf-ink);
  box-shadow: 0 40px 90px -30px rgba(0,0,0,.55);
}
.form h3 {
  color: var(--amf-ink);
  margin-bottom: .3em;
  font-size: clamp(1.35rem, 1.9vw, 1.6rem);
}
.form__intro {
  font-size: 1rem;
  color: var(--amf-muted);
  margin-bottom: 1.4em;
}


/* =========================================================================
   3. TWO-STEP PROGRESS
   theme.js toggles .on as the user moves between steps, and hides the whole
   strip once the form has been submitted.
   ========================================================================= */
.form__steps {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.form__dot {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--amf-canvas-3);
}
.form__dot.on { background: var(--amf-teal); }


/* =========================================================================
   4. FIELDS
   ========================================================================= */
/* The step fieldsets carry no chrome of their own — the card supplies it.
   (Replaces the inline style="border:0;padding:0;margin:0" that used to sit
   on #step1 / #step2.) */
.form__step {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-weight: 600;
  font-size: .98rem;
  margin-bottom: 7px;
}
.field label .opt {
  font-weight: 500;
  color: var(--amf-muted);
}

.field input[type=text],
.field input[type=tel],
.field input[type=email],
.field input[type=number],
.field textarea,
.field select {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--amf-body);
  font-size: 1.06rem;
  color: var(--amf-ink);
  padding: 15px 16px;
  min-height: var(--amf-control-h);
  border: 1.5px solid var(--amf-line);
  border-radius: var(--amf-radius-ctl);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--amf-teal);
  box-shadow: 0 0 0 3px rgba(43,102,137,.16);
}

/* Validation — theme.js sets aria-invalid and unhides .field__err */
.field input[aria-invalid="true"],
.field textarea[aria-invalid="true"],
.field select[aria-invalid="true"] { border-color: var(--amf-err); }
.field input[aria-invalid="true"]:focus,
.field textarea[aria-invalid="true"]:focus,
.field select[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgba(179,38,30,.16); }
.field__err {
  margin: 6px 0 0;
  font-size: .9rem;
  font-weight: 600;
  color: var(--amf-err);
}


/* =========================================================================
   5. SEGMENTED RADIO PAIRS
   "I prefer" and "Who is this benefits check for?" — the native radio is
   visually hidden and the label becomes the control.
   ========================================================================= */
.field__seg { display: flex; gap: 8px; }
.field__seg label {
  position: relative;          /* contains the absolutely-positioned input */
  flex: 1;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5em;
  border: 1.5px solid var(--amf-line);
  border-radius: var(--amf-radius-ctl);
  padding: 15px 10px;
  min-height: var(--amf-control-h);
  cursor: pointer;
  font-weight: 600;
  font-size: 1.02rem;
  background: #fff;
  transition: border-color .15s, background .15s, color .15s;
}
.field__seg label:hover { border-color: var(--amf-teal); }
.field__seg input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.field__seg label:has(input:checked) {
  border-color: var(--amf-teal);
  background: var(--amf-pend-bg);
  color: var(--amf-teal-dark);
}
.field__seg label:has(input:focus-visible),
.field__seg label:focus-within {
  outline: 3px solid var(--amf-teal);
  outline-offset: 2px;
}


/* =========================================================================
   6. SECURE NOTE / PRIVACY BOUNDARY
   ========================================================================= */
.form__secure {
  display: flex;
  align-items: center;
  gap: .5em;
  font-size: .9rem;
  color: var(--amf-muted);
  margin-bottom: 14px;
}
.form__secure svg {
  width: 15px;
  height: 15px;
  color: var(--amf-teal);
  flex: 0 0 auto;
}
/* Trailing variant that closes the form instead of introducing a group.
   (Replaces the inline style="margin:14px 0 0".) */
.form__secure--tail {
  margin: 14px 0 0;
}

/* Shown when the request is for someone else — states what we do NOT collect. */
.form__boundary {
  background: var(--amf-canvas-2);
  border: 1px solid var(--amf-line-soft);
  border-radius: var(--amf-radius-note);
  padding: 18px 20px;
  font-size: .98rem;
  color: var(--amf-ink-2);
  margin-bottom: 16px;
}
.form__boundary b { color: var(--amf-ink); }


/* =========================================================================
   7. CONSENT CHECKBOX
   ========================================================================= */
.consent {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 6px 0 18px;
}
.consent input {
  width: 20px;
  height: 20px;
  margin-top: 3px;
  accent-color: var(--amf-teal);
  flex: 0 0 auto;
}
.consent label {
  font-size: .9rem;
  color: var(--amf-muted);
  line-height: 1.55;
}


/* =========================================================================
   8. FORM NAVIGATION BUTTONS
   The buttons inherit .btn / .btn--primary from theme.css; only the in-form
   layout and the Back variant live here.
   ========================================================================= */
.form__nav {
  display: flex;
  gap: 10px;
}
.form__nav .btn { flex: 1; }
.form__back {
  flex: 0 0 auto !important;
  background: #fff;
  color: var(--amf-ink-2);
  border: 1.5px solid var(--amf-line);
}
.form__back:hover { border-color: var(--amf-ink-2); }


/* =========================================================================
   9. SUBMISSION ALERTS
   ========================================================================= */
.form__alert {
  border-radius: var(--amf-radius-note);
  padding: 18px 20px;
  font-size: .93rem;
  margin-bottom: 16px;
}
.form__alert--ok {
  background: var(--amf-ok-bg);
  border: 1px solid var(--amf-ok-line);
  color: var(--amf-ok-ink);
}
.form__alert--err {
  background: var(--amf-err-bg);
  border: 1px solid var(--amf-err-line);
  color: var(--amf-err-ink);
}
.form__alert a { font-weight: 700; }


/* =========================================================================
   10. STEP VISIBILITY
   theme.js drives the whole two-step flow with the `hidden` attribute
   (steps, error paragraphs, the self-only field group, the progress strip).
   theme.css carries the global [hidden] rule; this scoped copy keeps the
   form correct on its own.
   ========================================================================= */
.form [hidden] { display: none !important; }


/* =========================================================================
   11. GRAVITY FORMS SKIN
   Styles GF's own markup to match the card above. Scoped to .amh-gform
   (set as the form's CSS Class) so it never bleeds into other Gravity Forms.

   Field class names come from each field's `cssClass`:
     .amh-f--fname .amh-f--seg .amh-f--contact .amh-f--insurer
     .amh-f--who .amh-f--securenote .amh-f--familynote .amh-f--consent
   ========================================================================= */
.amh-gform_wrapper {
  font-family: var(--amf-body);
  color: var(--amf-ink);
  background: var(--amf-canvas);
  border-radius: var(--amf-radius);
  padding: var(--amf-pad);
  box-shadow: 0 40px 90px -30px rgba(0,0,0,.55);
  max-width: 100%;
}

/* When the landing template already supplies the .form card, the wrapper must
   not draw a second one inside it. */
.form--gf .amh-gform_wrapper {
  background: none;
  box-shadow: none;
  padding: 0;
  border-radius: 0;
}

/* --- GF chrome that fights the design --- */
.amh-gform_wrapper .gform_heading { margin-bottom: 1.2em; }
.amh-gform_wrapper .gform_title {
  font-family: var(--amf-head);
  font-weight: 500;
  line-height: 1.12;
  font-size: clamp(1.35rem, 1.9vw, 1.6rem);
  color: var(--amf-ink);
  margin: 0 0 .3em;
}
.amh-gform_wrapper .gform_description {
  font-size: 1rem;
  color: var(--amf-muted);
  display: block;
  margin-bottom: 1.2em;
}
.amh-gform_wrapper .gform_required_legend { display: none; }
.amh-gform_wrapper .gfield_required { color: var(--amf-teal-dark); }

/* --- Fields --- */
.amh-gform_wrapper .gform_fields { display: grid; gap: 16px; }
.amh-gform_wrapper .gfield { margin: 0; }
/* GF's legacy markup wraps choice fields in a bordered fieldset — strip it so
   radio groups sit flush like the rest of the form. */
.amh-gform_wrapper fieldset,
.amh-gform_wrapper .gfield fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}
.amh-gform_wrapper legend.gfield_label,
.amh-gform_wrapper .gfield legend {
  padding: 0;
  float: none;
  width: 100%;
}
.amh-gform_wrapper .gfield_label {
  display: block;
  font-weight: 600;
  font-size: .98rem;
  color: var(--amf-ink);
  margin-bottom: 7px;
  font-family: var(--amf-body);
}
.amh-gform_wrapper .gfield_description {
  font-size: .85rem;
  color: var(--amf-muted);
  padding-top: 6px;
}

.amh-gform_wrapper input[type=text],
.amh-gform_wrapper input[type=tel],
.amh-gform_wrapper input[type=email],
.amh-gform_wrapper input[type=number],
.amh-gform_wrapper textarea,
.amh-gform_wrapper select {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--amf-body);
  font-size: 1.06rem;
  color: var(--amf-ink);
  padding: 15px 16px;
  min-height: var(--amf-control-h);
  border: 1.5px solid var(--amf-line);
  border-radius: var(--amf-radius-ctl);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.amh-gform_wrapper input:focus,
.amh-gform_wrapper textarea:focus,
.amh-gform_wrapper select:focus {
  outline: none;
  border-color: var(--amf-teal);
  box-shadow: 0 0 0 3px rgba(43,102,137,.16);
}

/* --- Validation --- */
.amh-gform_wrapper .gfield_error input,
.amh-gform_wrapper .gfield_error textarea,
.amh-gform_wrapper .gfield_error select { border-color: var(--amf-err); }
.amh-gform_wrapper .gfield_error input:focus { box-shadow: 0 0 0 3px rgba(179,38,30,.16); }
.amh-gform_wrapper .validation_message {
  margin: 6px 0 0;
  padding: 0;
  border: 0;
  background: none;
  font-size: .9rem;
  font-weight: 600;
  color: var(--amf-err);
}
.amh-gform_wrapper .gform_validation_errors {
  background: var(--amf-err-bg);
  border: 1px solid var(--amf-err-line);
  color: var(--amf-err-ink);
  border-radius: var(--amf-radius-note);
  padding: 16px 20px;
  box-shadow: none;
  margin-bottom: 18px;
}
.amh-gform_wrapper .gform_validation_errors h2 {
  font-size: .95rem;
  margin: 0;
  color: var(--amf-err-ink);
  font-family: var(--amf-body);
}

/* --- Segmented radio pairs (I prefer / Who is this for) --- */
.amh-gform_wrapper .amh-f--seg .gfield_radio { display: flex; gap: 8px; }
.amh-gform_wrapper .amh-f--seg .gchoice {
  flex: 1;
  margin: 0;
  position: relative;
}
.amh-gform_wrapper .amh-f--seg .gchoice input[type=radio] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.amh-gform_wrapper .amh-f--seg .gchoice label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5em;
  border: 1.5px solid var(--amf-line);
  border-radius: var(--amf-radius-ctl);
  padding: 15px 10px;
  min-height: var(--amf-control-h);
  cursor: pointer;
  font-weight: 600;
  font-size: 1.02rem;
  background: #fff;
  margin: 0;
  transition: border-color .15s, background .15s, color .15s;
}
.amh-gform_wrapper .amh-f--seg .gchoice label:hover { border-color: var(--amf-teal); }
.amh-gform_wrapper .amh-f--seg .gchoice input[type=radio]:checked + label {
  border-color: var(--amf-teal);
  background: var(--amf-pend-bg);
  color: var(--amf-teal-dark);
}
.amh-gform_wrapper .amh-f--seg .gchoice input[type=radio]:focus-visible + label {
  outline: 3px solid var(--amf-teal);
  outline-offset: 2px;
}

/* --- Notes / boundary --- */
.amh-gform_wrapper .amh-note--secure {
  display: flex;
  align-items: flex-start;
  gap: .5em;
  font-size: .9rem;
  color: var(--amf-muted);
  margin: 0;
}
.amh-gform_wrapper .amh-boundary {
  background: var(--amf-canvas-2);
  border: 1px solid var(--amf-line-soft);
  border-radius: var(--amf-radius-note);
  padding: 18px 20px;
  font-size: .98rem;
  color: var(--amf-ink-2);
}
.amh-gform_wrapper .amh-boundary b { color: var(--amf-ink); }

/* --- Consent checkbox --- */
.amh-gform_wrapper .amh-f--consent .gfield_label { display: none; } /* the choice text is the label */
.amh-gform_wrapper .amh-f--consent .gchoice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.amh-gform_wrapper .amh-f--consent input[type=checkbox] {
  width: 20px;
  height: 20px;
  margin-top: 3px;
  accent-color: var(--amf-teal);
  flex: 0 0 auto;
}
.amh-gform_wrapper .amh-f--consent label {
  font-size: .9rem;
  color: var(--amf-muted);
  line-height: 1.55;
  font-weight: 400;
}

/* --- Buttons (GF markup has no .btn, so the pill identity is restated) --- */
.amh-gform_wrapper .gform_footer,
.amh-gform_wrapper .gform_page_footer {
  display: flex;
  gap: 10px;
  margin: 20px 0 0;
  padding: 0;
  border: 0;
}
.amh-gform_wrapper .gform_button,
.amh-gform_wrapper .gform_next_button,
.amh-gform_wrapper .gform_previous_button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  font-family: var(--amf-body);
  font-weight: 700;
  font-size: 1.08rem;
  line-height: 1;
  min-height: var(--amf-control-h);
  padding: 17px 30px;
  border-radius: 999px;
  border: 2px solid transparent;
  cursor: pointer;
  text-align: center;
  transition: transform .16s var(--amf-ease), box-shadow .2s, background .2s, color .2s;
  width: auto;
}
.amh-gform_wrapper .gform_button,
.amh-gform_wrapper .gform_next_button {
  flex: 1;
  background: var(--amf-teal);
  color: #fff;
  box-shadow: 0 12px 28px -10px rgba(43,102,137,.55);
}
.amh-gform_wrapper .gform_button:hover,
.amh-gform_wrapper .gform_next_button:hover {
  background: var(--amf-teal-dark);
  transform: translateY(-2px);
}
.amh-gform_wrapper .gform_previous_button {
  flex: 0 0 auto;
  background: #fff;
  color: var(--amf-ink-2);
  border-color: var(--amf-line);
}
.amh-gform_wrapper .gform_previous_button:hover { border-color: var(--amf-ink-2); }
.amh-gform_wrapper .gform_button:active,
.amh-gform_wrapper .gform_next_button:active { transform: translateY(0); }

/* --- Two-step progress (matches the design's dots) --- */
.amh-gform_wrapper .gf_progressbar_wrapper { margin: 0 0 20px; padding: 0; }
.amh-gform_wrapper .gf_progressbar_title { display: none; }
.amh-gform_wrapper .gf_progressbar {
  display: flex;
  gap: 8px;
  background: none;
  box-shadow: none;
  padding: 0;
  height: auto;
  border-radius: 0;
}
.amh-gform_wrapper .gf_progressbar::before,
.amh-gform_wrapper .gf_progressbar::after {
  content: '';
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--amf-canvas-3);
}
.amh-gform_wrapper .gf_progressbar::before { background: var(--amf-teal); }
.amh-gform_wrapper .gf_progressbar_percentage { display: none; }
.amh-gform_wrapper .gf_progressbar_wrapper.percentbar_blue .gf_progressbar_percentage { background: var(--amf-teal); }

/* --- Confirmation --- */
.amh-gform_wrapper .gform_confirmation_message,
.gform_confirmation_wrapper .gform_confirmation_message {
  background: var(--amf-ok-bg, #eef6ef);
  border: 1px solid var(--amf-ok-line, #bcd9c0);
  color: var(--amf-ok-ink, #1d4a28);
  border-radius: 12px;
  padding: 18px 20px;
  font-size: .93rem;
}

/* --- Honeypot / hidden --- */
.amh-gform_wrapper .gform_validation_container,
.amh-gform_wrapper .gfield_visibility_hidden { display: none !important; }


/* =========================================================================
   12. RESPONSIVE

   Desktop (no query) is the base above. The card, its padding and its type
   are clamp()-driven, so they scale continuously from 1440px down without
   needing a breakpoint of their own. What follows are the discrete changes.

   The .close section grid that holds the form stacks at <=1024px — that rule
   is section layout and lives in theme.css (.close__grid).
   ========================================================================= */

/* ---- Tablet (<= 900px): the card is full-width now, so tighten it ---- */
@media (max-width: 900px) {
  .form,
  .amh-gform_wrapper {
    --amf-pad: clamp(24px, 3.4vw, 34px);
  }
  .field { margin-bottom: 14px; }
  .amh-gform_wrapper .gform_fields { gap: 14px; }
}

/* ---- Large phone / small tablet (<= 740px) ---- */
@media (max-width: 740px) {
  .form h3,
  .amh-gform_wrapper .gform_title { font-size: 1.35rem; }
  .form__intro,
  .amh-gform_wrapper .gform_description { font-size: .98rem; }
}

/* ---- Phone (<= 520px) ----
   Segmented pairs stack (two long labels will not fit side by side), the
   card loses some padding, and the Back/Submit row is allowed to wrap. */
@media (max-width: 520px) {
  .form,
  .amh-gform_wrapper {
    --amf-pad: 22px 18px;
    --amf-radius: 18px;
  }

  .field__seg,
  .amh-gform_wrapper .amh-f--seg .gfield_radio { flex-direction: column; }

  .form__nav,
  .amh-gform_wrapper .gform_footer,
  .amh-gform_wrapper .gform_page_footer { flex-wrap: wrap; }

  .form__boundary,
  .amh-gform_wrapper .amh-boundary,
  .form__alert,
  .amh-gform_wrapper .gform_validation_errors { padding: 16px 16px; }
}

/* ---- Small phone (<= 380px): keep 56px targets, shrink the type ---- */
@media (max-width: 380px) {
  .field input[type=text],
  .field input[type=tel],
  .field input[type=email],
  .field input[type=number],
  .field textarea,
  .field select,
  .amh-gform_wrapper input[type=text],
  .amh-gform_wrapper input[type=tel],
  .amh-gform_wrapper input[type=email],
  .amh-gform_wrapper input[type=number],
  .amh-gform_wrapper textarea,
  .amh-gform_wrapper select { font-size: 1rem; padding: 15px 14px; }

  .form__nav .btn,
  .amh-gform_wrapper .gform_button,
  .amh-gform_wrapper .gform_next_button,
  .amh-gform_wrapper .gform_previous_button { padding: 17px 20px; font-size: 1rem; }
}


/* =========================================================================
   13. REDUCED MOTION
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
  .field input[type=text],
  .field input[type=tel],
  .field input[type=email],
  .field input[type=number],
  .field textarea,
  .field select,
  .field__seg label,
  .amh-gform_wrapper input,
  .amh-gform_wrapper textarea,
  .amh-gform_wrapper select,
  .amh-gform_wrapper .amh-f--seg .gchoice label { transition: none; }

  .amh-gform_wrapper .gform_button,
  .amh-gform_wrapper .gform_next_button,
  .amh-gform_wrapper .gform_previous_button,
  .amh-gform_wrapper .gform_button:hover,
  .amh-gform_wrapper .gform_next_button:hover { transition: none; transform: none; }
}
