/* Shared styles for interactive screening forms.
   Mobile-first. Print stylesheet renders a clean version sans nav/buttons. */

.screener-wrap { max-width: 760px; margin: 0 auto; padding: 0 var(--s-4); }

/* Reserve vertical space for the questionnaire that shared/runtime.js
   injects after first paint. Without this, the footer paints inside the
   viewport, then jumps offscreen once questions render. A CLS source
   of ~0.18 on the homepage-of-screeners pages. 80vh is generous enough
   for every screener (longest is M-CHAT-R/F at 20 questions). Real
   content collapses it back automatically once injected. */
#screener-host { min-height: 80vh; }

.screener-intro {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  margin-bottom: var(--s-5);
}
.screener-intro h2 {
  font-size: var(--text-base); font-weight: 700; margin: 0 0 var(--s-2);
}
.screener-intro p {
  font-size: var(--text-sm); color: var(--c-text-secondary); line-height: 1.5; margin: 0;
}

.screener-patient {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3);
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-lg); padding: var(--s-4); margin-bottom: var(--s-5);
}
@media (max-width: 480px) { .screener-patient { grid-template-columns: 1fr; } }
.screener-patient label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: var(--text-xs); font-weight: 600; color: var(--c-text-secondary);
}
.screener-patient input {
  padding: 8px 10px; border: 1px solid var(--c-border); border-radius: var(--r-md);
  font-family: var(--font); font-size: var(--text-sm); background: var(--c-surface);
}
.screener-patient input:focus {
  outline: none; border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.screener-questions { display: flex; flex-direction: column; gap: var(--s-3); margin-bottom: var(--s-5); }

.screener-q {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-lg); padding: var(--s-4);
}
.screener-q-text {
  display: flex; gap: var(--s-2); margin-bottom: var(--s-3);
  font-size: var(--text-sm); font-weight: 500; color: var(--c-text); line-height: 1.5;
}
.screener-q-num {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%;
  background: var(--c-primary-soft); color: var(--c-primary);
  font-size: var(--text-xs); font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.screener-q-help {
  font-size: var(--text-xs); color: var(--c-text-secondary);
  margin: 4px 0 var(--s-3) 32px;
}

.screener-options {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr));
  gap: 6px; margin-left: 32px;
}
.screener-options.is-binary { grid-template-columns: 1fr 1fr; max-width: 280px; }
.screener-options input[type="radio"] {
  position: absolute; opacity: 0; width: 0; height: 0;
}
.screener-option {
  display: block; padding: 10px 12px; border: 1px solid var(--c-border);
  border-radius: var(--r-md); background: var(--c-surface);
  cursor: pointer; font-size: var(--text-sm); font-weight: 500;
  text-align: center; color: var(--c-text);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.screener-option:hover { background: var(--c-border-light); }
input[type="radio"]:checked + .screener-option {
  background: var(--c-primary); color: #fff; border-color: var(--c-primary);
}
input[type="radio"]:focus-visible + .screener-option {
  outline: 2px solid var(--c-primary); outline-offset: 2px;
}

.screener-numeric input {
  margin-left: 32px; max-width: 140px;
  padding: 8px 10px; border: 1px solid var(--c-border); border-radius: var(--r-md);
  font-family: var(--font); font-size: var(--text-sm);
}

.screener-actions {
  display: flex; gap: var(--s-2); flex-wrap: wrap;
  padding: var(--s-4) 0; margin-bottom: var(--s-5);
}
.screener-actions .btn { flex: 1; min-width: 120px; }

.screener-result {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-lg); padding: var(--s-5); margin-bottom: var(--s-5);
}
.screener-result-banner {
  padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
  font-size: var(--text-base); font-weight: 700;
  margin-bottom: var(--s-3);
}
.screener-result-banner.level-ok        { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.screener-result-banner.level-warn      { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.screener-result-banner.level-risk-high { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.screener-result-banner.level-info      { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.screener-result-score {
  font-size: var(--text-xl); font-weight: 700; color: var(--c-primary);
  margin: 0 0 var(--s-2);
}
.screener-result-detail {
  font-size: var(--text-sm); color: var(--c-text-secondary); line-height: 1.5; margin-bottom: var(--s-4);
}
.screener-result-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

.screener-references {
  margin-top: var(--s-6); padding-top: var(--s-4);
  border-top: 1px solid var(--c-border-light);
  font-size: var(--text-xs); color: var(--c-text-secondary); line-height: 1.5;
}
.screener-references h3 {
  font-size: var(--text-xs); font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; margin: 0 0 var(--s-2);
}
.screener-references ul { margin: 0; padding-left: var(--s-4); }
.screener-references li { margin-bottom: 4px; }

.screener-disclaimer {
  font-size: var(--text-xs); color: var(--c-text-muted);
  background: var(--c-border-light);
  padding: var(--s-3); border-radius: var(--r-md);
  margin: var(--s-5) 0;
}

.screener-error {
  background: #fef2f2; border: 1px solid #fecaca; color: #991b1b;
  padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
  margin: var(--s-3) 0; font-size: var(--text-sm);
}

@media print {
  .tool-header, .tool-footer, .tool-mobile-overlay,
  .screener-actions, .screener-result-actions, .skip-link, .privacy-banner,
  .screener-error {
    display: none !important;
  }
  body { background: #fff; }
  .screener-wrap { max-width: none; padding: 0; }
  .screener-q, .screener-intro, .screener-patient, .screener-result {
    box-shadow: none; border: 1px solid #ddd; break-inside: avoid;
  }
  .screener-option {
    border: 1px solid #999; background: #fff !important; color: #000 !important;
  }
  input[type="radio"]:checked + .screener-option {
    background: #000 !important; color: #fff !important;
  }
}
