/* ============================================================
   aprende a programar()  —  ESTILOS
   Paleta cálida/educativa · modo claro y oscuro
   Tipografías: Fraunces (títulos) · Plus Jakarta Sans (texto)
               · JetBrains Mono (código)
   ============================================================ */

:root {
  /* --- Tema claro (papel) --- */
  --bg:        #f6f1e7;
  --bg-2:      #efe7d7;
  --surface:   #fffdf8;
  --surface-2: #f3ecdd;
  --ink:       #2a2620;
  --ink-soft:  #5d564b;
  --ink-faint: #8a8071;
  --line:      #e3d8c4;
  --line-soft: #ece3d3;

  --green:     #2f6b4f;   /* acento principal */
  --green-deep:#234f3b;
  --green-tint:#e4efe6;
  --amber:     #b9762a;   /* acento secundario */
  --amber-tint:#f6e7cf;

  --shadow:    0 1px 2px rgba(53,44,28,.05),
               0 10px 30px -12px rgba(53,44,28,.18);
  --shadow-sm: 0 1px 2px rgba(53,44,28,.06),
               0 4px 14px -8px rgba(53,44,28,.18);
  --radius:    16px;
  --radius-sm: 11px;
}

[data-theme="dark"] {
  --bg:        #16140f;
  --bg-2:      #1d1a13;
  --surface:   #211d16;
  --surface-2: #28231a;
  --ink:       #ece4d4;
  --ink-soft:  #c2b8a4;
  --ink-faint: #8f8472;
  --line:      #352f24;
  --line-soft: #2b271e;

  --green:     #6fb98f;
  --green-deep:#8fcfa9;
  --green-tint:#1f2e25;
  --amber:     #d99b51;
  --amber-tint:#2e2415;

  --shadow:    0 1px 2px rgba(0,0,0,.4),
               0 16px 40px -18px rgba(0,0,0,.7);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4),
               0 6px 18px -10px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 88% -8%, var(--green-tint), transparent 60%),
    radial-gradient(900px 500px at -6% 4%, var(--amber-tint), transparent 55%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background-color .4s ease, color .4s ease;
}

/* fina textura de papel */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.035'/%3E%3C/svg%3E");
}

.wrap { position: relative; z-index: 1; max-width: 1060px; margin: 0 auto; padding: 0 22px; }

/* ---------------- Encabezado ---------------- */
.site-header {
  padding: 54px 0 22px;
  text-align: center;
}
.brand {
  font-family: "JetBrains Mono", monospace;
  font-size: clamp(30px, 6vw, 52px);
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--ink);
  margin: 0;
  line-height: 1.05;
}
.brand .paren { color: var(--green); }
.brand .blink {
  display: inline-block;
  width: .58ch; height: 1.05em;
  margin-left: 1px;
  background: var(--amber);
  vertical-align: -.18em;
  border-radius: 2px;
  animation: caret 1.15s steps(1) infinite;
}
@keyframes caret { 50% { opacity: 0; } }

.tagline {
  margin: 14px auto 0;
  max-width: 620px;
  color: var(--ink-soft);
  font-size: 17px;
}

/* barra de herramientas (buscador + tema) */
.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 26px;
}
.search {
  position: relative;
  flex: 1 1 320px;
  max-width: 460px;
}
.search input {
  width: 100%;
  padding: 13px 16px 13px 44px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  font: inherit;
  font-size: 15.5px;
  box-shadow: var(--shadow-sm);
  transition: border-color .2s, box-shadow .2s;
}
.search input::placeholder { color: var(--ink-faint); }
.search input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 4px var(--green-tint);
}
.search svg { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; stroke: var(--ink-faint); }

.theme-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  border-radius: 999px;
  font: inherit; font-size: 14.5px; font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, border-color .2s, color .2s;
}
.theme-btn:hover { transform: translateY(-1px); border-color: var(--green); color: var(--green); }
.theme-btn svg { width: 18px; height: 18px; }

/* ---------------- Pestañas ---------------- */
.tabs-shell {
  position: sticky; top: 0; z-index: 20;
  margin: 26px 0 30px;
  padding: 10px 0;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}
.tabs {
  display: flex; gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  padding: 9px 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  border-radius: 999px;
  font: inherit; font-size: 14.5px; font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all .18s ease;
}
.tab:hover { border-color: var(--green); color: var(--green); }
.tab.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  box-shadow: 0 6px 16px -8px var(--green);
}
[data-theme="dark"] .tab.active { color: #11160f; }

/* ---------------- Tarjetas de tema ---------------- */
.cards { display: flex; flex-direction: column; gap: 22px; padding-bottom: 40px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  opacity: 0;
  transform: translateY(14px);
  animation: rise .55s cubic-bezier(.2,.7,.2,1) forwards;
  transition: box-shadow .5s ease;
}
@keyframes rise { to { opacity: 1; transform: none; } }

.card-head {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.logo-tile {
  flex: 0 0 auto;
  width: 54px; height: 54px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--surface) 60%, transparent);
}
.logo-tile img { width: 30px; height: 30px; display: block; }
.logo-tile .badge {
  font-family: "JetBrains Mono", monospace;
  font-weight: 700; font-size: 15px;
  line-height: 1;
}
.head-text { flex: 1 1 auto; min-width: 0; }
.card h2 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: clamp(20px, 3.4vw, 25px);
  line-height: 1.2;
  margin: 2px 0 4px;
  color: var(--ink);
}
.card .resumen { margin: 0; color: var(--ink-soft); font-size: 15px; }
.cat-chip {
  display: inline-block;
  margin-top: 10px;
  padding: 3px 11px;
  font-size: 12px; font-weight: 700;
  letter-spacing: .3px;
  color: var(--green-deep);
  background: var(--green-tint);
  border-radius: 999px;
}

/* acciones */
.card-actions {
  display: flex; flex-wrap: wrap; gap: 10px;
  padding: 14px 24px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-soft);
}
.act {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 15px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: transform .15s, border-color .2s, color .2s, background .2s;
}
.act svg { width: 17px; height: 17px; }
.act:hover { transform: translateY(-1px); }
.act.listen:hover  { border-color: var(--green); color: var(--green); }
.act.images:hover  { border-color: var(--amber); color: var(--amber); }
.act.reading {
  background: var(--green); border-color: var(--green); color: #fff;
}
[data-theme="dark"] .act.reading { color: #11160f; }

/* cuerpo */
.card-body { padding: 22px 24px 26px; }
.card-body > * + * { margin-top: 14px; }
.card-body p { margin: 0; color: var(--ink); }
.card-body .sub {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600; font-size: 18px;
  color: var(--green-deep);
  margin-top: 22px;
}
.card-body code {
  font-family: "JetBrains Mono", monospace;
  font-size: .86em;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  padding: .08em .4em;
  border-radius: 6px;
  color: var(--amber);
}
.card-body strong { color: var(--ink); font-weight: 700; }

.card-body ul {
  margin: 0; padding: 0; list-style: none;
  display: flex; flex-direction: column; gap: 10px;
}
.card-body ul li {
  position: relative;
  padding-left: 24px;
  color: var(--ink);
}
.card-body ul li::before {
  content: "";
  position: absolute; left: 4px; top: .62em;
  width: 7px; height: 7px;
  border-radius: 2px;
  background: var(--green);
  transform: rotate(45deg);
}

/* recuadros de analogía y dato */
.callout {
  border-radius: var(--radius-sm);
  padding: 15px 17px 15px 16px;
  border: 1px solid var(--line);
  display: flex; gap: 12px;
  font-size: 15.5px;
}
.callout .ic { flex: 0 0 auto; font-size: 20px; line-height: 1.4; }
.callout.analogia {
  background: var(--green-tint);
  border-color: color-mix(in srgb, var(--green) 30%, var(--line));
}
.callout.analogia .label { color: var(--green-deep); }
.callout.dato {
  background: var(--amber-tint);
  border-color: color-mix(in srgb, var(--amber) 32%, var(--line));
}
.callout.dato .label { color: var(--amber); }
.callout .label {
  display: block; font-weight: 700; font-size: 12.5px;
  letter-spacing: .4px; text-transform: uppercase; margin-bottom: 2px;
}

/* código */
.code {
  background: #1f1c16;
  border: 1px solid #2c281f;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
[data-theme="dark"] .code { background: #0f0e0a; }
.code .code-bar {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 14px;
  background: rgba(255,255,255,.04);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.code .dot { width: 11px; height: 11px; border-radius: 50%; }
.code .dot.r { background: #e0696b; } .code .dot.y { background: #e7c15c; } .code .dot.g { background: #7cc08a; }
.code .lang {
  margin-left: auto;
  font-family: "JetBrains Mono", monospace;
  font-size: 11.5px; letter-spacing: .5px;
  color: #b7ad97; text-transform: uppercase;
}
.code pre {
  margin: 0; padding: 16px 18px;
  overflow-x: auto;
  font-family: "JetBrains Mono", monospace;
  font-size: 13.5px; line-height: 1.65;
  color: #ede4d2;
}
.code pre::-webkit-scrollbar { height: 8px; }
.code pre::-webkit-scrollbar-thumb { background: #3a342a; border-radius: 8px; }

/* ---------------- Pie de tarjeta: ruta de aprendizaje ---------------- */
.card-foot {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  padding: 14px 24px 16px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
}
.ruta-paso {
  font-size: 12px; font-weight: 700; letter-spacing: .4px;
  text-transform: uppercase; color: var(--ink-faint);
}
.ruta-nav { display: flex; gap: 10px; flex-wrap: wrap; margin-left: auto; }
.ruta-link {
  display: inline-flex; align-items: center; gap: 9px;
  max-width: 230px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; text-align: left;
  transition: transform .15s, border-color .2s, color .2s, background .2s;
}
.ruta-link:hover { transform: translateY(-1px); border-color: var(--green); color: var(--green); }
.ruta-link svg { width: 17px; height: 17px; flex: 0 0 auto; }
.ruta-link .rl-txt { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; overflow: hidden; }
.ruta-link .rl-txt small {
  font-size: 10.5px; font-weight: 700; letter-spacing: .4px;
  text-transform: uppercase; color: var(--ink-faint);
}
.ruta-link .tt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.next-link .rl-txt { text-align: right; }
.ruta-fin {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 700; color: var(--ink-faint);
}
.ruta-fin svg { width: 16px; height: 16px; }

/* resaltado al saltar a una tarjeta por la ruta */
.card.destacar { box-shadow: var(--shadow), 0 0 0 3px var(--green); }

/* mensaje vacío de búsqueda */
.empty {
  text-align: center;
  padding: 70px 20px;
  color: var(--ink-soft);
}
.empty .big { font-family: "Fraunces", serif; font-size: 22px; color: var(--ink); }

/* ---------------- Reproductor de lectura ---------------- */
.player {
  position: fixed; left: 50%; bottom: 22px;
  transform: translate(-50%, 160%);
  z-index: 60;
  width: min(560px, calc(100% - 32px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 18px 50px -18px rgba(0,0,0,.45);
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  transition: transform .35s cubic-bezier(.2,.8,.2,1);
}
.player.show { transform: translate(-50%, 0); }
.player .pbar-ico {
  flex: 0 0 auto; width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--green-tint);
  display: grid; place-items: center;
}
.player .pbar-ico .wave { display: flex; gap: 3px; align-items: flex-end; height: 16px; }
.player .pbar-ico .wave span {
  width: 3px; background: var(--green); border-radius: 2px;
  animation: wave 1s ease-in-out infinite;
}
.player.paused .pbar-ico .wave span { animation-play-state: paused; }
.player .pbar-ico .wave span:nth-child(1){height:6px;animation-delay:0s}
.player .pbar-ico .wave span:nth-child(2){height:14px;animation-delay:.2s}
.player .pbar-ico .wave span:nth-child(3){height:9px;animation-delay:.4s}
.player .pbar-ico .wave span:nth-child(4){height:13px;animation-delay:.1s}
@keyframes wave { 0%,100%{transform:scaleY(.5)} 50%{transform:scaleY(1.2)} }

.player .pinfo { flex: 1 1 auto; min-width: 0; }
.player .pinfo .plabel { font-size: 11.5px; color: var(--ink-faint); letter-spacing: .4px; text-transform: uppercase; }
.player .pinfo .ptitle {
  font-weight: 700; font-size: 14.5px; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.player .pbtn {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
  display: grid; place-items: center;
  transition: background .2s, color .2s, transform .15s;
}
.player .pbtn:hover { transform: translateY(-1px); }
.player .pbtn.primary { background: var(--green); border-color: var(--green); color: #fff; }
[data-theme="dark"] .player .pbtn.primary { color: #11160f; }
.player .pbtn svg { width: 18px; height: 18px; }

/* ---------------- Pie ---------------- */
.site-footer {
  text-align: center;
  padding: 30px 0 90px;
  color: var(--ink-faint);
  font-size: 13.5px;
}
.site-footer code { font-family: "JetBrains Mono", monospace; color: var(--green); }

/* responsivo */
@media (max-width: 560px) {
  body { font-size: 16px; }
  .wrap { padding: 0 14px; }
  .site-header { padding: 34px 0 14px; }
  .toolbar { margin-top: 18px; }
  .search { flex: 1 1 100%; }

  .card-head { padding: 18px 16px 14px; gap: 13px; }
  .card-actions, .card-body { padding-left: 16px; padding-right: 16px; }
  .logo-tile { width: 46px; height: 46px; }
  .logo-tile img { width: 26px; height: 26px; }

  /* el botón "Escuchar / Ver imágenes" a lo ancho, dedos felices */
  .card-actions { gap: 8px; }
  .act { flex: 1 1 auto; justify-content: center; padding: 11px 14px; }

  /* pie de ruta: apilado y a todo lo ancho para no amontonarse */
  .card-foot { flex-direction: column; align-items: stretch; gap: 10px; padding: 14px 16px 16px; }
  .ruta-nav { margin-left: 0; gap: 8px; }
  .ruta-link { flex: 1 1 0; max-width: none; justify-content: center; padding: 11px 12px; }
  .next-link { justify-content: center; }
  .ruta-paso { text-align: center; }

  /* código y bloques: que no se desborden */
  .code pre { font-size: 12.5px; }
}

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