/* ==============================================
   COMPONENT: Form
   Description: Contact form — labels, inputs, select, textarea, submit, feedback states
   ============================================== */

/* --- Section wrapper --- */

.contact-form-section {
  padding-block: var(--space-12);
  background: var(--color-bg-section);
}

/* --- Block --- */

.form {
  max-width: 700px;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  margin-top: var(--space-8);
}

/* --- Form group --- */

.form__group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* --- Label --- */

.form__label {
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
}

.form__required {
  color: var(--color-vitality-orange);
  font-weight: var(--font-weight-bold);
  margin-left: var(--space-1);
}

/* --- Input, select, textarea --- */

.form__input,
.form__select,
.form__textarea {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-family-base);
  font-size: var(--text-base);
  font-weight: var(--font-weight-regular);
  color: var(--color-text-primary);
  background: var(--color-clinical-white);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.form__input::placeholder,
.form__textarea::placeholder {
  color: var(--color-text-secondary);
  opacity: 0.7;
}

.form__input:focus,
.form__select:focus,
.form__textarea:focus {
  border-color: var(--color-innovation-blue);
  box-shadow: 0 0 0 3px rgba(0, 82, 155, 0.12);
}

/* --- Select --- */

.form__select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234a5568' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-4) center;
  background-size: 16px;
  padding-right: var(--space-10);
  appearance: none;
}

/* --- Textarea --- */

.form__textarea {
  resize: vertical;
  min-height: 160px;
  line-height: 1.6;
}

/* --- Footer (Turnstile + submit button + privacy note) ---
   Mobile: stacked column — each child occupies full width.
   Tablet+: 2-column grid — Turnstile spans full width on row 1;
            button (auto) and privacy note (1fr) share row 2. */

.form__footer {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  align-items: flex-start;
}

/* --- Privacy note --- */

.form__privacy-note {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  line-height: 1.5;
}

.form__privacy-note a {
  color: var(--color-innovation-blue);
}

/* --- Success modal --- */

.form-success-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
}

.form-success-modal[hidden] {
  display: none;
}

.form-success-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(26, 32, 44, 0.6);
  cursor: pointer;
}

.form-success-modal__dialog {
  position: relative;
  background: var(--color-clinical-white);
  border-radius: var(--radius-lg);
  padding: var(--space-10) var(--space-8);
  max-width: 480px;
  width: calc(100% - var(--space-8));
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  text-align: center;
}

.form-success-modal__icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--color-synthesis-green);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.form-success-modal__icon svg {
  width: 28px;
  height: 28px;
  stroke: var(--color-clinical-white);
}

.form-success-modal__heading {
  font-size: var(--text-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  line-height: 1.25;
}

.form-success-modal__body {
  font-size: var(--text-base);
  color: var(--color-text-secondary);
  line-height: 1.6;
}

/* --- Error feedback state --- */

.form__error {
  background: var(--color-orange-light-tint);
  color: var(--color-vitality-orange);
  border: 1px solid var(--color-vitality-orange);
}

.form__error a {
  color: var(--color-vitality-orange);
  font-weight: var(--font-weight-bold);
}

/* --- Loading state on submit button --- */

.btn.is-loading {
  opacity: 0.7;
  cursor: not-allowed;
  pointer-events: none;
}

/* --- Responsive --- */

@media (min-width: 768px) {
  .contact-form-section {
    padding-block: var(--space-16);
  }

  /* Grid layout for form footer at tablet+:
     [start]----auto----[middle]----1fr----[end]
     Row 1: Turnstile widget spans start → end (full width)
     Row 2: Submit button (start → middle, auto) | Privacy note (middle → end, 1fr) */
  .form__footer {
    display: grid;
    grid-template-columns: [start] auto [middle] 1fr [end];
    align-items: center;
    gap: var(--space-4) var(--space-6);
  }

  /* Cloudflare Turnstile widget — spans the full row above the button */
  .form__footer > *:first-child {
    grid-column: start / end;
  }

  /* Prevent button from stretching to fill the auto column */
  .form__footer .btn {
    justify-self: start;
    align-self: center;
  }

  .form__footer .form__privacy-note {
    align-self: center;
  }
}

@media (min-width: 1024px) {
  .contact-form-section {
    padding-block: var(--space-20);
  }
}
