/* ============================================
   Contact form — static HTML mockup styled with our brand.

   At HubSpot port time, this form gets replaced with a HubSpot
   embed (`hbspt.forms.create({...})`) and the CSS adapter layer
   bridges these classes to HubSpot's generated classes:

     .gs-wgs-form__input   → .hs-input
     .gs-wgs-form__field   → .hs-form-field
     .gs-wgs-form__submit  → .hs-button.primary
     .gs-wgs-form__title   → .hs-form .hs-richtext h3

   See skills/why-giant-swarm/SKILL.md §6.7.

   White card w/ subtle grey border, comfortable padding. Inputs
   are pill-shaped to match the site's button language. Labels
   are visually hidden (placeholders carry the label visually);
   labels stay in the DOM for screen readers.
   ============================================ */

.gs-wgs-form {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.gs-wgs-form__title {
  font-size: var(--text-h4);
  color: var(--color-fg);
  margin: 0 0 0.5rem;
}

.gs-wgs-form__field {
  display: flex;
  flex-direction: column;
}

.gs-wgs-form__label {
  /* Visually hidden — placeholder carries the visible label.
     Kept in DOM for screen readers. */
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.gs-wgs-form__input {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.875rem 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-bg);
  color: var(--color-fg);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.gs-wgs-form__input::placeholder {
  color: var(--color-fg-muted);
}

.gs-wgs-form__input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(0, 124, 255, 0.15);
}

.gs-wgs-form__select {
  /* Custom dropdown caret via background-image since default
     <select> caret styling is messy across browsers. */
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%23525C68' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1.25rem center;
  padding-right: 3rem;
}

.gs-wgs-form__submit {
  align-self: flex-start;
  margin-top: 0.5rem;
}

@media (max-width: 767px) {
  /* Trim padding on phones — 2.5rem reads luxurious; 1.5rem keeps
     the inputs roomy but the card doesn't dominate. */
  .gs-wgs-form {
    padding: 1.75rem 1.5rem;
  }
}

/* ============================================
   HubSpot form embed adapter

   When a use-case page contains {% form form_to_use="..." %}, HubSpot
   renders its own DOM with class names like .hs-form, .hs-input,
   .hs-button, etc. Our gs-wgs-form classes do not match HubSpot's
   structure, so the form would render with browser-default chrome.

   The rules below bridge HubSpot's class names to our design tokens.
   Scoped under .gs-wgs-form--hs-embed so they only fire when we
   intentionally place a HubSpot form embed in our markup, not on
   any random hs-form elsewhere.

   Mapping:
     .hs-form                  → vertical flex layout (mirrors .gs-wgs-form)
     .hs-richtext h3           → .gs-wgs-form__title styling
     .hs-form-field            → .gs-wgs-form__field flex column
     label                     → visually-hidden (placeholder carries label)
     .input                    → no wrapper styling (HubSpot wraps input
                                  in an extra div; we ignore it)
     .hs-input                 → .gs-wgs-form__input — pill, padding,
                                  border, focus state
     select.hs-input           → .gs-wgs-form__select — appearance: none,
                                  custom caret background-image
     .hs-button.primary        → .gs-btn--primary — gradient pill button
     .hs-error-msgs            → small red error text below field
   ============================================ */

.gs-wgs-form--hs-embed .hs-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* HubSpot's iframe sibling — hidden by default but make sure */
.gs-wgs-form--hs-embed iframe[name^="target_iframe_"] {
  display: none;
}

/* Title — HubSpot renders the form's rich-text title block as
   `.hs-richtext h3` (or h2/h4 depending on form config). Style
   matches .gs-wgs-form__title. */
.gs-wgs-form--hs-embed .hs-richtext {
  margin: 0 0 0.5rem;
}

.gs-wgs-form--hs-embed .hs-richtext h2,
.gs-wgs-form--hs-embed .hs-richtext h3,
.gs-wgs-form--hs-embed .hs-richtext h4 {
  font-size: var(--text-h4);
  color: var(--color-fg);
  margin: 0;
  font-weight: 700;
}

/* Field wrapper */
.gs-wgs-form--hs-embed .hs-form-field {
  display: flex;
  flex-direction: column;
}

/* Labels — visually hidden (placeholder carries the visible label).
   Kept in DOM for screen readers. HubSpot already hides them via
   empty <span> inside the label, but we explicitly visually-hide
   the label itself so layout doesn't reserve space. */
.gs-wgs-form--hs-embed .hs-form-field > label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* HubSpot wraps the actual <input> in an extra <div class="input">.
   Strip its default block-level layout quirks. */
.gs-wgs-form--hs-embed .input {
  display: block;
}

/* Inputs (text, email, select). Pill-shaped, matches .gs-wgs-form__input. */
.gs-wgs-form--hs-embed .hs-input {
  width: 100%;
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.875rem 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-bg);
  color: var(--color-fg);
  box-sizing: border-box;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.gs-wgs-form--hs-embed .hs-input::placeholder {
  color: var(--color-fg-muted);
}

.gs-wgs-form--hs-embed .hs-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(0, 124, 255, 0.15);
}

/* Select gets a custom caret — same SVG as .gs-wgs-form__select. */
.gs-wgs-form--hs-embed select.hs-input {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%23525C68' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1.25rem center;
  padding-right: 3rem;
  cursor: pointer;
}

/* Placeholder state on the select — HubSpot adds .is-placeholder
   when nothing's selected. Dim the text to match input placeholders. */
.gs-wgs-form--hs-embed select.hs-input.is-placeholder {
  color: var(--color-fg-muted);
}

/* Submit area — HubSpot wraps the button in .hs_submit > .actions */
.gs-wgs-form--hs-embed .hs_submit {
  margin-top: 0.5rem;
}

.gs-wgs-form--hs-embed .hs-field-desc {
  display: none;
}

/* Submit button — match .gs-btn--primary (gradient pill).
   HubSpot renders as <input type="submit" class="hs-button primary large">
   so we target the class chain directly. */
.gs-wgs-form--hs-embed .hs-button {
  display: inline-block;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.875rem 1.75rem;
  border: none;
  border-radius: 999px;
  background: var(--gradient-cta);
  color: var(--color-on-accent, #fff);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.gs-wgs-form--hs-embed .hs-button:hover {
  filter: brightness(1.05);
  box-shadow: 0 6px 18px -6px rgba(255, 119, 0, 0.45);
  transform: translateY(-1px);
}

.gs-wgs-form--hs-embed .hs-button:active {
  transform: translateY(0);
  filter: brightness(0.97);
}

/* Error messages — small red text below the field on validation fail */
.gs-wgs-form--hs-embed .hs-error-msgs,
.gs-wgs-form--hs-embed .hs-error-msg {
  list-style: none;
  padding: 0;
  margin: 0.25rem 0 0;
  color: #d23a2a;
  font-size: 0.8125rem;
}

/* Dependent (conditional) fields — HubSpot wraps fields shown
   after a dropdown selection inside .hs-dependent-field, which
   doesn't get the parent .hs-form's flex gap. Re-establish the
   same vertical rhythm inside that wrapper so conditional
   fields sit at the same spacing as top-level fields. */
.gs-wgs-form--hs-embed .hs-dependent-field {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Lock the form wrapper at a sensible minimum height so the
   form→success-message swap doesn't collapse the visual block
   from "full form" to "tiny banner." 480px ≈ the IIoT form's
   resting height without dependent fields; shorter forms get
   a little breathing room, which the centred success message
   makes feel deliberate rather than empty. */
.gs-wgs-form--hs-embed {
  min-height: 480px;
}

/* When the form is replaced by the success message, centre the
   message vertically within the preserved wrapper height. The
   :has() selector flips justify-content only in the submitted
   state — the active form still aligns naturally from the top. */
.gs-wgs-form--hs-embed:has(.submitted-message) {
  justify-content: center;
}

/* Success message after submission — restyled as an intentional
   state, not a deflated remnant. No inner border/bg (the outer
   wrapper already carries the card chrome — nested cards looked
   off); larger type, centred copy, soft fade-in to smooth the
   form→message swap. The ::before pseudo-element renders a coral
   paper-plane icon (Lucide `send`) above the text — narrative
   fit for "your message is on its way." Inline SVG so no extra
   asset request; coral fill matches the brand-editorial token. */
.gs-wgs-form--hs-embed .submitted-message {
  text-align: center;
  padding: 2rem 1.5rem;
  color: var(--color-fg);
  font-size: var(--text-h5);
  animation: gs-form-success-fade 0.4s ease both;
}

.gs-wgs-form--hs-embed .submitted-message::before {
  content: '';
  display: block;
  width: 48px;
  height: 48px;
  margin: 0 auto 1.25rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23f65954' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z'/%3E%3Cpath d='m21.854 2.147-10.94 10.939'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

@keyframes gs-form-success-fade {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
