/* ================================================================
   TinyHumanMD | Wong-Baker FACES Pain Scale. Page-specific styles
   ©1983 Wong-Baker FACES Foundation. Used with permission.
   www.WongBakerFACES.org
   ================================================================ */

/* ── Attribution banner ──────────────────────────────────────── */
.attribution-banner {
  display: flex;
  gap: var(--s-3);
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--c-border);
  border-left: 4px solid var(--c-primary);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
  margin-bottom: var(--s-4);
  font-size: var(--text-sm);
  color: var(--c-text-secondary);
}

.attribution-banner a {
  color: var(--c-primary);
  font-weight: 600;
}

/* ── Usage note ───────────────────────────────────────────────── */
.usage-note {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: var(--r-md);
  padding: var(--s-4);
  margin-bottom: var(--s-5);
  font-size: var(--text-sm);
  color: #0c4a6e;
  line-height: 1.6;
}

.usage-note em {
  font-style: italic;
  color: #1e40af;
}

/* ── Pain scale grid ─────────────────────────────────────────── */
.pain-scale-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}

.pain-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-2);
  border: 2px solid var(--c-border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), transform var(--dur) var(--ease);
  position: relative;
  text-align: center;
}

.pain-opt:hover {
  border-color: var(--c-primary);
  background: var(--c-primary-soft);
  transform: translateY(-2px);
}

.pain-opt input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  margin: 0;
  cursor: pointer;
}

.pain-opt.selected,
.pain-opt:has(input:checked) {
  border-color: var(--c-primary);
  background: var(--c-primary-soft);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

/* ── CSS Face graphics (geometric, not official FACES) ─────── */
.face-circle {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: visible;
  flex-shrink: 0;
}

/* Face background colors. Gradient from happy (yellow-green) to sad (orange-red) */
.face-0  { background: #22c55e; } /* bright green */
.face-2  { background: #86efac; } /* light green */
.face-4  { background: #fbbf24; } /* yellow */
.face-6  { background: #f97316; } /* orange */
.face-8  { background: #ef4444; } /* red */
.face-10 { background: #b91c1c; } /* dark red */

/* ── Eyes ────────────────────────────────────────────────────── */
.face-eyes {
  display: flex;
  gap: 10px;
  margin-bottom: 6px;
  position: relative;
  z-index: 1;
}

.eye {
  width: 8px;
  height: 8px;
  background: #1e293b;
  border-radius: 50%;
}

/* Raised eyebrows for sad faces */
.eye-sad {
  /* Add a "down" inner shadow for sad/distressed look */
  box-shadow: 0 -2px 0 0 #1e293b;
  transform: translateY(-1px);
}

.eye-cry {
  box-shadow: 0 -1px 0 0 rgba(0,0,0,0.4);
}

.eye-squint {
  height: 5px;
  border-radius: 50% 50% 0 0;
  transform: translateY(2px);
}

/* ── Mouth shapes ─────────────────────────────────────────────── */
.face-mouth {
  width: 26px;
  height: 13px;
  position: relative;
  z-index: 1;
}

/* Score 0: big smile. Mouth curved strongly upward */
.mouth-0 {
  border: 3px solid #1e293b;
  border-top: none;
  border-radius: 0 0 30px 30px;
}

/* Score 2: slight smile */
.mouth-2 {
  border: 3px solid #1e293b;
  border-top: none;
  border-radius: 0 0 20px 20px;
  height: 10px;
}

/* Score 4: flat / neutral */
.mouth-4 {
  border-bottom: 3px solid #1e293b;
  height: 1px;
  margin-top: 6px;
}

/* Score 6: slight frown */
.mouth-6 {
  border: 3px solid #1e293b;
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  height: 10px;
}

/* Score 8: frown */
.mouth-8 {
  border: 3px solid #1e293b;
  border-bottom: none;
  border-radius: 26px 26px 0 0;
  height: 13px;
}

/* Score 10: open cry mouth */
.mouth-10 {
  border: 3px solid #1e293b;
  border-bottom: none;
  border-radius: 30px 30px 0 0;
  height: 14px;
  background: #7f1d1d;
  width: 28px;
}

/* ── Tears ────────────────────────────────────────────────────── */
.tear {
  position: absolute;
  width: 4px;
  height: 10px;
  background: #93c5fd;
  border-radius: 0 0 50% 50%;
  bottom: 8px;
}

.tear-l { left: 11px; }
.tear-r { right: 11px; }

/* ── Pain num + label ─────────────────────────────────────────── */
.pain-num {
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--c-primary);
  line-height: 1;
}

.pain-opt.selected .pain-num,
.pain-opt:has(input:checked) .pain-num {
  color: var(--c-primary);
}

.pain-label {
  font-size: var(--text-xs);
  color: var(--c-text-secondary);
  line-height: 1.3;
  text-align: center;
}

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

.faces-note a {
  color: var(--c-primary);
}

/* ── 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 denomination ─────────────────────────────────────── */
.result-denom {
  font-size: 0.6em;
  color: var(--c-text-secondary);
  font-weight: 500;
}

.result-item-large .result-value {
  font-size: var(--text-4xl);
}

/* ── Pain interpretation ─────────────────────────────────────── */
.pain-interpretation {
  margin-top: var(--s-5);
  padding-top: var(--s-5);
  border-top: 1px solid var(--c-border-light);
}

.guidance-text {
  font-size: var(--text-sm);
  color: var(--c-text);
  margin-bottom: var(--s-4);
  line-height: 1.6;
}

.pain-interpretation 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);
}

.intervention-list {
  margin: 0 0 var(--s-4) var(--s-5);
  font-size: var(--text-sm);
  color: var(--c-text);
  line-height: 1.6;
}

.intervention-list li {
  margin-bottom: var(--s-1);
}

.pain-disclaimer {
  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);
}

/* ── Result attribution. MANDATORY ─────────────────────────── */
.result-attribution {
  margin-top: var(--s-4);
  font-size: var(--text-xs);
  color: var(--c-text-secondary);
  text-align: center;
  padding: var(--s-2) 0;
  border-top: 1px solid var(--c-border-light);
}

.result-attribution a {
  color: var(--c-primary);
}

/* ── 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: 768px) {
  .pain-scale-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--s-3);
  }
}

@media (max-width: 480px) {
  .pain-scale-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .face-circle {
    width: 48px;
    height: 48px;
  }
}

/* ── Print ───────────────────────────────────────────────────── */
@media print {
  #calcBtn,
  #clearBtn,
  #downloadPdfBtn {
    display: none;
  }

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

  /* Always print attribution */
  .result-attribution,
  .attribution-banner {
    display: block !important;
  }
}
