/* ==========================================================================
   Diagnóstico PRE-CPP — self-assessment tool
   Visually integrated with the rest of the design system (same tokens,
   same button/field/chip components) rather than a separate skin.
   ========================================================================== */

.diagnostic {
  padding-block: 0 var(--section-pad);
  background: var(--paper);
  /* Defense in depth for any link that still lands on the section itself
     (browser history, an external/bookmarked #diagnostico anchor) — the
     real entry points (nav, footer) target #diagApp directly instead. */
  scroll-margin-top: var(--nav-h);
}

/* --- Dark intro band, echoes the hero's tone as the section's own "masthead" --- */
.diag-head {
  background: radial-gradient(ellipse 120% 100% at 15% 0%, var(--navy-800) 0%, var(--navy-950) 60%), var(--navy-950);
  padding-block: var(--section-pad) clamp(2rem, 5vw, 3rem);
  color: var(--text-1);
}

.diag-head .lede {
  max-width: 48rem;
  margin-top: var(--sp-3);
}

/* --- Progress rail --- */
.diag-rail {
  background: var(--navy-950);
  padding-bottom: clamp(1.5rem, 4vw, 2.25rem);
}

.diag-progress-track {
  height: 3px;
  background: var(--navy-700);
  border-radius: var(--r-pill);
  overflow: hidden;
}

.diag-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold-500), var(--gold-300));
  transition: width 0.5s var(--ease-out);
}

.diag-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: var(--text-3);
  margin-top: 0.6rem;
}

/* --- App shell: light card floating up from the dark head/rail --- */
.diag-app {
  position: relative;
  max-width: 46rem;
  margin-inline: auto;
  margin-top: clamp(-3rem, -4vw, -2rem);
  scroll-margin-top: calc(var(--nav-h) + var(--sp-4));
  background: var(--paper-raised);
  border: 1px solid var(--paper-line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  padding: clamp(1.5rem, 4vw, 2.75rem);
  color: var(--paper-ink-1);
}

.diag-screen {
  display: none;
}

.diag-screen.is-active {
  display: block;
  animation: diag-fade-in 0.4s ease;
}

@keyframes diag-fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .diag-screen.is-active {
    animation: none;
  }
}

.diag-step-eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-600);
  margin: 0 0 0.4rem;
}

.diag-screen-title {
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 1.1rem + 0.8vw, 1.7rem);
  font-weight: 600;
  color: var(--paper-ink-1);
  margin: 0 0 0.5rem;
  line-height: 1.2;
}

.diag-screen-sub {
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--paper-ink-2);
  max-width: 42rem;
  margin: 0 0 var(--sp-6);
}

/* --- Chat-style intro bubble --- */
.diag-chat {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  margin-bottom: var(--sp-5);
}

.diag-chat-avatar {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--navy-800);
  color: var(--gold-400);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.8rem;
  margin-top: 0.1rem;
}

.diag-chat-bubble {
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: var(--r-md);
  padding: 0.9rem 1.1rem;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--paper-ink-2);
}

/* --- Form fields (light-themed variant of the site's .field) --- */
.diag-field {
  margin-bottom: var(--sp-5);
}

.diag-field > label,
.diag-field-row > .diag-field > label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--paper-ink-1);
  margin-bottom: 0.5rem;
}

.diag-field input[type="text"],
.diag-field input[type="email"] {
  width: 100%;
  padding: 0.8em 0.9em;
  font-size: 0.95rem;
  font-family: var(--font-body);
  color: var(--paper-ink-1);
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: var(--r-sm);
  transition: border-color var(--dur-fast) var(--ease-out);
}

.diag-field input::placeholder {
  color: var(--paper-ink-3);
}

.diag-field input:focus {
  outline: none;
  border-color: var(--gold-500);
  box-shadow: 0 0 0 3px rgba(205, 161, 83, 0.18);
}

.diag-field.has-error input {
  border-color: var(--danger);
}

.diag-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}

@media (max-width: 560px) {
  .diag-field-row {
    grid-template-columns: 1fr;
  }
}

/* --- Choice grid (real <button> elements — keyboard + a11y friendly) --- */
.diag-choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  border-radius: var(--r-md);
  transition: box-shadow var(--dur-fast) var(--ease-out);
}

.diag-field.has-error .diag-choice-grid {
  box-shadow: 0 0 0 2px rgba(224, 101, 79, 0.5);
  padding: 0.4rem;
  margin: -0.4rem;
}

@media (max-width: 560px) {
  .diag-choice-grid {
    grid-template-columns: 1fr;
  }
}

.diag-choice {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--paper-line);
  border-radius: var(--r-sm);
  padding: 0.85em 1em;
  font-family: var(--font-body);
  font-size: 0.86rem;
  color: var(--paper-ink-2);
  background: var(--paper);
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.diag-choice:hover {
  border-color: var(--gold-500);
}

.diag-choice.is-selected {
  border-color: var(--navy-800);
  background: var(--navy-800);
  color: var(--text-1);
}

.diag-choice.is-selected::before {
  content: "✓ ";
  color: var(--gold-400);
  font-weight: 700;
}

/* --- Domain assessment --- */
.diag-domain-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--gold-600);
  margin-bottom: 0.6rem;
}

.diag-domain-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--navy-800);
  color: var(--gold-400);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.68rem;
}

.diag-question-card {
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-left: 3px solid var(--navy-800);
  border-radius: var(--r-sm);
  padding: 1.2rem 1.3rem;
  margin-bottom: var(--sp-4);
}

.diag-question-topic {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--paper-ink-1);
  line-height: 1.4;
  margin: 0 0 0.3rem;
}

.diag-question-sub {
  font-size: 0.78rem;
  color: var(--paper-ink-3);
  margin: 0 0 0.9rem;
}

.diag-scale {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.4rem;
}

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

.diag-scale-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.65em 0.2em 0.55em;
  border: 1px solid var(--paper-line);
  background: var(--paper-raised);
  border-radius: var(--r-sm);
  cursor: pointer;
  touch-action: manipulation;
  min-height: 44px;
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}

.diag-scale-btn:hover {
  border-color: var(--gold-500);
}

.diag-scale-btn .n {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--paper-ink-1);
}

.diag-scale-btn .lbl {
  font-size: 0.62rem;
  letter-spacing: 0.01em;
  color: var(--paper-ink-3);
  line-height: 1.2;
  text-align: center;
}

.diag-scale-btn.is-selected {
  background: var(--navy-800);
  border-color: var(--navy-800);
}

.diag-scale-btn.is-selected .n,
.diag-scale-btn.is-selected .lbl {
  color: var(--text-1);
}

/* --- Nav row --- */
.diag-nav-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-6);
  flex-wrap: wrap;
}

.diag-nav-row--start {
  justify-content: flex-start;
}

/* --- Results --- */
.diag-overall-panel {
  background: var(--navy-900);
  border-radius: var(--r-md);
  padding: clamp(1.3rem, 3vw, 2rem);
  color: var(--text-1);
  display: flex;
  align-items: center;
  gap: var(--sp-6);
  margin-bottom: var(--sp-6);
  flex-wrap: wrap;
}

.diag-overall-ring {
  position: relative;
  width: 116px;
  height: 116px;
  flex: none;
}

.diag-overall-ring svg {
  width: 100%;
  height: 100%;
}

.diag-ring-num {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.diag-ring-num .pct {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1;
}

.diag-ring-num .pct-sign {
  font-size: 0.68rem;
  color: var(--text-3);
}

.diag-overall-copy {
  flex: 1;
  min-width: 200px;
}

.diag-level-tag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--navy-950);
  background: var(--gold-400);
  padding: 0.3em 0.7em;
  border-radius: var(--r-pill);
  margin-bottom: 0.6rem;
}

.diag-overall-copy h4 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: var(--text-1);
}

.diag-overall-copy p {
  font-size: 0.85rem;
  color: var(--text-2);
  line-height: 1.55;
  margin: 0;
}

.diag-domain-results {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin-bottom: var(--sp-6);
}

.diag-domain-result-row {
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: var(--r-sm);
  padding: 0.9rem 1.05rem;
}

.diag-drr-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-3);
  margin-bottom: 0.5rem;
}

.diag-drr-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--paper-ink-1);
}

.diag-drr-pct {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--paper-ink-1);
  flex: none;
}

.diag-drr-bar-track {
  height: 7px;
  background: var(--paper-line);
  border-radius: var(--r-pill);
  overflow: hidden;
}

.diag-drr-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: var(--r-pill);
  transition: width 1s var(--ease-out);
}

.diag-level-legend {
  display: flex;
  gap: var(--sp-4);
  flex-wrap: wrap;
  font-size: 0.72rem;
  color: var(--paper-ink-3);
  margin-top: -0.4rem;
  margin-bottom: var(--sp-6);
  padding-top: 0.9rem;
  border-top: 1px solid var(--paper-line);
}

.diag-level-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.diag-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.diag-recommend-box {
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: var(--r-sm);
  padding: 1.3rem 1.4rem;
  margin-bottom: var(--sp-5);
}

.diag-recommend-box h4 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.7rem;
  color: var(--paper-ink-1);
}

.diag-recommend-box ul {
  margin: 0;
  padding-left: 1.1rem;
}

.diag-recommend-box li {
  font-size: 0.85rem;
  color: var(--paper-ink-2);
  line-height: 1.7;
}

.diag-motivation-summary {
  font-size: 0.82rem;
  color: var(--paper-ink-2);
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: var(--r-sm);
  padding: 0.95rem 1.1rem;
  margin-bottom: var(--sp-5);
  line-height: 1.6;
}

.diag-motivation-summary strong {
  color: var(--paper-ink-1);
}

.diag-footer-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.diag-db-status {
  font-size: 0.76rem;
  color: var(--paper-ink-3);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.9rem 0 0.2rem;
}

.diag-db-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--paper-ink-3);
  flex: none;
}

.diag-db-status.is-ok {
  color: var(--success);
}

.diag-db-status.is-ok::before {
  background: var(--success);
}

.diag-db-status.is-warn {
  color: var(--amber, #96631b);
}

.diag-db-status.is-warn::before {
  background: var(--amber, #96631b);
}

.diag-db-status.is-pending::before {
  animation: pulse-ring 1.4s ease-out infinite;
}

/* --- Historical participants panel ---
   Hidden by default: this lists other participants' names, organizations
   and scores, which is not appropriate for every visitor of a public page
   to browse. diagnostic.js only reveals it when the page is opened with
   ?admin=1, pending a real authenticated admin area. */
.diag-historico-panel {
  display: none;
  margin-top: var(--sp-7);
  padding-top: var(--sp-6);
  border-top: 1px solid var(--paper-line);
}

.diag-historico-panel.is-visible {
  display: block;
}

.diag-historico-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}

.diag-historico-header h4 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  color: var(--paper-ink-1);
}

.diag-shared-note {
  font-size: 0.76rem;
  color: var(--paper-ink-3);
  background: rgba(205, 161, 83, 0.12);
  border: 1px solid rgba(205, 161, 83, 0.35);
  border-radius: var(--r-sm);
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.9rem;
  line-height: 1.5;
}

.diag-historico-status {
  font-size: 0.78rem;
  color: var(--paper-ink-3);
  margin-bottom: 0.9rem;
}

.diag-historico-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 320px;
  overflow-y: auto;
}

.diag-historico-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: var(--r-sm);
  padding: 0.7rem 0.9rem;
}

.diag-hr-main {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.diag-hr-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--paper-ink-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.diag-hr-meta {
  font-size: 0.7rem;
  color: var(--paper-ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.diag-hr-pct {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  flex: none;
}
