/* Ficha pública de detalle de examen (/examenes/<slug>/).
   Mismo lenguaje visual que la ficha de organismo (organism-detail-2026.css)
   -- proporciones, densidad, hero, identidad -- pero SIN cargar ni copiar ese
   archivo: reutiliza los componentes globales (card, modern-card, pill, btn,
   public-eyebrow, breadcrumbs) y los tokens globales, y sólo define aquí las
   clases propias de esta página, con el prefijo `xdet-`. */

/* ---------- HERO ---------- */
.xdet-hero {
  padding-top: 24px;
  padding-bottom: 28px;
}

.xdet-hero__topline {
  margin-bottom: 12px;
}

.xdet-hero__card {
  background: var(--card);
  border: 1px solid rgba(30, 99, 255, 0.12);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px;
}

.xdet-hero__identity {
  display: flex;
  align-items: flex-start;
  gap: 20px;
}

.xdet-hero__logo {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 96px;
  height: 96px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.xdet-hero__logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.xdet-hero__logo svg {
  width: 52%;
  height: 52%;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* El SVG de fallback sólo se ve si no hay <img> (o si onerror la elimina). */
.xdet-hero__logo img + svg {
  display: none;
}

.xdet-hero__content {
  min-width: 0;
  flex: 1 1 auto;
}

.xdet-hero__title {
  margin: 8px 0 0;
  font-size: clamp(1.5rem, 1.1rem + 1.8vw, 2.15rem);
  line-height: 1.2;
  color: var(--text);
  /* break-word (no "anywhere"): parte una palabra sólo si por sí sola no
     cabe, evitando cortes feos tipo "Administrativ|o/a" cuando sí cabría
     en su propia línea. */
  overflow-wrap: break-word;
  hyphens: none;
}

.xdet-hero__org {
  margin: 10px 0 0;
  font-size: 1.05rem;
  font-weight: 750;
  color: var(--text-secondary);
}

.xdet-hero__org a {
  color: var(--primary);
  text-decoration: none;
}

.xdet-hero__org a:hover {
  text-decoration: underline;
}

.xdet-hero__facts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 0;
  margin: 14px 0 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 650;
}

.xdet-hero__facts span:not(:last-child)::after {
  content: "·";
  margin: 0 10px;
  color: var(--muted);
}

/* En móvil estrecho: una línea por dato, sin separadores colgando. */
@media (max-width: 460px) {
  .xdet-hero__facts {
    flex-direction: column;
  }
  .xdet-hero__facts span:not(:last-child)::after {
    content: none;
  }
}

.xdet-hero__plaza {
  margin: 12px 0 0;
}

.xdet-hero__plaza .pill {
  max-width: 100%;
  white-space: normal;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.xdet-hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.xdet-hero__actions .btn {
  min-height: 44px;
  white-space: normal;
}

/* ---------- LAYOUT PRINCIPAL ---------- */
.xdet-main {
  display: grid;
  gap: 18px;
  margin-bottom: 32px;
}

.xdet-content,
.xdet-attempts,
.xdet-run,
.xdet-staff {
  padding: 24px;
}

.xdet-content__head,
.xdet-section__head,
.xdet-more__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 18px;
  margin-bottom: 16px;
}

.xdet-content h2,
.xdet-attempts h2,
.xdet-run h2,
.xdet-more h2,
.xdet-staff h2 {
  margin: 0;
  font-size: 1.4rem;
  line-height: 1.2;
  color: var(--text);
}

.xdet-content__summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

/* ---------- CONTENIDO DEL EXAMEN (materias) ---------- */
.xdet-materias {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.xdet-materia__row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 14px;
}

.xdet-materia__name {
  min-width: 0;
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}

.xdet-materia__count {
  flex: 0 0 auto;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.xdet-materia__track {
  margin-top: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--border-light);
  overflow: hidden;
}

.xdet-materia__bar {
  display: block;
  height: 100%;
  min-width: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), #1f7db5);
}

.xdet-materia--none .xdet-materia__name {
  color: var(--muted);
}

.xdet-section__head a {
  color: var(--primary);
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
}

.xdet-section__head a:hover {
  text-decoration: underline;
}

/* ---------- ÚLTIMOS INTENTOS (autenticado) ---------- */
.xdet-attempts__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.xdet-attempt {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
}

.xdet-attempt__head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.85rem;
}

.xdet-attempt dl {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 12px;
  margin: 10px 0;
}

.xdet-attempt dt {
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.xdet-attempt dd {
  margin: 0;
  font-weight: 800;
}

/* ---------- REALIZA EL EXAMEN ---------- */
.xdet-correccion {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft, rgba(15, 23, 42, 0.02));
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
}

.xdet-correccion strong {
  color: var(--text);
}

.xdet-run__lead {
  margin: 0 0 16px;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.xdet-run__lead a {
  color: var(--primary);
}

.xdet-run__empty {
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
}

.xdet-run__empty p {
  margin: 0 0 12px;
  color: var(--text-secondary);
}

.xdet-run__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.xdet-run__actions .btn {
  min-height: 44px;
}

.xdet-shuffle {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.xdet-shuffle input {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.xdet-shuffle span {
  display: block;
}

.xdet-shuffle small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

/* ---------- PROGRESO (anónimo) ---------- */
.xdet-progress {
  margin: 0 0 18px;
}

.xdet-progress__text {
  margin: 0 0 8px;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text);
}

.xdet-progress__track {
  height: 8px;
  border-radius: 999px;
  background: var(--border-light);
  overflow: hidden;
}

.xdet-progress__bar {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), #1f7db5);
  transition: width 0.2s ease;
}

.xdet-progress__hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

/* ---------- RESULTADO (corrección anónima) ---------- */
.xdet-result {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 20px;
}

.xdet-result > div {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-align: center;
}

.xdet-result strong {
  display: block;
  color: var(--primary);
  font-size: 1.5rem;
  line-height: 1;
}

.xdet-result span {
  display: block;
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 700;
}

/* ---------- PREGUNTAS ---------- */
.xdet-form {
  display: grid;
  gap: 14px;
}

.xdet-q {
  margin: 0;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
}

.xdet-q__legend {
  display: block;
  width: 100%;
  padding: 0;
}

.xdet-q__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.xdet-q__num {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.xdet-q__tema {
  max-width: 100%;
  padding: 3px 10px;
  font-size: 0.72rem;
  white-space: normal;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.xdet-q__text {
  display: block;
  color: var(--text);
  font-size: 1rem;
  font-weight: 750;
  line-height: 1.5;
}

.xdet-q__options {
  counter-reset: xdetopt;
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.xdet-opt {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  min-height: 44px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.xdet-opt:hover {
  border-color: rgba(30, 99, 255, 0.3);
  background: rgba(30, 99, 255, 0.04);
}

.xdet-opt input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--primary);
}

.xdet-opt__mark {
  flex: 0 0 auto;
  font-weight: 800;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.xdet-opt__mark::after {
  counter-increment: xdetopt;
  content: counter(xdetopt, upper-alpha) ")";
}

.xdet-opt__text {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.xdet-opt__flag {
  flex: 0 0 auto;
  align-self: center;
  font-size: 0.78rem;
  font-weight: 800;
}

.xdet-opt__flag--ok {
  color: #047857;
}

.xdet-opt__flag--ko {
  color: #b91c1c;
}

.xdet-opt.is-correct {
  border-color: rgba(4, 120, 87, 0.5);
  background: rgba(16, 185, 129, 0.08);
}

.xdet-opt.is-wrong {
  border-color: rgba(185, 28, 28, 0.5);
  background: rgba(239, 68, 68, 0.07);
}

/* Foco visible, teclado. El label es la superficie clicable; el foco del
   input real se refleja en todo el recuadro. */
.xdet-opt:focus-within {
  outline: 3px solid rgba(30, 99, 255, 0.4);
  outline-offset: 2px;
}

.xdet-form__footer {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 4px;
}

.xdet-form__footer .btn {
  min-height: 44px;
}

/* ---------- MÁS EXÁMENES ---------- */
.xdet-more {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.xdet-more__head a {
  color: var(--primary);
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
  white-space: nowrap;
}

.xdet-more__head a:hover {
  text-decoration: underline;
}

.xdet-more__list {
  display: grid;
  gap: 10px;
}

.xdet-more__row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.xdet-more__logo {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--muted);
}

.xdet-more__logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

.xdet-more__body {
  min-width: 0;
}

.xdet-more__title {
  display: block;
  color: var(--text);
  font-weight: 750;
  font-size: 0.95rem;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.xdet-more__title:hover {
  color: var(--primary);
  text-decoration: underline;
}

.xdet-more__sub {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

/* ---------- STAFF ---------- */
.xdet-staff__list {
  padding-left: 20px;
  display: grid;
  gap: 12px;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 720px) {
  .xdet-result {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .xdet-hero__identity {
    gap: 14px;
  }

  .xdet-hero__logo {
    width: 68px;
    height: 68px;
    padding: 8px;
    border-radius: 12px;
  }

  .xdet-content,
  .xdet-attempts,
  .xdet-run,
  .xdet-more,
  .xdet-staff {
    padding: 18px;
  }

  .xdet-q {
    padding: 14px;
  }

  .xdet-hero__actions .btn,
  .xdet-run__actions .btn,
  .xdet-form__footer .btn {
    width: 100%;
  }
}

/* Muy estrecho (~320-400px): escudo encima del texto para que el H1
   disponga de todo el ancho y no se parta a mitad de palabra. */
@media (max-width: 400px) {
  .xdet-hero__identity {
    flex-direction: column;
    gap: 12px;
  }
}
