/* Documentación de PredictoFace (modo lectura). Va después de base.css. Sin border-left: los realces usan fondo,
   peso y color. */
:root {
  --codigo-fondo: light-dark(#0f1d33, #08111f);
  --codigo-texto: #e4ebf4;
  --codigo-borde: light-dark(#0f1d33, #26375a);
  --ancho-lectura: 72ch;
  --cabecera-alto: 64px;
}
html { scroll-padding-top: calc(var(--cabecera-alto) + 16px); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body { font-size: 1.0625rem; line-height: 1.65; }

/* ── Cabecera ─────────────────────────────────────────────── */
.cabecera { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--fondo) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  box-shadow: 0 1px 0 var(--linea); }
.cabecera-in { max-width: 1240px; margin: 0 auto; height: var(--cabecera-alto); padding: 0 32px; display: flex;
  align-items: center; justify-content: space-between; gap: 16px; }
.cabecera-enlaces { display: flex; gap: 4px; }
.cabecera-enlaces a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 10px;
  color: var(--texto-2); font-weight: 500; font-size: .9375rem; text-decoration: none; }
.cabecera-enlaces a:hover { color: var(--texto); background: var(--superficie-2); }

/* ── Estructura: índice fijo a la izquierda en escritorio ─── */
.contenedor { max-width: 1240px; margin: 0 auto; padding: 0 32px; display: grid;
  grid-template-columns: 248px minmax(0, 1fr); gap: 56px; align-items: start; }
.indice { position: sticky; top: calc(var(--cabecera-alto) + 24px); max-height: calc(100dvh - var(--cabecera-alto) - 48px);
  overflow: auto; padding: 8px 4px 24px 0; font-size: .9375rem; overscroll-behavior: contain; }
.indice > summary { display: none; }
.indice ol { list-style: none; margin: 0; padding: 0; }
.indice ol ol { margin: 2px 0 6px 12px; }
.indice li { margin: 1px 0; }
.indice a { display: block; padding: 6px 10px; border-radius: 8px; color: var(--texto-2); text-decoration: none; line-height: 1.35; }
.indice a:hover { color: var(--texto); background: var(--superficie-2); }
.indice a[aria-current="true"] { color: var(--acento-fuerte); background: var(--acento-suave); font-weight: 600; }

.doc { min-width: 0; padding: 48px 0 96px; }
.doc > h1 { font-size: 2.5rem; font-weight: 750; letter-spacing: -0.03em; margin: 0 0 16px; }
.entrada { font-size: 1.1875rem; line-height: 1.55; color: var(--texto-2); max-width: 62ch; margin: 0 0 8px; }
.doc section { max-width: 100%; }
.doc h2 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; margin: 72px 0 16px; padding-top: 8px; }
.doc h3 { font-size: 1.25rem; font-weight: 650; margin: 44px 0 10px; }
.doc h4 { font-size: 1rem; font-weight: 650; margin: 20px 0 8px; }
.doc p, .doc ul, .doc ol, .doc dl, .doc .nota { max-width: var(--ancho-lectura); }
.doc p { margin: 0 0 16px; }
.doc ul, .doc ol { padding-left: 1.4em; margin: 0 0 18px; }
.doc li { margin: 6px 0; }
.doc li::marker { color: var(--texto-2); }
.doc strong { font-weight: 650; }
:not(pre) > code { background: var(--superficie-2); color: var(--texto); padding: .1em .38em; border-radius: 6px;
  font-size: .875em; overflow-wrap: anywhere; }

/* Conceptos: lista de definiciones en dos columnas, sin tarjetas */
.conceptos { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 30ch), 1fr)); gap: 20px 32px;
  margin: 24px 0 24px; max-width: none !important; }
.conceptos div { padding-top: 14px; box-shadow: inset 0 1px 0 var(--linea); }
.conceptos dt { font-weight: 650; margin-bottom: 4px; }
.conceptos dd { margin: 0; color: var(--texto-2); }

.pasos-resumen { counter-reset: paso; list-style: none; padding: 0 !important; }
.pasos-resumen li { counter-increment: paso; display: grid; grid-template-columns: 2rem 1fr; gap: 12px; margin: 12px 0; }
.pasos-resumen li::before { content: counter(paso); display: grid; place-items: center; width: 2rem; height: 2rem;
  border-radius: 50%; background: var(--acento-suave); color: var(--acento-fuerte); font-weight: 700; font-size: .9375rem;
  font-variant-numeric: tabular-nums; }

/* Nota: fondo suave, sin barra lateral */
.nota { background: var(--acento-suave); border-radius: var(--radio); padding: 18px 22px; margin: 24px 0; }
.nota p:last-child { margin-bottom: 0; }
.nota-titulo { font-weight: 650; color: var(--acento-fuerte); margin-bottom: 6px !important; }

/* ── Código ───────────────────────────────────────────────── */
.codigo { position: relative; margin: 12px 0 20px; max-width: 100%; }
.codigo pre { margin: 0; background: var(--codigo-fondo); color: var(--codigo-texto); border: 1px solid var(--codigo-borde);
  border-radius: var(--radio); padding: 18px 20px; overflow-x: auto; font-size: .84375rem; line-height: 1.6;
  tab-size: 2; scrollbar-color: #3a4d6b transparent; color-scheme: dark; }
.codigo pre:focus-visible { box-shadow: var(--foco); }
.codigo pre::selection, .codigo pre *::selection { background: #2f6fbf; color: #fff; }
.copiar { position: absolute; top: 8px; right: 8px; min-height: 32px; padding: 0 10px; border-radius: 8px;
  border: 1px solid #33476a; background: #1a2b47; color: #e4ebf4; font: 500 .8125rem/1 var(--fuente); cursor: pointer;
  opacity: .85; transition: opacity .15s ease-out, background-color .15s ease-out; }
.copiar:hover, .copiar:focus-visible { opacity: 1; background: #24395c; }
.codigo:has(.copiar) pre { padding-top: 44px; }
@media (min-width: 720px) { .codigo:has(.copiar) pre { padding-top: 18px; padding-right: 96px; } }

/* Pestañas curl / Node / Python (las arma docs.js; sin JS se ven todas con su título) */
.ejemplos { margin: 16px 0 24px; }
.ejemplos.con-pestanas .ejemplo > .ejemplo-titulo { display: none; }
.ejemplo-titulo { font-weight: 650; margin: 20px 0 8px !important; }
.pestanas { display: flex; gap: 4px; padding: 4px; background: var(--superficie-2); border-radius: 12px; width: fit-content;
  max-width: 100%; overflow-x: auto; margin-bottom: 8px; }
.pestanas button { min-height: 40px; padding: 0 16px; border: 0; border-radius: 9px; background: none; color: var(--texto-2);
  font: 600 .875rem/1 var(--fuente); cursor: pointer; white-space: nowrap; }
.pestanas button:hover { color: var(--texto); }
.pestanas button[aria-selected="true"] { background: var(--superficie); color: var(--texto); box-shadow: var(--sombra); }

/* ── Tablas ───────────────────────────────────────────────── */
.tabla-envoltura { overflow-x: auto; margin: 16px 0 28px; padding: 6px; border-radius: var(--radio); box-shadow: inset 0 0 0 1px var(--linea);
  background: var(--superficie); }
.tabla-envoltura:focus-visible { box-shadow: var(--foco); }
table { width: 100%; border-collapse: collapse; font-size: .9375rem; line-height: 1.5; }
caption { text-align: left; font-weight: 650; padding: 14px 16px 6px; color: var(--texto); }
th, td { text-align: left; vertical-align: top; padding: 10px 16px; }
thead th:first-child { border-radius: 9px 0 0 9px; }
thead th:last-child { border-radius: 0 9px 9px 0; }
thead th { font-size: .8125rem; font-weight: 650; color: var(--texto-2); background: var(--superficie-2); white-space: nowrap; }
tbody tr + tr > * { box-shadow: inset 0 1px 0 var(--linea); }
tbody th { font-weight: 600; }
td:nth-child(2) { font-variant-numeric: tabular-nums; }
.tabla-rutas tbody th { white-space: nowrap; }
.tabla-rutas td:nth-child(2) { white-space: nowrap; color: var(--texto-2); }
.tabla-errores td:nth-child(2) { font-weight: 600; }
.metodo { display: inline-block; min-width: 4.2em; padding: 2px 6px; border-radius: 6px; font: 700 .6875rem/1.5 var(--mono);
  text-align: center; letter-spacing: .02em; }
.metodo-get { background: var(--exito-suave); color: var(--exito); }
.metodo-post { background: var(--acento-suave); color: var(--acento-fuerte); }
.metodo-delete { background: var(--peligro-suave); color: var(--peligro); }
.si-no { display: inline-block; font-weight: 700; font-size: .8125rem; padding: 1px 8px; border-radius: 999px; margin-right: 6px; }
.si-no.no { background: var(--exito-suave); color: var(--exito); }
.si-no.si { background: var(--superficie-2); color: var(--texto); }

.lista-controles { list-style: none; padding: 0 !important; }
.lista-controles li { margin: 0; padding: 12px 0; box-shadow: inset 0 -1px 0 var(--linea); }

/* ── Diagrama de secuencia ───────────────────────────────── */
.diagrama { margin: 20px 0 28px; }
.diagrama-desliza { overflow-x: auto; background: var(--superficie); border-radius: var(--radio);
  box-shadow: inset 0 0 0 1px var(--linea); padding: 12px; }
.diagrama-desliza:focus-visible { box-shadow: var(--foco); }
.sd { display: block; width: 100%; min-width: 720px; height: auto; color: var(--texto); font-family: var(--fuente); }
.sd text { font-size: 13px; fill: currentColor; }
.sd-actores rect { fill: var(--superficie-2); stroke: var(--linea); }
.sd-actores text { text-anchor: middle; font-weight: 650; font-size: 13.5px; }
.sd-actores .sd-propio { fill: var(--acento); stroke: none; }
.sd-actores .sd-propio-t { fill: var(--sobre-acento); }
.sd-vidas line { stroke: var(--linea); stroke-width: 1.5; stroke-dasharray: 2 5; }
.sd-mensajes line { stroke: var(--texto); stroke-width: 1.5; }
.sd-mensajes .sd-resp { stroke: var(--texto-2); stroke-dasharray: 6 4; }
.sd-mensajes text.fin { text-anchor: end; fill: var(--texto-2); }
.sd-mensajes text.centro { text-anchor: middle; font-weight: 600; }
.sd-nota { fill: var(--aviso-suave); stroke: none; }
.sd-punta { fill: var(--texto); }
figcaption { font-size: .9375rem; color: var(--texto-2); margin-top: 10px; max-width: var(--ancho-lectura); }

.pie { margin-top: 96px; padding-top: 20px; box-shadow: inset 0 1px 0 var(--linea); color: var(--texto-2); font-size: .9375rem; }

/* ── Móvil y tableta: índice plegable arriba ─────────────── */
@media (max-width: 1023px) {
  .contenedor { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 0 24px; }
  .indice { position: static; max-height: none; overflow: visible; margin-top: 20px; padding: 4px 0 0;
    background: var(--superficie); border-radius: var(--radio); box-shadow: inset 0 0 0 1px var(--linea); }
  .indice > summary { display: flex; align-items: center; justify-content: space-between; min-height: 52px; padding: 0 16px;
    font-weight: 650; cursor: pointer; list-style: none; border-radius: var(--radio); }
  .indice > summary::-webkit-details-marker { display: none; }
  .indice > summary::after { content: ""; width: 9px; height: 9px; border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); transition: transform .15s ease-out; }
  .indice[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
  .indice nav { padding: 0 8px 12px; }
  .doc { padding-top: 32px; }
}
@media (max-width: 640px) {
  .cabecera-in { padding: 0 16px; }
  .cabecera-enlaces a { padding: 0 8px; font-size: .875rem; }
  .marca small { display: none; }
  .contenedor { padding: 0 16px; }
  .doc > h1 { font-size: 2rem; }
  .entrada { font-size: 1.0625rem; }
  .doc h2 { font-size: 1.5rem; margin-top: 56px; }
  .codigo pre { font-size: .8125rem; padding: 14px 14px; border-radius: 12px; }
  .codigo:has(.copiar) pre { padding-top: 44px; }
  th, td { padding: 10px 12px; }
}
@media (forced-colors: active) {
  .indice a[aria-current="true"] { outline: 2px solid Highlight; }
  .pestanas button[aria-selected="true"] { outline: 2px solid Highlight; }
}
@media print {
  .cabecera, .indice, .copiar, .pestanas { display: none !important; }
  .contenedor { display: block; }
  .ejemplos.con-pestanas .ejemplo { display: block !important; }
}

/* Identificadores en tablas: no se parten a mitad de palabra */
th > code, .tabla-rutas code, .tabla-errores code { overflow-wrap: normal; white-space: nowrap; }
.tabla-rutas { table-layout: fixed; }
.tabla-rutas th:first-child { width: 48%; }
.tabla-rutas th:nth-child(2) { width: 17%; }
.diagrama-pista { display: none; font-size: .875rem; color: var(--texto-2); margin: 0 0 8px; }
@media (max-width: 760px) { .diagrama-pista { display: block; } .tabla-rutas { table-layout: auto; } }
@media (max-width: 640px) { .tabla-envoltura table { min-width: 34rem; } .tabla-envoltura caption { position: sticky; left: 0; } }
