/* ==========================================================================
   Gravity Forms -> St Michaels styling
   --------------------------------------------------------------------------
   Installs to: wp-content/themes/stmichaels/assets/css/layouts/contact.css

   FILENAME MATTERS. functions.php auto-enqueues assets/css/layouts/<slug>.css only when
   <slug> matches an ACF flexible-content layout rendered on the request. The layout is
   `contact`, so this file MUST be named contact.css. A file named gravity-forms.css would
   never be enqueued.

   APPROACH. Gravity Forms 2.9's Orbital theme cannot be switched off (the theme choice is
   global, and gravity-forms-orbital-theme.min.css is a 0-byte stub - the real styling lives
   in gravity-forms-theme-framework.min.css). Fighting it with selectors would be miserable.

   Fortunately the framework wraps its rules in :where(:not(.gform-theme__disable)...), which
   has ZERO specificity. So it is designed to be re-themed, and two things follow:
     1. Its custom properties are the intended hook - set those and the framework restyles
        itself. That is most of this file.
     2. Where a variable does not exist or does not reach, a single plain class selector
        beats the framework outright. One !important is used, on the submit button only - the reason is documented at that rule.

   Values are lifted from the .Form / .FormInput / .FormSubmit rules in live.css so the form
   matches the markup it replaced. The site's own design tokens do the work.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Re-theme the framework via its own custom properties
   -------------------------------------------------------------------------- */

.gform_wrapper.gform-theme {

  /* ---- text inputs, selects, textareas (live: .FormInput__input) ---- */
  --gf-ctrl-bg-color: var(--color-white);
  --gf-ctrl-bg-color-hover: var(--color-white);
  --gf-ctrl-bg-color-focus: var(--color-white);
  /* !important: GF injects an inline <style> at #gform_wrapper_N[data-form-index].gform-theme
     (specificity 1,2,0) which sets this. An ID beats any number of classes, so a plain
     class selector cannot win. Only these two variables are affected. */
  --gf-ctrl-border-color: rgba(var(--color-faded-nautical-rgb), .25) !important;
  --gf-ctrl-border-color-hover: rgba(var(--color-faded-nautical-rgb), .45);
  --gf-ctrl-border-color-focus: var(--color-faded-nautical);
  --gf-ctrl-border-width: 1px;
  --gf-ctrl-border-style: solid;
  --gf-ctrl-radius: 0;                 /* live inputs are square-cornered */
  --gf-ctrl-padding-x: 15px;
  --gf-ctrl-padding-y: 15px;
  /* --font-body is a FONT SHORTHAND (normal normal normal 1.125rem/1.5 "hoefler",sans-serif),
     not a family. Passing it to a font-family slot is invalid - use the family + size tokens. */
  --gf-ctrl-font-family: var(--font-family-body);
  --gf-ctrl-font-size: var(--font-size-body);

  /* Control height. Live inputs and selects are 59px: 15px padding + 27px line-height,
     border-box. GF defaults to 38px via --gf-ctrl-size-md, which its inline per-form style
     block sets at (1,2,0) - hence !important, same reason as --gf-ctrl-border-color above. */
  --gf-ctrl-size: 59px !important;
  --gf-ctrl-size-md: 59px !important;
  --gf-ctrl-line-height: 27px;
  --gf-ctrl-accent-color: var(--color-burnt-orange);

  /* error state: live signals invalid by opacity, not colour */
  --gf-ctrl-border-color-error: rgba(var(--color-faded-nautical-rgb), .25);
  --gf-ctrl-bg-color-error: var(--color-white);

  /* ---- field rhythm (live: --form-gap-x / --form-gap-y on .Form--style-primary) ---- */
  --gf-field-gap-x: 15px;
  --gf-field-gap-y: 25px;

  /* ---- submit button (live: .StyleUIButton, burnt orange on sun shadow) ---- */
  --gf-ctrl-btn-bg-color-primary: var(--color-burnt-orange);
  --gf-ctrl-btn-border-color-primary: var(--color-burnt-orange);
  --gf-ctrl-btn-color-primary: var(--color-sun-shadow);

  /* live inverts on hover rather than darkening */
  --gf-ctrl-btn-bg-color-hover-primary: transparent;
  --gf-ctrl-btn-border-color-hover-primary: var(--color-burnt-orange);
  --gf-ctrl-btn-color-hover-primary: var(--color-burnt-orange);

  --gf-ctrl-btn-bg-color-focus-primary: var(--color-burnt-orange);
  --gf-ctrl-btn-border-color-focus-primary: var(--color-burnt-orange);
  --gf-ctrl-btn-color-focus-primary: var(--color-sun-shadow);

  --gf-ctrl-btn-font-family: var(--font-family-ui-button);

  /* Button GEOMETRY is a separate set of variables from the controls above - note
     --gf-ctrl-btn-radius is NOT the same as --gf-ctrl-radius, and buttons ignore the latter.
     Defaults are radius 3px, height 38px, padding 0/16px. Live is square, 19px padding
     (calc(20px - 1px border)) and 200px minimum width. */
  --gf-ctrl-btn-radius: 0;
  /* !important: GF's inline per-form block sets both of these too (see the list at
     --gf-ctrl-border-color). Measured on live: 19px padding + 18px line = 56px. */
  --gf-ctrl-btn-size-md: 56px !important;
  --gf-ctrl-btn-size: 56px !important;
  --gf-ctrl-btn-padding-x: 19px !important;
  --gf-ctrl-btn-padding-y: 19px;
}

/* --------------------------------------------------------------------------
   2. Backstops - a plain class beats the framework's :where() at zero specificity
   --------------------------------------------------------------------------
   These cover the handful of things the variables above either do not expose or do not
   reach. Kept deliberately short; if a variable turns out to cover one of these, delete

   -------------------------------------------------------------------------- */

/* Square corners everywhere, including the button (no --gf-ctrl-btn-radius exists). */
.gform_wrapper.gform-theme .gform_footer .gform_button,
.gform_wrapper.gform-theme .ginput_container input,
.gform_wrapper.gform-theme .ginput_container select,
.gform_wrapper.gform-theme .ginput_container textarea {
  border-radius: 0;
}

/* Input colour + transition, matching .FormInput__input. */
.gform_wrapper.gform-theme .ginput_container input,
.gform_wrapper.gform-theme .ginput_container select,
.gform_wrapper.gform-theme .ginput_container textarea {
  color: var(--color-faded-nautical);
  transition:
    background-color var(--transition-fast),
    border-color var(--transition-fast),
    color var(--transition-fast);
}

/* live: .FormInput textarea.FormInput__input { min-height:10rem } */
.gform_wrapper.gform-theme .ginput_container textarea {
  min-height: 10rem;
}

/* Labels. Live applies its `.-type-ui-button` class to every form label:
     font-family:var(--font-family-ui-button); text-transform:uppercase;
     font-size:.875rem; letter-spacing:.2em
   Gravity Forms cannot add that class to its labels, so the treatment is reproduced here.
   This is the single biggest visual difference if it is missing - live labels are small,
   uppercase and letter-spaced, GF defaults are sentence-case body text. */
.gform_wrapper.gform-theme .gfield_label,
.gform_wrapper.gform-theme .gform-field-label,
.gform_wrapper.gform-theme .ginput_complex label {
  font-family: var(--font-family-ui-button);
  font-style: normal;
  font-weight: 400;
  text-transform: uppercase;
  font-size: .875rem;
  letter-spacing: .2em;
  line-height: 1.25;
  color: var(--color-faded-nautical);
  padding-bottom: 10px;
  text-rendering: optimizeLegibility;
}

/* Sub-labels (First / Last on the Name field) sit under their input on live-style forms;
   keep them visible for accessibility but quieter than the main label. */
.gform_wrapper.gform-theme .ginput_complex label {
  font-size: .75rem;
  opacity: .7;
  padding-top: 6px;
  padding-bottom: 0;
}

/* Required markers. Live has none, but this build shows them deliberately. They sit inside
   the label so they inherit the uppercase ui-button treatment; burnt orange and a size down
   makes them read as a marker rather than part of the label text. */
.gform_wrapper.gform-theme .gfield_required {
  display: inline;
  color: var(--color-burnt-orange);
  font-size: .75rem;
  letter-spacing: .1em;
  margin-left: .5em;
}

/* The submit sits left and has a minimum width, as .StyleUIButton does. */
.gform_wrapper.gform-theme .gform_footer {
  margin-top: var(--space-lg);
  padding: 0;
  justify-content: flex-start;
}

/* The button carries BOTH .gform_button and .button. Using both gets us to 0,5,0, which
   clears Gravity Forms' own rule - its framework sheet is enqueued AFTER this file, so an
   equal-specificity selector would lose on source order. Vertical padding and the radius
   come from the variables above; these two properties have no variable that reaches the
   element (GF re-declares --gf-ctrl-btn-padding-x locally, and there is no min-width var). */
.gform_wrapper.gform-theme .gform_footer .gform_button.button,
.gform_wrapper.gform-theme .gform-footer .gform_button.button {
  /* The only !important in this file, and it is deliberate. Gravity Forms' framework sheet
     is enqueued AFTER this one and sets the button's horizontal padding from
     --gf-ctrl-btn-padding-x, which it re-declares on the element itself - so neither the
     wrapper variable nor an ordinary selector reaches it. Physical longhands are used rather
     than padding-inline because a logical property loses to a later physical shorthand.
     Scoped to the submit button only. */
  min-width: 200px !important;
  padding-left: 19px !important;   /* live: calc(20px - 1px border) */
  padding-right: 19px !important;
  white-space: nowrap;
  text-align: center;
  cursor: pointer;
  transition:
    color var(--transition-fast),
    border-color var(--transition-fast),
    background-color var(--transition-fast);
}

/* Consent description (live: .FormInput__consent-description) */
.gform_wrapper.gform-theme .gfield--type-consent .gfield_description {
  opacity: .75;
  text-wrap: balance;
}

/* Validation text (live: .FormInput__error-message is opacity-only, no red) */
.gform_wrapper.gform-theme .gfield_validation_message,
.gform_wrapper.gform-theme .validation_message {
  background: none;
  border: none;
  color: currentColor;
  opacity: .5;
  padding: var(--space-sm) 0 0;
}

/* Section break sits as a heading within the form, not a boxed-off region. */
.gform_wrapper.gform-theme .gfield--type-section {
  border: none;
  padding-bottom: 0;
}

/* --------------------------------------------------------------------------
   3. Turnstile, for when the add-on goes in
   --------------------------------------------------------------------------
   live.css carries .Form__turnstile { width:100%; display:flex; justify-content:center }.
   The original Nuxt form had Turnstile; this rebuild dropped it.
   -------------------------------------------------------------------------- */

.gform_wrapper.gform-theme .gfield--type-turnstile,
.gform_wrapper.gform-theme .gfield--type-captcha {
  width: 100%;
  display: flex;
  justify-content: center;
}

/* --------------------------------------------------------------------------
   NOTES
   --------------------------------------------------------------------------
   - Scoped to .gform_wrapper, so it only affects Gravity Forms and cannot leak into the
     bespoke footer newsletter form, which still uses the .Form / .FormInput classes.
   - When the newsletter form migrates to Gravity Forms it will need these styles site-wide,
     not just on the contact layout. At that point move this out of assets/css/layouts/ and
     enqueue it directly in functions.php, or the footer form will render unstyled on every
     page except /contact/.
   - Half-width fields use GF's own .gfield--width-half, set per field in the form editor.
     No CSS needed here - the framework handles the grid.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Footer newsletter (form 2) - centred, matching .Form--align-center on the
   markup it replaced. The contact form stays left-aligned.
   -------------------------------------------------------------------------- */

#gform_wrapper_2 .gform_fields {
  /* NOT justify-items:center - that makes grid items size to their content, which
     collapses the email input to ~85px. Fields must stretch; centre the CONTENT instead,
     which is what .Form--align-center did on the markup this replaced. */
  text-align: center;
}

#gform_wrapper_2 .gform_footer {
  justify-content: center;
}

/* --------------------------------------------------------------------------
   Choice and consent labels are BODY text on live, not the ui-button treatment.
   --------------------------------------------------------------------------
   Live uses .FormInput__consent-text / .FormInput__checkbox-text, both of which are
   font:var(--font-body) - sentence case, no letter-spacing. Gravity Forms gives choice
   labels the same .gform-field-label class as field labels, so the uppercase rule above
   catches them unless they are excluded here.
   -------------------------------------------------------------------------- */

.gform_wrapper.gform-theme .gfield_checkbox label,
.gform_wrapper.gform-theme .gfield_radio label,
.gform_wrapper.gform-theme .ginput_container_consent label,
.gform_wrapper.gform-theme .gform-field-label--type-inline {
  font-family: var(--font-family-body);
  font-size: var(--font-size-body);
  text-transform: none;
  letter-spacing: normal;
  line-height: 1.4;
  padding-bottom: 0;
  opacity: 1;
}

/* --------------------------------------------------------------------------
   Phone field country selector
   --------------------------------------------------------------------------
   The country-code control is a <button> carrying GF's generic .gform-theme-button class,
   so it inherits the submit-button geometry set at the top of this file (19px padding,
   52px tall) and renders 59px tall beside a 38px input - visibly mismatched.

   Custom properties set ON an element beat ones inherited from an ancestor regardless of
   selector specificity, so re-declaring them here is enough; no !important needed, and it
   leaves the submit button untouched.
   -------------------------------------------------------------------------- */

.gform_wrapper.gform-theme .gform-phone__country-selector {
  --gf-ctrl-btn-padding-x: 15px;
  --gf-ctrl-btn-padding-y: 0;
  --gf-ctrl-btn-size: var(--gf-ctrl-size-md);
  --gf-ctrl-btn-size-md: var(--gf-ctrl-size-md);
  --gf-ctrl-btn-radius: 0;

  /* match the input it sits beside, not the submit button */
  font-family: var(--font-family-body);
  font-size: var(--font-size-body);
  background-color: var(--color-white);
  color: var(--color-faded-nautical);
}

/* --------------------------------------------------------------------------
   Newsletter (form 2) "Interested in" checkbox row
   --------------------------------------------------------------------------
   Live centres these via .Form--align-center .FormInput, which resolves to
   display:flex; flex-wrap:wrap; gap:20px; justify-content:center on
   .FormInput__input-wrapper--checkbox. Reproduced here for the footer form only -
   the contact form's consent tick stays left-aligned.
   -------------------------------------------------------------------------- */

#gform_wrapper_2 .gfield_checkbox {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
}

#gform_wrapper_2 .gfield_checkbox .gchoice {
  margin: 0;
}
