/* ============================================================
   RDK Terapia — Motor de Tests (test-engine.css)
   Vanilla CSS, mobile-first, identidad de rdkterapia.com:
   ocean #1B4965 · teal #5FA8D3 · cream #F4E9CD · coral #E07A5F
   warm #FDFAF3 · deep #0D2B3E · Inter (sans) + Playfair Display (serif)
   Wayne · C14·F1 · 2026-07-06
   ============================================================ */

.rdk-test {
  --ocean: #1B4965;
  --teal: #5FA8D3;
  --cream: #F4E9CD;
  --coral: #E07A5F;
  --coral-dark: #c9644b;
  --warm: #FDFAF3;
  --deep: #0D2B3E;
  --ok: #3f8f6a;
  --alert: #b1462f;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--deep);
  max-width: 640px;
  margin: 0 auto;
  position: relative;
}

.rdk-test * { box-sizing: border-box; }

.rdk-test .rdk-card {
  background: var(--warm);
  border: 1px solid rgba(27,73,101,0.10);
  border-radius: 20px;
  padding: 28px 22px;
  box-shadow: 0 10px 30px rgba(13,43,62,0.08);
  /* Deja aire para que un header sticky del sitio (comun en las paginas
     que usan este motor) no tape el titulo al hacer scrollIntoView. */
  scroll-margin-top: 90px;
}

@media (min-width: 640px) {
  .rdk-test .rdk-card { padding: 40px 44px; }
}

/* ---------- Progreso ---------- */
.rdk-progress-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}
.rdk-progress-track {
  flex: 1;
  height: 8px;
  background: rgba(27,73,101,0.12);
  border-radius: 99px;
  overflow: hidden;
}
.rdk-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--coral));
  border-radius: 99px;
  transition: width 0.4s ease;
  width: 0%;
}
.rdk-progress-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ocean);
  white-space: nowrap;
}

/* ---------- Intro ---------- */
.rdk-intro h2 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.5rem;
  color: var(--ocean);
  margin: 0 0 12px;
}
.rdk-intro p { line-height: 1.6; margin: 0 0 14px; color: #3a4a54; }
.rdk-intro ul { margin: 0 0 20px; padding-left: 1.2rem; line-height: 1.6; color: #3a4a54; }
.rdk-banner {
  background: rgba(95,168,211,0.14);
  border-left: 4px solid var(--teal);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--ocean);
  margin: 0 0 20px;
}

/* ---------- Preguntas ---------- */
.rdk-question { animation: rdkFadeUp 0.35s ease-out; }
.rdk-question legend,
.rdk-question .rdk-q-text {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.25rem;
  color: var(--ocean);
  line-height: 1.4;
  margin: 0 0 6px;
  display: block;
}
.rdk-q-kicker {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--coral);
  margin: 0 0 8px;
}
.rdk-q-sub {
  font-size: 0.9rem;
  color: #5a6a74;
  margin: 0 0 22px;
}

.rdk-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rdk-option {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 14px 18px;
  border: 2px solid rgba(27,73,101,0.15);
  border-radius: 14px;
  background: #fff;
  font-size: 1rem;
  font-weight: 500;
  color: var(--deep);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s, background 0.2s, transform 0.1s;
  width: 100%;
}
.rdk-option:hover { border-color: var(--teal); }
.rdk-option:active { transform: scale(0.99); }
.rdk-option .rdk-opt-key {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(27,73,101,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ocean);
}
.rdk-option[aria-pressed="true"] {
  border-color: var(--coral);
  background: rgba(224,122,95,0.08);
}
.rdk-option[aria-pressed="true"] .rdk-opt-key {
  background: var(--coral);
  border-color: var(--coral);
  color: #fff;
}
.rdk-option:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}

.rdk-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
}
.rdk-btn {
  min-height: 48px;
  padding: 12px 22px;
  border-radius: 999px;
  border: none;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s, box-shadow 0.2s;
}
.rdk-btn:active { transform: scale(0.97); }
.rdk-btn-primary { background: var(--coral); color: #fff; }
.rdk-btn-primary:hover { background: var(--coral-dark); }
.rdk-btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.rdk-btn-ghost { background: transparent; color: var(--ocean); border: 2px solid rgba(27,73,101,0.2); }
.rdk-btn-ghost:hover { background: rgba(27,73,101,0.06); }
.rdk-btn-secondary { background: var(--teal); color: #fff; }
.rdk-btn-secondary:hover { background: #4a8fb8; }
.rdk-btn-block { width: 100%; }

/* ---------- Resultado ---------- */
.rdk-result { animation: rdkReveal 0.6s cubic-bezier(.2,.9,.3,1.2); }
@keyframes rdkReveal {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes rdkFadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.rdk-result-score {
  text-align: center;
  margin-bottom: 18px;
}
.rdk-result-score .rdk-score-num {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 3.2rem;
  font-weight: 700;
  color: var(--ocean);
  line-height: 1;
  display: block;
}
.rdk-result-score .rdk-score-max {
  font-size: 1rem;
  color: #7a8790;
}
.rdk-badge {
  display: inline-block;
  margin-top: 10px;
  padding: 6px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.rdk-badge-minima { background: rgba(63,143,106,0.15); color: var(--ok); }
.rdk-badge-leve { background: rgba(95,168,211,0.18); color: var(--ocean); }
.rdk-badge-moderada { background: rgba(224,122,95,0.18); color: var(--coral-dark); }
.rdk-badge-severa { background: rgba(177,70,47,0.15); color: var(--alert); }
/* Bucket generico de 4 niveles de severidad (banda.severidad), usado por los
   tests 2-10: cada instrumento tiene sus propios ids de banda (bajo/leve/
   moderado/critico, muy_baja/saludable/alta, en_riesgo/solida...), asi que en
   vez de una clase CSS por cada id posible, el motor pinta segun 4 niveles
   fijos que cada banda declara explicitamente en su JSON. */
.rdk-badge-ok { background: rgba(63,143,106,0.15); color: var(--ok); }
.rdk-badge-atencion { background: rgba(95,168,211,0.18); color: var(--ocean); }
.rdk-badge-alerta { background: rgba(224,122,95,0.18); color: var(--coral-dark); }
.rdk-badge-critico { background: rgba(177,70,47,0.15); color: var(--alert); }

.rdk-result h3 {
  font-family: 'Playfair Display', Georgia, serif;
  color: var(--ocean);
  font-size: 1.3rem;
  margin: 18px 0 8px;
}
.rdk-result p { line-height: 1.65; color: #33424b; margin: 0 0 14px; }
.rdk-result ul { line-height: 1.6; color: #33424b; padding-left: 1.2rem; margin: 0 0 16px; }
.rdk-result-personal {
  background: rgba(224,122,95,0.08);
  border-left: 4px solid var(--coral);
  border-radius: 10px;
  padding: 14px 16px;
  font-style: italic;
  margin: 0 0 18px;
}

/* Recursos de crisis */
.rdk-crisis {
  background: #fdecea;
  border: 2px solid var(--alert);
  border-radius: 14px;
  padding: 18px;
  margin: 0 0 20px;
}
.rdk-crisis h3 { color: var(--alert); margin-top: 0; }
.rdk-crisis ul { margin: 10px 0 0; padding-left: 1.1rem; }
.rdk-crisis li { margin-bottom: 6px; }

.rdk-cta-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}
@media (min-width: 480px) {
  .rdk-cta-row { flex-direction: row; }
  .rdk-cta-row .rdk-btn { flex: 1; }
}

/* Gate de correo */
.rdk-gate {
  margin-top: 24px;
  border-top: 1px solid rgba(27,73,101,0.12);
  padding-top: 20px;
}
.rdk-gate h4 {
  font-family: 'Playfair Display', Georgia, serif;
  color: var(--ocean);
  margin: 0 0 6px;
}
.rdk-gate p { font-size: 0.9rem; color: #5a6a74; margin: 0 0 14px; }
.rdk-gate-form { display: flex; flex-direction: column; gap: 10px; }
.rdk-gate-form input[type="email"] {
  min-height: 48px;
  padding: 0 16px;
  border: 2px solid rgba(27,73,101,0.18);
  border-radius: 12px;
  font-size: 1rem;
  font-family: inherit;
}
.rdk-gate-form input[type="email"]:focus-visible { outline: 3px solid var(--teal); outline-offset: 1px; }
.rdk-gate-consent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.82rem;
  color: #5a6a74;
  line-height: 1.4;
}
.rdk-gate-consent input { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }
.rdk-gate-status { font-size: 0.85rem; margin-top: 8px; min-height: 1.2em; }
.rdk-gate-status.ok { color: var(--ok); font-weight: 600; }
.rdk-gate-status.err { color: var(--alert); font-weight: 600; }

.rdk-secondary-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.rdk-link-btn {
  background: none;
  border: none;
  color: var(--ocean);
  font-size: 0.85rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 6px 0;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.rdk-remind-note {
  font-size: 0.82rem;
  color: var(--ok);
  background: rgba(63,143,106,0.1);
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 10px;
}

.rdk-footnote {
  font-size: 0.78rem;
  color: #7a8790;
  margin-top: 22px;
  line-height: 1.5;
}

.rdk-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;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .rdk-test .rdk-question,
  .rdk-test .rdk-result,
  .rdk-test .rdk-progress-fill {
    animation: none !important;
    transition: none !important;
  }
}
