/* ==========================================================================
   Forms — Verity-wired inquiry forms (Home sidebar, Inquire, Contact, Tour,
   Military). Accessibility is the priority here.
   A11Y:
     - Every control has a <label for> association (no placeholder-as-label).
     - Required fields marked with a text asterisk + "(required)" in the label,
       AND aria-required — color is never the sole signal.
     - Errors are surfaced inline, linked via aria-describedby, and announced
       through an aria-live="assertive" region per field group.
     - Inputs meet 44px min target height and ≥3:1 border contrast.
   ========================================================================== */
.form-card {
  background: #ffffff;
  /* Reset text color: the home form card sits inside the navy hero (light
     text), so without this, inherited text (e.g. radio-pill labels) would be
     near-white on white and fail contrast. */
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: clamp(var(--space-3), 3vw, var(--space-5));
}
.form-card__head { margin-bottom: var(--space-3); }
.form-card__head h2,
.form-card__head h3 { font-size: var(--text-2xl); margin-bottom: 0.25rem; }
.form-card__head p { font-size: var(--text-sm); color: var(--color-text-muted); }

/* Dedicated form-page layout: supporting content + form side-by-side. */
.form-page-grid { display: grid; gap: var(--space-5); align-items: start; }
@media (min-width: 960px) {
  .form-page-grid { grid-template-columns: 1fr minmax(400px, 480px); gap: var(--space-8); }
}
.form-page-aside .lead { margin-bottom: var(--space-4); }
.form-next { list-style: none; margin: var(--space-3) 0 0; padding: 0; display: grid; gap: var(--space-2); counter-reset: step; }
.form-next li { display: grid; grid-template-columns: auto 1fr; gap: var(--space-2); align-items: start; }
.form-next .step-num {
  display: grid; place-items: center; width: 32px; height: 32px; flex-shrink: 0;
  border-radius: var(--radius-full); background: var(--color-accent); color: #fff;
  font-weight: var(--weight-bold); font-size: var(--text-sm);
}
.form-next strong { color: var(--color-primary); display: block; }
.form-next p { margin: 0; font-size: var(--text-sm); color: var(--color-text-muted); }

/* Sticky behavior for the home right-rail; only sticks on wide viewports. */
.form-sticky { position: static; }
@media (min-width: 1024px) {
  .form-sticky { position: sticky; top: calc(var(--sticky-top) + var(--space-2)); }
}

/* Layout helpers within a form */
.form-grid { display: grid; gap: var(--space-2); }
.form-row { display: grid; gap: var(--space-2); }
@media (min-width: 480px) { .form-row--2 { grid-template-columns: 1fr 1fr; } }

.field { display: flex; flex-direction: column; gap: 0.4rem; }
.field__label {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}
.field__req { color: var(--color-error); font-weight: var(--weight-bold); }
.field__hint { font-size: var(--text-xs); color: var(--color-text-muted); }

.input, .select, .textarea {
  width: 100%;
  min-height: 48px;
  padding: 0.7rem 0.85rem;
  font-size: var(--text-base);
  color: var(--color-text);
  background: #ffffff;
  border: 1.5px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
  -webkit-appearance: none;
  appearance: none;
}
.textarea { min-height: 120px; resize: vertical; line-height: var(--leading-normal); }
.input::placeholder, .textarea::placeholder { color: #94a3b8; } /* slate-400, decorative only */

.input:hover, .select:hover, .textarea:hover { border-color: var(--color-accent); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgb(33 114 193 / 0.18);
  outline: none; /* replaced by the ring above; focus-visible ring still applies via UA fallback */
}

/* Native select chevron (decorative SVG via background) */
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  padding-right: 2.5rem;
}

/* Error state: red border + asterisk + message text (3 redundant signals). */
.field[data-invalid='true'] .input,
.field[data-invalid='true'] .select,
.field[data-invalid='true'] .textarea {
  border-color: var(--color-error);
  box-shadow: 0 0 0 3px rgb(185 28 28 / 0.14);
}
.field__error {
  display: none;
  align-items: center;
  gap: 0.35rem;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-error);
}
.field[data-invalid='true'] .field__error { display: inline-flex; }

/* Checkbox / consent ---------------------------------------------------- */
.consent {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.65rem;
  padding: var(--space-2);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.consent input[type='checkbox'] {
  width: 22px; height: 22px;
  margin-top: 2px;
  accent-color: var(--color-accent);
  flex-shrink: 0;
}
.consent label { font-size: var(--text-xs); line-height: var(--leading-normal); color: var(--color-text-muted); }
.consent a { color: var(--color-accent-hover); }

.radio-group { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.radio-pill {
  position: relative;
}
.radio-pill input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.radio-pill span {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0.5rem 1rem;
  border: 1.5px solid var(--color-border-strong);
  border-radius: var(--radius-full);
  font-size: var(--text-sm); font-weight: var(--weight-medium);
}
.radio-pill input:hover + span { border-color: var(--color-accent); }
.radio-pill input:checked + span {
  border-color: var(--color-accent);
  background: #e7f0fb;
  color: var(--color-accent-hover);
  font-weight: var(--weight-semibold);
}
/* A11Y: keyboard focus ring mirrors the global focus-visible treatment. */
.radio-pill input:focus-visible + span { outline: 3px solid var(--color-focus); outline-offset: 2px; }

/* Submit + status ------------------------------------------------------ */
.form-submit { margin-top: var(--space-1); }
.form-status {
  margin-top: var(--space-2);
  padding: var(--space-2);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  display: none;
}
.form-status[data-state='error'] {
  display: block;
  background: var(--color-error-subtle);
  border: 1px solid #fca5a5;
  color: var(--color-error);
}
.form-status[data-state='loading'] {
  display: block;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
}

/* Loading spinner on the submit button */
.btn[aria-busy='true'] { opacity: 0.85; pointer-events: none; }
.btn__spinner {
  width: 18px; height: 18px;
  border: 2px solid rgb(255 255 255 / 0.4);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.form-fineprint { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: var(--space-2); }
.form-fineprint a { color: var(--color-accent-hover); }
