/* ─────────────────────────────────────────────────────────────────────────────
   PQA Contact Form
   Follows the PQA design system: Montserrat, --pqa-* custom properties,
   navy/light-navy/accent-blue palette, 6px border-radius tokens.

   Color convention:
     Default (light/white container) — navy labels, white inputs, navy focus ring.
     .dark container                 — white labels, translucent inputs, accent-blue ring.
     .pqa-highlight-accent override  — accent-blue focus ring in any container.
   ───────────────────────────────────────────────────────────────────────────── */

.pqa-contact-form-wrapper {
  max-width: 640px;
  /* Grid stacking: form and success share the same cell so the wrapper
     holds its height when we swap visibility — no layout shift. */
  display: grid;

  /* ── Focus ring CSS custom properties ──────────────────────────────────────
     Default: navy. Overridden per-context below.
     Usage: var(--pqa-field-focus-color) / var(--pqa-field-focus-ring)        */
  --pqa-field-focus-color: var(--pqa-navy);
  --pqa-field-focus-ring: rgba(43, 46, 95, 0.12);
}

.pqa-contact-form,
.pqa-newsletter-form,
.pqa-contact-success {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  /* Prevent grid blowout on narrow viewports. */
}

/* ── Form layout ─────────────────────────────────────────────────────────────── */

.pqa-contact-form,
.pqa-newsletter-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Submitted state: keep the layout space, remove interaction. */
.pqa-contact-form.pqa-submitted,
.pqa-newsletter-form.pqa-submitted {
  visibility: hidden;
  pointer-events: none;
}

.pqa-form-row--two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ── Field wrapper ───────────────────────────────────────────────────────────── */

.pqa-form-field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.pqa-form-field label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--pqa-navy);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pqa-required {
  color: var(--pqa-accent-blue);
  margin-left: 2px;
}

/* ── Inputs & textarea ───────────────────────────────────────────────────────── */

.pqa-form-field input[type="text"],
.pqa-form-field input[type="email"],
.pqa-form-field textarea {
  border: 1.5px solid var(--pqa-border);
  border-radius: 6px;
  padding: 0.625rem 0.875rem;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--pqa-text);
  background-color: var(--pqa-white);
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}

.pqa-form-field input[type="text"]:focus,
.pqa-form-field input[type="email"]:focus,
.pqa-form-field textarea:focus {
  outline: none;
  border-color: var(--pqa-field-focus-color);
  box-shadow: 0 0 0 3px var(--pqa-field-focus-ring);
}

.pqa-form-field input.has-error,
.pqa-form-field textarea.has-error {
  border-color: #c0002b;
}

.pqa-form-field textarea {
  resize: vertical;
  min-height: 148px;
  line-height: 1.6;
}

/* ── Checkbox ────────────────────────────────────────────────────────────────── */

.pqa-form-field--checkbox {
  flex-direction: row;
  align-items: flex-start;
  gap: 0;
}

.pqa-form-field--checkbox:last-of-type {
  padding-bottom: 0.5rem;
}

.pqa-form-field--checkbox label {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  font-weight: 400;
  font-size: 0.9rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--pqa-text-mid);
  cursor: pointer;
}

.pqa-form-field--checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--pqa-navy);
  cursor: pointer;
}

/* ── Inline field errors ─────────────────────────────────────────────────────── */

.pqa-field-error {
  font-size: 0.8rem;
  color: #c0002b;
  min-height: 1.1em;
  line-height: 1.3;
}

/* ── Submit row ──────────────────────────────────────────────────────────────── */

.pqa-form-actions {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  padding-top: 0.25rem;
}

/* Loading state: hide "Send Message", show "Sending…" */
.pqa-submit-btn .pqa-btn-sending {
  display: none;
}

.pqa-submit-btn.is-sending .pqa-btn-label {
  display: none;
}

.pqa-submit-btn.is-sending .pqa-btn-sending {
  display: inline;
}

.pqa-submit-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* Global error (below the button) */
.pqa-form-error--global {
  font-size: 0.875rem;
  color: #c0002b;
  margin: 0;
  flex-basis: 100%;
}

/* ── Success state ───────────────────────────────────────────────────────────── */

/* Hidden by default — JS adds .pqa-visible after a successful submission. */
.pqa-contact-success {
  display: none;
  visibility: hidden;
  pointer-events: none;
  /* Fill the full grid cell height and vertically center the content. */
  align-self: stretch;
  flex-direction: column;
  justify-content: center;
  padding: 2rem 2.25rem;
  background-color: var(--pqa-light-navy);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  /* Suppress focus ring — element is focused programmatically for screen readers
     only; it is not interactive and should not show a visible outline. */
  outline: none;
}

/* Rainbow left border via pseudo-element (CSS borders can't accept gradients). */
.pqa-contact-success::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--pqa-rainbow-vertical);
  border-radius: 12px 0 0 12px;
}

.pqa-contact-success.pqa-visible {
  display: flex;
  visibility: visible;
  pointer-events: auto;
}

/* ── Success icon ────────────────────────────────────────────────────────────── */

.pqa-success-icon {
  display: block;
  margin-bottom: 1.25rem;
}

.pqa-success-icon svg {
  width: 40px;
  height: 40px;
  color: var(--pqa-accent-blue);
  display: block;
}

/* ── Success copy ────────────────────────────────────────────────────────────── */

.pqa-contact-success .section-eyebrow {
  display: block;
  margin-bottom: 0.5rem;
}

.pqa-contact-success h3 {
  color: var(--pqa-navy);
  margin-bottom: 0.5rem;
}

.pqa-contact-success p {
  color: var(--pqa-text-mid);
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.7;
}

/* ── reCAPTCHA badge ─────────────────────────────────────────────────────────── */
/* Hidden per Google's policy when disclosure is included in the privacy policy. */

.grecaptcha-badge {
  visibility: hidden !important;
}

/* ── Responsive ──────────────────────────────────────────────────────────────── */

@media (max-width: 560px) {
  .pqa-form-row--two-col {
    grid-template-columns: 1fr;
  }

  .pqa-form-actions {
    flex-direction: column;
    align-items: flex-start;
  }

  .pqa-submit-btn {
    width: 100%;
    text-align: center;
  }
}

/* ── Dark container context ───────────────────────────────────────────────────
   Triggered when the block is placed inside any .dark element
   (section.dark, .wp-block-group.dark, etc.).
   ─────────────────────────────────────────────────────────────────────────── */

.dark .pqa-contact-form-wrapper {
  --pqa-field-focus-color: var(--pqa-accent-blue);
  --pqa-field-focus-ring: rgba(58, 186, 249, 0.2);
}

.dark .pqa-form-field label {
  color: var(--pqa-white);
}

.dark .pqa-form-field input[type="text"],
.dark .pqa-form-field input[type="email"],
.dark .pqa-form-field textarea {
  background-color: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.18);
  color: var(--pqa-white);
}

.dark .pqa-form-field input[type="text"]::placeholder,
.dark .pqa-form-field input[type="email"]::placeholder,
.dark .pqa-form-field textarea::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.dark .pqa-form-field--checkbox label {
  color: rgba(255, 255, 255, 0.75);
}

.dark .pqa-form-field--checkbox input[type="checkbox"] {
  accent-color: var(--pqa-accent-blue);
}

/* Success panel in dark context */
.dark .pqa-contact-success {
  background-color: rgba(255, 255, 255, 0.07);
}

.dark .pqa-contact-success h3 {
  color: var(--pqa-white);
}

.dark .pqa-contact-success p {
  color: rgba(255, 255, 255, 0.75);
}

/* ── Accent blue highlight override (.pqa-highlight-accent) ───────────────────
   Set via the "Field Highlight Color" ACF field. Forces accent-blue focus
   ring regardless of the container's light/dark context.
   ─────────────────────────────────────────────────────────────────────────── */

.pqa-highlight-accent,
.dark .pqa-highlight-accent {
  --pqa-field-focus-color: var(--pqa-accent-blue);
  --pqa-field-focus-ring: rgba(58, 186, 249, 0.2);
}