/* ================================================================
   TinyHumanMD | Pediatric BP Percentile. Page-specific styles
   ================================================================ */

/* ── Approx model callout ─────────────────────────────────────── */
.approx-callout {
  display: flex;
  gap: var(--s-3);
  align-items: flex-start;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-left: 4px solid var(--c-primary);
  border-radius: var(--r-md);
  padding: var(--s-4);
  margin-bottom: var(--s-5);
  font-size: var(--text-sm);
  color: #1e40af;
  line-height: 1.5;
}

.approx-callout svg {
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--c-primary);
}

.approx-callout a {
  color: var(--c-primary);
  font-weight: 600;
  text-decoration: underline;
}

/* ── Sex toggle ───────────────────────────────────────────────── */
.sex-toggle {
  display: flex;
  gap: var(--s-2);
  margin-top: var(--s-2);
}

.sex-btn {
  padding: var(--s-2) var(--s-5);
  border: 2px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-surface);
  color: var(--c-text-secondary);
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.sex-btn:hover {
  border-color: var(--c-primary);
  color: var(--c-primary);
}

.sex-btn.sex-btn-active {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: #fff;
}

.sex-btn:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
}

/* ── Form grid ────────────────────────────────────────────────── */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-4);
  margin-bottom: var(--s-4);
}

/* ── Risk Banner ─────────────────────────────────────────────── */
.risk-banner {
  padding: var(--s-4) var(--s-5);
  border-radius: var(--r-md);
  font-size: var(--text-base);
  font-weight: 600;
  margin-bottom: var(--s-4);
  text-align: center;
}

.risk-banner.level-ok {
  background: var(--c-green-soft);
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.risk-banner.level-warn {
  background: var(--c-amber-soft);
  color: #92400e;
  border: 1px solid #fde68a;
}

.risk-banner.level-risk-high {
  background: var(--c-red-soft);
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* ── Result grid ─────────────────────────────────────────────── */
.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--s-4);
  margin-bottom: var(--s-5);
}

.result-item {
  padding: var(--s-4);
  background: var(--c-bg-secondary);
  border-radius: var(--r-md);
  text-align: center;
  border: 1px solid var(--c-border-light);
}

.result-item-span {
  grid-column: 1 / -1;
}

.result-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--c-primary);
  margin-bottom: var(--s-1);
}

.result-value-lg {
  font-size: var(--text-3xl);
}

.result-label {
  font-size: var(--text-sm);
  color: var(--c-text-secondary);
  font-weight: 500;
}

.result-sublabel {
  font-size: var(--text-xs);
  color: var(--c-text-secondary);
  margin-top: var(--s-1);
}

/* ── BP Detail section ───────────────────────────────────────── */
.bp-detail {
  margin-top: var(--s-5);
  padding-top: var(--s-5);
  border-top: 1px solid var(--c-border-light);
}

.bp-detail h4 {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--c-text-secondary);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: var(--s-3);
}

.threshold-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  margin-bottom: var(--s-4);
}

.threshold-table th {
  text-align: center;
  padding: var(--s-2) var(--s-3);
  font-weight: 600;
  color: var(--c-text-secondary);
  border-bottom: 2px solid var(--c-border);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.threshold-table th:first-child {
  text-align: left;
}

.threshold-table td {
  padding: var(--s-2) var(--s-3);
  color: var(--c-text);
  border-bottom: 1px solid var(--c-border-light);
  text-align: center;
}

.threshold-table td:first-child {
  font-weight: 700;
  text-align: left;
}

.threshold-table tr:last-child td {
  border-bottom: none;
}

/* ── Component results ───────────────────────────────────────── */
.component-results {
  display: flex;
  gap: var(--s-3);
  flex-wrap: wrap;
  margin-bottom: var(--s-4);
}

.comp-result {
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm);
  font-size: var(--text-sm);
  font-weight: 600;
}

.comp-normal {
  background: var(--c-green-soft);
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.comp-elevated {
  background: var(--c-amber-soft);
  color: #92400e;
  border: 1px solid #fde68a;
}

.comp-stage1 {
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fed7aa;
}

.comp-stage2 {
  background: var(--c-red-soft);
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* ── Height warning ──────────────────────────────────────────── */
.height-warning {
  display: flex;
  gap: var(--s-2);
  align-items: flex-start;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--r-sm);
  padding: var(--s-3) var(--s-4);
  font-size: var(--text-xs);
  color: #92400e;
  margin-bottom: var(--s-3);
}

.height-warning svg {
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── Repeat note ─────────────────────────────────────────────── */
.repeat-note {
  font-size: var(--text-xs);
  color: var(--c-text-secondary);
  background: var(--c-bg-secondary);
  border: 1px solid var(--c-border-light);
  border-radius: var(--r-sm);
  padding: var(--s-3) var(--s-4);
}

/* ── Field error ─────────────────────────────────────────────── */
.field-error {
  padding: var(--s-3) var(--s-4);
  background: var(--c-red-soft);
  border: 1px solid #fecaca;
  border-radius: var(--r-md);
  color: #991b1b;
  font-size: var(--text-sm);
  margin-bottom: var(--s-4);
}

.field-error p {
  margin-bottom: var(--s-1);
}

.field-error p:last-child {
  margin-bottom: 0;
}

/* ── FAQ Section ─────────────────────────────────────────────── */
.faq-section {
  background: var(--c-bg-secondary);
  padding: var(--s-8) 0;
  margin-top: var(--s-8);
}

.faq-section h2 {
  margin-bottom: var(--s-6);
  font-size: var(--text-2xl);
  font-weight: 700;
}

.faq-item {
  margin-bottom: var(--s-4);
  border-bottom: 1px solid var(--c-border-light);
  padding-bottom: var(--s-4);
}

.faq-item:last-child {
  border-bottom: none;
}

.faq-question {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: var(--s-3) 0;
  background: none;
  border: none;
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--c-text-primary);
  cursor: pointer;
  text-align: left;
  transition: color var(--dur) var(--ease);
}

.faq-question:hover {
  color: var(--c-primary);
}

.faq-question svg {
  flex-shrink: 0;
  transition: transform var(--dur) var(--ease);
}

.faq-item.is-open .faq-question svg {
  transform: rotate(180deg);
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
  color: var(--c-text-secondary);
  line-height: 1.6;
}

.faq-item.is-open .faq-answer {
  max-height: 600px;
}

.faq-answer p {
  margin-bottom: var(--s-3);
}

.faq-answer p:last-child {
  margin-bottom: 0;
}

.faq-answer ul {
  margin: var(--s-2) 0 var(--s-3) var(--s-5);
}

.faq-answer li {
  margin-bottom: var(--s-1);
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 640px) {
  .form-row {
    grid-template-columns: 1fr;
  }

  .result-grid {
    grid-template-columns: 1fr 1fr;
  }

  .result-item-span {
    grid-column: 1 / -1;
  }

  .threshold-table .th-wide,
  .threshold-table td:nth-child(4),
  .threshold-table th:nth-child(4) {
    display: none;
  }
}

/* ── Print ───────────────────────────────────────────────────── */
@media print {
  .sex-toggle,
  #calcBtn,
  #clearBtn,
  #downloadPdfBtn,
  .approx-callout {
    display: none;
  }

  .risk-banner {
    border: 2px solid #333;
    background: #fff;
    color: #000;
  }
}
