/* ==========================================================
   WEB360 — Form Module (v1)
   Scope: Homepage form slots (form_module_1 .. form_module_6).
   Uses ONLY existing design tokens (00-tokens.css). No new variables.
   ========================================================== */

.form-module {
  padding: 60px 0;
  background: var(--mt-neutral-0, #ffffff);
  color: var(--mt-neutral-900, #0f172a);
}

/* ── Layout variants ── */
.form-module--contained { padding-left: 16px; padding-right: 16px; }
.form-module--full      { padding: 60px 0; }
.form-module--boxed     { padding: 40px 16px; }

/* ── Theme variants ── */
.form-module--neutral {
  background: var(--mt-neutral-50, #f8fafc);
}
.form-module--primary {
  background: var(--mt-brand-primary-soft, #FEF1E8);
}
.form-module--dark {
  background: var(--mt-neutral-900, #0f172a);
  color: var(--mt-neutral-50, #f8fafc);
}
.form-module--dark .form-module__help,
.form-module--dark .form-module__subtitle {
  color: var(--mt-neutral-300, #cbd5e1);
}

/* ── Inner container ── */
.form-module__inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 16px;
}
.form-module--boxed .form-module__inner {
  background: var(--mt-neutral-0, #ffffff);
  padding: 32px;
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(15, 23, 42, .06);
}

/* ── Heading ── */
.form-module__heading {
  text-align: center;
  margin-bottom: 28px;
}
.form-module__title {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 6px;
  line-height: 1.2;
}
.form-module__subtitle {
  color: var(--mt-neutral-600, #475569);
  font-size: 1rem;
  margin: 0;
}

/* ── Section grouping ────────────────────────────────────────────────
   A single-step form has exactly ONE section and looks exactly as it
   always has. A multi-step (wizard) form has one section PER STEP;
   _form_module_render.php gives every section after the first a native
   `hidden` attribute at render time, and form-module.js toggles that
   same attribute as the visitor moves through the wizard — one real
   <form>, one real submission, no second renderer, no page reload.
   flex+wrap is what makes layout.width (half/third, below) possible:
   every direct child defaults to a full-width "row" (flex-basis:100%),
   and a field opts into sharing a row only via its own width class. */
.form-module__section {
  background: var(--mt-neutral-0, #ffffff);
  border: 1px solid var(--mt-neutral-200, #e2e8f0);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 18px 16px;
}
/* Belt-and-braces: the UA stylesheet already makes [hidden] "display:none"
   with no CSS needed, but this survives even if a future rule ever gives
   .form-module__section its own competing `display`. */
.form-module__section[hidden] { display: none; }
.form-module__section:last-of-type { margin-bottom: 16px; }
.form-module__section > * { flex: 1 1 100%; min-width: 0; }
.form-module__section-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--mt-brand-primary, #E05A1A);
  margin: 0;
  padding: 0 0 10px;
  border-bottom: 2px solid var(--mt-neutral-200, #e2e8f0);
  letter-spacing: .01em;
}
.form-module__section-title:focus { outline: none; } /* programmatic focus target only (wizard step change) — never a click target */
.form-module__section-description {
  color: var(--mt-neutral-600, #475569);
  font-size: .9rem;
  margin: -8px 0 0;
}
@media (max-width: 640px) {
  .form-module__section { padding: 18px 16px; margin-bottom: 16px; gap: 14px; }
  .form-module__section-title { font-size: 1.1rem; }
}

/* ── Field layout width (Form Foundation Contract) ───────────────────
   Generic, field-key-agnostic — works for any current or future form.
   Default (no class) is full width; half/third only ever pull a field
   INTO a shared row with its neighbours, they never change a field's
   own internal content. Collapses to full width below 640px so nothing
   ever gets cramped on a phone. */
.form-module__field--half  { flex-basis: calc(50% - 8px); }
.form-module__field--third { flex-basis: calc(33.333% - (16px * 2 / 3)); }
@media (max-width: 640px) {
  .form-module__field--half,
  .form-module__field--third { flex-basis: 100%; }
}

/* ── Group label (Form Foundation Contract) ──────────────────────────
   A plain heading line before a run of consecutive same-group fields —
   never a bordered box or nested component, so a short form with one
   group doesn't suddenly look like a different, heavier product. */
.form-module__group-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--mt-neutral-500, #64748b);
  margin: 4px 0 -6px;
}
.form-module__group-label:first-child { margin-top: 0; }

/* ── Fields ── */
.form-module__field {
  margin-bottom: 0; /* spacing now comes from .form-module__section's own `gap` */
}
.form-module__label {
  display: block;
  font-size: .9rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: inherit;
}
.form-module__label .form-module__req {
  color: var(--mt-danger, #ef4444);
  margin-left: 2px;
}
.form-module__help {
  font-size: .78rem;
  color: var(--mt-neutral-500, #64748b);
  margin-top: 4px;
}
.form-module__heading-divider {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 24px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--mt-neutral-200, #e2e8f0);
}

/* ── Inputs ── */
.form-module__input,
.form-module__textarea,
.form-module__select {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  line-height: 1.4;
  border: 1px solid var(--mt-neutral-300, #cbd5e1);
  border-radius: 8px;
  background: var(--mt-neutral-0, #ffffff);
  color: var(--mt-neutral-900, #0f172a);
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
.form-module__textarea { min-height: 120px; resize: vertical; }
.form-module__input:focus,
.form-module__textarea:focus,
.form-module__select:focus {
  outline: none;
  border-color: var(--mt-brand-primary, #E05A1A);
  box-shadow: 0 0 0 3px rgba(var(--mt-brand-primary-rgb, 224, 90, 26), .15);
}
.form-module__input.has-error,
.form-module__textarea.has-error,
.form-module__select.has-error {
  border-color: var(--mt-danger, #ef4444);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .12);
}
/* Field-level error highlight: makes labels go red across ALL field types
   (including radio/checkbox where the inputs themselves don't carry the
   has-error class). Visible cue without altering layout. */
.form-module__field.has-error > .form-module__label {
  color: var(--mt-danger, #ef4444);
}
.form-module__field.has-error .form-module__option {
  border-color: var(--mt-danger, #ef4444);
}

/* ── Option lists (radio / checkbox) ── */
.form-module__options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.form-module__option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--mt-neutral-200, #e2e8f0);
  border-radius: 8px;
  cursor: pointer;
  transition: background-color .15s, border-color .15s;
  font-size: .95rem;
}
.form-module__option:hover {
  background: var(--mt-neutral-50, #f8fafc);
  border-color: var(--mt-neutral-300, #cbd5e1);
}
.form-module__option input { margin: 0; }

/* ── File ── */
.form-module__file-wrap {
  padding: 14px;
  border: 2px dashed var(--mt-neutral-300, #cbd5e1);
  border-radius: 10px;
  background: var(--mt-neutral-50, #f8fafc);
  font-size: .85rem;
}

/* ── Error messages ── */
.form-module__error {
  margin-top: 4px;
  font-size: .78rem;
  color: var(--mt-danger, #ef4444);
}
.form-module__flash {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 20px;
  font-size: .9rem;
  border: 1px solid;
}
.form-module__flash--success {
  background: var(--mt-success-soft, #f0fdf4);
  color: var(--mt-success, #22c55e);
  border-color: var(--mt-success, #22c55e);
}
.form-module__flash--danger {
  background: var(--mt-danger-soft, #fef2f2);
  color: var(--mt-danger, #ef4444);
  border-color: var(--mt-danger, #ef4444);
}

/* ── Controls ── */
/* ── Wizard progress (Form Foundation Contract) ──────────────────────
   Only rendered for a real multi-step form (2+ actual steps) — a
   single-step form has none of this markup at all, so it can never
   visually inherit a progress bar it has no use for. */
.form-module__progress { margin-bottom: 24px; }
.form-module__progress-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--mt-neutral-200, #e2e8f0);
  overflow: hidden;
}
.form-module__progress-fill {
  height: 100%;
  background: var(--mt-brand-primary, #E05A1A);
  border-radius: inherit;
  transition: width .25s ease;
}
@media (prefers-reduced-motion: reduce) {
  .form-module__progress-fill { transition: none; }
}
.form-module__progress-text {
  margin: 8px 0 0;
  font-size: .82rem;
  font-weight: 600;
  color: var(--mt-neutral-600, #475569);
  text-align: center;
}

.form-module__controls,
.form-module__wizard-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}
.form-module__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background-color .15s, border-color .15s, transform .05s;
}
.form-module__btn:active { transform: translateY(1px); }
.form-module__btn--primary {
  background: var(--mt-brand-primary, #E05A1A);
  color: #fff;
}
.form-module__btn--primary:hover {
  background: var(--mt-brand-primary-hover, #C84F16);
}
.form-module__btn--secondary {
  background: transparent;
  color: inherit;
  border-color: var(--mt-neutral-300, #cbd5e1);
}
.form-module__btn--secondary:hover {
  background: var(--mt-neutral-100, #f1f5f9);
}

/* (Step visibility classes removed — single-page form: all fields visible) */

/* ── Reset row ("Start Over") ── */
.form-module__reset-row {
  text-align: center;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--mt-neutral-200, #e2e8f0);
}
.form-module__btn--reset {
  font-size: 0.85rem;
  padding: 8px 18px;
  font-weight: 500;
}

/* ── Draft indicator ── */
.form-module__draft-note {
  font-size: .75rem;
  color: var(--mt-neutral-500, #64748b);
  text-align: center;
  margin-top: 10px;
}

/* ── Honeypot: visually & off-screen ── */
.form-module__hp {
  position: absolute !important;
  left: -10000px !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .form-module { padding: 40px 0; }
  .form-module__title { font-size: 1.45rem; }
  .form-module__controls,
  .form-module__wizard-nav { flex-direction: column-reverse; align-items: stretch; }
  .form-module__btn { justify-content: center; }
}

/* ── Per-field overrides (data-field-key scoped) ────────────────────
   Phase 3 review (Form Foundation Contract): kept, not removed. The new
   generic `layout.width` system (half/third, above) controls a FIELD's
   width relative to its SIBLINGS — a different axis entirely from what
   these two hacks solve, which is the arrangement of the OPTIONS *inside
   one* checkbox/radio field (Mon–Fri on one row; a consent checkbox
   sitting inline before its own label). Nothing in the Phase 1-3
   contract represents "lay this field's own options out horizontally",
   so these remain the only mechanism for that, and are still exactly as
   field-key-specific as they always were. Confirmed unaffected by the
   new .form-module__section flex/gap layout above (that layout treats
   each of these AS a normal, single flex item — same 1-1-100% default
   row as always — and never reaches into either hack's own internal
   `display:flex` rule for its children).

   2026-05-15 — TASK 1-A: session_days inline layout (T1).
   Registration form (form_id=2) step 2 "Weekly Sessions" checkbox list
   should render Mon–Fri on a single row, wrapping to a max of 2 rows
   on narrow viewports. Scoped strictly via [data-field-key="session_days"]
   so no other radio/checkbox group is affected. */
[data-field-key="session_days"] .form-module__options {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px 20px;
}

[data-field-key="session_days"] .form-module__option {
    width: auto;
    min-width: unset;
}

/* ── TASK 1-B: consent_* fields — inline checkbox layout (T2 2026-05-15)
   Container is flex-wrap so .form-module__help and .form-module__error
   (default order=0 in source, forced to order=3 here) drop to a new line
   at 100% basis when present, instead of squeezing inline with the
   checkbox + label row. Label has min-width:200px so the wrap point is
   predictable on narrow viewports. */
[data-field-key^="consent_"] {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px;
}
[data-field-key^="consent_"] .form-module__label {
    order: 2;
    flex: 1;
    min-width: 200px;
    margin-bottom: 0;
    cursor: pointer;
    font-weight: 400;
}
[data-field-key^="consent_"] .form-module__options {
    order: 1;
    flex-shrink: 0;
    margin-top: 3px;
}
[data-field-key^="consent_"] .form-module__option span {
    display: none;
}
[data-field-key^="consent_"] .form-module__help,
[data-field-key^="consent_"] .form-module__error {
    order: 3;
    flex-basis: 100%;
}
