/* ═══ LUMBRE KNOWLEDGE MAP — vista del mapa (§43-§45) ═══
   Mobile-first: en teléfono el "mapa" es una órbita vertical de burbujas táctiles;
   en escritorio la órbita se despliega radialmente. DOM+CSS, nunca canvas opaco:
   todo nodo es un <a> real (teclado, lectores de pantalla, click medio). */

.map-page { max-width: 1080px; margin: 0 auto; padding: 16px clamp(12px, 4vw, 28px) calc(84px + env(safe-area-inset-bottom)); } /* fondo: tab bar fija móvil (~59px) nunca tapa un CTA */

/* ── topbar: lentes + modo ── */
.map-topbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.map-lenses { display: flex; gap: 6px; }
.map-lens { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; font: 600 14px/1 var(--font-ui); }
.map-lens.is-on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.map-modes { display: flex; gap: 4px; }
.map-mode { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font: 600 13px/1 var(--font-ui); cursor: pointer; }
.map-mode.is-on { color: var(--accent); border-color: var(--accent); }

.map-note { color: var(--muted); font-size: 14px; line-height: 1.5; }

/* ── «Para ti» (Fase 8, §41/§68): sólo aparece si hay recorrido REAL del usuario ── */
.map-foryou { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); margin: 0 0 18px; }
.map-foryou-tile { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border: 1px dashed var(--line); border-radius: var(--radius-md); background: var(--surface); text-decoration: none; color: var(--ink); }
.map-foryou-tile:hover, .map-foryou-tile:focus-visible { border-color: var(--accent); border-style: solid; }
.map-foryou-tile .ic { font-size: 20px; line-height: 1; }
.map-foryou-tile .bd { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.map-foryou-tile small { color: var(--muted); font: 500 11.5px/1.2 var(--font-ui); text-transform: uppercase; letter-spacing: .04em; }
.map-foryou-tile strong { font: 600 14px/1.2 var(--font-ui); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── escalón «Tengo tarea / Preparar examen» (Fase 9, §23) ── */
.map-ladder { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); padding: 18px clamp(14px, 3vw, 22px); margin: 0 0 20px; box-shadow: var(--shadow-sm); }
.map-ladder h1 { font: 700 clamp(22px, 5vw, 30px)/1.2 var(--font-reading); margin: 0 0 6px; }
.map-ladder-form { display: grid; gap: 12px; grid-template-columns: 1fr; margin-top: 14px; align-items: end; }
@media (min-width: 780px) { .map-ladder-form { grid-template-columns: 1.2fr 1fr 1.4fr auto; } }
.map-ladder-form label { display: flex; flex-direction: column; gap: 6px; font: 600 13px/1.2 var(--font-ui); color: var(--muted); }
.map-ladder-form select { padding: 10px 12px; border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: 500 14px/1.2 var(--font-ui); min-height: 42px; }
.map-ladder-form select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.map-quicklinks { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; }
.map-quick { padding: 9px 15px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; font: 600 14px/1 var(--font-ui); }
.map-quick:hover, .map-quick:focus-visible { border-color: var(--accent); color: var(--accent); }

/* ── Resultados de «Tengo tarea» (§8): lo pertinente a la tarea, no el catálogo general ── */
.map-hw-results { margin-top: 16px; border-top: 1px dashed var(--line); padding-top: 14px; }
.map-hw-results h2 { font: 700 clamp(16px, 3.4vw, 20px)/1.2 var(--font-reading); margin: 0 0 10px; }
.map-hw-next { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--bg); }
.map-hw-next small { display: block; flex-basis: 100%; font: 700 11px/1.2 var(--font-ui); letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.map-hw-next strong { font: 600 15px/1.3 var(--font-reading); margin-right: auto; }
.map-hw-next .map-btn.primary { text-decoration: none; white-space: nowrap; }
.map-hw-alts { margin-top: 10px; font: 600 13.5px/1.4 var(--font-ui); color: var(--muted); }
.map-hw-alts summary { cursor: pointer; padding: 6px 0; }
.map-hw-alts ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.map-hw-alts a { display: block; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius-md); color: var(--ink); text-decoration: none; background: var(--surface); }
.map-hw-alts a:hover, .map-hw-alts a:focus-visible { border-color: var(--accent); color: var(--accent); }
.map-hw-alts b { color: var(--accent); font-weight: 700; }
.map-hw-away { margin: 8px 0 20px; padding: 10px 14px; border-radius: var(--radius-md); background: var(--surface); border: 1px solid var(--line); }
@media (prefers-reduced-motion: reduce) { .map-hw-next, .map-hw-alts a { transition: none; } }

/* ── ZOOM 0: dos ejes en la misma pantalla — «Por tema» y «Por etapa escolar» ── */
.map-hero h1 { font: 700 clamp(24px, 5vw, 34px)/1.15 var(--font-reading); margin: 0 0 6px; }
.map-group + .map-group { margin-top: 28px; }
.map-group-h { font: 700 clamp(17px, 3.4vw, 21px)/1.2 var(--font-reading); margin: 0 0 2px; }
.map-group > .map-note { margin: 0 0 4px; }
.map-territories { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); }
.map-territory { --tint: var(--accent); }
.map-territory.acc-science  { --tint: #138A72; }
.map-territory.acc-space    { --tint: #7557E8; }
.map-territory.acc-history  { --tint: #9D6500; }
.map-territory.acc-society  { --tint: #2f6d68; }
.map-territory.acc-language { --tint: #BF4018; }
.map-territory.acc-art      { --tint: #C2347E; }
.map-territory.acc-tech     { --tint: #3764ff; }
.map-territory.acc-money    { --tint: #0E7259; }
.map-territory.acc-life     { --tint: #B93E3E; }
.map-territory.acc-teach    { --tint: #5C6577; }
.map-territory.acc-school   { --tint: #146C94; }   /* etapas escolares: azul aula, distinto de los territorios */
.map-territory a { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border: 1px solid var(--line); border-left: 4px solid var(--tint); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-sm); text-decoration: none; color: var(--ink); transition: transform .15s ease, box-shadow .15s ease; }
.map-territory a:hover, .map-territory a:focus-visible { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.map-territory-icon { font-size: 26px; line-height: 1; }
.map-territory-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.map-territory-body strong { font: 600 16px/1.2 var(--font-ui); }
.map-territory-body small { color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.map-territory-count { font: 600 12px/1.2 var(--font-ui); color: var(--tint); white-space: nowrap; }
.map-territory-count b { font-size: 16px; display: block; }

/* ── Mi escuela ── */
.map-school h1 { font: 700 clamp(22px, 5vw, 30px)/1.2 var(--font-reading); margin: 0 0 6px; }
.map-subjectlist { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); }
.map-subjectlist a { display: flex; justify-content: space-between; gap: 8px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); text-decoration: none; color: var(--ink); font-weight: 600; }
.map-subjectlist a:hover { border-color: var(--accent); }
.map-subjectlist small { color: var(--muted); font-weight: 400; }

/* pasos de la declaración «Mi escuela» (escuela → plan → grado → materias) */
.map-steps { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 16px; padding: 0; font: 600 12.5px/1 var(--font-ui); }
.map-steps li { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); background: var(--surface); }
.map-steps li.is-on { border-color: var(--accent); color: var(--accent); }
.map-steps li.is-done { border-color: var(--line); color: var(--ink); opacity: .7; }

/* listas de opción (elegir escuela / plan / grado / inscribirse) */
.map-choicelist { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); }
.map-choicelist form { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.map-choicelist strong { font: 600 15px/1.25 var(--font-ui); min-width: 0; }
.map-choicelist .map-btn { padding: 8px 14px; border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 600 13.5px/1 var(--font-ui); cursor: pointer; white-space: nowrap; }
.map-choicelist .map-btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.map-choicelist .map-btn:hover, .map-choicelist .map-btn:focus-visible { border-color: var(--accent); }

/* ── STAGE (zoom > 0) ── */
.map-crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font: 600 13px/1 var(--font-ui); margin-bottom: 10px; }
.map-crumbs a { color: var(--accent); text-decoration: none; }
.map-crumbs a:hover { text-decoration: underline; }
.map-crumbs .sep { color: var(--muted); }
.map-crumbs .here { color: var(--muted); font-weight: 500; }

.map-where h2 { font: 700 clamp(20px, 4vw, 28px)/1.2 var(--font-reading); margin: 0 0 4px; }

/* Órbita: centro + hijos alrededor. Móvil: lista vertical de chips. */
.map-orbit { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; }
.map-bubble { --tint: var(--accent); display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 1.5px solid var(--tint); border-radius: 999px; background: var(--surface); color: var(--ink); text-decoration: none; font: 600 14px/1.2 var(--font-ui); box-shadow: var(--shadow-sm); width: fit-content; max-width: 100%; }
.map-bubble:hover, .map-bubble:focus-visible { background: color-mix(in srgb, var(--tint) 10%, var(--surface)); transform: scale(1.02); }
.map-bubble .n { margin-left: auto; color: var(--tint); font-size: 12px; font-weight: 700; background: color-mix(in srgb, var(--tint) 12%, transparent); padding: 2px 8px; border-radius: 999px; }
.map-bubble.center { border-width: 2.5px; background: color-mix(in srgb, var(--tint) 12%, var(--surface)); cursor: default; }
.map-bubble.is-current { outline: 3px solid var(--tint); outline-offset: 2px; }
.map-bubble[role="listitem"] { list-style: none; }

/* Escalón 3+: radial en escritorio */
@media (min-width: 760px) {
  .map-orbit.radial { position: relative; display: block; min-height: 340px; }
  .map-orbit.radial .map-bubble { position: absolute; transform: translate(-50%, -50%); width: max-content; max-width: 240px; }
  .map-orbit.radial .map-bubble.center { left: 50%; top: 50%; }
}

/* ── preguntas antes/después ── */
.map-questions { display: grid; gap: 12px; grid-template-columns: 1fr; margin: 18px 0; }
@media (min-width: 700px) { .map-questions { grid-template-columns: 1fr 1fr; } }
.map-qblock { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); padding: 14px 16px; }
.map-qblock h3 { margin: 0 0 10px; font: 700 15px/1.2 var(--font-ui); }
.map-qblock ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.map-qblock a { display: flex; gap: 8px; align-items: center; color: var(--ink); text-decoration: none; font: 500 14px/1.3 var(--font-ui); padding: 6px 8px; border-radius: var(--radius-sm); }
.map-qblock a:hover { background: var(--accent-soft); color: var(--accent); }
.map-qblock .rel { color: var(--muted); font-size: 12px; }

/* ── contenido (OA del nodo) ── */
.map-content { margin: 20px 0; }
.map-content h3 { font: 700 15px/1.2 var(--font-ui); margin: 0 0 10px; }
.map-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); }
.map-cards a { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); text-decoration: none; color: var(--ink); box-shadow: var(--shadow-sm); }
.map-cards a:hover { border-color: var(--accent); }
.map-cards a.is-current-item { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent); }
.map-cards img { width: 52px; height: 40px; object-fit: cover; border-radius: 6px; background: var(--line); }
.map-cards .ph { width: 52px; height: 40px; border-radius: 6px; display: grid; place-items: center; background: var(--accent-soft); font-size: 20px; }
.map-cards .body { min-width: 0; }
.map-cards .body strong { display: block; font: 600 14px/1.3 var(--font-ui); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.map-cards .body small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
/* columnas de la vista lista: ocultas en modo fichas (por defecto) */
.map-cards .lcols { display: none; }
.map-cards-head { display: none; }

.map-actions { margin-top: 22px; }
.map-btn { padding: 10px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 600 14px/1 var(--font-ui); cursor: pointer; }
.map-btn:hover { border-color: var(--accent); color: var(--accent); }
.map-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; min-height: 42px; }
.map-btn.primary:hover { color: #fff; filter: brightness(1.08); }

/* señales honestas en las tarjetas (§25: evaluable / donde fallaste / ya visto) */
.map-cards .sig { display: inline-block; margin-left: 6px; font-size: 11px; font-weight: 700; color: var(--muted); }
.map-cards .sig.err { color: #B93E3E; }
.map-cards .sig.eval { color: var(--accent); }

/* ── OVERLAY contextual desde un OA (§38): el mapa encima de la ficha, con botón de cerrar;
      se reusa el stage dentro de un dialog a pantalla completa. ── */
.map-overlay { position: fixed; inset: 0; z-index: 60; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); display: flex; flex-direction: column; }
.map-overlay[hidden] { display: none; }
.map-overlay-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px clamp(12px, 4vw, 28px); border-bottom: 1px solid var(--line); }
.map-overlay-head strong { font: 700 15px/1.2 var(--font-ui); }
.map-overlay-close { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 14px; font: 600 14px/1 var(--font-ui); cursor: pointer; color: var(--ink); }
.map-overlay .map-body { flex: 1; overflow: auto; padding: 14px clamp(12px, 4vw, 28px) 40px; max-width: 1080px; margin: 0 auto; width: 100%; }

/* ── vista lista (§45): alternativa equivalente, no decorativa ── */
.map-page.mode-list .map-orbit { display: grid; grid-template-columns: 1fr; }
.map-page.mode-list .map-orbit.radial { min-height: 0; }
.map-page.mode-list .map-orbit .map-bubble { position: static; width: auto; max-width: none; }

/* contenido en «☰ Lista»: filas tipo Google Drive (Nombre · Tipo · Duración) */
.map-page.mode-list .map-cards-head {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) 92px 84px; gap: 14px;
  align-items: center; padding: 8px 14px; border: 1px solid var(--line); border-bottom: 0;
  border-radius: var(--radius-md) var(--radius-md) 0 0; background: var(--accent-soft);
  font: 700 11px/1 var(--font-ui); letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
}
.map-page.mode-list .map-cards-head .hc-dur { text-align: right; }
.map-page.mode-list .map-cards {
  grid-template-columns: 1fr; gap: 0; margin-top: 0;
  border: 1px solid var(--line); border-radius: 0 0 var(--radius-md) var(--radius-md); overflow: hidden; background: var(--surface);
}
.map-page.mode-list .map-cards li + li { border-top: 1px solid var(--line); }
.map-page.mode-list .map-cards a {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) 92px 84px; gap: 14px; align-items: center;
  border: 0; border-radius: 0; box-shadow: none; padding: 10px 14px;
}
.map-page.mode-list .map-cards a:hover { background: var(--accent-soft); border-color: transparent; }
.map-page.mode-list .map-cards a.is-current-item { box-shadow: none; background: var(--accent-soft); border-left: 3px solid var(--accent); padding-left: 11px; }
.map-page.mode-list .map-cards img, .map-page.mode-list .map-cards .ph { width: 34px; height: 26px; font-size: 16px; }
.map-page.mode-list .map-cards .body strong { white-space: normal; overflow: visible; text-overflow: clip; max-width: none; }
.map-page.mode-list .map-cards .meta { display: none; }                 /* el meta va en sus columnas */
.map-page.mode-list .map-cards .lcols { display: contents; }            /* .lc pasan a ser celdas de la rejilla */
.map-page.mode-list .map-cards .lc { color: var(--muted); font: 500 13px/1.2 var(--font-ui); }
.map-page.mode-list .map-cards .lc.dur { text-align: right; }

/* ── accesibilidad: movimiento reducido ── */
@media (prefers-reduced-motion: reduce) {
  .map-territory a, .map-bubble, .map-bubble:hover { transition: none; transform: none !important; }
}
