/* =========================================================
   Base · estética "EdTech gamificado / RPG cartoon"
   Tarjetas blancas con contorno negro y sombra dura,
   cabeceras de color vibrante y tipografía redondeada.
   ========================================================= */

:root {
  --ink: #1A1A1A;
  --paper: #FFFFFF;
  --muted: #4B5563;
  --sky: #E3F3FF;
  --sky-dot: #C6E4FF;

  --blue: #0095FF;
  --blue-dark: #0070C0;
  --blue-soft: #E0F2FF;
  --yellow: #FFB800;
  --yellow-dark: #D99A00;
  --yellow-soft: #FFF4D1;
  --purple: #8A2BE2;
  --purple-dark: #6A1BB5;
  --purple-soft: #F1E6FF;
  --green: #22C55E;
  --green-dark: #15803D;
  --green-soft: #DCFCE7;
  --red: #FF4B4B;
  --red-dark: #C81E1E;
  --red-soft: #FFE4E4;

  --code-bg: #1E293B;
  --code-ink: #E2E8F0;

  --radius: 20px;
  --border: 3px solid var(--ink);
  --shadow: 0 6px 0 var(--ink);
  --shadow-sm: 0 4px 0 var(--ink);

  --font-display: "Lilita One", "Fredoka", system-ui, sans-serif;
  --font-head: "Fredoka", "Nunito", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-code: "Fira Code", ui-monospace, Menlo, Consolas, monospace;

  color-scheme: light;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Color de cada mundo: --wc principal · --wc-dark · --wc-soft */
.w-cs1, .w-lab { --wc: var(--blue);   --wc-dark: var(--blue-dark);   --wc-soft: var(--blue-soft); }
.w-cs2 { --wc: var(--purple); --wc-dark: var(--purple-dark); --wc-soft: var(--purple-soft); }
.w-gd1 { --wc: var(--yellow); --wc-dark: var(--yellow-dark); --wc-soft: var(--yellow-soft); }

/* ---------- reset y tipografía ---------- */
html { font-size: 112.5%; scroll-padding-top: env(safe-area-inset-top, 0px); }
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  background:
    radial-gradient(var(--sky-dot) 2px, transparent 2.6px) 0 0 / 26px 26px,
    var(--sky);
}
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  z-index: 30;
  background: var(--paper);
}

h1, h2, h3 { font-family: var(--font-head); font-weight: 700; line-height: 1.15; margin: 0 0 .4em; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.2rem; }
p { margin: 0 0 .8em; }
code, .code, textarea { font-family: var(--font-code); }
a { color: var(--blue-dark); }
:focus-visible { outline: 4px solid var(--yellow); outline-offset: 3px; border-radius: 10px; }

/* Título con contorno oscuro (texto blanco, trazo y sombra dura). */
.outline-title {
  --stroke: 7px;
  font-family: var(--font-display);
  font-weight: 400;
  color: #fff;
  letter-spacing: .01em;
  -webkit-text-stroke: var(--stroke) var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 calc(var(--stroke) * .7) 0 var(--ink);
}
.outline-title.sm { --stroke: 5px; }
.outline-text {
  color: #fff;
  -webkit-text-stroke: 4px var(--ink);
  paint-order: stroke fill;
}

/* ---------- iconos y mascota ---------- */
.ico { width: 1.5em; height: 1.5em; flex: none; display: inline-block; vertical-align: -.35em; overflow: visible; }

.mascot {
  --f: 0;
  display: inline-block;
  aspect-ratio: 1;
  background: url("../assets/hero.webp") no-repeat;
  background-size: 900% 100%;
  background-position: calc(var(--f) * 12.5%) 0;
  flex: none;
}
.mascot[data-pose="walk"]  { --f: 1; }
.mascot[data-pose="run"]   { --f: 2; }
.mascot[data-pose="jump"]  { --f: 3; }
.mascot[data-pose="code"]  { --f: 4; }
.mascot[data-pose="cheer"] { --f: 5; }
.mascot[data-pose="read"]  { --f: 6; }
.mascot[data-pose="dizzy"] { --f: 7; }
.mascot[data-pose="ko"]    { --f: 8; }
.mascot.flip { transform: scaleX(-1); }
.mascot.bob { animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px); } }

/* ---------- tarjetas ---------- */
.card {
  background: var(--paper);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 18px;
  background: var(--head, var(--wc, var(--blue)));
  border-bottom: var(--border);
}
.card-head h2, .card-head h3 { margin: 0; flex: 1; min-width: 0; }
.card-head h2 { font-size: 1.45rem; }
.card-body { padding: 18px 20px; }
.card-body > :last-child { margin-bottom: 0; }

.head-blue   { --head: var(--blue); }
.head-yellow { --head: var(--yellow); }
.head-purple { --head: var(--purple); }
.head-green  { --head: var(--green); }
.head-red    { --head: var(--red); }
.head-dark   { --head: var(--code-bg); }

/* Fondo de "rayos" para cabeceras grandes */
.rays {
  background:
    repeating-conic-gradient(from 0deg at 85% 40%, rgba(255, 255, 255, .13) 0 10deg, transparent 10deg 20deg),
    var(--head, var(--wc, var(--blue)));
}

/* Cuadro de icono */
.tile {
  width: 56px;
  height: 56px;
  display: flex; /* flex (no grid) para que el % de alto del icono se resuelva */
  align-items: center;
  justify-content: center;
  flex: none;
  background: var(--paper);
  border: var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  font-size: 1.8rem;
  line-height: 1;
}
.tile .ico { width: 72%; height: 72%; }
.tile.lg { width: 84px; height: 84px; border-radius: 22px; font-size: 2.6rem; }

/* Píldoras */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px;
  font: 600 .9rem/1.5 var(--font-head);
  color: var(--ink);
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 3px 0 var(--ink);
  white-space: nowrap;
}
.pill .ico { width: 1.25em; height: 1.25em; vertical-align: -.25em; }
.pill.yellow { background: var(--yellow); }
.pill.blue { background: var(--blue-soft); }
.pill.purple { background: var(--purple-soft); }
.pill.green { background: var(--green-soft); }
.pill.dark { background: var(--code-bg); color: #fff; }

/* Círculos numerados */
.num {
  width: 2.1em;
  height: 2.1em;
  display: inline-grid;
  place-items: center;
  flex: none;
  font: 700 1.05rem/1 var(--font-head);
  color: var(--ink);
  background: var(--yellow);
  border: var(--border);
  border-radius: 50%;
  box-shadow: 0 3px 0 var(--ink);
}
.num.blue { background: var(--blue); color: #fff; }
.num.purple { background: var(--purple); color: #fff; }
.num.done { background: var(--green); color: #fff; }

/* ---------- botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: 600 1.02rem/1.2 var(--font-head);
  color: var(--ink);
  text-decoration: none;
  padding: 10px 18px;
  background: var(--paper);
  border: var(--border);
  border-radius: 14px;
  box-shadow: 0 5px 0 var(--ink);
  cursor: pointer;
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn .ico { width: 1.4em; height: 1.4em; }
.btn:hover { filter: brightness(1.05); transform: translateY(-1px); box-shadow: 0 6px 0 var(--ink); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn.go, .btn.stop, .btn.blue, .btn.purple {
  color: #fff;
  -webkit-text-stroke: 3.5px var(--ink);
  paint-order: stroke fill;
  letter-spacing: .02em;
}
.btn.go { background: var(--green); }
.btn.stop { background: var(--red); }
.btn.blue { background: var(--blue); }
.btn.purple { background: var(--purple); }
.btn.yellow { background: var(--yellow); }
.btn.big { font-size: 1.2rem; padding: 13px 24px; border-radius: 16px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- cabecera ---------- */
.top {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 20px;
  background: var(--paper);
  border-bottom: var(--border);
  box-shadow: 0 4px 0 rgba(26, 26, 26, .12);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 400 1.45rem/1 var(--font-display);
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.brand .ico { width: 1.6em; height: 1.6em; }
.nav { display: flex; gap: 6px; overflow-x: auto; flex: 1; padding: 4px 2px 8px; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 13px 5px 8px;
  border: 2.5px solid transparent;
  border-radius: 999px;
  text-decoration: none;
  color: var(--ink);
  font: 600 .95rem/1.4 var(--font-head);
  white-space: nowrap;
}
.nav a .ico { width: 1.5em; height: 1.5em; }
.nav a:hover { background: var(--sky); border-color: var(--ink); }
.nav a[aria-current="page"] {
  background: var(--yellow);
  border-color: var(--ink);
  box-shadow: 0 3px 0 var(--ink);
}
.stars-total { font-size: 1.05rem; padding: 4px 14px 4px 8px; }
@media (max-width: 760px) {
  .top { flex-wrap: wrap; gap: 6px; padding: 8px 14px; }
  .nav { order: 3; flex-basis: 100%; }
  .brand { font-size: 1.2rem; flex: 1; }
}

/* ---------- estructura ---------- */
main { max-width: 1200px; margin: 0 auto; padding: 28px 18px 64px; }
footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 18px 40px;
  color: var(--muted);
  font-size: .85rem;
  text-align: center;
}
.section-gap { margin-top: 30px; }
.lead { font-size: 1.08rem; color: var(--muted); max-width: 66ch; }

/* Banner de página (laboratorio, taller y mundos) */
.banner { position: relative; overflow: visible; margin-bottom: 26px; }
.banner .card-head { padding: 22px 26px; gap: 18px; border-radius: 17px 17px 0 0; }
.banner h1 { font-size: clamp(2rem, 5vw, 3.1rem); margin: 0; line-height: 1.05; }
.banner .card-body { padding-right: 180px; min-height: 70px; }
.banner .card-body p { margin: 0; font-size: 1.08rem; max-width: 62ch; }
.banner .mascot {
  position: absolute;
  right: 18px;
  bottom: 6px;
  width: 170px;
  pointer-events: none;
  filter: drop-shadow(0 5px 0 rgba(26, 26, 26, .25));
}
@media (max-width: 640px) {
  .banner .card-head { padding: 16px 18px; }
  .banner .card-body { padding-right: 110px; }
  .banner .mascot { width: 110px; }
}

/* ---------- código ---------- */
.code {
  margin: 12px 0 0;
  padding: 12px 16px;
  font-size: .88rem;
  line-height: 1.65;
  color: var(--code-ink);
  background: var(--code-bg);
  border: var(--border);
  border-radius: 14px;
  overflow-x: auto;
  white-space: pre;
}
/* Resaltado: palabra clave, string, número, comentario, objeto del juego */
.t-k { color: #FF79C6; font-weight: 600; }
.t-s { color: #A5E075; }
.t-n { color: #FFB86C; }
.t-c { color: #94A3B8; font-style: italic; }
.t-h { color: #5CC8FF; font-weight: 600; }
.ic {
  font-family: var(--font-code);
  font-size: .86em;
  font-weight: 600;
  background: var(--code-bg);
  color: var(--code-ink);
  padding: 2px 8px;
  border-radius: 7px;
}

/* Lista de metas (laboratorio y taller) */
.goals { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 10px; }
.goals li { font: 600 .92rem/1.5 var(--font-head); }
.goals li.done { background: var(--green-soft); }
.goals li.done .label { text-decoration: line-through; text-decoration-thickness: 2px; }

/* Flecha de flujo */
.flow-arrow { width: 54px; height: 40px; flex: none; color: var(--blue); }
.flow-arrow path { fill: currentColor; stroke: var(--ink); stroke-width: 3; stroke-linejoin: round; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
