/* ==========================================================================
   NextPatch — Lista pública de retos (/retos, marketing F0-8)
   Página autónoma como la landing y el blog: no carga app.css. Misma paleta
   (fondo #12141D, índigo #635BFF, coral #FF7A59) y mismas fuentes (Outfit;
   JetBrains Mono solo para la marca y los datos). Prefijo de clases: rt-.

   A lo ancho como la landing: las bandas (intro, catálogo, cierre) llegan de
   lado a lado y solo su contenido se limita a --rt-maxw.
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --np-bg: #12141d;
  --np-surface: #1b1e2b;
  --np-surface-2: #232738;
  --np-border: #2e3347;
  --np-text: #eceef6;
  --np-muted: #9aa0b5;
  --np-primary: #635bff;
  --np-primary-hover: #756eff;
  --np-primary-soft: rgba(99, 91, 255, 0.14);
  --np-accent: #ff7a59;
  --np-accent-soft: rgba(255, 122, 89, 0.12);

  /* Texto secundario de lectura y enlaces: los mismos valores que el blog. */
  --rt-text-2: #c4c8d6;
  --rt-link: #8f89ff;

  --rt-space-1: 4px;
  --rt-space-2: 8px;
  --rt-space-3: 12px;
  --rt-space-4: 16px;
  --rt-space-5: 24px;
  --rt-space-6: 32px;
  --rt-space-7: 48px;
  --rt-space-8: 72px;

  --rt-pad: clamp(16px, 5vw, 104px);
  --rt-maxw: 1400px;
  --rt-index-w: 260px;
  --rt-radius: 14px;
  --rt-nav-h: 61px;

  /* Curva de salida fuerte (Emil Kowalski), como en el blog. */
  --rt-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --rt-dur-fast: 160ms;
  --rt-dur: 220ms;

  --rt-icon-arrow: url('/icons/np/flecha-circulo-derecha.svg');
  --rt-icon-chevron: url('/icons/np/angulo-circulo-izquierda.svg');
  --rt-icon-today: url('/icons/np/fill/calendario.svg');
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--rt-nav-h) + 16px);
  scrollbar-color: var(--np-border) var(--np-bg);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: 'Outfit', system-ui, sans-serif;
  background: var(--np-bg);
  color: var(--np-text);
  font-size: 16px;
  line-height: 1.6;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

main {
  display: block;
  flex: 1 0 auto;
}

main:focus {
  outline: none;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
  letter-spacing: 0;
  text-wrap: balance;
}

p {
  margin: 0;
}

a {
  color: inherit;
}

::selection {
  background: rgba(99, 91, 255, 0.45);
  color: #fff;
}

:focus-visible {
  outline: 2px solid var(--rt-link);
  outline-offset: 3px;
  border-radius: 6px;
}

.rt-ico {
  display: inline-block;
  flex: none;
  width: 1em;
  height: 1em;
  background: currentColor;
  -webkit-mask: var(--rt-icon) center / contain no-repeat;
  mask: var(--rt-icon) center / contain no-repeat;
}

.rt-ico--arrow {
  --rt-icon: var(--rt-icon-arrow);
  width: 18px;
  height: 18px;
  transition: transform var(--rt-dur) var(--rt-ease-out);
}

.rt-ico--chevron {
  --rt-icon: var(--rt-icon-chevron);
}

.rt-ico--up {
  --rt-icon: var(--rt-icon-chevron);
  transform: rotate(90deg);
}

/* Saltar al contenido -------------------------------------------------- */

.rt-skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 50;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--np-primary);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
}

.rt-skip:focus {
  top: 12px;
}

/* Botones ---------------------------------------------------------------- */

.rt-btn {
  --_bg: var(--np-surface-2);
  --_fg: var(--np-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: var(--_bg);
  color: var(--_fg);
  font: inherit;
  font-weight: 600;
  font-size: 14.5px;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--rt-dur-fast) ease, border-color var(--rt-dur-fast) ease,
    color var(--rt-dur-fast) ease, box-shadow var(--rt-dur-fast) ease;
}

.rt-btn:active {
  transform: translateY(1px);
}

.rt-btn--primary {
  --_bg: var(--np-primary);
  --_fg: #fff;
  box-shadow: 0 10px 24px -12px rgba(99, 91, 255, 0.75);
}

.rt-btn--ghost {
  --_bg: transparent;
  border-color: var(--np-border);
}

.rt-btn--lg {
  min-height: 52px;
  padding: 14px 24px;
  font-size: 15.5px;
  border-radius: 13px;
}

/* El coral, como en la landing, solo para los CTA grandes y poco frecuentes. */
@media (hover: hover) and (pointer: fine) {
  .rt-btn--primary:hover {
    background: var(--np-primary-hover);
  }

  .rt-btn--primary.rt-btn--lg:hover {
    background: var(--np-accent);
    color: #24120d;
    box-shadow: 0 14px 30px -12px rgba(255, 122, 89, 0.55);
  }

  .rt-btn--ghost:hover {
    border-color: var(--np-muted);
    background: var(--np-surface-2);
  }

  .rt-btn:hover .rt-ico--arrow {
    transform: translateX(3px);
  }
}

/* Marca ------------------------------------------------------------------ */

.rt-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 600;
}

.rt-brand__mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--np-primary);
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  box-shadow: 0 4px 14px rgba(99, 91, 255, 0.35);
}

.rt-brand__name {
  font-size: 18px;
}

/* Cabecera ---------------------------------------------------------------- */

.rt-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--rt-space-4);
  min-height: var(--rt-nav-h);
  padding: 8px var(--rt-pad);
  background: rgba(18, 20, 29, 0.88);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--np-border);
}

.rt-nav__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.rt-nav__sep {
  color: var(--np-border);
  font-size: 22px;
  font-weight: 300;
}

.rt-nav__section {
  font-size: 16px;
  font-weight: 500;
  color: var(--np-text);
  text-decoration: none;
}

.rt-nav__cta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.rt-nav__link {
  padding: 8px 10px;
  font-size: 14px;
  color: var(--np-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--rt-dur-fast) ease;
}

.rt-nav__cta .rt-btn {
  padding: 9px 16px;
  min-height: 40px;
  font-size: 13.5px;
}

@media (hover: hover) and (pointer: fine) {
  .rt-nav__link:hover {
    color: var(--np-text);
  }
}

/* Intro + reto de hoy ------------------------------------------------------ */

.rt-intro {
  width: 100%;
  padding: var(--rt-space-8) var(--rt-pad) 64px;
  border-bottom: 1px solid var(--np-border);
}

.rt-intro__inner {
  max-width: var(--rt-maxw);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 420px);
  align-items: end;
  gap: var(--rt-space-7) 64px;
}

.rt-intro__title {
  font-size: clamp(32px, 4.6vw, 54px);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.02em;
}

.rt-intro__lead {
  max-width: 60ch;
  margin-top: var(--rt-space-5);
  color: var(--rt-text-2);
  font-size: clamp(16px, 1.4vw, 18px);
}

.rt-intro__stats {
  margin-top: var(--rt-space-5);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13.5px;
  color: var(--np-muted);
  font-variant-numeric: tabular-nums;
}

/* El reto de hoy: la única pieza con caja de la intro. El icono en coral es
   la «energía» de la marca (racha, XP): aquí, lo de cada día. */
.rt-today {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: var(--rt-space-4);
  row-gap: var(--rt-space-2);
  padding: 28px;
  border-radius: 18px;
  background: var(--np-surface);
  border: 1px solid rgba(99, 91, 255, 0.38);
  box-shadow: 0 24px 48px -32px rgba(99, 91, 255, 0.55);
}

.rt-today__ico {
  grid-row: span 2;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--np-accent-soft);
  position: relative;
}

.rt-today__ico::after {
  content: '';
  position: absolute;
  inset: 11px;
  background: var(--np-accent);
  -webkit-mask: var(--rt-icon-today) center / contain no-repeat;
  mask: var(--rt-icon-today) center / contain no-repeat;
}

.rt-today__title {
  font-size: 22px;
  font-weight: 600;
  align-self: end;
}

.rt-today__text {
  color: var(--rt-text-2);
  font-size: 14.5px;
}

.rt-today .rt-btn {
  grid-column: 1 / -1;
  margin-top: var(--rt-space-4);
  width: 100%;
}

/* Catálogo: índice fijo + transiciones ------------------------------------- */

.rt-body {
  width: 100%;
  padding: 56px var(--rt-pad) 96px;
}

.rt-body__inner {
  max-width: var(--rt-maxw);
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--rt-index-w) minmax(0, 1fr);
  gap: 56px;
  align-items: start;
}

.rt-index {
  position: sticky;
  top: calc(var(--rt-nav-h) + 24px);
  max-height: calc(100vh - var(--rt-nav-h) - 48px);
  overflow-y: auto;
  scrollbar-width: thin;
}

.rt-index__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--np-muted);
  margin-bottom: var(--rt-space-3);
}

.rt-index__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}

.rt-index__link {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--rt-space-3);
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--rt-text-2);
  text-decoration: none;
  font-size: 15px;
  transition: background-color var(--rt-dur-fast) ease, color var(--rt-dur-fast) ease;
}

.rt-index__n {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--np-muted);
  font-variant-numeric: tabular-nums;
}

@media (hover: hover) and (pointer: fine) {
  .rt-index__link:hover {
    background: var(--np-surface);
    color: var(--np-text);
  }
}

.rt-catalog {
  display: grid;
  gap: var(--rt-space-8);
  min-width: 0;
}

.rt-tr__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--rt-space-2) var(--rt-space-5);
  padding-bottom: var(--rt-space-4);
  margin-bottom: var(--rt-space-4);
  border-bottom: 1px solid var(--np-border);
}

.rt-tr__title {
  font-size: clamp(24px, 2.6vw, 32px);
  font-weight: 600;
}

.rt-tr__meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--np-muted);
  font-variant-numeric: tabular-nums;
}

.rt-lessons {
  display: grid;
  gap: var(--rt-space-2);
}

/* Lección plegable: <details> nativo (teclado y lector de pantalla gratis). */
.rt-lesson {
  border-radius: var(--rt-radius);
  border: 1px solid transparent;
  transition: background-color var(--rt-dur-fast) ease, border-color var(--rt-dur-fast) ease;
}

.rt-lesson[open] {
  background: var(--np-surface);
  border-color: var(--np-border);
}

.rt-lesson__sum {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--rt-space-4);
  padding: 14px 16px;
  border-radius: var(--rt-radius);
  cursor: pointer;
  list-style: none;
}

.rt-lesson__sum::-webkit-details-marker {
  display: none;
}

.rt-lesson__heading {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.rt-lesson__unit {
  font-size: 12.5px;
  color: var(--np-muted);
}

.rt-lesson__title {
  font-size: 17px;
  font-weight: 500;
}

.rt-lesson__count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  color: var(--np-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* La flecha del icono mira a la izquierda: abajo cerrada, arriba abierta. */
.rt-lesson__sum .rt-ico--chevron {
  width: 20px;
  height: 20px;
  color: var(--np-muted);
  transform: rotate(-90deg);
  transition: transform var(--rt-dur) var(--rt-ease-out), color var(--rt-dur-fast) ease;
}

.rt-lesson[open] > .rt-lesson__sum .rt-ico--chevron {
  transform: rotate(90deg);
  color: var(--np-text);
}

@media (hover: hover) and (pointer: fine) {
  .rt-lesson:not([open]):hover {
    background: var(--np-surface);
  }

  .rt-lesson__sum:hover .rt-ico--chevron {
    color: var(--np-text);
  }
}

/* Lista de retos de una lección. */
.rt-list {
  list-style: none;
  margin: 0;
  padding: 0 8px 8px;
  display: grid;
  gap: 2px;
}

.rt-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--rt-space-4);
  padding: 12px 10px;
  border-radius: 10px;
  text-decoration: none;
  transition: background-color var(--rt-dur-fast) ease;
}

.rt-item__n {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--np-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.rt-item__hook {
  color: var(--rt-text-2);
  font-size: 15px;
  line-height: 1.45;
  transition: color var(--rt-dur-fast) ease;
}

.rt-item__meta {
  display: inline-flex;
  align-items: center;
  gap: var(--rt-space-3);
  justify-self: end;
}

.rt-tag {
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--np-border);
  font-size: 12px;
  color: var(--rt-text-2);
  white-space: nowrap;
}

/* Dificultad 1..5: cinco barras, las encendidas en índigo. */
.rt-diff {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
}

.rt-diff > span {
  width: 4px;
  border-radius: 1px;
  background: var(--np-border);
}

.rt-diff > span:nth-child(1) { height: 5px; }
.rt-diff > span:nth-child(2) { height: 7px; }
.rt-diff > span:nth-child(3) { height: 9px; }
.rt-diff > span:nth-child(4) { height: 11px; }
.rt-diff > span:nth-child(5) { height: 12px; }

.rt-diff > span.is-on {
  background: var(--rt-link);
}

@media (hover: hover) and (pointer: fine) {
  .rt-item:hover {
    background: var(--np-surface-2);
  }

  .rt-item:hover .rt-item__hook {
    color: var(--np-text);
  }
}

.rt-tr__top {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: var(--rt-space-4);
  padding: 6px 4px;
  font-size: 13.5px;
  color: var(--np-muted);
  text-decoration: none;
}

.rt-tr__top .rt-ico {
  width: 16px;
  height: 16px;
}

/* En escritorio el índice está siempre a la vista: el «volver» sobra. */
@media (min-width: 1025px) {
  .rt-tr__top {
    display: none;
  }
}

@media (hover: hover) and (pointer: fine) {
  .rt-tr__top:hover {
    color: var(--np-text);
  }
}

/* Vacío ------------------------------------------------------------------ */

.rt-empty {
  width: 100%;
  padding: 96px var(--rt-pad);
}

.rt-empty__inner {
  max-width: 560px;
  margin: 0 auto;
  text-align: center;
  display: grid;
  justify-items: center;
  gap: var(--rt-space-4);
}

.rt-empty h2 {
  font-size: 24px;
  font-weight: 600;
}

.rt-empty p {
  color: var(--rt-text-2);
}

/* Cierre ------------------------------------------------------------------ */

.rt-final {
  width: 100%;
  padding: 64px var(--rt-pad);
  border-top: 1px solid var(--np-border);
  background: var(--np-surface);
}

.rt-final__inner {
  max-width: var(--rt-maxw);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--rt-space-5) var(--rt-space-7);
}

.rt-final h2 {
  font-size: clamp(24px, 2.8vw, 32px);
  font-weight: 600;
}

.rt-final p {
  max-width: 60ch;
  margin-top: var(--rt-space-3);
  color: var(--rt-text-2);
}

/* Pie (mismo que landing y blog) ----------------------------------------- */

.rt-foot {
  border-top: 1px solid var(--np-border);
  background: var(--np-bg);
}

.rt-foot__inner,
.rt-foot__bottom {
  max-width: calc(var(--rt-maxw) + 2 * var(--rt-pad));
  margin: 0 auto;
  padding: 0 var(--rt-pad);
}

.rt-foot__inner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 24px;
  padding-top: 28px;
  padding-bottom: 20px;
}

.rt-foot__nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  font-size: 13.5px;
}

.rt-foot__nav a {
  color: var(--np-muted);
  text-decoration: none;
  padding: 4px 0;
}

@media (hover: hover) and (pointer: fine) {
  .rt-foot__nav a:hover {
    color: var(--np-text);
  }
}

.rt-foot__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 16px;
  padding-bottom: 24px;
  border-top: 1px solid var(--np-border);
  font-size: 12.5px;
  color: var(--np-muted);
}

.rt-foot__beta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1px solid var(--np-border);
  border-radius: 999px;
  padding: 2px 7px;
}

/* Movimiento reducido: sin desplazamientos, el cambio de estado se queda. */
@media (prefers-reduced-motion: reduce) {
  .rt-ico--arrow,
  .rt-lesson__sum .rt-ico--chevron {
    transition: none;
  }

  .rt-btn:hover .rt-ico--arrow {
    transform: none;
  }

  .rt-btn:active {
    transform: none;
  }
}

/* Responsive --------------------------------------------------------------- */

/* Tablet: el índice deja de ser lateral y pasa arriba, en rejilla. */
@media (max-width: 1024px) {
  .rt-intro__inner {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
  }

  .rt-today {
    max-width: 560px;
  }

  .rt-body__inner {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--rt-space-7);
  }

  .rt-index {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .rt-index__list {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 6px;
  }

  .rt-index__link {
    border: 1px solid var(--np-border);
  }
}

@media (max-width: 720px) {
  .rt-intro {
    padding-top: var(--rt-space-7);
    padding-bottom: var(--rt-space-7);
  }

  .rt-today {
    padding: 22px 20px;
  }

  .rt-body {
    padding-top: var(--rt-space-6);
    padding-bottom: var(--rt-space-8);
  }

  .rt-catalog {
    gap: 56px;
  }

  .rt-nav__link,
  .rt-nav__login {
    display: none;
  }

  /* En móvil el reto ocupa la fila; número y metadatos debajo del gancho. */
  .rt-list {
    padding: 0 4px 6px;
  }

  .rt-item {
    grid-template-columns: 22px minmax(0, 1fr);
    gap: 6px 10px;
    padding: 12px 8px;
  }

  .rt-item__n {
    align-self: start;
    padding-top: 2px;
  }

  .rt-item__meta {
    grid-column: 2;
    justify-self: start;
  }

  .rt-lesson__sum {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 14px 12px;
  }

  .rt-lesson__count {
    display: none;
  }

  .rt-final .rt-btn {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .rt-nav .rt-brand__name {
    display: none;
  }

  .rt-nav__cta .rt-btn {
    padding: 8px 12px;
    font-size: 13px;
  }
}
