/* The layout borrows the chapter's paper questionnaire: thick navy rules between
   groups, labels set small inside the top-left of each box, boxes sharing their
   borders, gold numerals on the essay questions. */

:root {
  --navy: #00193f;
  --gold: #d59c23;
  --gold-ink: #9a6b0c;   /* gold dark enough to read as text on white */
  --rule: #9aa3b2;
  --label: #4a5568;
  --paper: #ffffff;
  --ground: #eef0f3;
  --ink: #111418;
  --focus: #fff8e6;
  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --heavy: "Arial Black", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 16px/1.5 var(--font);
}

.sheet {
  max-width: 880px;
  margin: 32px auto;
  background: var(--paper);
  padding: 48px 56px 36px;
  border: 1px solid #d5d9e0;
}

.masthead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}
.masthead h1, .pagehead {
  font: 900 30px/1.08 var(--heavy);
  color: var(--navy);
  margin: 0;
  letter-spacing: -0.01em;
}
.logo { width: 290px; height: auto; flex: none; margin-top: 4px; }

.lede { margin: 0 0 6px; max-width: 64ch; color: #2b3240; }
.draft-note { margin: 0 0 22px; font-size: 14px; color: var(--label); }
.linkish {
  background: none; border: 0; padding: 0; font: inherit; color: var(--navy);
  text-decoration: underline; cursor: pointer;
}
.req { color: var(--gold-ink); font-weight: 700; }

/* ---- groups: a navy rule, then a grid of shared-border boxes ---- */
fieldset {
  border: 0; margin: 0; padding: 0; min-width: 0;
}
.group { margin-top: 18px; }
.group::before {
  content: ""; display: block; height: 8px; background: var(--navy);
}
.group legend {
  /* kept for screen readers; the rule does the visual separating, as on paper */
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
}
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  border-left: 1px solid var(--rule);
}
.cell {
  grid-column: span 12;
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 6px 10px 6px;
  min-width: 0;
  background: var(--paper);
  transition: background-color .12s;
}
.cell:focus-within { background: var(--focus); }
.cell label {
  display: block;
  font-size: 13px;
  line-height: 1.3;
  color: var(--label);
}
.cell input, .cell select, .cell textarea {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  font: 16px/1.45 var(--font);
  color: var(--ink);
  padding: 3px 0 2px;
  margin: 0;
  outline: none;
}
.cell textarea { resize: vertical; min-height: 4.5em; }
.cell select { appearance: none; -webkit-appearance: none; cursor: pointer; }
.cell.invalid { background: #fdecec; }
.cell.invalid label { color: #a11a1a; }

/* children rows */
.kids .row { display: contents; }
.addrow {
  margin: 8px 0 0; background: none; border: 1px solid var(--navy); color: var(--navy);
  font: 600 14px/1 var(--font); padding: 8px 12px; cursor: pointer;
}
.addrow:hover { background: var(--navy); color: #fff; }

/* ---- page two ---- */
.pagebreak {
  margin: 56px -56px 0;
  padding: 40px 56px 0;
  border-top: 1px dashed #c9ced6;
}
.pagebreak .logo { width: 220px; display: block; margin-bottom: 18px; }
.pagehead { text-transform: uppercase; font-size: 34px; margin-bottom: 8px; }
.essay { margin-top: 26px; }
.essay label {
  display: block;
  font-size: 17px;
  line-height: 1.45;
  color: #2b3240;
  margin-bottom: 8px;
  max-width: 70ch;
}
.essay .num {
  font: 900 26px/1 var(--heavy);
  color: var(--gold);
  margin-right: 6px;
  vertical-align: -1px;
}
.essay textarea {
  display: block; width: 100%;
  border: 1px solid var(--rule);
  font: 16px/1.5 var(--font);
  padding: 10px 12px;
  min-height: 10em;
  resize: vertical;
  color: var(--ink);
}
.essay textarea:focus { outline: 2px solid var(--gold); outline-offset: -1px; background: var(--focus); }
.essay.invalid textarea { border-color: #c53030; background: #fdecec; }
.count { font-size: 13px; color: var(--label); margin-top: 4px; text-align: right; }

/* ---- submit ---- */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.submitbar {
  margin-top: 36px; padding-top: 22px; border-top: 8px solid var(--navy);
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
button[type="submit"], #printBtn {
  background: var(--navy); color: #fff; border: 0;
  font: 700 16px/1 var(--font); padding: 15px 26px; cursor: pointer;
}
button[type="submit"]:hover, #printBtn:hover { background: #0b2c63; }
button[type="submit"]:disabled { opacity: .55; cursor: progress; }
#status { margin: 0; font-size: 15px; }
#status.err { color: #a11a1a; }

#done { border-top: 8px solid var(--navy); margin-top: 28px; padding-top: 20px; }
#done h2 { font: 900 24px/1.2 var(--heavy); color: var(--navy); margin: 0 0 10px; }

.foot { margin-top: 40px; font-size: 13px; color: var(--label); }
.foot a { color: var(--navy); }

#printCopy { display: none; }

/* ---- phone ---- */
@media (max-width: 720px) {
  .sheet { margin: 0; padding: 24px 16px 24px; border: 0; }
  .masthead { flex-direction: column-reverse; gap: 14px; }
  .masthead h1 { font-size: 24px; }
  .logo { width: 220px; }
  .cell { grid-column: span 12 !important; }
  .kids .cell.sex, .kids .cell.birthday { grid-column: span 6 !important; }
  .pagebreak { margin: 40px -16px 0; padding: 28px 16px 0; }
  .pagehead { font-size: 26px; }
  .essay label { font-size: 16px; }
}

/* ---- print: only the applicant's copy ---- */
@media print {
  body { background: #fff; }
  .sheet { display: none; }
  #printCopy { display: block; }
  @page { margin: 0.6in; }
}
