/* Generic form section — visual style matches the legacy hardcoded
 * forms (contact_form, volunteer_form, burn_form). Same .bf-* class
 * vocabulary, same theme tokens, same chrome (white card, accent
 * submit button, focus ring on inputs). Where this file diverges from
 * the legacy ones is the per-field row-width grid: .bf-fields is a
 * 12-column CSS grid so the admin's full / half / third picks let
 * fields share lines until they overflow.
 *
 * Everything is scoped under .section-form so this file can sit on a
 * page alongside any of the legacy form sections without bleeding into
 * them. The runtime (forms-runtime.js) emits markup in the same shape
 * the .bf-* class names expect.
 */

.section-form .section-inner {
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.section-form .form-section-loading,
.section-form .form-section-error {
  margin: 0;
  font-style: italic;
  color: var(--color-muted);
}

.section-form .form-section-error {
  color: var(--color-danger, #b91c1c);
  font-style: normal;
}

/* ─── Card chrome (matches contact_form's .bf-card) ───────────────── */

.section-form .bf-card {
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-lg);
  box-shadow: var(--shadow);
}

.section-form .bf-card h2 {
  font-size: var(--font-lg);
  margin: 0 0 var(--space-xs);
  color: var(--color-heading);
}

.section-form .bf-intro {
  margin: 0 0 var(--space-md);
  font-size: var(--font-sm);
  color: var(--color-muted);
}

.section-form .bf-req { color: var(--color-accent); }

/* ─── Form layout — 12-column grid for per-field widths ──────────── */

.section-form .bf-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.section-form .bf-fields {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--space-md);
  align-items: start;
}

.section-form .bf-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  grid-column: span 12;
  min-width: 0;
}

.section-form .bf-field-w-three-quarter { grid-column: span 9; }
.section-form .bf-field-w-half          { grid-column: span 6; }
.section-form .bf-field-w-third         { grid-column: span 4; }
.section-form .bf-field-w-quarter       { grid-column: span 3; }

/* Turnstile widget + the default submit-row both render inside
   .bf-fields and should claim a full row of their own. The inline
   variant of the submit row (bf-actions-inline) opts out of the
   full-row default and shrinks to a quarter-width grid item so it
   flows inline with adjacent fields. */
.section-form .cf-turnstile-wrap,
.section-form .bf-actions {
  grid-column: span 12;
}

.section-form .bf-actions.bf-actions-inline {
  grid-column: span 3;
  /* Bottom-align so the button visually rests at the same baseline
     as the input bottoms in adjacent fields (those fields have a
     label above, the submit button doesn't). */
  align-self: end;
  /* Default .bf-actions is right-aligned; when inline the row holds
     just one button and we want it to fill the cell so it reads as a
     quarter-width field rather than a tiny right-floated button. */
  justify-content: stretch;
}

.section-form .bf-actions.bf-actions-inline .bf-btn {
  width: 100%;
}

/* Mobile: every field (and the inline submit) gets the full row. */
@media (max-width: 600px) {
  .section-form .bf-field-w-three-quarter,
  .section-form .bf-field-w-half,
  .section-form .bf-field-w-third,
  .section-form .bf-field-w-quarter,
  .section-form .bf-actions.bf-actions-inline {
    grid-column: span 12;
  }
  .section-form .bf-actions.bf-actions-inline { justify-content: flex-end; }
}

.section-form .bf-field > label {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--color-text);
}

/* ─── Inputs ──────────────────────────────────────────────────────── */

.section-form .bf-input {
  width: 100%;
  padding: 10px var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--color-text);
  font-size: var(--font-md);
  font-family: var(--font-body);
  line-height: 1.3;
  min-height: 44px;
}

.section-form .bf-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(29, 47, 71, 0.18);
}

.section-form .bf-textarea {
  min-height: 140px;
  resize: vertical;
  font-family: var(--font-body);
}

/* Native <select> using the same chrome. The dropdown chevron is
   rendered as a background-image so the field height matches inputs. */
.section-form .bf-select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 20 20' fill='none' stroke='%231d2f47' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='5 8 10 13 15 8'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px 14px;
  padding-right: 36px;
}

/* ─── Buttons ─────────────────────────────────────────────────────── */

.section-form .bf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  min-height: 44px;
  padding: 10px var(--space-lg);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-size: var(--font-sm);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.section-form .bf-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.section-form .bf-btn--primary {
  background: var(--color-accent);
  color: var(--color-accent-fg);
}

.section-form .bf-btn--primary:hover:not(:disabled) {
  background: var(--color-accent-hover);
}

.section-form .bf-btn--secondary {
  background: var(--color-primary);
  color: var(--color-primary-fg);
}

.section-form .bf-btn--secondary:hover:not(:disabled) {
  background: #243a59;
}

.section-form .bf-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

/* Submit row — primary button right-aligned, error message inline. */
.section-form .bf-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
  justify-content: flex-end;
}

/* Form-wide error banner above the fields. Matches the
   .bf-form-error styling from contact_form.css. */
.section-form .bf-error {
  margin: 0;
  padding: 10px var(--space-md);
  background: rgba(185, 28, 28, 0.08);
  border: 1px solid rgba(185, 28, 28, 0.4);
  color: #b91c1c;
  border-radius: var(--radius);
  font-size: var(--font-sm);
}

/* Success banner — shown below the form on success. Same chrome as
   contact_form's .bf-banner--success. */
.section-form .bf-success {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius);
  border: 1px solid rgba(56, 161, 105, 0.5);
  background: rgba(56, 161, 105, 0.08);
  color: var(--color-heading);
  font-weight: 600;
}

/* ─── Choices field (checkbox / radio / select) ──────────────────── */

.section-form .bf-choices {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 0;
}

/* Inline lay-out for short-label option lists. */
.section-form .bf-choices.bf-choices-checkbox,
.section-form .bf-choices.bf-choices-radio {
  flex-direction: row;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.section-form .bf-choice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: var(--font-md);
  color: var(--color-text);
}

.section-form .bf-choice input[type="checkbox"],
.section-form .bf-choice input[type="radio"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--color-primary);
  cursor: pointer;
}

/* When the runtime renders choices as a select, give it the bf-input
   chrome plus the chevron from .bf-select. */
.section-form select.bf-input {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 20 20' fill='none' stroke='%231d2f47' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='5 8 10 13 15 8'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px 14px;
  padding-right: 36px;
  font-weight: 600;
}

/* ─── Toggle field (single boolean) ──────────────────────────────── */

.section-form .bf-field-toggle {
  align-items: flex-start;
}

.section-form .bf-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-md);
  color: var(--color-text);
  cursor: pointer;
  padding: 6px 0;
}

.section-form .bf-toggle-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--color-primary);
  cursor: pointer;
}

/* ─── File field ─────────────────────────────────────────────────── */

.section-form .bf-file {
  font-size: var(--font-sm);
  padding: 10px var(--space-md);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  cursor: pointer;
}

.section-form .bf-file:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.section-form .bf-file-status {
  margin-top: 6px;
  font-size: var(--font-sm);
  color: var(--color-muted);
  min-height: 1.4em;
}

.section-form .bf-file-status:not(:empty) {
  color: var(--color-text);
}

/* ─── GPS field ──────────────────────────────────────────────────── */

.section-form .bf-gps {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.section-form .bf-gps-button {
  align-self: flex-start;
}

.section-form .bf-gps-status {
  font-size: var(--font-sm);
  color: var(--color-muted);
}

.section-form .bf-gps-status:not(:empty):not([data-empty]) {
  color: var(--color-text);
}

/* ─── Turnstile wrap ─────────────────────────────────────────────── */

.section-form .cf-turnstile-wrap > div {
  min-height: 65px;
}

/* ─── Date / number / native pickers — use the bf-input chrome ───── */

.section-form input[type="date"].bf-input,
.section-form input[type="number"].bf-input,
.section-form input[type="tel"].bf-input,
.section-form input[type="email"].bf-input {
  font-family: var(--font-body);
}
