/* ============================================================
   Design system del libro
   --------------------------------------------------------
   Define aquí los tokens de tu libro. Cambia los valores y
   todo el libro se adapta. Los nombres siguen convenciones
   de design tokens estándar (--bg, --ink, --primary, etc.)

   Cómo usar:
   1. Edita los valores dentro de :root
   2. Si quieres dark mode, ajusta el bloque @media
   3. Las features (reader.js, lab, nav, etc.) consumen estos
      tokens automáticamente.
   ============================================================ */

:root {
  /* === SUPERFICIES === */
  --bg: #f4f1ec;                    /* fondo principal */
  --bg-elevated: #fffdf8;           /* tarjetas, sidebar */
  --bg-sunken: #ebe6dd;             /* header sticky */

  /* === TINTA (texto) === */
  --ink: #1a1d24;                   /* texto principal */
  --ink-soft: #3d4750;              /* texto secundario */
  --ink-mute: #6a737d;              /* metadatos */

  /* === BORDES === */
  --rule: #d1c9b8;                  /* bordes suaves */
  --rule-strong: #b8ad97;           /* separadores */

  /* === ACENTOS === */
  --primary: #1f6feb;               /* enlaces, marca */
  --primary-ink: #fffdf8;
  --accent: #c85534;                /* CTAs, hover */
  --accent-soft: #f1ddd4;
  --cyan: #168798;                  /* badges, kickers */
  --cyan-soft: #dceff1;

  /* === CÓDIGO === */
  --code-bg: #1a1d24;
  --code-fg: #e8eee9;
  --code-key: #f5a472;
  --code-str: #b8d68c;
  --code-com: #8a7a60;
  --code-fn:  #8ec5e0;

  /* === ADMONITIONS === */
  --note-bg: #eaf2f8;        --note-border: #1f6feb;
  --tip-bg: #eaf7ed;         --tip-border: #27ae60;
  --warning-bg: #fdf6e3;     --warning-border: #d4a72c;
  --important-bg: #fbeae5;   --important-border: #c0392b;
  --humor-bg: #f7eee5;       --humor-border: #b89169;
  --recipe-bg: #e8eff0;      --recipe-border: #43808a;
}

/* === DARK MODE (opcional) === */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1d24;
    --bg-elevated: #252830;
    --bg-sunken: #11141a;
    --ink: #e8e9eb;
    --ink-soft: #b8bcc4;
    --ink-mute: #8a8e96;
    --rule: #383c45;
    --rule-strong: #4d525c;
    --primary: #58a6ff;
    --accent: #f08070;
    --cyan: #79c0d0;
  }
}

/* === BASE === */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  font-size: 17px; line-height: 1.65;
  font-feature-settings: "kern" 1, "liga" 1, "onum" 1;
  -webkit-font-smoothing: antialiased;
  hyphens: auto;
}

a { color: var(--primary); text-underline-offset: 0.18em; }

/* === FEATURE: nav-superior === */
.nav-superior {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg-elevated); border-bottom: 1px solid var(--rule);
  padding: 0.6em 1.5em;
  display: flex; justify-content: space-between; align-items: center;
  font-family: -apple-system, "Helvetica Neue", sans-serif;
  font-size: 0.85em;
}
.nav-superior a { color: var(--ink-soft); text-decoration: none; padding: 0.4em 0.8em; border-radius: 4px; }
.nav-superior a:hover { color: var(--primary); background: var(--bg-sunken); }
.nav-superior .volver { font-weight: 600; }
.nav-superior .ubicacion {
  flex: 1 1 auto; text-align: center; color: var(--ink-mute);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 1em;
}

/* === FEATURE: nav-inferior === */
.nav-inferior {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 1em;
  max-width: 42em; margin: 4em auto 3em;
  padding: 1.5em 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.nav-inferior a {
  flex: 1 1 12em; min-width: 0;
  text-decoration: none; color: var(--ink-soft);
  font-family: -apple-system, sans-serif; font-size: 0.9em;
  padding: 0.7em 1em; border: 1px solid var(--rule); border-radius: 6px;
  background: var(--bg-elevated);
  transition: all 180ms ease;
}
.nav-inferior a:hover {
  border-color: var(--primary); color: var(--primary);
  background: var(--bg-elevated); transform: translateY(-1px);
}
.nav-inferior .siguiente { text-align: right; }
.nav-inferior .anterior::before { content: "← "; }
.nav-inferior .siguiente::after { content: " →"; }
.nav-inferior .nav-etiqueta {
  display: block; font-size: 0.72em; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-mute); margin-bottom: 0.2em;
}
.nav-inferior .nav-titulo { display: block; font-weight: 600; color: var(--ink); }

/* === FEATURE: cap-itulo y anexo === */
.capitulo, .anexo, .front-matter, .back-matter {
  margin: 2em auto; padding: 0 2em;
}

/* === FEATURE: admonition === */
.admonitionblock {
  margin: 1.5rem 0; padding: 1rem 1.25rem;
  border-radius: 8px; border-left: 4px solid var(--note-border);
  background: var(--note-bg);
  page-break-inside: avoid;
}
.admonitionblock .title {
  font-weight: 700; text-transform: uppercase; font-size: 0.78em;
  letter-spacing: 0.1em; margin-bottom: 0.4em; display: block;
}
.admonitionblock.note       { border-color: var(--note-border);      background: var(--note-bg); }
.admonitionblock.note .title{ color: var(--note-border); }
.admonitionblock.tip        { border-color: var(--tip-border);       background: var(--tip-bg); }
.admonitionblock.tip .title { color: var(--tip-border); }
.admonitionblock.important  { border-color: var(--important-border); background: var(--important-bg); }
.admonitionblock.important .title { color: var(--important-border); }
.admonitionblock.warning    { border-color: var(--warning-border);   background: var(--warning-bg); }
.admonitionblock.warning .title { color: var(--warning-border); }
.admonitionblock.humor      { border-color: var(--humor-border);     background: var(--humor-bg); }
.admonitionblock.humor .title { color: var(--humor-border); }
.admonitionblock.recipe     { border-color: var(--recipe-border);    background: var(--recipe-bg); }
.admonitionblock.recipe .title { color: var(--recipe-border); }

/* === FEATURE: code blocks (heredado de reader.css) === */
pre {
  background: var(--code-bg); color: var(--code-fg);
  padding: 1em 1.2em; border-radius: 8px;
  overflow-x: auto; font-size: 0.92em; line-height: 1.55;
  font-family: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
}
:not(pre) > code {
  background: var(--bg-elevated); border: 1px solid var(--rule);
  padding: 0.1em 0.4em; border-radius: 4px;
  font-size: 0.88em; font-family: "JetBrains Mono", monospace;
}

/* === FEATURE: lab === */
.reader-lab {
  margin: 1.5rem 0 2.25rem;
  padding: clamp(1rem, 2.5vw, 1.6rem);
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--cyan);
  border-radius: 10px;
}
.reader-lab-kicker {
  margin: 0 0 0.55rem; color: var(--cyan);
  font: 700 0.7rem/1 -apple-system, sans-serif;
  letter-spacing: 0.12em; text-transform: uppercase;
}

/* === FEATURE: imagenes / diagramas === */
.imageblock { margin: 2em 0; text-align: center; }
.imageblock img {
  max-width: 100%; height: auto;
  border-radius: 8px; border: 1px solid var(--rule);
  box-shadow: 0 8px 24px rgba(17, 25, 29, 0.12);
}
.imageblock .title {
  display: block; margin-top: 0.6em;
  font-size: 0.88em; font-style: italic; color: var(--ink-mute);
}

/* === TABLAS === */
table {
  width: 100%; border-collapse: collapse;
  margin: 1.5em 0; font-size: 0.95em;
  background: var(--bg-elevated); border: 1px solid var(--rule);
  border-radius: 6px; overflow: hidden;
}
th { background: var(--bg-sunken); font-weight: 700; text-align: left; padding: 0.6em 0.8em; border-bottom: 2px solid var(--rule-strong); }
td { padding: 0.55em 0.8em; border-top: 1px solid var(--rule); }
tbody tr:nth-child(even) { background: rgba(0,0,0,0.02); }

/* === PRINT === */
@media print {
  body { background: white; color: black; font-size: 11pt; }
  .nav-inferior, .nav-superior, .reader-progress, .reader-toolbar-host { display: none !important; }
  pre { background: #f4f4f4; color: black; border: 1px solid #ccc; }
  .admonitionblock { border: 1px solid #999; background: #f8f8f8; page-break-inside: avoid; }
}
