/* Form kit for the application page and any future form.
   Pieces: .form-section (fieldset + legend), .form-grid, .field (label, hint, error, control), .input / .select / .textarea,
   .choice-group + .choice (checkboxes and radios), .file-drop (CV upload), .form-actions.
   Validation: put aria-invalid="true" on the control and show the matching .field__error (give it an id and reference it in aria-describedby).
   Mark required fields with data-required on the label AND the required attribute on the control. */

.form-section { min-width: 0; margin: 0 0 var(--space-7); padding: 0; border: 0; }
.form-section__title { margin: 0 0 var(--space-1); padding: 0; font: 800 1.3rem/1.2 var(--font); letter-spacing: -.015em; }
.form-section__intro { margin: 0 0 var(--space-5); color: var(--muted); font-size: .98rem; }
.form-grid + .form-section__intro { margin-top: var(--space-5); }   /* an intro that follows a block of fields, not the section title */

.form-grid { display: grid; grid-template-columns: 1fr; gap: var(--space-5); }
@media (min-width: 640px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .field--full { grid-column: 1 / -1; }
}

/* ---- field ---- */
.field { display: grid; align-content: start; gap: 6px; min-width: 0; }
.field[hidden] { display: none; }   /* conditional fields (see join-form.js) */
.field__label { font-size: .95rem; font-weight: 700; }
.field__label[data-required]::after { content: " *"; color: var(--danger); }
.field__hint { margin: 0; color: var(--muted); font-size: .88rem; line-height: 1.45; }
.field__error { margin: 0; color: var(--danger); font-size: .88rem; font-weight: 600; line-height: 1.45; }
.field__error[hidden] { display: none; }

/* ---- text controls ---- */
.input, .select, .textarea { width: 100%; min-height: 48px; padding: 0 var(--space-4); border: 1.5px solid var(--line); border-radius: var(--radius-input);
  background: var(--bg); color: var(--ink); font: inherit; transition: border-color .15s, box-shadow .15s; }
.textarea { min-height: 128px; padding: var(--space-3) var(--space-4); line-height: 1.5; resize: vertical; }
.select { padding-right: 44px; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 22px) 50%, calc(100% - 16px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: 1; }
.input:hover, .select:hover, .textarea:hover { border-color: color-mix(in srgb, var(--teal) 55%, var(--line)); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--teal); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 30%, transparent); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-2); opacity: .65; cursor: not-allowed; }

.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); }
.input[aria-invalid="true"]:focus, .select[aria-invalid="true"]:focus, .textarea[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 25%, transparent); }

/* ---- checkboxes and radios ---- */
.choice-group { display: grid; gap: var(--space-3); min-width: 0; margin: 0; padding: 0; border: 0; }
.choice-group__legend { margin: 0 0 var(--space-2); padding: 0; font-size: .95rem; font-weight: 700; }
.choice-group__legend[data-required]::after { content: " *"; color: var(--danger); }
@media (min-width: 640px) { .choice-group--cols { grid-template-columns: 1fr 1fr; } .choice-group__legend { grid-column: 1 / -1; } }
.choice { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) 14px; border: 1.5px solid var(--line); border-radius: var(--radius-input); background: var(--bg); cursor: pointer; transition: border-color .15s, background .15s; }
.choice:hover { border-color: color-mix(in srgb, var(--teal) 55%, var(--line)); }
.choice:has(:checked) { border-color: var(--teal); background: color-mix(in srgb, var(--teal) 10%, var(--bg)); }
.choice:has(:disabled) { opacity: .6; cursor: not-allowed; }
.choice__input { flex: none; width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); }
.choice__text { font-size: .98rem; line-height: 1.45; }
.choice__text[data-required]::after { content: " *"; color: var(--danger); }   /* a required acknowledgement */

/* ---- file upload box (progressive enhancement by file-drop.js) ---- */
.file-drop { position: relative; display: block; }
.file-drop__input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-drop__body { display: grid; place-items: center; gap: 4px; min-height: 120px; padding: var(--space-4); border: 2px dashed var(--line); border-radius: var(--radius-input);
  background: var(--bg); color: var(--muted); text-align: center; transition: border-color .15s, background .15s; }
.file-drop__prompt strong { color: var(--ink); }
.file-drop__meta { font-size: .88rem; }
.file-drop__name { display: none; color: var(--ink); font-weight: 700; word-break: break-all; }
.file-drop:hover .file-drop__body, .file-drop.is-dragover .file-drop__body { border-color: var(--teal); background: color-mix(in srgb, var(--teal) 8%, var(--bg)); }
.file-drop__input:focus-visible + .file-drop__body { outline: 3px solid var(--focus); outline-offset: 3px; }
.file-drop.has-file .file-drop__body { border-style: solid; border-color: var(--teal); }
.file-drop.has-file .file-drop__name { display: block; }
.file-drop.has-file .file-drop__prompt { display: none; }
.file-drop__input[aria-invalid="true"] + .file-drop__body { border-color: var(--danger); }

.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4); margin-top: var(--space-6); }
.form-note { margin: 0; color: var(--muted); font-size: .88rem; }
.form-note[data-gate-note] { flex: 1 1 100%; color: var(--ink); font-weight: 600; }   /* says why the submit button is disabled */
