/*--------------------------------------------------------------
# H4H website forms (Phase 2)
# Loaded LAST (after main.css, mobile.css and dark-mode.css), so these
# rules win. Covers: Contact, Book a Consultation, Refer a Friend and the
# Get A Quote pop-up.
#   - 16px text in every field (smaller text makes iPhones zoom in)
#   - tap targets of at least 44px
#   - visible labels, error messages, SMS consent boxes
#   - matching dark mode
--------------------------------------------------------------*/

:root {
  --h4h-field-border: color-mix(in srgb, var(--default-color), transparent 72%);
  --h4h-field-hint: color-mix(in srgb, var(--default-color), transparent 38%);
  --h4h-error: #b42318;
  --h4h-error-bg: #fef3f2;
}

html[data-theme="dark"] {
  --h4h-field-border: color-mix(in srgb, var(--default-color), transparent 70%);
  --h4h-error: #ff9b94;
  --h4h-error-bg: #3a1d1d;
}

/* ── Fields: 16px, 48px tall, readable placeholders ─────────────── */
.h4h-form .form-control,
.h4h-form .form-select,
.contact .php-email-form.h4h-form .form-control,
.appointment-scheduler__panel .form-control,
.appointment-scheduler__panel .form-select {
  font-size: 16px;
  min-height: 48px;
  line-height: 1.4;
}

.h4h-form textarea.form-control {
  min-height: 120px;
}

.appointment-scheduler__panel textarea.form-control {
  min-height: 96px;
}

.h4h-form .form-control::placeholder,
.contact .php-email-form.h4h-form .form-control::placeholder {
  color: var(--h4h-field-hint);
  opacity: 1;
}

.contact .php-email-form.h4h-form .form-control {
  border-color: var(--h4h-field-border);
  padding: 12px 14px;
}

/* ── Labels and errors ───────────────────────────────────────────── */
.h4h-field {
  display: grid;
  gap: 6px;
  text-align: left;
}

.h4h-field__label {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--default-color);
}

.h4h-field__optional {
  font-weight: 400;
  color: var(--h4h-field-hint);
}

.h4h-field__error {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--h4h-error);
}

.h4h-form [aria-invalid="true"].form-control,
.h4h-form [aria-invalid="true"].form-select,
.contact .php-email-form.h4h-form [aria-invalid="true"].form-control {
  border-color: var(--h4h-error);
  box-shadow: 0 0 0 1px var(--h4h-error);
}

.h4h-field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.h4h-form__group-title {
  color: var(--default-color);
  margin: 8px 0 -4px;
  font-size: 1rem;
  font-weight: 700;
  text-align: left;
}

/* Headings that receive focus when a step changes: no focus box */
.h4h-form h2[tabindex="-1"]:focus,
.h4h-form h3[tabindex="-1"]:focus {
  outline: none;
}

/* Clear keyboard focus ring on everything else */
.h4h-form :is(input, select, textarea, button, a):focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent-color), transparent 35%);
  outline-offset: 2px;
}

/* ── Checkboxes and radios: big enough to tap ────────────────────── */
.h4h-check {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  align-items: start;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--h4h-field-border);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  font-size: 0.95rem;
}

.h4h-check input,
.h4h-sms-consent input,
.appointment-contact-method input {
  width: 22px;
  height: 22px;
  margin: 1px 0 0;
  accent-color: var(--accent-color);
  cursor: pointer;
}

.appointment-contact-method {
  gap: 8px;
}

.appointment-contact-method label {
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--h4h-field-border);
  border-radius: 10px;
  cursor: pointer;
  font-size: 1rem;
}

.appointment-contact-method label:has(input:checked) {
  border-color: var(--accent-color);
  background: color-mix(in srgb, var(--accent-color), transparent 90%);
}

.appointment-contact-method[aria-invalid="true"] label {
  border-color: var(--h4h-error);
}

/* ── SMS consent (two optional boxes, A2P wording) ───────────────── */
.h4h-sms-consent {
  display: grid;
  gap: 10px;
  margin: 4px 0 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.h4h-sms-consent__legend {
  float: none;
  width: auto;
  margin: 0 0 2px;
  padding: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--default-color);
}

.h4h-sms-consent__option {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid var(--h4h-field-border);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  font-size: 0.8rem;
  line-height: 1.5;
  color: color-mix(in srgb, var(--default-color), transparent 15%);
}

.h4h-sms-consent__option:has(input:checked) {
  border-color: var(--accent-color);
  background: color-mix(in srgb, var(--accent-color), transparent 92%);
}

.h4h-sms-consent a {
  color: var(--accent-color);
  text-decoration: underline;
}

/* ── Status messages ─────────────────────────────────────────────── */
.h4h-form .error-message {
  background: var(--h4h-error-bg);
  color: var(--h4h-error);
  border: 1px solid color-mix(in srgb, var(--h4h-error), transparent 60%);
}

/* ── Buttons: 44px minimum ──────────────────────────────────────── */
.appointment-back-btn {
  min-height: 44px;
  padding: 8px 20px;
}

.quote-modal__close {
  width: 44px;
  height: 44px;
}

.h4h-form .btn-appointment,
.contact .php-email-form.h4h-form button[type="submit"] {
  min-height: 48px;
}

/* ── Book a Consultation summary ────────────────────────────────── */
.appointment-scheduler__picked {
  font-size: 1.05rem;
  line-height: 1.5;
}

/* ── Get A Quote pop-up ─────────────────────────────────────────── */
/* dvh = the visible height on phones (excludes the browser bars and keyboard) */
.quote-modal__panel {
  max-height: calc(100dvh - 24px);
  overscroll-behavior: contain;
}

.quote-modal .quote-step-body .h4h-field {
  gap: 6px;
}

/* Back / Next always visible at the bottom of the pop-up, even when a step
   is taller than the screen (the step scrolls under them) */
.quote-modal .quote-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin: 18px -34px -34px;
  padding: 14px 34px calc(14px + env(safe-area-inset-bottom, 0px));
  background: var(--surface-color);
  border-top: 1px solid var(--h4h-field-border);
}

/* Phones: the pop-up is a full-height sheet, so nothing hides behind the
   site header and no page scrolling is ever needed */
@media (max-width: 767px) {
  .quote-modal {
    align-items: stretch;
    padding: 0;
  }

  .quote-modal__panel {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .quote-modal .quote-form {
    display: flex;
    flex-direction: column;
    min-height: 100%;
  }

  .quote-modal__content {
    flex: 1;
    padding: 20px 18px 0;
  }

  .quote-modal .quote-actions {
    margin: auto -18px 0; /* "auto" pushes the buttons to the bottom on short steps */
    padding: 12px 18px calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .quote-modal__close {
    top: 10px;
    right: 10px;
  }

  .quote-modal__content h2 {
    font-size: 1.6rem;
    margin-bottom: 14px;
  }
}

/* ── Dark mode ──────────────────────────────────────────────────── */
/* Light arrow on dark dropdowns (Bootstrap draws a dark one by default) */
html[data-theme="dark"] .form-select {
  --bs-form-select-bg-img: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23d4dbe1' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}

/* Calendar icon in date fields */
html[data-theme="dark"] .h4h-form input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.85);
}

/* ── Phones ─────────────────────────────────────────────────────── */
@media (max-width: 575px) {
  .h4h-field-row {
    grid-template-columns: 1fr;
  }

  .contact .php-email-form.h4h-form {
    padding: 20px 16px;
  }
}

/* Respect "reduce motion" settings */
@media (prefers-reduced-motion: reduce) {
  .h4h-form *,
  .quote-modal * {
    transition: none !important;
    animation: none !important;
  }
}
