/* v5 forms -- the four intake forms in the v5 design language.
 *
 * Designed 2026-10-01 because v5.css had no form styling at all, and the
 * designer's handoff never drew a form. Loaded only by pages that carry one,
 * after v5.css, and scoped entirely under .v5-form.
 *
 * STYLING ONLY. Not one element, attribute or class of the form markup changes:
 * the markup comes from src/lib/*Form.mjs exactly as before, so every hidden
 * field id, every consent sentence and everything check-form-wiring pins is
 * untouched. The outer <form> gains the class v5-form, which nothing in
 * form-relay.js or the checks reads.
 *
 * The register: a form here is Daniel asking questions, so the questions are set
 * in the reading face (Newsreader), and the dream itself is written in the face it
 * will be read in. Controls -- inputs, notes, buttons -- are DM Sans, as
 * everywhere else in v5.
 *
 * Contrast, measured rather than eyeballed: field and chip borders are #857a63,
 * 3.5-4.0:1 against every ground they sit on (WCAG 1.4.11 asks 3:1). The v5
 * rule colour, #d6bf94, is 1.5:1 and would have failed. Placeholder text 4.7:1.
 */

.v5-form{max-width:680px;margin:0;font-family:var(--v5-sans);color:var(--v5-body)}
.v5-form{--f-border:#857a63;--f-fill:var(--v5-cream-3);--f-radius:8px}
/* Send button: evergreen, Daniel's choice (option B, 2026-10-25). Kept here, not in
   v5.css, so no page outside the four forms can pick it up. Cream on #224f3c is
   8.29:1; on the hover #1a3e2f, 10.52:1. */
.v5-form{--f-send:#224f3c;--f-send-deep:#1a3e2f}

/* ---- sections ------------------------------------------------------------ */
.v5-form fieldset{margin:0;padding:36px 0 0;border:0;border-top:1px solid var(--v5-rule);min-width:0}
.v5-form fieldset:first-of-type{padding-top:0;border-top:0}
.v5-form fieldset + fieldset,.v5-form details + fieldset,.v5-form fieldset + details{margin-top:40px}
/* A browser draws a legend INSIDE the fieldset's top border, so the rule ran out
   to the right of every section heading. Floated, the legend is an ordinary block
   below the rule; the clear keeps what follows from wrapping beside it. */
.v5-form fieldset > legend + *{clear:both}
/* the folded section already draws a rule beneath itself */
.v5-form details + fieldset{border-top:0;padding-top:12px}
/* a note under a section heading is a sentence, not more capitals */
.v5-form legend .field-note{display:block;margin:8px 0 0;font-size:14.5px;font-weight:400;
  letter-spacing:0;text-transform:none;color:var(--v5-muted-2)}
.v5-form legend{float:left;width:100%;padding:0;margin:0 0 22px;font-family:var(--v5-sans);font-size:13px;font-weight:500;
  letter-spacing:.26em;text-transform:uppercase;color:var(--v5-gold)}

/* ---- one question -------------------------------------------------------- */
.v5-form .field{display:flex;flex-direction:column;gap:8px;margin:0 0 28px}
.v5-form .field > label,.v5-form .choice-field > legend{
  font-family:var(--v5-serif);font-size:20px;line-height:1.35;color:var(--v5-ink)}
.v5-form .field-note{display:block;font-family:var(--v5-sans);font-size:14.5px;line-height:1.55;
  color:var(--v5-muted-2);max-width:60ch}
/* "optional" sitting inside a question reads as an aside, not a second line */
.v5-form label .field-note{display:inline;margin-left:8px;font-size:13px;letter-spacing:.02em}
/* ...except the Contact message's note, which is a full instruction, not an aside:
   inline it wrapped back under "REQUIRED" into an uneven block (Astra, 2026-10-02). */
.v5-form label[for="c-message"] .field-note{display:block;margin:6px 0 0;font-size:14.5px;letter-spacing:0}
.v5-form .req{display:inline-block;margin-left:10px;font-family:var(--v5-sans);font-size:11.5px;
  font-weight:500;letter-spacing:.16em;text-transform:uppercase;color:var(--v5-gold);vertical-align:2px}

/* A question answered by a set of choices is a fieldset INSIDE a section, so it
   must not inherit the section's rule and gold heading. Its legend is the
   question, set like every other question. */
.v5-form .choice-field{margin:0 0 28px;padding:0;border:0}
.v5-form .choice-field > legend{margin:0 0 8px;letter-spacing:0;text-transform:none;font-weight:400}
.v5-form .choice-field > legend .field-note{display:inline;margin:0 0 0 8px;font-size:13px;letter-spacing:.02em}
.v5-form .choice-set + input,.v5-form .choice-set + textarea{margin-top:12px}

/* two short questions side by side, from a phone's width upward */
/* align-items:end so two inputs in a row share an edge even when only one field
   carries a help note above its box (Kimi review: Phone vs State, Title vs Date). */
.v5-form .field-grid{display:grid;grid-template-columns:1fr;column-gap:24px;align-items:end}
/* except the birth-details row, where "Time unknown" sits BELOW the time input:
   aligning bottoms there lifted the time box 34px above the date beside it */
.v5-form .field-grid:has(.birth-time-unknown){align-items:start}
@media (min-width:640px){ .v5-form .field-grid{grid-template-columns:1fr 1fr} }

/* ---- the controls -------------------------------------------------------- */
.v5-form input:not([type=checkbox]):not([type=radio]),
.v5-form select,.v5-form textarea{
  box-sizing:border-box;width:100%;min-height:52px;margin:0;padding:13px 16px;
  font-family:var(--v5-sans);font-size:17px;line-height:1.4;color:var(--v5-ink);
  background:var(--f-fill);border:1px solid var(--f-border);border-radius:var(--f-radius);
  transition:border-color .15s ease,box-shadow .15s ease}
/* the dream is written in the face it will be read in */
.v5-form textarea{min-height:9rem;resize:vertical;font-family:var(--v5-serif);font-size:19px;line-height:1.6}
.v5-form #f-dream{min-height:14rem}
.v5-form ::placeholder{color:#6b6e83;opacity:1}
.v5-form input:not([type=checkbox]):hover,.v5-form select:hover,.v5-form textarea:hover{border-color:var(--v5-ink)}
.v5-form input:focus-visible,.v5-form select:focus-visible,.v5-form textarea:focus-visible{
  outline:2px solid var(--v5-gold);outline-offset:2px;border-color:var(--v5-ink)}
.v5-form select{appearance:none;-webkit-appearance:none;padding-right:44px;cursor:pointer;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%231d2244' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat:no-repeat;background-position:right 18px center}
/* a field the browser has already marked wrong, after the visitor has touched it */
.v5-form input:user-invalid,.v5-form textarea:user-invalid,.v5-form select:user-invalid{border-color:#9b2c2c}

/* ---- checkboxes ---------------------------------------------------------- */
.v5-form input[type=checkbox]{width:22px;height:22px;margin:0;flex:none;accent-color:var(--v5-ink);cursor:pointer}

/* a set of choices: each one a pill, filled when chosen */
.v5-form .choice-set{display:flex;flex-wrap:wrap;gap:10px;margin-top:6px}
/* A fold inside a choice set (the seven perspectives behind "Let Daniel choose",
   2026-10-27) takes its own row and spaces its pills like the set around it. */
.v5-form .choice-set>details.fold{flex-basis:100%}
.v5-form .choice-set .fold-inner{display:flex;flex-wrap:wrap;gap:10px}
.v5-form .choice{position:relative;display:inline-flex;align-items:center;min-height:44px;padding:10px 18px;
  font-family:var(--v5-sans);font-size:15px;color:var(--v5-ink);background:var(--v5-cream);
  border:1px solid var(--f-border);border-radius:22px;cursor:pointer;line-height:1.4;
  transition:background .15s ease,color .15s ease,border-color .15s ease}
/* The input is the pill's painted layer, behind the text, so a ticked choice shows
   in every browser: a tint and an ink ring. Where :has() works (iOS 15.4+, Chrome
   105+, Firefox 121+) the dark pill below takes over and clears the tint. Without
   this, an older phone showed no change at all on a tap. top/left as well as inset,
   which needs iOS 14.5. */
.v5-form .choice{z-index:0}
.v5-form .choice input{position:absolute;top:0;left:0;inset:0;width:100%;height:100%;margin:0;cursor:pointer;
  z-index:-1;-webkit-appearance:none;appearance:none;border:0;border-radius:inherit;background:transparent}
.v5-form .choice input:checked{background:#e9dcbd;box-shadow:inset 0 0 0 2px var(--v5-ink)}
.v5-form .choice:hover{border-color:var(--v5-ink)}
.v5-form .choice:has(input:checked){background:var(--v5-ink);border-color:var(--v5-ink);color:var(--v5-cream)}
.v5-form .choice:has(input:checked) input{background:transparent;box-shadow:none}
.v5-form .choice:has(input:focus-visible){outline:2px solid var(--v5-gold);outline-offset:2px}
.v5-form .choice:has(input:checked)::before{content:"";width:6px;height:10px;margin:-3px 10px 0 -2px;
  border:solid currentColor;border-width:0 2px 2px 0;transform:rotate(45deg)}

/* "time unknown" beside the birth time. Qualified with .field > so it outranks
   the question-label rule, which would otherwise set it in large serif. */
.v5-form .field > label.birth-time-unknown,.v5-form .birth-time-unknown{display:inline-flex;align-items:center;gap:10px;margin-top:4px;
  font-family:var(--v5-sans);font-size:15px;color:var(--v5-body);cursor:pointer}

/* consent: each sentence on its own card, the box where the eye lands first */
.v5-form .consent{display:flex;gap:14px;align-items:flex-start;margin:0 0 12px;padding:16px 18px;
  font-family:var(--v5-sans);font-size:15.5px;line-height:1.55;color:var(--v5-body);
  background:var(--f-fill);border:1px solid transparent;border-radius:var(--f-radius);cursor:pointer;
  transition:border-color .15s ease}
.v5-form .consent:hover{border-color:var(--f-border)}
.v5-form .consent input{margin-top:1px}
.v5-form .consent:has(input:focus-visible){outline:2px solid var(--v5-gold);outline-offset:2px}
.v5-form .consent .req,.v5-form .consent .field-note{margin-left:8px}
/* The one OPTIONAL consent (teaching and research) is set apart from the required
   ones: space above it, and its "optional" marker shown first, as a small label,
   instead of trailing a long sentence (Astra review; spec amendment, 2026-10-02).
   CSS only: the checkbox, its sentence and what it records are unchanged. */
.v5-form .consent:has(> input:not([required])){margin-top:28px}
.v5-form .consent:has(> input:not([required])) > span{display:flex;flex-direction:column;gap:4px}
.v5-form .consent:has(> input:not([required])) > span > .field-note{order:-1;margin:0;
  font-size:11.5px;font-weight:500;letter-spacing:.16em;text-transform:uppercase;color:var(--v5-gold)}

.v5-form .safety-note{margin:20px 0 0;padding:16px 20px;font-family:var(--v5-sans);font-size:14.5px;
  line-height:1.6;color:var(--v5-body);background:var(--v5-cream-2);border-left:2px solid var(--v5-gold);
  border-radius:0 var(--f-radius) var(--f-radius) 0}
.v5-form .safety-note a,.v5-form .field-note a{color:var(--v5-link);text-underline-offset:.16em}

/* ---- the optional context, folded away ------------------------------------ */
.v5-form details{margin:40px 0 0;border-top:1px solid var(--v5-rule);border-bottom:1px solid var(--v5-rule)}
.v5-form summary{display:flex;align-items:baseline;flex-wrap:wrap;gap:4px 12px;padding:20px 40px 20px 0;
  position:relative;list-style:none;cursor:pointer;font-family:var(--v5-serif);font-size:20px;color:var(--v5-ink)}
.v5-form summary::-webkit-details-marker{display:none}
.v5-form summary::after{content:"+";position:absolute;right:4px;top:50%;transform:translateY(-50%);
  font-family:var(--v5-sans);font-size:26px;font-weight:300;color:var(--v5-gold)}
.v5-form details[open] summary::after{content:"\2212"}
.v5-form summary .field-note{display:inline;margin:0;font-size:14px}
.v5-form summary:focus-visible{outline:2px solid var(--v5-gold);outline-offset:2px}
.v5-form .dream-more-inner{padding:8px 0 12px}

/* A fold inside a part (dream form regroup, 2026-10-14, after the prototype): a quiet
   line under the question it follows, not a ruled band. Optional questions only. */
.v5-form details.fold{margin:4px 0 8px;border:0}
.v5-form details.fold>summary{display:inline-flex;align-items:center;min-height:44px;padding:0 0 0 30px;
  font-family:var(--v5-sans);font-size:15px;color:var(--v5-link);text-decoration:underline;text-underline-offset:.2em}
.v5-form details.fold>summary::after{right:auto;left:0;font-size:24px;text-decoration:none}
.v5-form .fold-inner{padding:12px 0 0}

/* ---- sending --------------------------------------------------------------- */
.v5-form button{display:block;width:100%;min-height:56px;margin:32px 0 0;padding:16px 32px;
  font-family:var(--v5-sans);font-size:17px;font-weight:500;letter-spacing:.01em;color:var(--v5-cream);
  background:var(--f-send);border:0;border-radius:999px;cursor:pointer;
  transition:background .15s ease,transform .15s ease}
/* Every selector here is "button", not "button[type=submit]": inertForm() turns
   the submit into type=button disabled on the CMS preview, and Daniel should see
   the same button there that a visitor sees. */
@media (min-width:640px){ .v5-form button{width:auto} }
.v5-form button:hover{background:var(--f-send-deep);transform:translateY(-1px)}
.v5-form button:focus-visible{outline:2px solid var(--v5-gold);outline-offset:3px}
.v5-form button:disabled{opacity:.55;cursor:not-allowed;transform:none}
.v5-form .form-status{margin:24px 0 0;padding:14px 18px;font-family:var(--v5-sans);font-size:15.5px;
  line-height:1.5;color:var(--v5-ink);background:var(--v5-cream-2);border-radius:var(--f-radius)}
.v5-form .form-status[hidden]{display:none}
/* form-relay.js sets "form-status is-error" when a send fails */
.v5-form .form-status.is-error{color:#7a1f1f;background:#f6e4df;border-left:3px solid #9b2c2c;
  border-radius:0 var(--f-radius) var(--f-radius) 0}
.v5-form .turnaround-note{margin-top:16px}

@media (prefers-reduced-motion:reduce){
  .v5-form *{transition:none!important}
  .v5-form button:hover{transform:none}
}
