/* Manual de Grimorio. Se apoya en site.css (colores, letra, kbd, tablas) y
   solo añade la maqueta del manual: índice lateral fijo y el texto largo. */

.manual {
  max-width: 1240px; margin: 0 auto; padding: 56px 24px 80px;
  display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: 56px; align-items: start;
}

/* ——— índice lateral ——— */
.indice {
  position: sticky; top: 84px; max-height: calc(100vh - 104px); overflow-y: auto;
  padding: 4px 6px 24px 0; scrollbar-width: thin; scrollbar-color: var(--borde-2) transparent;
}
.indice .titulo-indice {
  font-size: 12.5px; letter-spacing: .1em; text-transform: uppercase; font-weight: 560;
  color: var(--tenue); margin: 18px 0 8px 12px;
}
.buscar-manual { position: relative; }
.buscar-manual svg { position: absolute; left: 11px; top: 50%; width: 15px; height: 15px; transform: translateY(-50%); color: var(--tenue); pointer-events: none; }
.buscar-manual input {
  width: 100%; height: 38px; padding: 0 12px 0 34px; border-radius: 10px;
  border: 1px solid var(--borde); background: var(--panel); color: var(--texto);
  font: inherit; font-size: 14.5px; transition: border-color .15s;
}
.buscar-manual input::placeholder { color: var(--tenue); }
.buscar-manual input:focus { outline: none; border-color: var(--acento); }
.indice ul { list-style: none; margin: 0; padding: 0; }
.indice .toc > li { margin: 1px 0; }
.indice a {
  display: block; text-decoration: none; color: var(--tenue-2); font-size: 14.5px; line-height: 1.35;
  padding: 6px 12px; border-radius: 8px; border-left: 2px solid transparent; transition: color .15s, background .15s, border-color .15s;
}
.indice a:hover { color: var(--texto); background: var(--panel); }
.indice .toc ul { margin: 2px 0 6px 12px; padding-left: 0; display: none; }
.indice .toc ul a { font-size: 13.5px; padding: 4px 12px; color: var(--tenue); }
.indice .toc > li.abierta > ul { display: block; }
.indice a.activa { color: var(--texto); background: var(--panel); border-left-color: var(--acento); }
.indice .toc ul a.activa { background: transparent; color: var(--acento); }
.resultados li a small { display: block; color: var(--tenue); font-size: 12.5px; margin-top: 2px; }
.resultados .vacio { color: var(--tenue); font-size: 14px; padding: 8px 12px; }
.indice .resultados[hidden], .indice .toc[hidden] { display: none; }
.indice .volver { margin-top: 18px; font-size: 13.5px; }

/* ——— texto ——— */
.texto-manual { max-width: 780px; min-width: 0; }
.texto-manual > header h1 { font-size: clamp(38px, 5vw, 56px); letter-spacing: -.035em; margin-bottom: 18px; }
.texto-manual > header .entrada { font-size: 19px; color: var(--tenue-2); line-height: 1.55; }
.texto-manual section { padding-top: 64px; }
.texto-manual h2 { font-size: clamp(28px, 3.4vw, 36px); letter-spacing: -.025em; margin-bottom: 16px; }
.texto-manual h3 { font-size: 20px; margin: 36px 0 10px; }
.texto-manual h4 { font-size: 16.5px; margin: 24px 0 8px; font-weight: 620; }
.texto-manual p, .texto-manual li { color: var(--tenue-2); }
.texto-manual strong { color: var(--texto); font-weight: 600; }
.texto-manual ul, .texto-manual ol { padding-left: 22px; margin: 0 0 1em; }
.texto-manual li { margin: 4px 0; }
.texto-manual li::marker { color: var(--acento); }
.texto-manual h2 a.ancla, .texto-manual h3 a.ancla {
  margin-left: 8px; color: var(--tenue); text-decoration: none; opacity: 0; font-weight: 400; transition: opacity .15s;
}
.texto-manual h2:hover a.ancla, .texto-manual h3:hover a.ancla, .texto-manual a.ancla:focus { opacity: 1; }
.texto-manual :not(pre) > code {
  font-size: .88em; background: var(--panel-2); border: 1px solid var(--borde);
  padding: 1px 6px; border-radius: 5px; color: var(--texto); overflow-wrap: anywhere;
}
.texto-manual kbd { font-size: .8em; padding: 3px 7px 4px; min-width: 0; border-bottom-width: 2px; vertical-align: .05em; }
.texto-manual .combo { white-space: nowrap; }
.texto-manual .codigo { margin: 18px 0 22px; box-shadow: none; }
.texto-manual .codigo pre { white-space: pre; }

/* figuras */
.texto-manual figure { margin: 26px 0 28px; }
.texto-manual figure img { width: 100%; border-radius: 12px; border: 1px solid var(--borde); background: var(--panel); }
.texto-manual figcaption { color: var(--tenue); font-size: 14px; margin-top: 10px; line-height: 1.5; }

/* tablas */
.texto-manual .tabla-envoltura { margin: 18px 0 24px; border-radius: 14px; }
.texto-manual table { font-size: 15px; }
.texto-manual th, .texto-manual td { padding: 11px 16px; }
.texto-manual td { color: var(--tenue-2); }
.texto-manual td:first-child { white-space: nowrap; color: var(--texto); }
.texto-manual td.envuelve, .texto-manual .tabla-ancha td:first-child { white-space: normal; }
.texto-manual caption { caption-side: top; text-align: left; padding: 12px 16px; font-weight: 600; color: var(--texto); background: var(--panel-2); border-bottom: 1px solid var(--borde); }

/* avisos */
.nota {
  margin: 20px 0 24px; padding: 14px 18px; border-radius: 12px; background: var(--panel);
  border: 1px solid var(--borde); border-left: 3px solid var(--acento);
}
.nota p:last-child { margin-bottom: 0; }
.nota.cuidado { border-left-color: var(--ambar); }

/* preguntas */
.texto-manual details {
  border: 1px solid var(--borde); border-radius: 12px; background: var(--panel); margin: 10px 0; padding: 0 18px;
}
.texto-manual details summary {
  cursor: pointer; padding: 14px 0; font-weight: 560; color: var(--texto); list-style: none; position: relative; padding-right: 26px;
}
.texto-manual details summary::-webkit-details-marker { display: none; }
.texto-manual details summary::after {
  content: "+"; position: absolute; right: 0; top: 12px; color: var(--acento); font-size: 20px; line-height: 1;
}
.texto-manual details[open] summary::after { content: "−"; }
.texto-manual details > div { padding-bottom: 6px; }

/* resaltado de la búsqueda al saltar */
.texto-manual .destacado { outline: 2px solid var(--acento); outline-offset: 6px; border-radius: 4px; transition: outline-color 1.2s; }
.texto-manual .destacado.apagando { outline-color: transparent; }

/* ——— pantallas medianas y móvil ——— */
@media (max-width: 960px) {
  html { scroll-padding-top: 176px; }
  .manual { grid-template-columns: minmax(0, 1fr); gap: 0; padding-top: 0; }
  .indice {
    position: sticky; top: 64px; z-index: 20; max-height: none; overflow: visible;
    margin: 0 -24px; padding: 10px 24px; background: color-mix(in srgb, var(--fondo) 92%, transparent);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--borde);
  }
  .indice .titulo-indice, .indice .volver { display: none; }
  .indice .toc {
    display: flex; gap: 6px; overflow-x: auto; margin-top: 10px; scrollbar-width: none; scroll-snap-type: x proximity;
  }
  .indice .toc::-webkit-scrollbar { display: none; }
  .indice .toc > li { flex: none; margin: 0; scroll-snap-align: start; }
  .indice .toc > li > a { border: 1px solid var(--borde); border-radius: 999px; padding: 5px 12px; font-size: 13.5px; white-space: nowrap; }
  .indice .toc > li > a.activa { border-color: var(--acento); }
  .indice .toc ul, .indice .toc > li.abierta > ul { display: none; }
  .resultados { max-height: 50vh; overflow-y: auto; margin-top: 8px; background: var(--panel); border: 1px solid var(--borde); border-radius: 10px; padding: 4px; }
  .texto-manual { padding-top: 36px; }
}
@media (max-width: 640px) {
  .manual { padding-left: 18px; padding-right: 18px; }
  .indice { margin: 0 -18px; padding: 10px 18px; }
  .texto-manual > header .entrada { font-size: 17px; }
  .texto-manual section { padding-top: 48px; }
  .texto-manual th, .texto-manual td { padding: 10px 12px; }
  .texto-manual table { font-size: 14px; }
}
@media print {
  .cabecera, .indice, .pie, .salto { display: none; }
  .manual { display: block; padding: 0; }
  .texto-manual details { break-inside: avoid; }
}
