@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Nunito:wght@400;700;800;900&display=swap');

:root {
  --py-blue: #306998;
  --py-blue-dark: #1e4a6e;
  --py-blue-light: #4b8bbe;
  --py-yellow: #ffd43b;
  --py-yellow-dark: #e8b900;
  --py-green: #6fa96f;
  --py-coral: #ff4b4b;
  --bg: #eef3fa;
  --bg-panel: #ffffff;
  --ink: #1f2733;
  --ink-soft: #4b5666;
  --border: #0b0e1a;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: 'Nunito', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
}

h1, h2, h3, .pixel {
  font-family: 'Press Start 2P', 'Nunito', monospace;
  line-height: 1.4;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--py-blue);
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(238, 243, 250, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 3px solid var(--border);
}

.nav .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  padding-bottom: 10px;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  text-decoration: none;
  color: var(--ink);
}

.nav-logo img {
  height: 34px;
  width: auto;
}

.nav-links {
  display: flex;
  gap: 22px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links a {
  text-decoration: none;
  color: var(--ink);
  font-weight: 800;
  font-size: 0.95rem;
  padding: 6px 2px;
  border-bottom: 3px solid transparent;
}

.nav-links a:hover,
.nav-links a.active {
  border-bottom-color: var(--py-yellow-dark);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.7rem;
  text-decoration: none;
  color: #fff;
  background: var(--py-blue);
  border: 3px solid var(--border);
  border-radius: 10px;
  padding: 14px 22px;
  box-shadow: 0 5px 0 var(--border);
  transition: transform 0.08s ease;
}

.btn:hover {
  transform: translateY(2px);
  box-shadow: 0 3px 0 var(--border);
}

.btn.secondary {
  background: var(--py-yellow);
  color: #2b2200;
}

.btn.preview {
  background: var(--py-yellow);
  color: #c46302;
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  box-shadow: 0 5px 0 rgba(11,14,26,0.25);
}

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(180deg, #58b0e6 0%, #bfe3fb 60%, var(--bg) 100%);
  border-bottom: 4px solid var(--border);
  overflow: clip;
}

.hero .wrap {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 40px;
  align-items: center;
  padding-top: 56px;
  padding-bottom: 40px;
}

.hero h1 {
  font-size: 1.8rem;
  color: var(--py-blue-dark);
  text-shadow: 3px 3px 0 #fff;
  margin: 0 0 18px;
}

.hero p.tagline {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
  max-width: 46ch;
}

.hero .cta-row {
  margin-top: 26px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.hero-art img {
  border-radius: 18px;
  border: 4px solid var(--border);
  box-shadow: 10px 10px 0 rgba(11,14,26,0.18);
}

/* ---------- Sections ---------- */
section {
  padding: 64px 0;
}

.section-title {
  text-align: center;
  font-size: 1.3rem;
  color: var(--py-blue-dark);
  margin-bottom: 8px;
}

.section-sub {
  text-align: center;
  color: var(--ink-soft);
  max-width: 60ch;
  margin: 0 auto 40px;
  font-weight: 700;
}

/* ---------- Feature cards ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 22px;
}

.card {
  background: var(--bg-panel);
  border: 3px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  box-shadow: 6px 6px 0 rgba(11,14,26,0.12);
}

.card img.icon {
  width: 52px;
  height: 52px;
  object-fit: contain;
  margin-bottom: 12px;
  image-rendering: pixelated;
}

.card img.icon-wide {
  height: 80px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  margin-bottom: 12px;
  image-rendering: pixelated;
}

.card .icon-emoji {
  font-size: 2.5rem;
  line-height: 1;
  margin-bottom: 12px;
}

.card h3 {
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  font-size: 1.05rem;
  margin: 0 0 8px;
  color: var(--ink);
}

.card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

/* ---------- World chips (index) ---------- */
.worlds-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

.world-chip {
  text-decoration: none;
  color: #fff;
  border: 3px solid var(--border);
  border-radius: 12px;
  padding: 14px 12px;
  font-weight: 800;
  font-size: 0.85rem;
  box-shadow: 4px 4px 0 rgba(11,14,26,0.2);
  transition: transform 0.08s ease;
}

.world-chip:hover {
  transform: translateY(-3px);
}

.world-chip span.order {
  display: block;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.65rem;
  opacity: 0.85;
  margin-bottom: 6px;
}

/* ---------- Footer ---------- */
footer {
  background: var(--border);
  color: #cfd6e4;
  padding: 34px 0;
  text-align: center;
  font-size: 0.9rem;
}

footer a {
  color: var(--py-yellow);
}

footer .license-badge {
  margin: 6px auto 0;
}

/* ---------- Autor ---------- */
.author-photo {
  width: 220px;
  height: 220px;
  object-fit: cover;
  border-radius: 20px;
  border: 4px solid var(--border);
  box-shadow: 8px 8px 0 rgba(11,14,26,0.12);
  margin: 0 auto 30px;
}

.author-bio p {
  color: var(--ink-soft);
  font-weight: 600;
  margin: 0 0 16px;
}

.author-bio p:last-child {
  margin-bottom: 0;
}

/* ---------- Wiki page ---------- */
.wiki-hero {
  background: linear-gradient(180deg, var(--py-blue-dark) 0%, var(--py-blue) 100%);
  color: #fff;
  border-bottom: 4px solid var(--border);
  padding: 54px 0 44px;
  text-align: center;
}

.wiki-hero img {
  width: 84px;
  margin: 0 auto 18px;
  image-rendering: pixelated;
}

.wiki-hero h1 {
  font-size: 1.6rem;
  margin: 0 0 14px;
  text-shadow: 3px 3px 0 rgba(0,0,0,0.35);
}

.wiki-hero p {
  max-width: 62ch;
  margin: 0 auto;
  font-weight: 700;
  color: #dceafc;
}

.wiki-hero p.version-pill {
  display: inline-block;
  margin-top: 16px;
  background: rgba(255,255,255,0.12);
  border: 2px solid rgba(255,255,255,0.4);
  border-radius: 20px;
  padding: 6px 18px;
  font-size: 0.85rem;
  color: #fff;
}

.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 26px auto 0;
  max-width: 900px;
}

.toc a {
  text-decoration: none;
  background: rgba(255,255,255,0.14);
  border: 2px solid rgba(255,255,255,0.5);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
  padding: 8px 14px;
  border-radius: 20px;
}

.toc a:hover {
  background: rgba(255,255,255,0.28);
}

.chapter {
  border: 3px solid var(--border);
  border-radius: 16px;
  margin: 0 0 42px;
  overflow: clip;
  background: var(--bg-panel);
  box-shadow: 8px 8px 0 rgba(11,14,26,0.12);
  scroll-margin-top: 90px;
}

.chapter-head {
  padding: 22px 26px;
  color: #fff;
}

.chapter-head .kicker {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.62rem;
  opacity: 0.85;
  margin-bottom: 8px;
  display: block;
}

.chapter-head h2 {
  margin: 0 0 4px;
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  font-size: 1.35rem;
}

.chapter-head .subtitle {
  font-weight: 700;
  opacity: 0.9;
  font-size: 0.95rem;
}

.chapter-body {
  padding: 24px 26px 28px;
}

.lore-block {
  font-style: italic;
  color: var(--ink-soft);
  border-left: 4px solid var(--py-yellow-dark);
  padding-left: 16px;
  margin: 0 0 22px;
}

.lore-block p {
  margin: 0 0 12px;
}

.lore-block p:last-child {
  margin-bottom: 0;
}

.prologue {
  background: linear-gradient(180deg, #1b2a44 0%, #101a2b 100%);
  color: #e7edf7;
  border: 3px solid var(--border);
  border-radius: 16px;
  padding: 30px 30px 26px;
  margin-bottom: 42px;
  box-shadow: 8px 8px 0 rgba(11,14,26,0.12);
}

.prologue .kicker {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.62rem;
  color: #ffd43b;
  display: block;
  margin-bottom: 10px;
}

.prologue h2 {
  margin: 0 0 16px;
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  font-size: 1.35rem;
  color: #fff;
}

.prologue p {
  color: #c3cee0;
  font-weight: 600;
  margin: 0 0 14px;
}

.prologue p:last-child {
  margin-bottom: 0;
}

.prologue strong {
  color: #ffd43b;
}

.glossary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.term {
  border: 2px solid #dfe4ec;
  border-radius: 10px;
  padding: 14px;
  background: #fbfcfe;
}

.term .emoji {
  font-size: 1.4rem;
}

.term h4 {
  margin: 6px 0 2px;
  font-size: 0.95rem;
}

.term .concept {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.6rem;
  color: var(--py-blue);
  display: inline-block;
  margin-bottom: 6px;
}

.term p {
  margin: 0 0 8px;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.term code {
  display: block;
  background: #1f2733;
  color: #ffd43b;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 0.82rem;
  overflow-x: auto;
}

.table-scroll {
  overflow-x: auto;
  margin-bottom: 22px;
  border-radius: 10px;
  border: 2px solid #28405e;
}

.func-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
  font-size: 0.88rem;
}

.func-table th {
  background: #1f2f4d;
  color: #ffd43b;
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 10px 14px;
  text-align: left;
  white-space: nowrap;
}

.func-table td {
  padding: 10px 14px;
  border-top: 1px solid #28405e;
  background: #16243b;
  color: #b9c6dc;
  vertical-align: top;
}

.func-table td code {
  background: #0f1826;
  color: #ffd43b;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 0.85rem;
  white-space: nowrap;
}

.func-table .ret {
  font-weight: 800;
  white-space: nowrap;
}

.func-table .ret-num { color: #7ee787; }
.func-table .ret-color { color: #ff9f5a; }
.func-table .ret-bool { color: #58b0e6; }
.func-table .ret-none { color: #6b7690; font-weight: 700; }
.func-table .ret-obj { color: #d9a8ff; }

.secret-portrait {
  width: 96px;
  margin: 0 auto 18px;
  image-rendering: pixelated;
}

.boss-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #241019;
  color: #ffd3d3;
  border: 2px solid #4a1420;
  border-radius: 12px;
  padding: 14px 18px;
}

.boss-card .emoji {
  font-size: 2rem;
}

.boss-card h4 {
  margin: 0 0 4px;
  color: #ff8a8a;
  font-size: 1rem;
}

.boss-card p {
  margin: 0;
  font-size: 0.85rem;
  color: #f0c6c6;
}

/* ---------- Descargas ---------- */
.hero-logo-download {
  /* 84px (ancho base de `.wiki-hero img`) + 20%, pedido explícito de
     Manuel — solo en esta página, el resto de `.wiki-hero img` (wiki.html)
     no cambia. */
  width: 101px;
}


.platform-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
}

.platform-card {
  background: var(--bg-panel);
  border: 3px solid var(--border);
  border-radius: 16px;
  padding: 26px;
  box-shadow: 8px 8px 0 rgba(11,14,26,0.12);
  display: flex;
  flex-direction: column;
}

.platform-card .icon-emoji {
  font-size: 2.5rem;
  line-height: 1;
  margin-bottom: 10px;
}

.platform-card h3 {
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  font-size: 1.15rem;
  margin: 0 0 8px;
}

.platform-card p {
  color: var(--ink-soft);
  font-size: 0.95rem;
  margin: 0 0 16px;
}

.status-pill {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-radius: 20px;
  padding: 4px 12px;
  margin-bottom: 14px;
}

.status-pill.available {
  background: #e3f6e9;
  color: #1f7a45;
  border: 2px solid #1f7a45;
}

.status-pill.soon {
  background: #f1f2f5;
  color: #6b7690;
  border: 2px solid #b7bdc9;
}

.platform-card .btn,
.platform-card .btn-disabled {
  margin-top: auto;
  text-align: center;
}

.btn-disabled {
  display: inline-block;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.7rem;
  color: #8890a0;
  background: #e6e8ee;
  border: 3px solid #b7bdc9;
  border-radius: 10px;
  padding: 14px 22px;
  cursor: not-allowed;
}

.req-box {
  margin-top: 46px;
  background: var(--bg-panel);
  border: 3px solid var(--border);
  border-radius: 16px;
  padding: 26px 30px;
  box-shadow: 8px 8px 0 rgba(11,14,26,0.12);
}

.req-box h3 {
  margin: 0 0 14px;
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  font-size: 1.1rem;
}

.req-box ul {
  margin: 0 0 18px;
  padding-left: 20px;
  color: var(--ink-soft);
  font-weight: 600;
}

.req-box li {
  margin-bottom: 6px;
}

.req-note {
  background: #fff8e1;
  border: 2px solid var(--py-yellow-dark);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 0.9rem;
  color: #6b5300;
  font-weight: 700;
}

/* ---------- Bob, el ayudante del CodeVerse ---------- */
.bob-widget {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  font-family: 'Nunito', system-ui, sans-serif;
}

.bob-toggle {
  width: 68px;
  height: 68px;
  padding: 0;
  border-radius: 50%;
  border: 3px solid var(--border);
  background: var(--py-yellow);
  box-shadow: 0 6px 0 rgba(11,14,26,0.25);
  cursor: pointer;
  overflow: hidden;
  animation: bob-float 2.4s ease-in-out infinite;
}

.bob-toggle img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.bob-toggle:hover {
  animation-play-state: paused;
  transform: translateY(-2px);
}

@keyframes bob-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.bob-bubble {
  position: relative;
  max-width: 220px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  font-size: 0.9rem;
  border: 3px solid var(--border);
  border-radius: 14px;
  padding: 10px 14px;
  box-shadow: 4px 4px 0 rgba(11,14,26,0.18);
  opacity: 0;
  transform: translateY(8px) scale(0.9);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.bob-bubble::after {
  content: "";
  position: absolute;
  right: 22px;
  bottom: -10px;
  border: 8px solid transparent;
  border-top-color: var(--border);
  border-bottom: none;
}

.bob-bubble.bob-bubble-show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  cursor: pointer;
}

.bob-panel {
  width: min(340px, calc(100vw - 40px));
  max-height: min(480px, calc(100vh - 120px));
  display: none;
  flex-direction: column;
  background: var(--bg-panel);
  border: 3px solid var(--border);
  border-radius: 16px;
  box-shadow: 8px 8px 0 rgba(11,14,26,0.2);
  overflow: hidden;
}

/* Único interruptor de estado: la clase "bob-open" en el contenedor raíz.
   Sin ella: ícono + globo. Con ella: panel de chat. Nunca los dos a la vez. */
.bob-widget.bob-open .bob-toggle,
.bob-widget.bob-open .bob-bubble {
  display: none;
}

.bob-widget.bob-open .bob-panel {
  display: flex;
}

.bob-panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--py-blue-dark);
  color: #fff;
}

.bob-panel-head img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  image-rendering: pixelated;
  border-radius: 50%;
  background: var(--py-yellow);
  border: 2px solid var(--border);
}

.bob-panel-title {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  flex: 1;
}

.bob-panel-title span {
  font-size: 0.75rem;
  opacity: 0.85;
  font-weight: 700;
}

.bob-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1;
}

.bob-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg);
}

.bob-msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: pre-wrap;
  border: 2px solid var(--border);
}

.bob-msg-assistant {
  align-self: flex-start;
  background: #fff;
  color: var(--ink);
  border-bottom-left-radius: 2px;
}

.bob-msg-user {
  align-self: flex-end;
  background: var(--py-yellow);
  color: #2b2200;
  border-bottom-right-radius: 2px;
}

.bob-msg-thinking {
  opacity: 0.7;
  font-style: italic;
}

.bob-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 3px solid var(--border);
  background: var(--bg-panel);
}

.bob-form input {
  flex: 1;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 0.9rem;
}

.bob-form button {
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--py-blue);
  color: #fff;
  font-weight: 900;
  padding: 8px 14px;
  cursor: pointer;
}

@media (max-width: 480px) {
  .bob-widget {
    right: 12px;
    bottom: 12px;
  }
  .bob-toggle {
    width: 58px;
    height: 58px;
  }
}

@media (max-width: 760px) {
  .hero .wrap {
    grid-template-columns: 1fr;
    padding-top: 30px;
  }
  .nav-links {
    gap: 6px 12px;
    /* 6 links ya no caben en una sola fila a partir de que se agregó
       "Aprende" — sin esto, `.nav .wrap` (display:flex sin wrap) se
       desbordaba horizontalmente en celulares angostos (confirmado con
       Playwright a 390px de ancho). Envolver a una segunda fila, pegada a
       la derecha, es más simple que reducir más la fuente o esconder
       links detrás de un menú hamburguesa. */
    flex-wrap: wrap;
    justify-content: flex-end;
    row-gap: 4px;
  }
  .nav-links a {
    font-size: 0.82rem;
  }
}
