/* ==========================================================================
   Wellington Orthopedic Institute — Patient Intake (STAGING)
   Screen + print styles for patient-forms.html and patient-intake.html.
   Extends the tokens defined in style.css.
   ========================================================================== */

.staging-banner {
  background: #7A1B1F;
  color: #fff;
  text-align: center;
  padding: 0.7rem 1rem;
  font-size: var(--text-sm);
  line-height: 1.45;
  letter-spacing: .01em;
}
.staging-banner strong { color: #FFD9A8; }

/* ---------- Landing page choice cards ---------- */
.intake-wrap { max-width: 900px; margin: 0 auto; }
.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
  margin: var(--sp-4) 0 var(--sp-4);
}
.choice-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--navy-15);
  border-top: 4px solid var(--teal);
  border-radius: 10px;
  background: #fff;
  padding: var(--sp-4) var(--sp-3);
  box-shadow: 0 2px 14px rgba(13, 35, 64, .05);
}
.choice-card--print { border-top-color: var(--gold); }
.choice-card h2 { font-size: var(--text-lg); margin: 0 0 0.4rem; }
.choice-card .choice-meta {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-weight: 700;
  color: var(--teal);
  margin: 0 0 var(--sp-2);
}
.choice-card--print .choice-meta { color: var(--gold); }
.choice-card p { color: var(--ink-soft); font-size: var(--text-sm); margin: 0 0 var(--sp-2); }
.choice-card ul { margin: 0 0 var(--sp-3); padding-left: 1.15rem; font-size: var(--text-sm); color: var(--ink-soft); }
.choice-card ul li { margin-bottom: .35em; }
.choice-card .btn { margin-top: auto; align-self: flex-start; }

.notice {
  border-left: 5px solid var(--navy);
  background: var(--gray);
  border-radius: 0 6px 6px 0;
  padding: var(--sp-3);
  font-size: var(--text-sm);
  margin: var(--sp-3) 0;
}
.notice--warn { border-left-color: #B4232A; background: #fdf2f2; color: #7d1a20; }
.notice h3 { font-size: var(--text-base); margin: 0 0 0.4rem; color: inherit; }
.notice p:last-child { margin-bottom: 0; }

/* ---------- Wizard shell ---------- */
.wizard { max-width: 940px; margin: 0 auto; }

.progress-rail {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--rule);
  padding: var(--sp-2) 0;
  margin-bottom: var(--sp-4);
}
.progress-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem 1rem;
  margin-bottom: 0.5rem;
}
.progress-head .p-step { font-weight: 700; color: var(--navy); font-size: var(--text-sm); }
.progress-head .p-count { font-size: var(--text-xs); color: var(--ink-soft); letter-spacing: .06em; text-transform: uppercase; }
.progress-track { height: 8px; border-radius: 99px; background: var(--navy-15); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--teal); transition: width .28s ease; }
.progress-dots { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.55rem; list-style: none; padding: 0; }
.progress-dots li { font-size: 0; }
.progress-dots button {
  /* 44px keeps the step targets tappable on phones and iPads. */
  min-width: 44px; min-height: 44px;
  border-radius: 6px;
  border: 1px solid var(--navy-15);
  background: #fff;
  color: var(--ink-soft);
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 700;
  cursor: pointer;
}
.progress-dots button[aria-current="step"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.progress-dots button.is-done { background: rgba(14, 116, 144, .12); border-color: var(--teal); color: #0b5b70; }
.progress-dots button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.step-panel {
  border: 1px solid var(--navy-15);
  border-radius: 10px;
  background: #fff;
  padding: var(--sp-4);
  box-shadow: 0 2px 14px rgba(13, 35, 64, .05);
}
.step-panel[hidden] { display: none; }
.step-panel > h2 {
  font-size: var(--text-xl);
  margin: 0 0 0.4rem;
  padding-bottom: 0.6rem;
  border-bottom: 2px solid var(--gold);
}
.step-panel > p.step-intro { font-size: var(--text-sm); color: var(--ink-soft); margin: var(--sp-2) 0 var(--sp-3); }

fieldset.sub { border: 0; padding: 0; margin: 0 0 var(--sp-4); }
fieldset.sub > legend {
  font-weight: 700;
  color: var(--navy);
  font-size: var(--text-base);
  padding: 0;
  margin-bottom: var(--sp-2);
  border-bottom: 1px solid var(--rule);
  width: 100%;
  padding-bottom: 0.35rem;
}
.hint { font-weight: 400; color: var(--ink-soft); font-size: var(--text-xs); display: block; margin-top: 0.15rem; }
.req { color: #A11B22; font-weight: 700; }
.optional-tag { font-weight: 400; color: var(--ink-soft); font-size: var(--text-xs); }

/* Fields: ensure 44px touch targets and WCAG-contrast borders */
.field input, .field select, .field textarea {
  min-height: 46px;
  border: 1px solid rgba(13, 35, 64, .38) !important;
  color: var(--ink);
}
.field textarea { min-height: 96px; }
.field input[aria-invalid="true"], .field select[aria-invalid="true"], .field textarea[aria-invalid="true"] {
  border-color: #A11B22 !important;
  background: #fffafa;
}
.field .field-msg { color: #8d1c22; font-size: var(--text-xs); font-weight: 500; min-height: 0; }
.field-3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: var(--sp-3); }
.field-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-3); }

/* Screen-reader-only text */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Choice chips (checkbox / radio sets) */
fieldset.chips-wrap { border: 0; padding: 0; margin: 0 0 var(--sp-3); }
fieldset.chips-wrap > legend { padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.25rem 0 var(--sp-3); padding: 0; border: 0; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.5rem 0.9rem;
  border: 1px solid rgba(13, 35, 64, .32);
  border-radius: 99px;
  background: #fff;
  cursor: pointer;
  font-size: var(--text-sm);
  line-height: 1.3;
}
.chip:hover { border-color: var(--teal); background: #fbfdfe; }
.chip input { width: 18px; height: 18px; accent-color: var(--teal); margin: 0; }
.chip:has(input:checked) { border-color: var(--teal); background: rgba(14, 116, 144, .10); font-weight: 500; }
.chip:focus-within { outline: 3px solid var(--gold); outline-offset: 2px; }

/* Yes / No rows (history) */
.yn-list { display: grid; gap: 0.4rem; }
.yn {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #fff;
}
.yn:nth-child(odd) { background: #fbfcfd; }
.yn > .yn-label { font-size: var(--text-sm); }
.yn-toggle { display: flex; gap: 0.4rem; }
.yn-toggle label {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  min-width: 62px; min-height: 44px;
  border: 1px solid rgba(13, 35, 64, .32);
  border-radius: 8px; background: #fff; cursor: pointer;
  font-size: var(--text-sm); font-weight: 500;
}
.yn-toggle label:has(input:checked) { border-color: var(--teal); background: rgba(14, 116, 144, .12); }
.yn-toggle input { width: 16px; height: 16px; accent-color: var(--teal); margin: 0; }
.yn-toggle label:focus-within { outline: 3px solid var(--gold); outline-offset: 2px; }
.yn-detail { grid-column: 1 / -1; }
.yn-detail[hidden] { display: none; }
.yn-detail input { width: 100%; min-height: 44px; padding: 0.55rem 0.7rem; border: 1px solid rgba(13,35,64,.32); border-radius: 6px; font: inherit; }

.sys-group { margin-bottom: var(--sp-3); }
.sys-group > h4 {
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--teal);
  margin: 0 0 0.5rem;
}

/* Pain scale */
.pain-scale { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.4rem 0 var(--sp-2); padding: 0; border: 0; }
.pain-scale label {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px;
  border: 1px solid rgba(13, 35, 64, .32);
  border-radius: 8px; background: #fff;
  font-weight: 700; cursor: pointer;
}
.pain-scale label:has(input:checked) { background: var(--navy); color: #fff; border-color: var(--navy); }
.pain-scale label:focus-within { outline: 3px solid var(--gold); outline-offset: 2px; }
.pain-scale input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.scale-ends { display: flex; justify-content: space-between; font-size: var(--text-xs); color: var(--ink-soft); max-width: 560px; }

/* Legal blocks */
.legal-doc {
  background: var(--gray);
  border-left: 5px solid var(--navy);
  border-radius: 0 6px 6px 0;
  padding: var(--sp-3);
  font-size: 0.88rem;
  line-height: 1.7;
  max-height: 380px;
  overflow-y: auto;
  margin-bottom: var(--sp-3);
}
.legal-doc h4 { margin: 0 0 0.5rem; font-size: var(--text-base); }
.legal-doc p { margin: 0 0 0.85em; }
.legal-doc ol, .legal-doc ul { margin: 0 0 0.85em; padding-left: 1.3rem; }
.legal-doc li { margin-bottom: 0.5em; }

.ack {
  display: flex; gap: 0.75rem; align-items: flex-start;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(13, 35, 64, .32);
  border-radius: 8px; background: #fff; cursor: pointer;
  font-size: var(--text-sm); line-height: 1.5;
  margin-bottom: var(--sp-2);
  min-height: 44px;
}
.ack:has(input:checked) { border-color: var(--teal); background: rgba(14, 116, 144, .07); }
.ack input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--teal); flex: 0 0 auto; }
.ack:focus-within { outline: 3px solid var(--gold); outline-offset: 2px; }

/* Signature */
.sig-box { border: 1px solid rgba(13, 35, 64, .32); border-radius: 8px; background: #fff; padding: var(--sp-2); }
.sig-canvas {
  display: block; width: 100%; height: 200px;
  border: 1px dashed rgba(13, 35, 64, .45);
  border-radius: 6px;
  background: #fdfdfe;
  touch-action: none;
  cursor: crosshair;
}
.sig-canvas:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.sig-tools { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: var(--sp-2); }
.sig-tools .btn-mini {
  min-height: 44px; padding: 0.5rem 0.95rem;
  border: 1px solid rgba(13, 35, 64, .32); border-radius: 6px;
  background: #fff; font: inherit; font-size: var(--text-sm); font-weight: 500; cursor: pointer;
}
.sig-tools .btn-mini:hover { border-color: var(--teal); }
.sig-status { font-size: var(--text-xs); color: var(--ink-soft); }

/* Errors / summary */
.err-summary {
  border-left: 5px solid #A11B22;
  background: #fdf2f2;
  color: #7d1a20;
  border-radius: 0 6px 6px 0;
  padding: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.err-summary[hidden] { display: none; }
.err-summary h3 { margin: 0 0 0.5rem; font-size: var(--text-base); color: inherit; }
.err-summary ul { margin: 0; padding-left: 1.2rem; font-size: var(--text-sm); }
.err-summary a { color: #7d1a20; text-decoration: underline; }

/* Nav buttons */
.wizard-nav {
  display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center;
  margin-top: var(--sp-4); padding-top: var(--sp-3); border-top: 1px solid var(--rule);
}
.wizard-nav .spacer { flex: 1 1 auto; }
.wizard-nav .btn { min-height: 48px; }
.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0.7rem 1.3rem;
  border: 1px solid rgba(13, 35, 64, .35); border-radius: 4px;
  background: #fff; color: var(--navy); font: inherit; font-weight: 700; cursor: pointer;
  text-decoration: none;
}
.btn-ghost:hover { border-color: var(--teal); color: var(--navy); }

/* Review + confirmation */
.review-block { border: 1px solid var(--rule); border-radius: 8px; padding: var(--sp-3); margin-bottom: var(--sp-2); }
.review-block h4 { margin: 0 0 0.5rem; font-size: var(--text-sm); text-transform: uppercase; letter-spacing: .1em; color: var(--teal); }
.review-block dl { display: grid; grid-template-columns: minmax(140px, 34%) 1fr; gap: 0.35rem 1rem; margin: 0; font-size: var(--text-sm); }
.review-block dt { color: var(--ink-soft); }
.review-block dd { margin: 0; font-weight: 500; }
.confirm-panel { border: 1px solid var(--navy-15); border-top: 4px solid #1E874B; border-radius: 10px; background: #fff; padding: var(--sp-5) var(--sp-4); text-align: center; }
.confirm-panel[hidden] { display: none; }
.confirm-panel .ref {
  display: inline-block; margin-top: var(--sp-3); padding: 0.6rem 1rem;
  background: var(--gray); border-left: 4px solid var(--navy);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: var(--text-sm); text-align: left;
}
.timeout-panel { }
.timeout-panel[hidden] { display: none; }

.token-chip {
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-size: var(--text-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 0.35rem 0.7rem; border-radius: 99px; margin-bottom: var(--sp-2);
}
.token-chip.is-ok { background: rgba(30, 135, 75, .12); color: #14603a; }
.token-chip.is-missing { background: rgba(176, 125, 42, .16); color: #6b4a12; }

@media (max-width: 760px) {
  .choice-grid, .field-2, .field-3 { grid-template-columns: 1fr; }
  .step-panel { padding: var(--sp-3); }
  .yn { grid-template-columns: 1fr; }
  .yn-toggle label { flex: 1 1 auto; }
  .review-block dl { grid-template-columns: 1fr; }
  .review-block dt { font-weight: 700; }
}

/* ==========================================================================
   PRINT — produce a clean completed form (or a clean blank form)
   ========================================================================== */
@media print {
  @page { size: letter portrait; margin: 0.6in 0.55in; }

  .util-bar, .nav, .footer, .sticky-bar, .progress-rail, .wizard-nav,
  .staging-banner, .sig-tools, .cta-band, .err-summary, .no-print,
  .page-hero { display: none !important; }

  html, body { background: #fff !important; color: #000 !important; font-size: 10.5pt; }
  body { padding: 0 !important; }
  .section { padding: 0 !important; }
  .wrap { max-width: none !important; padding: 0 !important; }
  .wizard, .intake-wrap { max-width: none !important; }

  /* Show every step, in order, regardless of wizard state */
  .step-panel[hidden] { display: block !important; }
  .step-panel {
    border: 0 !important; box-shadow: none !important; padding: 0 !important;
    margin: 0 0 14pt !important; break-inside: auto;
  }
  .step-panel > h2 {
    font-size: 12.5pt; border-bottom: 1pt solid #000; padding-bottom: 3pt;
    margin: 0 0 6pt; break-after: avoid;
  }
  fieldset.sub > legend { font-size: 10.5pt; break-after: avoid; }
  .legal-doc { max-height: none !important; overflow: visible !important; background: #fff !important; border-left: 2pt solid #000; font-size: 8.5pt; }
  .field input, .field select, .field textarea {
    border: 0 !important; border-bottom: 0.7pt solid #444 !important;
    border-radius: 0 !important; min-height: 0 !important; padding: 1pt 2pt !important;
    background: #fff !important; font-size: 10pt;
  }
  .field textarea { min-height: 34pt !important; border: 0.7pt solid #444 !important; }
  .chip, .yn-toggle label, .pain-scale label, .ack { border-color: #666 !important; background: #fff !important; }
  .yn-detail[hidden] { display: block !important; }
  .sig-canvas { border: 0.7pt solid #444 !important; height: 90pt !important; }
  .confirm-panel, .timeout-panel { display: none !important; }
  /* Screen-only orientation copy has no place on the printed packet. */
  #step-welcome, .token-chip { display: none !important; }
  .print-header { display: block !important; }
  a[href]:after { content: ""; }
}

/* While the print dialog is open every panel is revealed. */
body.is-printing .step-panel { display: block !important; }
body.is-printing .progress-rail { visibility: hidden; }

.print-header { display: none; }
.print-header h1 { font-size: 15pt; margin: 0 0 2pt; }
.print-header p { margin: 0 0 8pt; font-size: 9pt; }

/* Staging / test-only gate banner on the intake page. Deliberately loud: the
   form must never be mistaken for a live patient-facing submission channel while
   the production PHI controls are still outstanding. */
.notice.is-staging {
  border-color: #B45309;
  background: #FFFBEB;
  border-left-width: 4px;
}
.notice.is-staging h3 { color: #92400E; letter-spacing: .02em; }
.notice.is-staging p { color: #78350F; }

/* ── Submitted confirmation ──────────────────────────────────────────────
   The badge is the one thing a patient must be able to read from arm's
   length: their form reached the office and no further action is needed. */
.confirm-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 12px;
  padding: 7px 13px;
  border-radius: 999px;
  background: #ECFDF5;
  border: 1px solid #15803D;
  color: #14532D;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.1px;
}
#confirm-panel .ref { margin: 6px 0; }

/* Submit button while a submission is in flight. The label changes as well,
   so the state does not rely on colour alone. */
#btn-submit[aria-busy="true"] { opacity: 0.75; cursor: progress; }
