/* Catppuccin Mocha. Interfaz en Handjet, texto en Lora. Sin recursos externos. */

@font-face {
  font-family: "Handjet";
  src: url("fuentes/Handjet.woff") format("woff");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Lora";
  src: url("fuentes/Lora.woff") format("woff");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Lora";
  src: url("fuentes/Lora-Italic.woff") format("woff");
  font-weight: 400 700;
  font-style: italic;
  font-display: swap;
}

:root {
  --rosewater: #f5e0dc; --flamingo: #f2cdcd; --pink: #f5c2e7; --mauve: #cba6f7;
  --red: #f38ba8; --maroon: #eba0ac; --peach: #fab387; --yellow: #f9e2af;
  --green: #a6e3a1; --teal: #94e2d5; --sky: #89dceb; --sapphire: #74c7ec;
  --blue: #89b4fa; --lavender: #b4befe;
  --text: #cdd6f4; --subtext1: #bac2de; --subtext0: #a6adc8;
  --overlay2: #9399b2; --overlay1: #7f849c; --overlay0: #6c7086;
  --surface2: #585b70; --surface1: #45475a; --surface0: #313244;
  --base: #1e1e2e; --mantle: #181825; --crust: #11111b;

  --fuente-ui: "Handjet", ui-monospace, "DejaVu Sans Mono", monospace;
  --fuente-texto: "Lora", Georgia, "DejaVu Serif", serif;
  --ancho-lateral: 325px;
  --ancho-esquema: 260px;
  --alto-barra: 38px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--base);
  color: var(--text);
  font-family: var(--fuente-texto);
  font-size: 18px;
  line-height: 1.7;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--surface1) transparent;
  scrollbar-width: thin;
}
* { scrollbar-color: var(--surface1) transparent; scrollbar-width: thin; }
::selection { background: var(--mauve); color: var(--base); }
:focus-visible { outline: 2px solid var(--mauve); outline-offset: 2px; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.ico { width: 18px; height: 18px; flex: none; stroke-width: 1.75; }

/* Handjet viene muy apretada: un respiro en letras y palabras */
#lateral, #barra, #esquema, .buscador-caja, .callout-titulo, .tabla th, .nota-cuerpo code {
  letter-spacing: .03em;
  word-spacing: .2em;
}

/* ---------- estructura ---------- */

#app {
  display: grid;
  grid-template-columns: var(--ancho-lateral) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

#lateral {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--mantle);
  border-right: 1px solid var(--surface0);
  font-family: var(--fuente-ui);
  font-size: 18px;
  line-height: 1.1;
  color: var(--subtext0);
}

#velo { display: none; }
#cuerpo { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

#zona { display: flex; flex: 1; min-height: 0; }
#pagina { flex: 1; min-width: 0; overflow-y: auto; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { #pagina { scroll-behavior: auto; } }

/* ---------- barra lateral ---------- */

.lateral-acciones {
  display: flex;
  justify-content: center;
  gap: 14px;
  height: var(--alto-barra);
  align-items: center;
  flex: none;
}
.lateral-acciones button,
.barra-izq button,
.barra-der button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 28px;
  border-radius: 6px;
  color: var(--subtext0);
}
.lateral-acciones button:hover,
.barra-izq button:hover,
.barra-der button:hover { background: var(--surface0); color: var(--text); }

#btn-plegar .ico-chevrons-up-down { display: none; }
.todo-plegado #btn-plegar .ico-chevrons-up-down { display: block; }
.todo-plegado #btn-plegar .ico-chevrons-down-up { display: none; }

#arbol { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 10px 16px; }
#arbol ul { list-style: none; margin: 0; padding: 0; }
#arbol ul ul { margin-left: 17px; border-left: 1px solid var(--surface0); padding-left: 0; }

#arbol summary,
#arbol a.nota {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 26px;
  padding: 2px 8px 2px 4px;
  border-radius: 6px;
  color: var(--subtext0);
  text-decoration: none;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
#arbol summary::-webkit-details-marker { display: none; }
#arbol summary:hover,
#arbol a.nota:hover { background: var(--surface0); color: var(--text); }

#arbol summary .ico-chevron-right { width: 15px; height: 15px; color: var(--overlay0); transition: transform .12s; }
details[open] > summary .ico-chevron-right { transform: rotate(90deg); }
#arbol summary .ico-carpeta { width: 16px; height: 16px; color: var(--overlay1); }
#arbol a.nota { padding-left: 24px; }

#arbol a.nota.activa,
#arbol a.nota.activa:hover { background: var(--mauve); color: var(--base); font-weight: 600; }

.lateral-pie {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-top: 1px solid var(--surface0);
  color: var(--overlay1);
  text-decoration: none;
  font-size: 17px;
}
.lateral-pie:hover { color: var(--text); }

/* ---------- barra superior ---------- */

#barra {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: var(--alto-barra);
  padding: 0 10px;
  flex: none;
  font-family: var(--fuente-ui);
}
.barra-izq, .barra-der { display: flex; align-items: center; gap: 2px; }
.barra-der { justify-content: flex-end; }
#barra-titulo {
  font-size: 18px;
  color: var(--subtext1);
  max-width: 50vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#btn-menu { display: none !important; }

/* ---------- nota ---------- */

.nota-cuerpo {
  max-width: 740px;
  margin: 0 auto;
  padding: 44px 36px 140px;
}

.nota-titulo {
  font-family: var(--fuente-texto);
  font-weight: 700;
  font-size: 2.15rem;
  line-height: 1.2;
  margin: 0 0 1.1em;
  color: var(--text);
  letter-spacing: -0.005em;
}

.nota-cuerpo p { margin: 0 0 1.1em; }

.nota-cuerpo h2,
.nota-cuerpo h3,
.nota-cuerpo h4 {
  font-family: var(--fuente-texto);
  font-weight: 700;
  line-height: 1.3;
  scroll-margin-top: 18px;
  color: var(--text);
}
.nota-cuerpo h2 {
  font-size: 1.55rem;
  margin: 2.1em 0 .7em;
  padding-bottom: .25em;
  border-bottom: 1px solid var(--surface0);
}
.nota-cuerpo h3 { font-size: 1.22rem; margin: 1.8em 0 .5em; color: var(--lavender); }
.nota-cuerpo h4 { font-size: 1.05rem; margin: 1.5em 0 .4em; color: var(--subtext1); }

.nota-cuerpo a { color: var(--blue); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--blue) 40%, transparent); text-underline-offset: 3px; }
.nota-cuerpo a.interno { color: var(--mauve); text-decoration-color: color-mix(in srgb, var(--mauve) 40%, transparent); }
.nota-cuerpo a:hover { text-decoration-color: currentColor; }

.nota-cuerpo strong { font-weight: 700; color: var(--text); }
.nota-cuerpo em { color: var(--subtext1); }

.nota-cuerpo ul, .nota-cuerpo ol { margin: 0 0 1.1em; padding-left: 1.4em; }
.nota-cuerpo li { margin: .25em 0; }
.nota-cuerpo li::marker { color: var(--overlay1); }
.nota-cuerpo li > p { margin-bottom: .4em; }

.nota-cuerpo code {
  font-family: var(--fuente-ui);
  font-size: 1.2em;
  line-height: 1;
  padding: .06em .4em;
  border-radius: 4px;
  background: var(--surface0);
  color: var(--rosewater);
  word-break: break-word;
}
.nota-cuerpo pre {
  margin: 0 0 1.1em;
  padding: 12px 16px;
  overflow-x: auto;
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-radius: 8px;
}
.nota-cuerpo pre code { padding: 0; background: none; color: var(--text); font-size: 1.1rem; line-height: 1.4; }

.nota-cuerpo hr { border: 0; border-top: 1px solid var(--surface0); margin: 2em 0; }

.nota-cuerpo blockquote {
  margin: 0 0 1.1em;
  padding: .2em 1em;
  border-left: 3px solid var(--surface2);
  color: var(--subtext1);
}
.nota-cuerpo blockquote > :last-child { margin-bottom: 0; }

/* callouts */
.nota-cuerpo blockquote.callout {
  --c: var(--blue);
  margin: 1.4em 0;
  padding: .7em 1em .8em;
  border: 0;
  border-left: 3px solid var(--c);
  border-radius: 6px;
  background: color-mix(in srgb, var(--c) 9%, var(--base));
  color: var(--text);
}
.callout-nota { --c: var(--blue); }
.callout-aviso { --c: var(--yellow); }
.callout-consejo { --c: var(--green); }
.callout-peligro { --c: var(--red); }
.callout-pendiente { --c: var(--peach); }
.callout-titulo {
  font-family: var(--fuente-ui);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--c);
  margin-bottom: .2em;
}

/* tablas */
.tabla { overflow-x: auto; margin: 0 0 1.3em; border: 1px solid var(--surface0); border-radius: 8px; }
.tabla table { border-collapse: collapse; width: 100%; font-size: .9rem; line-height: 1.45; }
.tabla th, .tabla td { padding: 8px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--surface0); }
.tabla tr:last-child td { border-bottom: 0; }
.tabla th {
  font-family: var(--fuente-ui);
  font-size: 1.15rem;
  font-weight: 700;
  background: var(--mantle);
  color: var(--subtext1);
  white-space: nowrap;
}
.tabla td code { font-size: 1.05em; }

/* ---------- esquema ---------- */

#esquema {
  flex: none;
  width: var(--ancho-esquema);
  overflow-y: auto;
  padding: 14px 14px 40px 16px;
  background: var(--mantle);
  border-left: 1px solid var(--surface0);
  font-family: var(--fuente-ui);
}
.sin-esquema #esquema { display: none; }
#esquema:has(#esquema-lista:empty) { display: none; }

.esquema-cab { font-size: 16px; letter-spacing: .08em; text-transform: uppercase; color: var(--overlay0); margin-bottom: 8px; }
#esquema-lista { list-style: none; margin: 0; padding: 0; }
#esquema-lista a {
  display: block;
  padding: 3px 0 3px 10px;
  border-left: 2px solid var(--surface0);
  font-size: 17px;
  line-height: 1.2;
  color: var(--subtext0);
  text-decoration: none;
}
#esquema-lista .nivel-3 a { padding-left: 24px; font-size: 16px; color: var(--overlay1); }
#esquema-lista a:hover { color: var(--text); }
#esquema-lista a.actual { color: var(--mauve); border-left-color: var(--mauve); }

/* ---------- buscador ---------- */

#buscador {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 11vh 16px 16px;
  background: rgba(17, 17, 27, .72);
}
.buscador-caja {
  width: min(640px, 100%);
  max-height: 76vh;
  display: flex;
  flex-direction: column;
  background: var(--mantle);
  border: 1px solid var(--surface1);
  border-radius: 10px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .55);
  font-family: var(--fuente-ui);
  overflow: hidden;
}
.buscador-campo { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--surface0); color: var(--overlay1); }
.buscador-campo input {
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  outline: 0;
  color: var(--text);
  font: inherit;
  font-size: 22px;
}
.buscador-campo input::placeholder { color: var(--overlay0); }
#buscador-lista { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
#buscador-lista li a {
  display: block;
  padding: 8px 12px;
  border-radius: 6px;
  border-left: 3px solid transparent;
  text-decoration: none;
  color: var(--text);
}
#buscador-lista li.sel a { background: var(--surface0); border-left-color: var(--mauve); }
.res-titulo { font-size: 20px; line-height: 1.2; }
.res-titulo small { font-size: 16px; color: var(--overlay1); margin-left: 8px; }
.res-seccion { font-size: 16px; color: var(--mauve); }
.res-texto { font-family: var(--fuente-texto); font-size: 13.5px; line-height: 1.4; color: var(--subtext0); margin-top: 2px; }
.res-texto mark { background: none; color: var(--yellow); font-weight: 700; }
.res-vacio { padding: 18px 14px; color: var(--overlay1); font-size: 18px; }
.buscador-pie { display: flex; gap: 18px; padding: 8px 16px; border-top: 1px solid var(--surface0); color: var(--overlay0); font-size: 16px; }

/* ---------- pantallas medianas y estrechas ---------- */

@media (max-width: 1100px) {
  #esquema, #btn-esquema { display: none !important; }
}

@media (max-width: 900px) {
  #app { grid-template-columns: minmax(0, 1fr); }
  #lateral {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(var(--ancho-lateral), 86vw);
    z-index: 30;
    transform: translateX(-102%);
    transition: transform .16s ease-out;
  }
  .lateral-abierto #lateral { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .6); }
  #velo { position: fixed; inset: 0; z-index: 20; background: rgba(17, 17, 27, .6); }
  .lateral-abierto #velo { display: block; }
  #btn-menu { display: grid !important; }
  .nota-cuerpo { padding: 28px 18px 100px; font-size: 17px; }
  .nota-titulo { font-size: 1.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  #lateral, details[open] > summary .ico-chevron-right { transition: none; }
}
