/* hdpf-form.css — form fields, checkbox, radio, toggle.
 *
 * Variants: default, error, disabled
 */

.hdpf-field {
  display: flex;
  flex-direction: column;
  gap: var(--hdpf-space-2);
  width: 100%;
  max-width: 28rem;
}

.hdpf-field__label {
  font-size: var(--hdpf-fs-caption);
  font-weight: var(--hdpf-fw-semibold);
  color: var(--hdpf-ink-strong);
}

.hdpf-field__hint {
  font-size: var(--hdpf-fs-micro);
  color: var(--hdpf-ink-muted);
}

.hdpf-field__error {
  font-size: var(--hdpf-fs-micro);
  color: var(--hdpf-danger-fg);
}

.hdpf-field__control {
  position: relative;
  display: flex;
  align-items: center;
}

.hdpf-input,
.hdpf-textarea,
.hdpf-select {
  width: 100%;
  min-height: var(--hdpf-touch-target);
  padding: var(--hdpf-space-2) var(--hdpf-space-3);
  border: 1px solid var(--hdpf-border-strong);
  border-radius: var(--hdpf-radius-md);
  background: var(--hdpf-surface);
  color: var(--hdpf-ink);
  transition:
    border-color var(--hdpf-duration-fast) var(--hdpf-ease-standard),
    box-shadow var(--hdpf-duration-fast) var(--hdpf-ease-standard);
}

.hdpf-input::placeholder,
.hdpf-textarea::placeholder {
  color: var(--hdpf-ink-faint);
}

.hdpf-input:hover,
.hdpf-textarea:hover,
.hdpf-select:hover {
  border-color: var(--hdpf-accent);
}

.hdpf-input:focus-visible,
.hdpf-textarea:focus-visible,
.hdpf-select:focus-visible {
  outline: 2px solid var(--hdpf-focus-outline);
  outline-offset: 2px;
  border-color: var(--hdpf-accent);
  box-shadow: var(--hdpf-shadow-ring-accent);
}

.hdpf-textarea {
  min-height: 6rem;
  resize: vertical;
  line-height: var(--hdpf-lh-normal);
}

.hdpf-select {
  appearance: none;
  padding-right: var(--hdpf-space-8);
  background-image: linear-gradient(45deg, transparent 50%, var(--hdpf-ink-muted) 50%),
    linear-gradient(135deg, var(--hdpf-ink-muted) 50%, transparent 50%);
  background-position:
    calc(100% - 1.1rem) 50%,
    calc(100% - 0.75rem) 50%;
  background-size: 0.35rem 0.35rem, 0.35rem 0.35rem;
  background-repeat: no-repeat;
}

.hdpf-field--error .hdpf-input,
.hdpf-field--error .hdpf-textarea,
.hdpf-field--error .hdpf-select {
  border-color: var(--hdpf-danger);
}

.hdpf-field--error .hdpf-input:focus-visible,
.hdpf-field--error .hdpf-textarea:focus-visible,
.hdpf-field--error .hdpf-select:focus-visible {
  outline-color: var(--hdpf-danger);
  box-shadow: 0 0 0 3px var(--hdpf-danger-soft);
}

.hdpf-input:disabled,
.hdpf-textarea:disabled,
.hdpf-select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: var(--hdpf-surface-inset);
}

.hdpf-field__leading {
  position: absolute;
  left: var(--hdpf-space-3);
  color: var(--hdpf-ink-muted);
  pointer-events: none;
}

.hdpf-field__control:has(.hdpf-field__leading) .hdpf-input {
  padding-left: var(--hdpf-space-8);
}

/* Checkbox & radio */
.hdpf-check,
.hdpf-radio {
  display: inline-flex;
  align-items: flex-start;
  gap: var(--hdpf-space-2);
  cursor: pointer;
  font-size: var(--hdpf-fs-body);
  color: var(--hdpf-ink);
}

.hdpf-check input,
.hdpf-radio input {
  width: 1.125rem;
  height: 1.125rem;
  margin-top: 0.2rem;
  accent-color: var(--hdpf-accent);
  flex-shrink: 0;
}

.hdpf-check:has(input:disabled),
.hdpf-radio:has(input:disabled) {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Toggle / switch */
.hdpf-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--hdpf-space-3);
  cursor: pointer;
}

.hdpf-toggle__track {
  position: relative;
  width: 2.75rem;
  height: 1.5rem;
  border-radius: var(--hdpf-radius-pill);
  background: var(--hdpf-border-strong);
  transition: background-color var(--hdpf-duration-fast) var(--hdpf-ease-standard);
  flex-shrink: 0;
}

.hdpf-toggle__thumb {
  position: absolute;
  top: 0.15rem;
  left: 0.15rem;
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 50%;
  background: var(--hdpf-surface);
  box-shadow: var(--hdpf-shadow-xs);
  transition: transform var(--hdpf-duration-fast) var(--hdpf-ease-standard);
}

.hdpf-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.hdpf-toggle input:checked + .hdpf-toggle__track {
  background: var(--hdpf-accent);
}

.hdpf-toggle input:checked + .hdpf-toggle__track .hdpf-toggle__thumb {
  transform: translateX(1.25rem);
}

.hdpf-toggle input:focus-visible + .hdpf-toggle__track {
  outline: 2px solid var(--hdpf-focus-outline);
  outline-offset: 2px;
}

.hdpf-toggle:has(input:disabled) {
  opacity: 0.55;
  cursor: not-allowed;
}

.hdpf-toggle__label {
  font-size: var(--hdpf-fs-body);
  color: var(--hdpf-ink);
}

/* ================================================================== *
 * Simple form shell — the single-step forms (general inquiry, client
 * support) built from the form registry (app/components/forms.php).
 * A surface card on a page; chrome-free inside a modal (the modal body
 * already frames it). The consult form keeps its own stepped shell.
 * ================================================================== */
.hdpf-simple-form {
  display: flex;
  flex-direction: column;
  gap: var(--hdpf-space-5);
  padding: var(--hdpf-space-7);
  background: var(--hdpf-surface);
  border: 1px solid var(--hdpf-border);
  border-radius: var(--hdpf-radius-xl);
  box-shadow: var(--hdpf-shadow-sm);
}

.hdpf-simple-form--modal {
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.hdpf-simple-form__head { display: flex; flex-direction: column; gap: var(--hdpf-space-1); }

.hdpf-simple-form__head h2 {
  margin: 0;
  font-family: var(--hdpf-font-display);
  font-size: var(--hdpf-fs-headline);
  color: var(--hdpf-ink-strong);
}

.hdpf-simple-form__hint {
  margin: 0;
  color: var(--hdpf-ink-muted);
  font-size: var(--hdpf-fs-caption);
}

/* Fields fill the shell (the 28rem cap is for inline forms, not these). */
.hdpf-simple-form .hdpf-field { max-width: none; }

.hdpf-simple-form__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--hdpf-space-3);
}

/* Narrow container for a standalone form page (general inquiry / client
 * support dedicated pages). Keeps the card at a comfortable reading width. */
.hdpf-form-narrow {
  max-width: 40rem;
  margin-inline: auto;
}

/* ================================================================== *
 * Cloudflare Turnstile widget
 * Managed mode renders a fixed ~300x65 box only when a challenge is
 * shown (invisible otherwise). It's a direct child of the form, so the
 * form's flex `gap` already spaces it from the consent row / submit
 * button — we only need to center it and keep the fixed-width iframe
 * from forcing the layout wider than its container. Narrow-modal fitting
 * lives in hdpf-modal.css (that's where the tight container is).
 * ================================================================== */
.cf-turnstile {
  display: flex;
  justify-content: center;
  /* width:100% + min-width:0 make the widget box shrink to the container so the
   * fixed-width iframe is centred relative to the container (not left-anchored),
   * which keeps any overflow symmetric instead of shearing one edge. */
  width: 100%;
  min-width: 0;
}
