/* ============================================================
   Pudú — identidad visual (mascota del bosque del sur).
   Mobile-first, ancho de referencia 390px, tope 560px.
   ============================================================ */

:root {
  --bosque: #2F5D50;      /* primario: botones, títulos, progreso */
  --bosque-osc: #234539;
  --pudu: #A0522D;        /* café del pudú: acentos, chip "Por reforzar" */
  --crema: #F6F1E7;       /* fondo general */
  --papel: #FFFDF8;       /* tarjetas */
  --musgo: #C9B458;       /* acento: XP, chip "En camino" */
  --musgo-claro: #F1EBC8;
  --ok: #3B8B5A;  --ok-claro: #E3F2E7;
  --error: #C0583A; --error-claro: #FBE9E2;
  --tinta: #1F2A26;  --tinta-suave: #5B6B64;
  --borde: #E4DCCB;

  /* Tonos derivados: solo para texto/badges que necesitan AA sobre fondo claro. */
  --ok-osc: #2E6B45;
  --error-osc: #A9472C;

  --radio-tarjeta: 16px;
  --radio: 14px;
  --sombra-tarjeta: 0 2px 0 var(--borde), 0 8px 20px rgba(31, 42, 38, .05);
  --alto-cabecera: 60px;
  --nodo: 56px;
  --alto-colinas: 170px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--crema);
  color: var(--tinta);
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.55;
  overflow-x: hidden;
}

body.con-cabecera { padding-top: var(--alto-cabecera); }

/* ---------- colinas decorativas (solo inicio) ---------- */

.colinas {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 0;
  pointer-events: none;
}

.colinas[hidden] { display: none; }

.colinas svg { display: block; width: 100%; height: var(--alto-colinas); }

/* ---------- cabecera fija (todas las pantallas menos inicio) ---------- */

.cabecera {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--alto-cabecera);
  background: var(--crema);
  border-bottom: 2px solid var(--borde);
  z-index: 20;
}

.cabecera[hidden] { display: none; }

.cabecera__interior {
  max-width: 560px;
  margin: 0 auto;
  height: 100%;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cabecera__marca { display: inline-flex; align-items: center; gap: 8px; }

.cabecera__logo {
  display: block;
  width: 32px;
  height: 32px;
  border-radius: 9px;
}

.cabecera__nombre {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.01em;
  color: var(--bosque);
}

.cabecera__stats { display: inline-flex; align-items: center; gap: 8px; }

.cabecera__item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border: 1.5px solid var(--borde);
  border-radius: 999px;
  background: var(--papel);
  color: var(--tinta);
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- contenedor ---------- */

.app {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

/* ---------- inicio ---------- */

.inicio {
  min-height: calc(100vh - 60px);
  min-height: calc(100svh - 60px);
  padding-bottom: 80px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.inicio__pudu { margin-bottom: 10px; }

.inicio__pudu-img {
  display: block;
  height: 180px;
  width: auto;
  animation: flotar 3s ease-in-out infinite;
}

@keyframes flotar {
  0%, 100% { transform: translateY(-6px); }
  50%      { transform: translateY(6px); }
}

.inicio__titulo {
  margin: 0 0 2px;
  font-size: 44px;
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -.03em;
  color: var(--bosque);
}

.inicio__sub {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 600;
  color: var(--tinta-suave);
}

.inicio__linea {
  margin: 0 0 26px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--tinta-suave);
}

.inicio__acciones {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.inicio__nota {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--tinta-suave);
}

/* ---------- botones ---------- */

.btn {
  width: 100%;
  min-height: 52px;
  padding: 13px 20px;
  border: 2px solid transparent;
  border-radius: var(--radio);
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: .01em;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease,
              transform .06s ease, box-shadow .06s ease;
}

.btn:disabled { opacity: .55; cursor: default; }

.btn--primario {
  background: var(--bosque);
  color: #fff;
  box-shadow: 0 4px 0 var(--bosque-osc);
}

.btn--primario:hover:not(:disabled) { background: #356a5b; }

.btn--primario:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--bosque-osc);
}

.btn--borde {
  background: var(--papel);
  color: var(--bosque);
  border-color: var(--borde);
  box-shadow: 0 4px 0 var(--borde);
}

.btn--borde:hover:not(:disabled) { border-color: var(--bosque); }

.btn--borde:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--borde);
}

.btn--texto {
  min-height: 44px;
  background: transparent;
  color: var(--bosque);
  border-color: transparent;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn--peligro {
  background: var(--papel);
  color: var(--error-osc);
  border-color: #E7C6B8;
}

.btn--peligro:hover:not(:disabled) { background: var(--error-claro); }

/* ---------- barra de progreso ---------- */

.prog { margin: 0 0 18px; }

.prog__texto {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--tinta-suave);
  font-variant-numeric: tabular-nums;
}

.prog__caja {
  height: 10px;
  border-radius: 999px;
  background: var(--borde);
  overflow: hidden;
}

.prog__barra {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--bosque);
  transition: width .25s ease;
}

/* ---------- meta (unidad / nivel) ---------- */

.meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }

.chip {
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--musgo-claro);
  color: var(--tinta);
  font-size: 12px;
  font-weight: 800;
}

.chip--nivel { background: var(--papel); border: 1.5px solid var(--borde); color: var(--bosque); }

/* ---------- burbuja del pudú (primera pregunta del diagnóstico) ---------- */

.burbuja {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  margin: 0 0 20px;
}

.burbuja__pudu {
  flex: 0 0 auto;
  display: block;
  width: 60px;
  height: auto;
}

.burbuja__texto {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  margin: 0 0 22px;
  padding: 12px 15px;
  border: 2px solid var(--borde);
  border-radius: var(--radio-tarjeta);
  border-bottom-left-radius: 6px;
  background: var(--papel);
  box-shadow: 0 2px 0 var(--borde);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

/* cola de la burbuja, apuntando al pudú */
.burbuja__texto::before,
.burbuja__texto::after {
  content: "";
  position: absolute;
  bottom: 10px;
  width: 0;
  height: 0;
  border-style: solid;
}

.burbuja__texto::before {
  left: -12px;
  border-width: 8px 12px 8px 0;
  border-color: transparent var(--borde) transparent transparent;
}

.burbuja__texto::after {
  left: -8px;
  bottom: 12px;
  border-width: 6px 9px 6px 0;
  border-color: transparent var(--papel) transparent transparent;
}

/* ---------- enunciado ---------- */

.enunciado {
  font-size: 17px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.enunciado .katex { font-size: 1.02em; }

.tabla {
  width: 100%;
  margin: 10px 0;
  border-collapse: collapse;
  font-size: 15px;
}

.tabla th,
.tabla td {
  border: 1px solid var(--borde);
  padding: 6px 8px;
  text-align: left;
  overflow-wrap: anywhere;
}

.tabla th { background: var(--musgo-claro); font-weight: 800; }

.figura {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 16px auto;
  border: 2px solid var(--borde);
  border-radius: 12px;
  background: #fff;
}

/* ---------- alternativas ---------- */

.alts {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

.alt {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 60px;
  padding: 12px 14px;
  border: 2px solid var(--borde);
  border-radius: var(--radio);
  background: var(--papel);
  color: var(--tinta);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--borde);
  transition: border-color .15s ease, background-color .15s ease,
              opacity .15s ease, transform .06s ease;
}

.alt:hover:not(:disabled) { border-color: var(--bosque); }

.alt:active:not(:disabled) { transform: translateY(2px); }

.alt:disabled { cursor: default; }

.alt__letra {
  flex: 0 0 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--crema);
  border: 1.5px solid var(--borde);
  color: var(--bosque);
  font-size: 14px;
  font-weight: 900;
}

.alt--correcta {
  border-color: var(--ok);
  background: var(--ok-claro);
  box-shadow: 0 2px 0 var(--ok);
}

.alt--correcta .alt__letra {
  background: var(--ok-osc);
  border-color: var(--ok-osc);
  color: #fff;
}

.alt--incorrecta {
  border-color: var(--error);
  background: var(--error-claro);
  box-shadow: 0 2px 0 var(--error);
}

.alt--incorrecta .alt__letra {
  background: var(--error-osc);
  border-color: var(--error-osc);
  color: #fff;
}

.alt--atenuada { opacity: .5; }

/* ---------- hoja inferior de feedback (bottom sheet) ---------- */

.hoja {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  max-width: 560px;
  max-height: 74vh;
  margin: 0 auto;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  box-shadow: 0 -6px 24px rgba(31, 42, 38, .16);
  transform: translateY(105%);
  transition: transform .2s ease;
}

.hoja--visible { transform: translateY(0); }

.hoja--ok { background: var(--ok-claro); border-top: 4px solid var(--ok); }
.hoja--error { background: var(--error-claro); border-top: 4px solid var(--error); }

.hoja__cab { display: flex; align-items: flex-start; gap: 12px; }

.hoja--ok .hoja__cab { align-items: center; }

.hoja__pudu { flex: 0 0 auto; display: block; width: 64px; height: auto; }

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

.hoja__titulo {
  margin: 0 0 4px;
  font-size: 19px;
  font-weight: 800;
  line-height: 1.3;
  color: var(--tinta);
}

.hoja--ok .hoja__titulo { color: var(--ok-osc); font-size: 22px; }
.hoja--error .hoja__titulo { color: var(--error-osc); }

.hoja__xp {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 10px;
  vertical-align: 3px;
  border-radius: 999px;
  background: var(--musgo-claro);
  color: #6B5A12;
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
}

.hoja__texto {
  margin: 0;
  font-size: 16px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.hoja .btn { margin-top: 14px; }

/* ---------- desplegable ---------- */

.desp {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1.5px solid rgba(31, 42, 38, .12);
}

.desp summary {
  list-style: none;
  color: var(--bosque);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}

.desp summary::-webkit-details-marker { display: none; }

.desp summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 6px;
  transition: transform .15s ease;
}

.desp[open] summary::before { transform: rotate(90deg); }

.desp__cuerpo {
  margin-top: 10px;
  font-size: 16px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

/* ---------- títulos de pantalla ---------- */

.titulo-pantalla {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -.02em;
  color: var(--bosque);
}

.sub-pantalla {
  margin: 0 0 20px;
  font-size: 15px;
  font-weight: 600;
  color: var(--tinta-suave);
}

/* ---------- resultado del diagnóstico ---------- */

.res__pudu {
  display: block;
  width: 120px;
  height: auto;
  margin: 0 auto 14px;
}

.res__pudu + .titulo-pantalla { margin-bottom: 18px; text-align: center; }

.res {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
}

.res__item {
  padding: 12px 14px;
  border: 2px solid var(--borde);
  border-radius: var(--radio);
  background: var(--papel);
  box-shadow: 0 2px 0 var(--borde);
}

.res__item--bad { border-color: #EDCFC4; box-shadow: 0 2px 0 #EDCFC4; }
.res__item--mid { border-color: var(--musgo); box-shadow: 0 2px 0 var(--musgo); }
.res__item--ok  { border-color: #BEDCC8; box-shadow: 0 2px 0 #BEDCC8; }

.res__linea {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.res__unidad {
  font-size: 15px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.res__marcador {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 700;
  color: var(--tinta-suave);
  font-variant-numeric: tabular-nums;
}

.res__estado {
  display: inline-block;
  margin-top: 6px;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.res__item--bad .res__estado { background: var(--error-claro); color: var(--pudu); }
.res__item--mid .res__estado { background: var(--musgo-claro); color: var(--tinta); }
.res__item--ok  .res__estado { background: var(--ok-claro); color: var(--bosque-osc); }

.destacado {
  margin: 0 0 20px;
  padding: 13px 15px;
  border-radius: var(--radio);
  background: var(--musgo-claro);
  color: var(--bosque-osc);
  font-size: 15px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

/* ---------- mapa: tu sendero ---------- */

.mapa { display: flex; flex-direction: column; gap: 14px; }

.tarjeta {
  padding: 14px;
  border: 2px solid var(--borde);
  border-radius: var(--radio-tarjeta);
  background: var(--papel);
  box-shadow: var(--sombra-tarjeta);
}

.tarjeta__cab {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.tarjeta__titulo {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.badge {
  flex: 0 0 auto;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.badge--bad { background: var(--error-claro); color: var(--pudu); }
.badge--mid { background: var(--musgo-claro); color: var(--tinta); }
.badge--ok  { background: var(--ok-claro); color: var(--bosque-osc); }

/* el sendero: 3 nodos circulares unidos por una línea punteada */
.sendero {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.sendero::before {
  content: "";
  position: absolute;
  top: calc(var(--nodo) / 2 - 1.5px);
  left: 16.6%;
  right: 16.6%;
  border-top: 3px dashed var(--borde);
}

.tarjeta--con-pudu .sendero { padding-top: 62px; }

.tarjeta--con-pudu .sendero::before { top: calc(62px + var(--nodo) / 2 - 1.5px); }

.nodo-celda {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.nodo {
  position: relative;
  width: var(--nodo);
  height: var(--nodo);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  font: inherit;
  background: var(--papel);
}

.nodo .ico { width: 24px; height: 24px; color: #fff; }

.nodo--superada {
  background: var(--ok);
  border: 3px solid var(--ok);
}

.nodo--bloqueada {
  background: var(--borde);
  border: 3px solid var(--borde);
}

.nodo--bloqueada .ico { color: #6E7B74; }

.nodo--proximamente {
  background: var(--papel);
  border: 3px dashed var(--borde);
}

.nodo__pronto {
  font-size: 11px;
  font-weight: 800;
  color: var(--tinta-suave);
}

.nodo--disponible {
  background: #fff;
  border: 4px solid var(--bosque);
  box-shadow: 0 3px 0 var(--bosque-osc);
  cursor: pointer;
  transition: transform .06s ease, box-shadow .12s ease;
}

.nodo--disponible::after {
  content: "";
  position: absolute;
  inset: -9px;
  border: 3px solid var(--bosque);
  border-radius: 50%;
  opacity: .8;
  animation: latir 1.8s ease-out infinite;
}

@keyframes latir {
  0%   { transform: scale(.92); opacity: .75; }
  70%  { transform: scale(1.12); opacity: 0; }
  100% { transform: scale(1.12); opacity: 0; }
}

.nodo--disponible .ico { width: 22px; height: 22px; margin-left: 3px; color: var(--bosque); }

.nodo--disponible:hover { background: var(--ok-claro); }
.nodo--disponible:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--bosque-osc); }
.nodo--disponible:focus-visible { outline: 3px solid var(--musgo); outline-offset: 4px; }

.nodo__nom {
  font-size: 12px;
  font-weight: 800;
  color: var(--tinta-suave);
  text-align: center;
}

/* el pudú "¡Aquí!" posado arriba del primer nodo disponible de la página */
.nodo__pudu {
  position: absolute;
  bottom: 100%;
  left: 50%;
  margin-bottom: -2px;
  transform: translateX(-50%);
  pointer-events: none;
}

.nodo__pudu-img {
  display: block;
  width: 40px;
  height: auto;
  animation: flotar 3s ease-in-out infinite;
}

.nodo__pudu--izq .nodo__globo { left: auto; right: 30px; }

.nodo__globo {
  position: absolute;
  bottom: 30px;
  left: 30px;
  padding: 3px 9px;
  border: 2px solid var(--borde);
  border-radius: 999px;
  background: var(--papel);
  color: var(--bosque);
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
  box-shadow: 0 2px 0 var(--borde);
}

/* ---------- pie ---------- */

.pie {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 28px;
  text-align: center;
}

.pie__texto {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--tinta-suave);
}

/* ---------- fin de etapa ---------- */

.fin {
  position: relative;
  min-height: calc(100vh - var(--alto-cabecera) - 80px);
  min-height: calc(100svh - var(--alto-cabecera) - 80px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 10px 0 24px;
  text-align: center;
}

/* confeti: capa fija a pantalla completa, cae una sola vez */
.confeti {
  position: fixed;
  inset: 0;
  z-index: 40;
  overflow: hidden;
  pointer-events: none;
}

.confeti__pieza {
  position: absolute;
  top: -20px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  animation: caer 1.5s cubic-bezier(.25, .6, .45, 1) 1 both;
}

.confeti__pieza--redonda { width: 10px; height: 10px; border-radius: 50%; }

@keyframes caer {
  0%   { transform: translate(0, 0) rotate(0deg); opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translate(var(--deriva, 0px), 105vh) rotate(var(--giro, 360deg)); opacity: 0; }
}

.fin__pudu {
  position: relative;
  display: block;
  width: 140px;
  height: auto;
  margin: 0 auto 12px;
}

.fin__titulo {
  position: relative;
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -.02em;
  color: var(--bosque);
}

.fin__sub {
  position: relative;
  margin: 0 0 24px;
  color: var(--tinta-suave);
  font-size: 16px;
  font-weight: 700;
}

.fin__acciones {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- error ---------- */

.error {
  margin-top: 40px;
  padding: 16px;
  border: 2px solid #EDCFC4;
  border-radius: var(--radio);
  background: var(--error-claro);
  color: var(--error-osc);
  font-size: 15px;
  overflow-wrap: anywhere;
}

/* ---------- accesibilidad: menos movimiento ---------- */

@media (prefers-reduced-motion: reduce) {
  .inicio__pudu-img,
  .nodo__pudu-img { animation: none; }

  .nodo--disponible::after { animation: none; opacity: .35; }

  .confeti { display: none; }

  .hoja { transition: none; }

  .prog__barra,
  .desp summary::before,
  .btn,
  .alt { transition: none; }
}

/* Enlaces legales del inicio (Google los exige en la página principal) */
.inicio__legal { position: relative; z-index: 1; margin-top: 18px; font-size: 13px; color: var(--tinta-suave); }
.inicio__legal a { color: var(--tinta-suave); text-decoration: underline; }

/* ---------- cuenta (login opcional) ---------- */

.btn--enlace {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.avatar {
  width: 28px;
  height: 28px;
  margin-left: 4px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bosque);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  line-height: 28px;
  text-align: center;
  flex: none;
}

.avatar img { display: block; width: 28px; height: 28px; object-fit: cover; }

.pie__cuenta {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--tinta-suave);
}

.pie__salir {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 800;
  color: var(--bosque);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
