/* ============================================================
   Form visual language (GDS-derived). The single source of truth
   for every form outside the progress boards.
   Spec: docs/superpowers/specs/2026-07-02-form-visual-language-design.md
   ============================================================ */

:root {
  --form-measure: 30rem;       /* 480px: the one standard form width */
  --form-measure-wide: 35rem;  /* 560px: dense forms only */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 16px;
  --sp-4: 24px;
  --sp-5: 32px;
  --focus-yellow: #FFDD00;      /* the one imported GDS colour */
}

/* --- Section heading (site serif, one consistent size) ----- */
.form-section {
  font-family: var(--display);
  font-weight: 600;
  font-size: 20px;
  line-height: 1.2;
  margin: var(--sp-4) 0 var(--sp-3);   /* breathing room above headings */
}

/* --- Stacked form container -------------------------------- */
/* A form panel fills its content column: every light-background panel on a
   page shares one width, and its controls fill it (no stranded 480px islands).
   Card chrome matches the app idiom (radius 12 + soft shadow, like .proj-card). */
.form {
  display: grid;
  /* Auto two columns only when the panel is wide enough for two ~26rem fields;
     stays single column on a normal-width column (supporters) and flows to two
     on a wide one (Us). No per-page classes needed. */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr));
  gap: var(--sp-3) var(--sp-4);
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: var(--sp-4);
  box-shadow: 0 6px 20px rgba(28, 28, 24, 0.05);
}
.form--plain { background: none; border: 0; border-radius: 0; padding: 0; box-shadow: none; }

/* Headings, textareas, and actions always span the full width of the form,
   so only short single-line fields ever pair up into two columns. */
.form > .form-section,
.form > label:has(textarea),
.form > .full,
.form > button,
.form > .btn,
.form > .form-actions {
  grid-column: 1 / -1;
}

/* --- Field group: the wrapping <label> is the group -------- */
.form label:not(.form-check),
.form-group > label,
.form-label {
  display: grid;
  gap: var(--sp-1);
  font-family: var(--body);
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
}
.form-group { display: grid; gap: var(--sp-1); }
.form .hint, .form-group .hint { font-size: 13px; font-weight: 400; color: var(--muted); margin: 0; }

/* Inline checkbox/radio label: keep control and text on one line */
.form-check {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-weight: 500;
}

/* --- Controls ---------------------------------------------- */
.form input:not([type=checkbox]):not([type=radio]),
.form select,
.form textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-family: var(--body);
  font-size: 14px;
  color: var(--ink);
  background: #fff;
}
.form input:hover:not([type=checkbox]):not([type=radio]),
.form select:hover,
.form textarea:hover { border-color: var(--ink); }

/* The GDS yellow focus highlight, on every control and button */
.form input:focus,
.form select:focus,
.form textarea:focus,
.form-inline input:focus,
.form-inline select:focus,
.btn:focus-visible {
  outline: 3px solid var(--focus-yellow);
  outline-offset: 0;
  box-shadow: inset 0 0 0 2px var(--ink);
}

/* --- Error state (the only home for --danger on forms) ----- */
.form-group--error { border-left: 3px solid var(--danger); padding-left: var(--sp-2); }
.form-error { color: var(--danger); font-size: 13px; margin: 0; }

/* --- Actions row ------------------------------------------- */
.form-actions { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }

/* --- Buttons: three variants, nothing else ----------------- */
.btn {
  display: inline-block;
  font-family: var(--body);
  font-weight: 600;
  font-size: 14px;
  line-height: 1;
  padding: 11px 16px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 2px 0 rgba(0,0,0,0.22);   /* GDS press shadow */
  transition: transform .04s ease, box-shadow .04s ease;
}
.btn:active { transform: translateY(2px); box-shadow: 0 0 0 rgba(0,0,0,0); }
.btn--primary { background: var(--green); color: #fff; }
.btn--secondary {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: 0 2px 0 var(--line);
}
.btn--link {
  background: none;
  box-shadow: none;
  padding: 6px 4px;
  color: var(--muted);
  font-weight: 500;
  text-decoration: underline;
}
.btn--link:active { transform: none; }

/* --- Inline add-bar ---------------------------------------- */
/* Fills its column too; the input(s) grow, the button stays put on the right. */
.form-inline {
  display: flex;
  gap: var(--sp-2);
  align-items: end;
  flex-wrap: wrap;
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 var(--sp-3);
}
.form-inline--full { max-width: none; }
.form-inline input,
.form-inline select {
  flex: 1 1 12ch;
  min-width: 0;
  box-sizing: border-box;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-family: var(--body);
  font-size: 14px;
  background: #fff;
}
.form-inline .btn { flex: 0 0 auto; }
